Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the name of gmon.out file when compiling with -pg [duplicate]

Is it possible to change the default name of the file gmon.out, which is created when the profile flag (-pg) is set when compiling with gcc, to, for example, [executable name].gmon.out?

I need this because I have more than one executables, which are located in the same directory, and have to run parallel.

like image 837
Emiswelt Avatar asked Dec 13 '22 20:12

Emiswelt


1 Answers

Not so short, but actually the answer is YES - if using glibc (at least with version 2.11.1, which is the version I used to test this).

To have your -pg compiled and linked executable create different names then the default gmon.out, just set the environment variable GMON_OUT_PREFIX to a value of your choice and the profiling output will be written to [value of your choice].[pid] where [pid] is the process-ID of the process the profiling data belongs to.

like image 162
alk Avatar answered Jan 25 '23 23:01

alk