__bb_exit_func is registered with atexit(), to save the profiling data.
I haven't analysed the situation in detail, but this appears to run before functions declared with __attribute__((destructor)), at least. So those don't get profiled (and, slightly more importantly, test coverage misses them).
(If this isn't fixed in the next release, it should probably be documented as a limitation and referenced from the gcov manual).
gcc version 3.2.1 20020830 (Debian prerelease)
could you confirm whether this behavior is still the case in gcc 3.3? A testcase of the
'unreliable' behavior would also be much apprecaited. Thanks,
The problem is that the write out for the data is done before global destructors are done.
I am not familiar with global destructors mechanizm, but can we assign each profiled file global destructor that will save profiles only for that file and manage priorities so they are run very last? That would solve this problem as well as the problem with profile being corrupted when dlclose is called...
*** Bug 16855 has been marked as a duplicate of this bug. ***
This bug *still* exists as of i686-apple-darwin10-g++-4.2.1. The problem is apparently the collision of two at_exit() handlers, with C++'s global destructor coming in last.