c - “符号”列显示地址而不是函数名
问题描述
这是我的系统信息。
$ 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。
- 最高访问权限。
解决方案
使用以下命令为 libc 安装调试符号以获取库函数的名称。
sudo apt-get install libc6-dbg
sudo apt-get source libc6-dev
推荐阅读
- javascript - 我如何在 Javascript 中使用 Bind
- jquery - Jquery 样式和颜色
- java - 使用 @Qualifier 指定的 bean 注入点时如何扩展命名的 Spring bean?
- apache - MAMP:Apache 服务器在 Windows 10 中自动关闭
- reactjs - 为什么会出现“object not function”?
- php - 使用从用户输入收集的 AJAX 请求发送的 POST 数据强制下载使用 php 创建的 ics 文件
- vb6 - 使用VB6执行批处理传递两个参数,两个变量由空格分隔
- npm - 从存储库克隆后,sails.js 停止工作
- vb.net - 使用自动编号主键绑定到 MS Access 表的 DataGridView 导致并发错误
- javascript - 如何在 React 中显示来自 api 的图像