I am using GCC 4.9 with GCOV to get the code and span the branches. However, the results for spanning branches are completely useless for my C ++ code. GCC seems to be building templates, despite using all the -fno-*-inline flags that I know of.
Here is a small sample application that illustrates the problem:
#include <string> #include <iostream> using namespace std; int main() { string foo; foo = "abc"; cout << foo << endl; }
I will compile the program with g++ -O0 -fno-inline -fno-inline-small-functions -fno-default-inline --coverage -fprofile-arcs test.cpp -o test
After running test , gcovr -r . -b gcovr -r . -b prints:
------------------------------------------------------------------------------ GCC Code Coverage Report Directory: . ------------------------------------------------------------------------------ File Branches Taken Cover Missing ------------------------------------------------------------------------------ test.cpp 14 7 50% 7,8,9,10 ------------------------------------------------------------------------------ TOTAL 14 7 50% ------------------------------------------------------------------------------
There is no branch in our main function. For example, line 7 contains string foo; . The std::basic_string<...> constructor seems to have some if statement in it, but this is not useful information when viewing the main coverage.
The problem is that all of these built-in branches are summarized, and the branch coverage calculated for my actual unit tests is about 40%. I'm interested in the coverage of my code, as opposed to how many branches I got into the C ++ standard library.
Is there a way to completely close inlining in the compiler or say GCOV so as not to consider inline branches? I could not find any guidance on the GCOV homepage or anywhere else on this topic.
Any help is greatly appreciated.
c ++ gcc templates gcov
neverlord
source share