[2] Re: [gcov] No data gathered for child processes

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

 



On Wed, Sep 23, 2009 at 06:48:29PM +0200, Holger Blasum wrote:
> > You must note that the parent process and the child processes have the  
> > exact same code. In fact, the parent process is just forked.
> 
> Ah now I understand. Well then one has a classical race condition: 
> the same infrastructure for storing coverage data (*.gcda files) is 
> used by both parent and child, and who terminates last will get the 
> overwrite I guess.

Let me stress: I'm not sure at the moment whether that race condition
is necessary or just accidental (and no-one has ever bothered to fix
it). Study the gcov sources (not long and documented in the paper I 
linked to in yesterday's mail) - don't have patience atm to do that myself.
Special things to look at is e.g. atexit() and how this is used in 
a forking context.

> > I did not yet resolve the problem. I hope I will be able with your help.
> 
> Fixing ideas: 
> (1) try renaming functions in your child (ugly, I agree, but could be automated).
>  Maybe first try out whether this works with a very small example.
> (2) modify gcov so that that the gcda files are written in a way that if 
> 	a child with say process ID (pid) 2 has a main.c 
> 	and a parent with say pid 1 has main.c, then the data is dumped into
> 	main.1.gcda, main.2.gcda, and modify gcov.c to sum up both 
> 
> BTW, anyone else is encouraged to comment on too (I had just been a user 
> of gcov too - no contributions to development). There is also a list
> with gcov knowledge at the lcov project 
> http://ltp.sourceforge.net/coverage/lcov.php

Oops, https://lists.sourceforge.net/lists/listinfo/ltp-coverage to give
a more useful pointer.

-- 
Holger

[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