[PATCH, RFC] gcov: dump in a static dtor instead of in an atexit handler

Martin Liška mliska@suse.cz
Wed Aug 10 10:43:00 GMT 2016


Hello.

There are multiple PRs (mentioned in ChangeLog) which suffer from missing capability of gcov
to save counters for functions with constructor/destructor attributes. I done that by simply
replacing atexit handler (gcov_exit) with a new static destructor (__gcov_exit), which has
priority 99 (I did the same for __gcov_init). However, I'm not sure whether it's possible
that a ctor defined in a source file can be potentially executed before __gcov_init (w/ the default
priority)?

Patch survives:
make check -k -j10 RUNTESTFLAGS="gcov.exp"
make check -k -j10 RUNTESTFLAGS="tree-prof.exp"

I've just also verified that a DSO gcov dump works as before. I'm attaching a test-case which 
tests both static ctors/dtors, as well as C++ ctors/dtors.

Thoughts?
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gcov-dump-in-a-static-dtor-instead-of-in-an-atexit-h.patch
Type: text/x-patch
Size: 4994 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160810/61a660a7/attachment.bin>


More information about the Gcc-patches mailing list