This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcov and C++'s global destructors


On Fri, Jan 11, 2002 at 09:57:34AM -0800, Joe Buck wrote:
> 
> > I am trying to use gcov in conjunction with unit testing to find out
> > which lines of code were not yet covered by the tests.  Alas, I found out 
> > that those lines that were called by destructors of global variables
> > were assumed to be not executed at all.  Example code is appended.
> 
> Probably what is happening is that the routine that dumps the gcov
> statistics is being called before the calls to destructors to global
> variables are executed.

I looked into it a bit and this does seem to be what's happening.

> > My GCC version is: gcc version 2.95.3 20010315 (SuSE) on Intel.
> > 
> > Does someone know how to make this work?  I didn't find something in the
> > documentation or mailing list archives concerning this issue.
> 
> I don't know if there is an easy fix or not.

Try adding the following line to the end of the source file containing
the destructor definitions:

  __asm(" .section .fini; call __bb_exit_func")

It worked for me to get the destructor counts, although it also doubles
all of the other counts.

Janis


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]