I'm using perf record -g on x86-64 Linux to profile a program. Several symbols in libc or libstdc++ have 0 as a parent: __GI___strcmp_ssse3 (libc) and strcmp@plt (libstdc++) for example. (I can actually break on these symbols in the debugger and get a backtrace.)

I'd love to know what the major callers of these functions are, and why they are not recorded. Is this because libc and libstdc++ do not have frame pointers on x86_64? And, more practically, is there some way around this?


This is an old question, but this in now possible with --call-graph dwarf. From the man page:

       Enables call-graph (stack chain/backtrace) recording.

       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 record --call-graph dwarf solves this problem for me. unfortunately, it seems that perf has problems showing caller-based (i.e. "inverted") call-graphs when using dwarf information. That is why I started using FlameGraph for visualisation. – blue Feb 12 '17 at 13:29

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.