Any way to specify the location of profile data

Too badly, the environment variable GMON_OUT_PREFIX is not documented in the glibc. I got the following information from the web and tested on my machine.

if you set the environment variable GMON_OUT_PREFIX, then the output file is named as ${GMON_OUT_PREFIX}.[PID], the pid is the id of the profiled process.

For example:

GMON_OUT_PREFIX=mygmon; gcc -o foo -pg foo.c

the gmon out file is: mygmon.12345, assuming the foo process id=12345.


jscoot's solution worked for me, with the important difference of setting GMON_OUT_PREFIX at execution time, not at compile time.

Tags:

Linux

Gcc

Gprof