This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -fprofile-arcs and gcov: data without exit()
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Astroman <palpablelaconic at mailinator dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 11 Oct 2005 17:56:49 +0200
- Subject: Re: -fprofile-arcs and gcov: data without exit()
- References: <1091619.post@talk.nabble.com>
On 10/11/05, Astroman (sent by Nabble.com) <lists@nabble.com> wrote:
>
> I am working on a piece of software that never exits and I am trying to use -fprofile-arcs and gcov to gather coverage data on it.
> The code looks like this:
> int main(){
> while(1){
> foo();
> nanosleep(50);
> }
> }
> This is a child process that as you can see will never exit on its own so eventually it is just signal killed by the parent process. This code could be changed to exit properly but that is not an option in this case. I am compiling the code with -fprofile-arcs and -ftest-coverage and I am able to obtain accurate coverage data for all the files in the project that exit normally. Is there any way to collect the .da file data before exit? Is it temporarily stored anywhere or could I alter the gcc library to store this information more often?
Make it SIGTERM, add a signal handler and do proper sigsetjmp/siglongjmp to
jump to a clean exit point. The output should be worth the extra 10
lines of code.
Richard.