Linux 性能分析器中的调用堆栈

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12160449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 14:11:48  来源:igfitidea点击:

Call stack in the perf profiler

linuxprofilingperf

提问by erezz

I'm running "perf" in the following way:

我正在以下列方式运行“perf”:

perf record -a --call-graph -p some_pid

perf report --call-graph --stdio

Then, I see this:

然后,我看到这个:

 1.60%     my_binary  my_binary                [.] my_func
           |
           --- my_func
              |          
              |--71.10%-- (nil)
              |          (nil)
              |          
               --28.90%-- 0x17f310000000a

I can't see which functions call my_func(). I see "nil" and "0x17f310000000a" instead. Am I doing something wrong? It is probably not a debug info problem because some symbols are shown while others are not shown.

我看不到哪些函数调用了 my_func()。我看到的是“nil”和“0x17f310000000a”。难道我做错了什么?这可能不是调试信息问题,因为显示了一些符号而其他符号未显示。

More info:

更多信息:

  • I'm runnning CentOS 6.2 (kernel 2.6.32-220.4.1).
  • perf rpm - perf-2.6.32-279.5.2.el6.x86_64.
  • 我正在运行 CentOS 6.2(内核 2.6.32-220.4.1)。
  • perf rpm - perf-2.6.32-279.5.2.el6.x86_64。

回答by federal

Have you tried profiling with Zoom? It can use perf, a custom driver, or oprofile to collect samples. If you're just interested in looking at one process, try the "Thread Time" configuration.

您是否尝试过使用Zoom 进行分析?它可以使用 perf、自定义驱动程序或 oprofile 来收集样本。如果您只对查看一个进程感兴趣,请尝试“线程时间”配置。

I'd be interested to know if any of Zoom's options are better/different at getting the function information than stand-alone perf.

我很想知道 Zoom 的任何选项在获取功能信息方面是否比独立性能更好/不同。

回答by Andriy

Make sure you compiled the code with -fno-omit-frame-pointergccoption.

确保使用-fno-omit-frame-pointergcc选项编译代码。

回答by holygeek

You're almost there, you're missing the -Goption (you might need a more recent perf than the one installed on your system):

你快到了,你错过了这个-G选项(你可能需要一个比你系统上安装的更新的性能):

$ perf report --call-graph --stdio -G

From perf help report:

来自perf help report

   -G, --inverted
       alias for inverted caller based call graph.