Thursday, 15 January 2015

c++ - Why does gcov report in-class function definitions as not executable? -



c++ - Why does gcov report in-class function definitions as not executable? -

it seems gcov not study inline definitions of class methods executable lines. example:

#include <iostream> struct foo { void bar() {} void baz() {} }; int main() { foo foo; foo.bar(); }

if compile above programme g++ -g -o0 -ftest-coverage -fprofile-arcs -o main main.cpp, run it, , phone call gcov on it, next report:

-: 0:source:main.cpp -: 0:graph:main.gcno -: 0:data:main.gcda -: 0:runs:1 -: 0:programs:1 -: 1:#include <iostream> -: 2: -: 3:struct foo { 1: 4: void bar() {} -: 5: void baz() {} -: 6:}; -: 7: 1: 8:int main() { -: 9: foo foo; 1: 10: foo.bar(); 4: 11:}

why line 5 reported non-executable, though method above reported correctly executed once?

update

according gcov documentation (https://gcc.gnu.org/onlinedocs/gcc/invoking-gcov.html#invoking-gcov), - denotes non-executable line while ##### , ==== mark lines can executed weren't.

gcov reporting after linking binary, there never possibility of foo::baz() beingness executed.

the linker removed function, no executable code associated line anymore.

c++ g++ code-coverage gcov

No comments:

Post a Comment