Problems with gcov

Andrew Wall andrew.j.wall@ntlworld.com
Mon Aug 2 20:51:00 GMT 2004


James,
Thanks for your prompt reply.

I'm very surprised that the compiler writers themselves cannot arrange for
their own specific compiler switches to arrange for an object to be
constructed first and thus destructed last.

I'll see if I can file a report on bugzilla, but in the mean time I might
investigate regressing to gcc-3.3, or see if I can write programs that hide
the static destructors from gcov.

Andrew -Wall


> -----Original Message-----
> From: James E Wilson [mailto:wilson@specifixinc.com] 
> Sent: 02 August 2004 01:35
> To: Andrew Wall
> Cc: gcc-bugs@gcc.gnu.org
> Subject: Re: Problems with gcov
> 
> 
> Andrew Wall wrote:
> > The problem I can see is that while gcov correcty reports that the
function
> > 'void uncalled(void)' is in fact not called, it incorrectly reports that
the
> > destructor ~Test(void) is not called.
> > The run of the program demonstrates that the destructor _is_ called.
> 
> Gcov needs to initialize some data when the program starts, and write 
> some data to a file when the program exits.  This works fine for C 
> files, but for C++ programs which have their own static 
> constructors/destructors that also run at program start and exit, then 
> we have an ordering problem.  If the gcov exit function runs before your 
> static destructor, then indeed the output file correctly claims that 
> your static destructor was never run (yet).
> 
> It isn't hard to see this by running the program under gdb, putting a 
> breakpoint in fwrite, and then noting that the gcov exit function runs 
> before your static destructor.
> 
> We use a static constructor to initialize gcov, and a call to atexit to 
> register the exit function.  I don't know offhand if there is anything 
> we can do to fix this.  Though it is curious that this works in gcc-3.3 
> but not in gcc-3.4.  I don't see any obvious difference in the assembly 
> language.  Maybe there was a change to the order in which we run static 
> constructors?
> 
> We don't track bug reports mailed to this list.  If you want a solution, 
> then you should consider filing a bug report into our bugzilla bug 
> database.  See
>      http://gcc.gnu.org/bugzilla
> -- 
> Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27/07/2004
 



More information about the Gcc-bugs mailing list