From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 890043858D20; Fri, 3 Feb 2023 18:28:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 890043858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675448902; bh=8i6Wb9NvoTje3Bhj0oH35t26cWfZ3OcaDCartJAnwjo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mrG2akTrznl6QnhyflRGVEE/DDxNemTOdNby2HdOyO9QKPQhuzQTFCSakgkIhMlT5 JVllNK4Lbb2o0GY/mmJ5cydsu3sP80sGZ7nOFuqcPx94fLICkw9OBkwhzUmZytlWtM llKYFgNQhlhO+Hwkgl6ZrI5id2erNuAv6vMNsmUY= From: "sebastian.huber@embedded-brains.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/108658] [GCOV] Function entry is not recorded in a function containing an infinite loop from another thread depending on the optimization level Date: Fri, 03 Feb 2023 18:28:22 +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: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sebastian.huber@embedded-brains.de 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: resolution bug_status 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108658 Sebastian Huber changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |--- Status|RESOLVED |UNCONFIRMED --- Comment #4 from Sebastian Huber --- What is interesting is that -g changes the behaviour. I guess there is an e= rror in the mapping of the profiling counter to the associated source code lines. gcc-12 -O2 --coverage -c main.c -g rm -f *.gc?? gcc-12 -pthread -fprofile-update=3Datomic -O2 --coverage -c idle.c -g gcc-12 -pthread --coverage main.o idle.o ./a.out gcov-12 idle.c File 'idle.c' Lines executed:66.67% of 3 Creating 'idle.c.gcov' Lines executed:66.67% of 3 cat idle.c.gcov -: 0:Source:idle.c -: 0:Graph:idle.gcno -: 0:Data:idle.gcda -: 0:Runs:1 #####: 1:void *idle(void *ignored) -: 2:{ 213413784: 3: while (1) { -: 4: /* Do nothing */ 213413784: 5: } -: 6: -: 7: return 0; -: 8:} rm -f *.gc?? gcc-12 -pthread -fprofile-update=3Datomic -Og --coverage -c idle.c -g gcc-12 -pthread --coverage main.o idle.o ./a.out gcov-12 idle.c File 'idle.c' Lines executed:66.67% of 3 Creating 'idle.c.gcov' Lines executed:66.67% of 3 cat idle.c.gcov -: 0:Source:idle.c -: 0:Graph:idle.gcno -: 0:Data:idle.gcda -: 0:Runs:1 #####: 1:void *idle(void *ignored) -: 2:{ 214569562: 3: while (1) { -: 4: /* Do nothing */ 214569562: 5: } -: 6: -: 7: return 0; -: 8:} rm -f *.gc?? gcc-12 -pthread -fprofile-update=3Datomic -O0 --coverage -c idle.c -g gcc-12 -pthread --coverage main.o idle.o ./a.out gcov-12 idle.c File 'idle.c' Lines executed:100.00% of 2 Creating 'idle.c.gcov' Lines executed:100.00% of 2 cat idle.c.gcov -: 0:Source:idle.c -: 0:Graph:idle.gcno -: 0:Data:idle.gcda -: 0:Runs:1 214896204: 1:void *idle(void *ignored) -: 2:{ 214896204: 3: while (1) { -: 4: /* Do nothing */ -: 5: } -: 6: -: 7: return 0; -: 8:}=