branches within C++ destructors (gcov)

Axel Freyn
Thu Feb 18 15:38:00 GMT 2010


On Thu, Feb 18, 2010 at 03:52:28PM +0530, Rohit Gupta wrote:
> [...]
> I am having problem understanding branches ( number ) generated by
> gcov  report for c++ program. Might you please clear my doubts.
I fear there is no such possibility, as states:

"There can be multiple branches and calls listed for a single source
line if there are multiple basic blocks that end on that line. In this
case, the branches and calls are each given a number."


"There is no simple way to map these branches and calls back to source
constructs. In general, though, the lowest numbered branch or call will
correspond to the leftmost construct on the source line. "

In addition, the compiler seems to use its internal representation to
define the "calls" and "branches", e.g. at the end of main gcov states:

> function __static_initialization_and_destruction_0(int, int) called 1 returned 100% blocks executed 100%
> function global constructors keyed to main called 1 returned 100% blocks executed 100%
>         3:   54:}

thus calling two functions which you never called (but which are called
by the system). So I think, in order to fully understand the output of gcov,
you would have to look at the internal way how the compiler constructs
the code. 



More information about the Gcc-help mailing list