This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: profiling question
- From: Brian Dessent <brian at dessent dot net>
- To: Juan Carlos Franzoy <jfranzoy at yahoo dot com dot ar>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 14 Dec 2007 16:29:18 -0800
- Subject: Re: profiling question
- References: <414116.94719.qm@web32709.mail.mud.yahoo.com>
- Reply-to: binutils at sourceware dot org
Juan Carlos Franzoy wrote:
> I compiled it with -pg and -g and installed it. After
> 24 hours it took more than 25% and we killed -15 it.
> It generates a gmon.out.
>
> Out surprise was when we run gprof myapp gmon.out. All
> counters except where in zero. What am I doing wrong?
First note that gprof is part of binutils and not part of gcc so it'd
probably be better to use the binutils mailing list (binutils at
sourceware.org) for this.
The problem with terminating the program with kill -15 is that the
profiling library registers its mcleanup() routine with atexit(), and
this is what writes all the data to the gmon.out file. So the app must
either return from main() or call exit() in order to get any profile
data, it won't happen for a SIGTERM or any other abnormal termination
sequence. You might be able to work around this by e.g. installing a
signal handler that explicitly calls exit() or something. Or perhaps
you could use a different profiling method like oprofile.
Brian