“符号”列显示地址而不是函数名称

时间:2018-10-17 22:08:02

标签: c linux perf

这是我的系统信息。

$ uname -a
Linux pjchiou-X550JX 4.16.0-041600-generic #201804012230 SMP Sun Apr 1 22:31:39 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

我使用一个非常简单的C程序来测试perf

#include <stdio.h>
#include <stdlib.h>

void myloop()
{
    for (int i = 0; i < 100000; i++)
        printf("%d", i);
}

int main(void)
{
    myloop();
    return (0);
}

编译:

gcc -g -o test test.c

然后使用以下方法收集样本:

perf record ./test

最后,显示报告:

perf report

但是,我在报告中看到的是这样的:

# Overhead  Command  Shared Object      Symbol                      
# ........  .......  .................  ............................
#
 9.64%  test     libc-2.27.so       [.] 0x000000000005cb14
 6.17%  test     libc-2.27.so       [.] 0x000000000005bf8e
 5.75%  test     libc-2.27.so       [.] 0x000000000005885e
 5.61%  test     libc-2.27.so       [.] 0x000000000005886b
 5.33%  test     libc-2.27.so       [.] 0x00000000000587b0
 5.28%  test     libc-2.27.so       [.] 0x000000000005b6ff
 5.23%  test     [kernel.kallsyms]  [k] n_tty_write

为什么“ 符号”列显示地址而不是函数名称?

  • 已安装gdb。
  • 已安装libc6,libc6-dbg,libc6-dev。
  • 最高访问权限。

1 个答案:

答案 0 :(得分:2)

为libc安装调试符号,以使用以下命令获取库函数的名称。

sudo apt-get install libc6-dbg
sudo apt-get source libc6-dev
相关问题