Code (see uuencoded file src.tgz at the end of the message) being compiled with command: > g++ -fprofile-arcs -ftest-coverage *.cc -o tst Then program is being run: > ./tst Then gcov being run: > gcov -l a.cc > gcov -l b.cc WRONG RESULT OBTAINED: in b.cc.a.h.gcov I find: <snip> void ###### a() { ###### printf("AA\n"); } <snip> this report means that function A::a() isn't used in b.cc In fact as seen in sources it's invoked from b.cc. Thanx, Yuri. --------- code ---------------------------------------------- begin 644 src.tgz M'XL(`)X0+#\``^V644^#,!"`>>ZON.#+9A3;44;BC,GP;_A2"@K)9`N%1;/L MOWNLFT9T\@1;LOM>#CB@38_OBBGUG=,SG$L>!@%&SL-P:N-4[N(>!Q/"YX)/ M)L+!$(3<@:#OB374IE(E@/-1E_G_]Z6E&6)"PV*P_LK3NL\QL)Y\*N71^D^$ M;-5?^$(XP/N<U($+K_]57NA%G:3@*B]SV?=IW)RR]+U*RP+6RSP!/1K/&,N+ MBKVIO!CA`:CR5=^`7A:F`IWA.E[CE?48-@Q@#FJ&(8(8GP)0GFJ>!XB]V![@ M9[=[(]@W;]FIU^(2:?R/3^R_D/YO_WWR?P@Z_&>-^0S]_$OI58D]X&7DWB+/ MA3MN>TY:GS]V_\]Z':-[_V___PDA0_)_"+Z$?S!5DB^][)$QO5#&H.P;MJKC M1:[O;1=0^RYPT'X^M])O]UTB;N>CGWG=SC\=\ML9-8D38??_\_,_X.3_$!SW H/^KR/^KP/^KP/R+_"8(@"((@"((@"((@"((@"*(?/@&S1(U$`"@````` ` end
From yuri@tsoft.com: CORRECTION (reformulation): After some experimentation I figured that ####### actually means "used" butwhycounter didn't appear? Is this a bug? In another header actual counters appeared.
Created attachment 4647 [details] testcases Please use bugzilla's "create new attachment" to add files to bug reports, rather than including them in the message. Not only does it make my life easier, it also makes the audit trail more intelligible.
Nathan, would you mind clarify whether the reported behavior is a bug? Thanks.
will investigate
not a bug, but an outcome of inline functions and weak linkage. I used the current mainline, which mangles gcov file names differently. You'll see (well I did) that a.cc##a.h contains 2 counts for A::a. so overall, the execution counts are correct, just not where you expected them. What is happening is this, 1) you're compiling without optimization, thus function calls are not inlined. 2) both a.cc and b.cc need to emit a body of A::a, which they each call. 3) those A::a functions are emitted with weak linkage, which means one of them will 'win' in the linking phase. 4) at the linking phase the A::a emitted in a.o is selected, and the call of A::a in b.o ends up calling the body of A::a that was emitted in a.o 5) thus the body of A::a emitted in b.o is never called. need to write something in the documentation about this.
2003-12-15 Nathan Sidwell <nathan@codesourcery.com> PR c++/11773 * doc/gcov.texi (Gcov and Optimization): Document inline function behaviour. Fix some file suffixes.
Subject: Bug 11773 CVSROOT: /cvs/gcc Module name: gcc Changes by: nathan@gcc.gnu.org 2003-12-15 14:29:11 Modified files: gcc : ChangeLog gcc/doc : gcov.texi Log message: PR c++/11773 * doc/gcov.texi (Gcov and Optimization): Document inline function behaviour. Fix some file suffixes. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1995&r2=2.1996 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/gcov.texi.diff?cvsroot=gcc&r1=1.18&r2=1.19
Documentation fixed for 3.4.