Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gprof and arguments to executable

when using gprof:

$ gprof options [executable-file [profile-data-files...]] [> outfile] 

if you have options to pass to the executable like:

gprof a.out --varfred=32 

then gprof assumes that I am passing an invalid option to it, instead of to the program being profiled (a.out).

Any way to get around this?

like image 613
Thorvaldur Avatar asked Apr 08 '09 14:04

Thorvaldur


People also ask

How does gprof work?

Gprof works by automatically instrumenting your code during compilation, and then sampling the application's program counter during execution. Sampling data is saved in a file, typically named gmon. out, which can then be read by the gprof command.

What is gprof tool?

gprof is a type of tool called a profiler. Profiling allows you to learn where your program spent its time and which functions called which other functions while it was executing.

How do I read GMON files?

gprof is the tool that reads a gmon. out file and displays information from it.

How do I use gprof on Windows?

Just to double check, mingw32-make should be under the bin folder. Compile the file with gcc. The '-pg' will enable profiling. Run the program The profiling data will be written to a file called 'gmon.


1 Answers

You don't run your executable with gprof, so you only specify it so gprof can load symbols. You run the executable first, on its own just as normal, and it then emits profiling data.

This data is loaded, along with the executable, by gprof later.

This is all explained in the gprof manual, of course.

like image 156
unwind Avatar answered Sep 25 '22 22:09

unwind