34

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?

unwind
  • 391,730
  • 64
  • 469
  • 606
Thorvaldur
  • 531
  • 2
  • 5
  • 9

1 Answers1

38

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.

The Beast
  • 1,629
  • 2
  • 29
  • 42
unwind
  • 391,730
  • 64
  • 469
  • 606
  • link is broken [Maybe here we can find that info](https://sourceware.org/binutils/docs-2.17/gprof/) – Gabo Mar 26 '15 at 04:07
  • 4
    It may be explained in the manual, but one of the first Google hits is [bad information](http://www.thegeekstuff.com/2012/08/gprof-tutorial/). God I hate blogs.... – jww Sep 22 '15 at 21:23