When gcc 4.1 (using gcov) next line:
p = new Class;
is reported as 100% branch coverage <-- THIS IS OK for me.
Why using gcc 4.4 and higher same line is reportted as:
[+ -] p = new Class; (50% branch coverage)... <-- THIS IS a problem for covering 100% !!!
Can I set any extra options to newer gcc versions in order to report same branch coverage as gcc 4.1 for single lines as "p = new Class;".
Thanks in advance.
DESCRIPTION. gcov is a test coverage program. Use it in concert with GCC to analyze your programs to help create more efficient, faster running code and to discover untested parts of your program. You can use gcov as a profiling tool to help discover where your optimization efforts will best affect your code.
Lcov is a graphical front-end for gcov. It collects gcov data for multiple source files and creates HTML pages containing the source code annotated with coverage information. It also adds overview pages for easy navigation within the file structure. Lcov supports statement, function, and branch coverage measurement.
You need to re-enable it by either: editing your ~/. lcovrc file (copied from /etc/lcovrc) to change lcov_branch_coverage setting to 1. adding --rc lcov_branch_coverage=1 to your lcov command lines.
Solved !
We have some C/C++ files with and without exceptions handling, so lcov/gcov process "exceptions handling" for each code block.
Inside a normal block, for example:
int main(void)
{
...
...
[+ -] printf("Hello\n");
...
}
gcov reports that printf line has a "branch coverage" of 50% ---> WHY ?
Because exceptions handling is enabled !!!
In order to solve this issue, specify:
-fno-exceptions
in g++ command line.
Example:
g++ -O0 --coverage -fno-exceptions -fno-inline ....
Thanks !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With