This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: FW: -fprofile-generate.
Hello Yves,
On Tue, May 05, 2009 at 09:46:06PM +0000, Cadieux, Yves wrote:
> I have a program multi-threaded
Warning: for multi-threaded programs, while gcov may give you good heuristic
guidance for most things you want to do, in theory it can give you misleading
numbers which might matter in a safety-critical context (see below).
> and that programs is invoked multi times for my application. My questions are
> 1-Will I get a .gcda file for each invocation?
No. Multiple gcda files fill up existing ones. New ones are only created
the first time.
> 2-How can I merge the .gcda ?
The design is that you don't have to: if you invoke twice, the gcda
counters are added up within the gcda file. (I agree I don't spot this
info in http://gcc.gnu.org/onlinedocs/gcc/Gcov.html, if you have to,
doing dirty things such as interim recompiles for whatever reason:
http://www.nabble.com/merge-two-.gcda-files-td22575093.html)
> 3-Also sometimes I do not get the .gcda for the program file but I do get the .gcda for the objects that make the program. What am I missing.
? Iirc, you get a .gcda for each source file that makes the program.
(Maybe I misunderstood.)
Multithreaded: the gcov infrastructure had not been designed for
multithreaded use and while useful for explorative purposes cannot
guarantee even conservative numbers (because subtraction is used to
interpolate intermediate results). As discussed in [1] I guess it
would be easy to modify gcc/gcov in a way to get at least rid of
the interpolation feature, this would come at the price of less
efficiency for non-multithreaded systems though.
[1] http://sysrun.haifa.il.ibm.com/hrl/greps2007/papers/gcov-on-an-embedded-system.pdf
Cheers,
--
Holger Blasum
SYSGO AG / www.sysgo.com