This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: profiling question


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]