在 perf 中使用调试符号

Using debug symbols with perf

我监控 PowerPC 系统上的进程以提取性能信息。 如何加载此进程的调试符号? 我使用以下命令

perf record -g dwarf -p 4591

我认为 "dwarf cannot be found (no such file or directory)" 能否请您提示如何加载有关生成报告时调用的函数的调试信息?

perf record -g dwarf -p 4591

如今,选择方法的正确选项是 --call-graph,而 -g 只是一个标志,用于使用其默认方法 fp.

启用调用堆栈

来自 man perf-record

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

--call-graph
    Setup and enable call-graph (stack chain/backtrace) recording,
    implies -g.  Default is "fp".

    Allows specifying "fp" (frame pointer) or "dwarf"
    (DWARF's CFI - Call Frame Information) or "lbr"
    (Hardware Last Branch Record facility) 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 or libdw library) should be used instead.
    Using the "lbr" method doesn't require any compiler options. It
    will produce call graphs from the hardware LBR registers. The
    main limitation is that it is only available on new Intel
    platforms, such as Haswell. It can only get user call chain. It
    doesn't work with branch stack sampling at the same time.

    When "dwarf" recording is used, perf also records (user) stack dump
    when sampled.  Default size of the stack dump is 8192 (bytes).
    User can change the size by passing the size after comma like
    "--call-graph dwarf,4096".

顺便说一句,首先尝试 fp - 它效率更高,但不适用于优化的二进制文件(例如 --fomit-frame-pointer)。这也与调试信息关系不大。如果您不需要知道堆栈跟踪,则无需添加 -g.

您使用的 old version of perf 不支持 -g dwarf,但仅支持 -g(无参数),即它不支持 DWARF 展开。