From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6C197385781A; Thu, 24 Jun 2021 11:58:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C197385781A From: "njuwy at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/101192] New: [GCOV] The coverage of a callee function goes wrong. Date: Thu, 24 Jun 2021 11:58:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: gcov-profile X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: njuwy at smail dot nju.edu.cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: 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: Thu, 24 Jun 2021 11:58:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101192 Bug ID: 101192 Summary: [GCOV] The coverage of a callee function goes wrong. Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: njuwy at smail dot nju.edu.cn CC: marxin at gcc dot gnu.org Target Milestone: --- $ gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto= -wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure -enable-checking=3Drelease -enable-languages= =3Dc,c++ -disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.0 (GCC) $ cat test.c #include #include char a[] =3D "12345"; char b[] =3D "12345"; void loop(char *pz, char *pzDta) { for (;;) { switch (*(pz++) =3D *(pzDta++)) { case 0: goto loopDone2; case '"': case '\\': pz[-1] =3D '\\'; *(pz++) =3D pzDta[-1]; } } loopDone2:; if (a - pz !=3D b - pzDta) abort(); } int main() { loop(a, b); exit(0); } $ gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov libgcov profiling error:/home/wangyang/coverage/test/test.gcda:overwriting = an existing profile data with a different timestamp File 'test.c' Lines executed:71.43% of 14 Creating 'test.c.gcov' -: 0:Source:test.c -: 0:Graph:test.gcno -: 0:Data:test.gcda -: 0:Runs:1 -: 1:#include -: 2:#include -: 3:char a[] =3D "12345"; -: 4:char b[] =3D "12345"; -: 5: 6: 6:void loop(char *pz, char *pzDta) { -: 7: for (;;) { 6: 8: switch (*(pz++) =3D *(pzDta++)) { 1: 9: case 0: 1: 10: goto loopDone2; -: 11: #####: 12: case '"': -: 13: case '\\': #####: 14: pz[-1] =3D '\\'; #####: 15: *(pz++) =3D pzDta[-1]; -: 16: } -: 17: } 1: 18:loopDone2:; -: 19: 1: 20: if (a - pz !=3D b - pzDta) #####: 21: abort(); 1: 22:} -: 23: 1: 24:int main() { 1: 25: loop(a, b); 1: 26: exit(0); -: 27:} Lets see line 6, "loop" function was only executed once.=