Re: gcov vs. multiple objects derived from the same source

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Bernd,

On Wed, Mar 05, 2008 at 11:08:04AM +0200, Bernd Jendrissek wrote:
> I'm worried that when I do gcov *.o, gcov might not notice that two
> objects are derived from the same file, and thus the coverage notes
> might reflect coverage only of a subset of the use cases - those that
> exercise foo.c through ${bindir}/bar but not those that exercise it
> through ${bindir}/baz.

> Are there any guarantees (or specific lack thereof) about gcov's
> behaviour under these circumstances?

"gcov bar.o baz.o" ->
  gcov bar.o reads bar.gcno and bar.gcda, then writes output into foo.c.gcov
  gcov baz.o reads baz.gcno and baz.gcda, then writes output into foo.c.gcov
    (overwriting the first foo.c) (tested with gcc-3.4.4)

(Although it is built in into the gnu coverage framework to be able to
add up counts this from different runs of the *same* executable, this
is done at the gcda level and not at the foo.c.gcov level, possibly with
the intention to keep things simple.)

Solution: use lcov from the linux test project that has adding
  up functionality at the *.c.gcov level (internally it just uses
  the same gcov framework)

(Let's assume that bar contains bar.o and baz contain baz.o)

  lcov --zerocounters
  ./bar
  lcov --capture --output-file barbaz.info
  ./baz
  lcov --capture --output-file barbaz.info
  genhtml barbaz.info

HTH,

-- 
Holger Blasum AT www.sysgo.com

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux