Why does gcov (gcc 12) outputs line summary twice?

94 Views Asked by At

I have a project which I used to build with gcc toolchain version 10.2.0 (Rev6, Built by MSYS2 project) and analyze test coverage with gcov:

C:\test>gcov.exe "C:\test\Appl.c.gcda"
File 'C:/test/Appl.c'
Lines executed:27.54% of 207
Creating 'Appl.c.gcov'


C:\test>

However, after an upgrade to gcc version 12.2.0 (Rev5, Built by MSYS2 project), the line summary is duplicated in the output:

C:\test>gcov.exe "C:\test\Appl.c.gcda"
File 'C:/test/Appl.c'
Lines executed:27.54% of 207
Creating 'Appl.c.gcov'

Lines executed:27.54% of 207

C:\test>

I have a small shell script that uses this output to print out files with insufficient coverage which is now broken. Should I adapt it to the new output format, or is it a bug and I should just skip the buggy version until a fix comes out?

1

There are 1 best solutions below

0
Dmitry Grigoryev On

In the new version, the last line of gcov output summarizes the line coverage of all files which have produced code in a given compilation unit. This happens for instance when a .c file includes header files containing inline functions:

C:\test>gcov.exe "C:\test\Appl.c.gcda"
File 'C:/test/Appl.c'
Lines executed:26.92% of 130
Creating 'Appl.c.gcov'

File 'C:/test/Appl.h'
Lines executed:0.00% of 8
Creating 'Appl.h.gcov'

Lines executed:25.36% of 138

C:\test>