This is the mail archive of the gcc-bugs@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: 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



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