This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Code coverage for _constructor()/_destructor()'s?
- From: Ian Lance Taylor <iant at google dot com>
- To: jay dot vaughan at thalesgroup dot com
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 30 Jun 2010 23:58:08 -0700
- Subject: Re: Code coverage for _constructor()/_destructor()'s?
- References: <4C28904D.5010807@thalesgroup.com>
Jay Vaughan <jay.vaughan@thalesgroup.com> writes:
> Are there methods of using GNU coverage which will allow me to save my
> coverage information for the cases where death is warranted by my
> guardian library? Is there some way for me to manually force coverage
> to be written prior to doing my big exit() call in the constructor?
> Has anyone else run into this problem and solved it?
The coverage code runs a constructor at the default initialization
priority. Since your code is running at a higher priority, it runs
before coverage has been initialized.
Ideally you could call __gcov_init (info) at the start of your
constructor. The problem is that __gcov_init takes an argument, a
pointer to a struct gcov_info, and you should really pass the same
pointer as the default constructor will pass. But there is no way for
your code to get that value.
I can't think of anything that would work without changing and
rebuilding the compiler and the gcov support code.
Ian