From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0F726385381B; Fri, 28 May 2021 09:57:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F726385381B From: "gejoed at rediffmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/100751] __gcov_dump and __gcov_reset usage Date: Fri, 28 May 2021 09:57:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: gcov-profile X-Bugzilla-Version: 8.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gejoed at rediffmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WORKSFORME X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 May 2021 09:57:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100751 --- Comment #21 from Gejoe --- (In reply to Martin Li=C5=A1ka from comment #20) > > I'm trying to understand line #22 to #26 specifically of .c.gcov file(as > > shown in commment #16. Let me know if the steps followed in compilation= or > > execution had any thing wrong. >=20 > What is wrong with that? What values are expected? Actually if we look at line #22 should have the value 16 (after a.out run) = and line #24,25 should have values 4 each instead of what is actually present t= here in comment#16.Instead the value of 16,4,4 are shown for line # 24,26,27 respectively. That was my query. Is that because of some difference with source files and .gcda files as sho= wn there (in .c.gcov file in Comment #16) as follows ?=20 0:Source is newer than graph I did delete the gcda file and did the same compilation steps again : $ gcc -v -save-temps -fprofile-arcs -ftest-coverage sample-prog.c $ gcc -fprofile-arcs -ftest-coverage sample-prog.o $./a.out The output was : $ ./a.out=20 __gcov_dump() invoked! __gcov_reset() invoked! __gcov_dump() invoked! __gcov_reset() invoked! The sample-prog.c.gcov file contents now look fine : -: 0:Source:sample-prog.c -: 0:Graph:sample-prog.gcno -: 0:Data:sample-prog.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:#include -: 2:#include -: 3:#include -: 4: -: 5:extern void __gcov_reset(void); -: 6:extern void __gcov_flush(void); -: 7:extern void __gcov_dump( void); -: 8: 1: 9:int main() -: 10:{ -: 11: unsigned char c; 1: 12: int count=3D0; 1: 13: c =3D 'g'; -: 14: -: 15: do { -: 16:=20=20=20 10: 17: if(c =3D=3D 'g'){ 2: 18: __gcov_dump(); #####: 19: printf("__gcov_dump() invoked!\n"); #####: 20: c =3D 'r'; -: 21: } 8: 22: else if(c =3D=3D 'r'){ #####: 23: __gcov_reset(); 2: 24: printf("__gcov_reset() invoked!\n"); 2: 25: c =3D 'f'; -: 26: } 10: 27: if(count =3D=3D 2) 1: 28: c =3D 'g'; 9: 29: else if (count > 10) 1: 30: c =3D 'e'; 10: 31: count++; 10: 32: }while(c !=3D 'e'); -: 33:=20=20=20=20 1: 34: return 0; -: 35:} =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D So, for either a one time call of __gcov_dump (though we may attempt to call __gcov_dump many times) or at the exit of the program execution, the merge= of profile happens due to which __gcov_reset doesn't get reflected at all. Am I right ? Thanks again!=