Make sure you compiled the code with -fno-omit-frame-pointer gcc option.
Make sure you compiled the code with -fno-omit-frame-pointer gcc option.
You're almost there, you're missing the -G option (you might need a more recent perf than the one installed on your system):
$ perf report --call-graph --stdio -G
From perf help report:
-G, --inverted
alias for inverted caller based call graph.
Videos
This is an old question, but this in now possible with --call-graph dwarf. From the man page:
-g
Enables call-graph (stack chain/backtrace) recording.
--call-graph
Setup and enable call-graph (stack chain/backtrace) recording, implies -g.
Allows specifying "fp" (frame pointer) or "dwarf"
(DWARF's CFI - Call Frame Information) as the method to collect
the information used to show the call graphs.
In some systems, where binaries are build with gcc
--fomit-frame-pointer, using the "fp" method will produce bogus
call graphs, using "dwarf", if available (perf tools linked to
the libunwind library) should be used instead.
I believe this requires a somewhat recent Linux kernel (>=3.9? I'm not entirely sure). You can check if your distro's perf package is linked with libdw or libunwind with readelf -d $(which perf) | grep -e libdw -e libunwind. On Fedora 20, perf is linked with libdw.
perf is a kernel tool which shows elapsed time for system calls.
You are looking for GNU gprof. "gprof - display call graph profile data".
To use gprof you need to compile your sources with the -pg switch.
Beside of this there are a lot of sophisticated profiling tools like eclipse-cdt-profiling-framework.