如何让 callgrind 转储源行信息?

发布于 2024-09-03 03:38:45 字数 353 浏览 10 评论 0原文

我正在尝试在 GNU/Linux 上分析一个进行实时音频处理的共享库,因此性能很重要。我运行另一个程序,将其连接到系统的音频输入和输出,并使用 callgrind 对其进行分析。

通过查看 KCacheGrind 中的结果,我获得了有关哪些函数占用了我大部分时间的重要信息。但是,它不会让我逐行查看信息,而是说我需要使用调试符号对其进行编译并再次运行分析。

我正在分析的程序不是用调试符号编译的,但库是用调试符号编译的。我知道这一点,因为有趣的是,cachegrind 的源代码注释工作得很好。

当我运行 callgrind 时,它说默认是转储源行信息,但它只是没有这样做。有什么方法可以强迫它这样做,或者找出阻止它的原因吗?

I'm trying to profile a shared library on GNU/Linux which does real-time audio processing, so performance is important. I run another program which hooks it up to the audio input and output of my system, and profile that with callgrind.

Looking at the results in KCacheGrind, I get great information about what functions are taking up most of my time. However, it won't let me look at the line by line information, and instead says I need to compile it with debugging symbols and run the profiling again.

The program which I am profiling is not compiled with debug symbols, but the library is. And I know this, because interestingly, source code annotations for cachegrind work fine.

When I run callgrind, it says the default is to dump source line information, but it just isn't doing that. Is there some way I could force it to, or figure out what's stopping it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

简单 2024-09-10 03:38:46

您是否使用 --dump-instr=yes --trace-jump=yes 来获取指令级别信息?

Are you using --dump-instr=yes --trace-jump=yes to get the instruction level information?

生寂 2024-09-10 03:38:46

正如您已正确识别的那样,默认情况下,callgrind 正在源代码级别执行事件计数。
引用 callgrind 的手册页 -

--dump-line=<no|yes> [default: yes]

但在后处理过程中,您必须使用 --include 为 callgrind_annotate 工具提供源文件的路径 选项用于生成带有逐行信息的带注释的源代码。
引用 callgrind_annotate 的手册页 -

       -I, --include=<dir>
           Add dir to the list of directories to search for source files.

这是对我有用的示例命令 -

callgrind_annotate --auto=yes --include=/home/sangeek/source callgrind.out.15078 > callgrind.annotate.txt 

另请注意,源代码级别注释报告放置在通常的 file:function 文件中的摘要报告。因此,您必须滚动浏览报告中的内容才能找到它们。

As you have correctly identified callgrind by default is performing the event count at source code level.
Quoting from the man page of callgrind -

--dump-line=<no|yes> [default: yes]

But then during post-processing, you have to provide the path to source files for the callgrind_annotate tool using the --include option for it to generate the annotated source-code with line by line information.
Quoting from the man page of callgrind_annotate -

       -I, --include=<dir>
           Add dir to the list of directories to search for source files.

This is the sample command that worked for me -

callgrind_annotate --auto=yes --include=/home/sangeek/source callgrind.out.15078 > callgrind.annotate.txt 

Also please note that the source-code level annotated report is placed after the usual file:function summary report in the file. So, you'll have to scroll past those in the report to reach them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文