Category: Code
Date: 2008.05.04

gcov file summaries vs. manpage

Playing with gcov recently, I noticed the output on multiple machines does not match the manpage. On a larger program the gcov summary of a source file appears displays a value the man page implies should be total lines but is in reality ... not.

Even the trivial example from the gcov man page (from both OS X leopard and redhat box) produces different output (in format an values).

man page:

gcov -b tmp.c
90.00% of 10 source lines executed in file tmp.c
80.00% of 5 branches executed in file tmp.c
80.00% of 5 branches taken at least once in file tmp.c
50.00% of 2 calls executed in file tmp.c
Creating tmp.c.gcov.

reality:

ryans-mac-pro:Gcov rbetts$ gcov -b man.c
File 'man.c'
Lines executed:87.50% of 8
Branches executed:100.00% of 4
Taken at least once:75.00% of 4
Calls executed:50.00% of -2
man.c:creating 'man.c.gcov'

The useful in-file annotations are correct and on the non-trivial program match my understanding of what's being excercised.

Wonder how lcov generates its results? From the summary or by recalculating from the source annotations? It does make pretty summaries, though: