如何生成符号信息以与 Linux 版本的英特尔 VTune Amplifier 一起使用?
我正在使用英特尔 VTune Amplifier XE 2011 来分析我的程序的性能。我希望能够在分析结果中查看源代码,文档说我需要提供符号信息。不幸的是,它没有说明在编译我的程序时如何生成该符号信息。在 VTune 的 Windows 版本中,我所要做的就是提供 Microsoft Visual Studio 将生成的“.pdb”文件。我可以使用 g++ 创建类似的文件来提供此符号信息吗?
I am using Intel VTune Amplifier XE 2011 to analyze the performance of my program. I want to be able to view the source code in the analysis results, and the documentation says I need to provide the symbol information. Unfortunately, it does not state how to generate that symbol information when compiling my program. In the Windows version of VTune all I had to do was provide the ".pdb" file that Microsoft Visual Studio would generate. Is there a similar kind of file I can create using g++ to provide this symbol information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否尝试过使用 -g 进行编译?通常,这就是为调试器、分析器等生成符号数据所需的全部内容。
顺便说一句,对于 Linux 上的分析,Zoom from RotateRight .com 比 VTune 更加用户友好。 (更新:遗憾的是,不再支持 Zoom。使用
perf
进行简单的分析。)Have you tried compiling with -g ? Normally that is all you need to generate symbolic data for debuggers, profilers, etc.
Incidentally, for profiling on Linux, Zoom from RotateRight.com is a lot more user-friendly than VTune. (UPDATE: Zoom is unfortunately no longer supported. Use
perf
for simple profiling.)使用 GCC 获取包含调试信息的可执行文件的最“经典”方法是指定其他海报提到的“-g”命令行选项。这不会造成任何性能影响,因为调试信息驻留在 ELF 部分中,而 ELF 部分不是代码或数据段的一部分。也就是说,.debug* 部分在正常程序执行期间不会映射到内存中,只是调试器在调试时将它们映射到内存中。
对于任何开发生产软件的开发人员来说,另一个有用的考虑因素是使用 单独的调试信息文件。假设如上所述使用“-g”编译程序,然后使用 objcopy 实用程序将包含调试信息的 ELF 部分复制到单独的文件中,并添加从原始二进制文件到单独的调试信息文件的链接。这对于能够存储发布给客户的位的调试信息非常有用,以便可以进行事后调试。当然,也适用于发布位的性能分析。
The most "classic" way to get an executable to contain the debug information with GCC is to specify the "-g" command line option as mentioned by the other posters. This does not incur any performance hit since debug information resides in ELF sections which are not part of the code or data segment. That is, the .debug* sections are not mapped into the memory during normal program execution, it's only the debug time when the debugger gets them in.
Another useful consideration for any developer working on production software is to use separate debug information files. That assumes compiling the program with "-g" as described above and then using objcopy utility to copy out the ELF sections containing debug information into a separate file and adding a link from the original binary file to the separate debug information file. This is extremely useful for being able to store the debug information for the bits you released to a customer so that post-mortem debugging is possible. And of course, for performance profiling on the release bits, too.
gcc -g
应该是所有必需的。不过我用的是旧版本。新内容的命令行选项是 此处
编辑:
这个SO答案可能更有价值比这里的任何东西都重要。
gcc -g <your stuff>
should be all that's necessary. However I used an older version.The command line options for the newer stuff is here
EDIT:
This SO answer is probably more valuable than anything here.