如何获得性能以在程序中查找符号 [英] How can I get perf to find symbols in my program
问题描述
使用perf report
时,我的程序没有看到任何符号,而是得到如下输出:
When using perf report
, I don't see any symbols for my program, instead I get output like this:
$ perf record /path/to/racket ints.rkt 10000
$ perf report --stdio
# Overhead Command Shared Object Symbol
# ........ ........ ................. ......
#
70.06% ints.rkt [unknown] [.] 0x5f99b8
26.28% ints.rkt [kernel.kallsyms] [k] 0xffffffff8103d0ca
3.66% ints.rkt perf-32046.map [.] 0x7f1d9be46650
这是毫无根据的.
相关程序是用调试符号构建的,sysprof
工具显示了适当的符号,Zoom也是如此,我认为它是在引擎盖下使用perf
的.
The relevant program is built with debugging symbols, and the sysprof
tool shows the appropriate symbols, as does Zoom, which I think is using perf
under the hood.
请注意,这是在x86-64上,因此二进制文件是使用-fomit-frame-pointer
编译的,但是在其他工具下运行时也是如此.
Note that this is on x86-64, so the binary is compiled with -fomit-frame-pointer
, but that's the case when running under the other tools as well.
推荐答案
此帖子已有一年多的历史了,但是由于遇到相同问题时它出现在我的Google搜索结果的顶部,所以我认为d在这里回答.经过一番搜索之后,我发现了这个相关StackOverflow问题中的答案非常有帮助.然后,在我的Ubuntu Raring系统上,我完成了以下操作:
This post is already over a year old, but since it came out at the top of my Google search results when I had the same problem, I thought I'd answer it here. After some more searching around, I found the answer given in this related StackOverflow question very helpful. On my Ubuntu Raring system, I then ended up doing the following:
- 用
-g
编译我的C ++源代码(显然,您需要调试符号) -
以
运行
perf
- Compile my C++ sources with
-g
(fairly obvious, you need debug symbols) Run
perf
as
record -g dwarf -F 97 /path/to/my/program
通过这种方式perf
能够处理 DWARF 2 调试格式,标准格式gcc
在Linux上使用. -F 97
参数将采样率降低到97 Hz.默认采样率对于我的系统来说显然太大,并导致出现以下消息:
This way perf
is able to handle the DWARF 2 debug format, which is the standard format gcc
uses on Linux. The -F 97
parameter reduces the sampling rate to 97 Hz. The default sampling rate was apparently too large for my system and resulted in messages like this:
Warning:
Processed 172390 events and lost 126 chunks!
Check IO/CPU overload!
和perf report
之后的调用将因分段错误而失败.在降低采样率的情况下,一切正常.
and the perf report
call afterwards would fail with a segmentation fault. With the reduced sampling rate everything worked out fine.
as root can help as well, if kernel symbols are required.
这篇关于如何获得性能以在程序中查找符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!