public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug gcov-profile/107537] New: gcov skips throw/fallthrough annotations for 'never executed' branches @ 2022-11-05 19:20 grregd at gmail dot com 2022-11-10 14:19 ` [Bug gcov-profile/107537] " marxin at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: grregd at gmail dot com @ 2022-11-05 19:20 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107537 Bug ID: 107537 Summary: gcov skips throw/fallthrough annotations for 'never executed' branches Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: grregd at gmail dot com CC: marxin at gcc dot gnu.org Target Milestone: --- $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.3.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-xKiWfi/gcc-11-11.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-xKiWfi/gcc-11-11.3.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04) $ gcov -v gcov (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 $ cat prog.cpp #include <iostream> void foo1() { try { std::cout << "here\n"; } catch (...) {} } void foo2() { try { std::cout << "there\n"; } catch (...) {} } int main() { foo1(); } $ g++ --coverage prog.cpp -o prog && ./prog && gcov -b -o . prog && cat prog.cpp.gcov here File 'prog.cpp' Lines executed:54.55% of 11 Branches executed:50.00% of 4 Taken at least once:25.00% of 4 Calls executed:40.00% of 5 Creating 'prog.cpp.gcov' File '/usr/include/c++/11/iostream' No executable lines No branches No calls Removing 'iostream.gcov' Lines executed:54.55% of 11 -: 0:Source:prog.cpp -: 0:Graph:./prog.gcno -: 0:Data:./prog.gcda -: 0:Runs:1 -: 1:#include <iostream> -: 2: function _Z4foo1v called 1 returned 100% blocks executed 60% 1: 3:void foo1() -: 4:{ -: 5: try { 1: 6: std::cout << "here\n"; call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% (throw) -: 7: } =====: 8: catch (...) {} call 0 never executed 1: 9:} -: 10: function _Z4foo2v called 0 returned 0% blocks executed 0% #####: 11:void foo2() -: 12:{ -: 13: try { #####: 14: std::cout << "there\n"; call 0 never executed branch 1 never executed branch 2 never executed -: 15: } =====: 16: catch (...) {} call 0 never executed #####: 17:} -: 18: function main called 1 returned 100% blocks executed 100% 1: 19:int main() -: 20:{ 1: 21: foo1(); call 0 returned 100% 1: 22:} Both functions foo1 and foo2 are essentially the same. foo1 is called once, foo2 is never called. foo1 contains 2 branches in line 6, both branches labeled with annotations (fallthrough/throw). The same code in foo2 in line 14 also has 2 branches, however these are not labeled with annotations. Accoding to the source code of gcov it always skips throw/fallthrough annotations for 'never executed' branches (https://github.com/gcc-mirror/gcc/blob/50bc9185c2821350f0b785d6e23a6e9dcde58466/gcc/gcov.c#L2861) Is there any reason why gcov skips throw/fallthrough annotations for branches which were never executed? According to my investigation, those flags are there and after modifying gcov to print annotations always, it produces output with annotations for those never executed branches. But perhaps those flags are invalid in this case and can't be used? In some specific conditions, those annotations would be very helpful for tools like lcov or gcovr. Problem that occurrs in gcovr is described here - https://github.com/gcovr/gcovr/issues/677#issuecomment-1282355159 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/107537] gcov skips throw/fallthrough annotations for 'never executed' branches 2022-11-05 19:20 [Bug gcov-profile/107537] New: gcov skips throw/fallthrough annotations for 'never executed' branches grregd at gmail dot com @ 2022-11-10 14:19 ` marxin at gcc dot gnu.org 2022-12-04 20:45 ` michael.foerderer at gmx dot de ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: marxin at gcc dot gnu.org @ 2022-11-10 14:19 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107537 Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-11-10 Status|UNCONFIRMED |ASSIGNED Assignee|unassigned at gcc dot gnu.org |marxin at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> --- I'm going to take a look. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/107537] gcov skips throw/fallthrough annotations for 'never executed' branches 2022-11-05 19:20 [Bug gcov-profile/107537] New: gcov skips throw/fallthrough annotations for 'never executed' branches grregd at gmail dot com 2022-11-10 14:19 ` [Bug gcov-profile/107537] " marxin at gcc dot gnu.org @ 2022-12-04 20:45 ` michael.foerderer at gmx dot de 2022-12-14 13:45 ` marxin at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: michael.foerderer at gmx dot de @ 2022-12-04 20:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107537 --- Comment #2 from michael.foerderer at gmx dot de --- Created attachment 54009 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54009&action=edit Patch for annotation of uncovered branches ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/107537] gcov skips throw/fallthrough annotations for 'never executed' branches 2022-11-05 19:20 [Bug gcov-profile/107537] New: gcov skips throw/fallthrough annotations for 'never executed' branches grregd at gmail dot com 2022-11-10 14:19 ` [Bug gcov-profile/107537] " marxin at gcc dot gnu.org 2022-12-04 20:45 ` michael.foerderer at gmx dot de @ 2022-12-14 13:45 ` marxin at gcc dot gnu.org 2022-12-14 20:06 ` michael.foerderer at gmx dot de ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: marxin at gcc dot gnu.org @ 2022-12-14 13:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107537 --- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> --- Hello. Sorry for the delay. > Is there any reason why gcov skips throw/fallthrough annotations for > branches which were never executed? No. Your patch is fine and pre-approved, please include the PR entry in ChangeLog and send it to gcc-patches. Once doing that, you can commit it (if you have a copyright assignment and git write access?). ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/107537] gcov skips throw/fallthrough annotations for 'never executed' branches 2022-11-05 19:20 [Bug gcov-profile/107537] New: gcov skips throw/fallthrough annotations for 'never executed' branches grregd at gmail dot com ` (2 preceding siblings ...) 2022-12-14 13:45 ` marxin at gcc dot gnu.org @ 2022-12-14 20:06 ` michael.foerderer at gmx dot de 2022-12-15 10:59 ` cvs-commit at gcc dot gnu.org 2022-12-15 11:00 ` marxin at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: michael.foerderer at gmx dot de @ 2022-12-14 20:06 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107537 --- Comment #4 from michael.foerderer at gmx dot de --- This is my first patch, I hope that I did it right: https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608512.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/107537] gcov skips throw/fallthrough annotations for 'never executed' branches 2022-11-05 19:20 [Bug gcov-profile/107537] New: gcov skips throw/fallthrough annotations for 'never executed' branches grregd at gmail dot com ` (3 preceding siblings ...) 2022-12-14 20:06 ` michael.foerderer at gmx dot de @ 2022-12-15 10:59 ` cvs-commit at gcc dot gnu.org 2022-12-15 11:00 ` marxin at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2022-12-15 10:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107537 --- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>: https://gcc.gnu.org/g:c263c3eba8953c341cd8ac2d0a5f2b8f38623016 commit r13-4715-gc263c3eba8953c341cd8ac2d0a5f2b8f38623016 Author: Spacetown <michael.foerderer@gmx.de> Date: Sun Dec 4 21:03:34 2022 +0100 gcov: annotate uncovered branches [PR107537] PR gcov-profile/107537 gcc/ChangeLog: * gcov.cc (output_branch_count): Add annotation '(fallthrough)' or '(throw)' also to uncovered branches. Signed-off-by: Michael Förderer <michael.foerderer@gmx.de> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/107537] gcov skips throw/fallthrough annotations for 'never executed' branches 2022-11-05 19:20 [Bug gcov-profile/107537] New: gcov skips throw/fallthrough annotations for 'never executed' branches grregd at gmail dot com ` (4 preceding siblings ...) 2022-12-15 10:59 ` cvs-commit at gcc dot gnu.org @ 2022-12-15 11:00 ` marxin at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: marxin at gcc dot gnu.org @ 2022-12-15 11:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107537 Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|ASSIGNED |RESOLVED --- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> --- Fixed on master. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-12-15 11:00 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-11-05 19:20 [Bug gcov-profile/107537] New: gcov skips throw/fallthrough annotations for 'never executed' branches grregd at gmail dot com 2022-11-10 14:19 ` [Bug gcov-profile/107537] " marxin at gcc dot gnu.org 2022-12-04 20:45 ` michael.foerderer at gmx dot de 2022-12-14 13:45 ` marxin at gcc dot gnu.org 2022-12-14 20:06 ` michael.foerderer at gmx dot de 2022-12-15 10:59 ` cvs-commit at gcc dot gnu.org 2022-12-15 11:00 ` marxin at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).