https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108658
Sebastian Huber <sebastian.hu...@embedded-brains.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |--- Status|RESOLVED |UNCONFIRMED --- Comment #4 from Sebastian Huber <sebastian.hu...@embedded-brains.de> --- What is interesting is that -g changes the behaviour. I guess there is an error 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=atomic -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=atomic -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=atomic -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:}