Reputation: 1
I'm getting incorrect function coverage output from genhtml
when using C++ templates from multiple files. In particular, the function name symbols in the lcov
.dat
files have the source filename prepended to the function symbol, and this makes it impossible to create a testcase that hits those expanded function symbols.
For example, a .dat
file may have a line like follows:
FN:264,stub_handler.cc:_ZZN7Koltrek6PolicyERKNS1_18AbstractSyntaxTree16HeaderFieldMatchEENK3$_9clEv
And elsewhere the symbol appears without stub_handler.cc
. Because the template is being instantiated in different files, there's a huge number of generated function symbols, almost all of which aren't being exercised by the tests. Explicitly instantiating the testcase using the relevant template parameters has no effect in getting genhtml
to recognize that the functions were actually exercised.
I'm confused to what part of the stack is at fault here. We're using bazel
to generate coverage using clang
. We then run genhtml
on the output.
Any hints on where to look and where to debug are much appreciated, thanks in advance.
I tried:
lcov
from source.-fno-inline
.sed
to directly edit the .dat
files, stripping the filename prefix from the function name. This increases the function coverage to what it should be; however, the html output still doesn't look correct.Upvotes: 0
Views: 223
Reputation: 91
If I understand your goal, the easiest way to achieve it is via "genhtml --filter function ...". This option causes lcov/genhtml to aggregate all the functions which have the same location (filename:start_line) - on the belief that they are likely template instances or generated functions. You might also want to use the '--demangle-cpp' flag (to either 'lcov --capture ...' or to 'genhtml ...') - to see more human-readable function names. Similarly, 'genhtml --show-proportion ...' may help to prioritize partially exercised functions for further verification.
Upvotes: 0