gcov incorrect coverage results
Aaron Merey
amerey@redhat.com
Wed Feb 26 15:45:44 GMT 2025
Hi,
I'm trying to use gcov/lcov to examine test coverage for a gdb patch.
I want to quantify how well the tests added in the patch cover the new
lines of code added in the patch.
I'm running into a problem with gcov where a function added in the patch
must be called by the new tests, yet gcov indicates that this function
is called 0 times.
I can verify that the function is called since adding an early return
or a failing assert to the beginning of the function causes the new
tests to fail. In any case gcov claims the function is called 0 times.
There are other functions in the same source file which gcov marks as
called.
My versions of gcov and lcov are
gcov (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7)
LCOV version 2.0-1
CFLAGS and CXXFLAGS are set to
-O0 -g -fprofile-arcs -ftest-coverage -fno-inline
Here is how I generate the coverage results after building gdb with
my patch and the above CFLAGS/CXXFLAGS:
$ make check TESTS=<new tests>.exp
$ lcov -c -d ./ -o lcov.info
$ genhtml -o html lcov.info --synthesize-missing --ignore-errors source
Am I running into a bug or have I missed something?
Thanks,
Aaron
More information about the Gcc-help
mailing list