operf, gprof & kcachegrind

It is possible to combine output from gprof and opreport, howver, one must take care. Both gprof and opreport require access to the executable (and its debugging symbols) at runtime in order to resolve addresses to symbols. Additionally gprof requires a modified executable which accurately counts function calls at the cost of producing an overhead on each call, something one probably does not want when analysing with opreport.

The simple recipe for using operf with kcachegrind was:

[Compile with -g]
$ operf -gl ./a.out
$ op2kcg -o out.dat
$ kcachegrind out.dat &

To use with gprof this becomes

[Compile with -g]
$ operf -gl ./a.out
[Change to a different directory, and compile with -pg -g]
/else/where$ ./a.out
/else/where$ gprof -q -b > gprof.out
[Copy gprof.out to directory in which the operf run was performed]
$ op2kcg -pg -o out.dat
$ kcachegrind out.dat &

KCachegrind screenshot

If recompiling like this is not possible, one can consider using callgrind instead.