gprofdoesn't produce output
Q: Every time I run the profiler it says "gmon.out: no such file or
directory" and no profile is produced. What is this
file, and why won't
gprof compute the profile?
gmon.out is the file with raw execution counts and timing
gprof needs to produce the profile. The file is
written by the profiled program when it exits. If the file isn't
created, it might be because of one of the following reasons:
-pgswitch. Note that both compilation and link need to be done with
-pg, because the functions that actually write the results to
gmon.outare only linked in when GCC sees
-pgon the link command line.
ld.exedirectly to link your program and forgot to mention the files and switches necessary for the profiled program operation. You should use
gccto link your program instead of calling the linker directly; a
gccis all that it takes to make sure that the linker will get all the necessary arguments22.
gmon.outis registered with the
atexitlibrary function, and won't be called if the program was terminated in an abnormal way. Make sure that your program exits with a call to
exitlibrary function or with a
returnstatement in your
mainfunction. For example, if your program dies with an exception or a signal, you need to install a handler for that signal and make it call
|webmaster donations bookstore||delorie software privacy|
|Copyright © 2001 by Eli Zaretskii||Updated Apr 2001|