Debian / Ubuntu的Debug信息文件约定? [英] Debug information file conventions for Debian/Ubuntu?

查看:210
本文介绍了Debian / Ubuntu的Debug信息文件约定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据洛杉矶的如何在构建目标之外生成gcc调试符号的答案,我可以创建一个两部分的可执行文件 - 剥离的可执行文件和调试信息文件。

According to lothar's answer at How to generate gcc debug symbol outside the build target, I can create a two part executable - the stripped executable and the debug information file.

创建剥离的可执行文件和调试信息文件后,我正常安装可执行文件(使用 make install )。但是我不知道Debian / Ubuntu的调试信息文件如何处理。

After creating the stripped executable and the debug information file, I install the executable as normal (with make install). But I'm not sure what to do with the debug information file for Debian/Ubuntu.

我有两个与GDB或LLDB调试可执行文件相关的问题(如果调试需要):

I have two questions related to debugging the executable with GDB or LLDB (if debugging is needed):


  • Debian / Ubuntu上调试信息文件的名称是什么?有没有遵循的约定,所以调试器会自动将它们与可执行文件相关联?

  • What is the name of the debug information file on Debian/Ubuntu? Is there a convention to follow so the debugger associates them with the executable automatically?

在Debian / Ubuntu上将调试信息文件放在哪里?调试程序在调试可执行文件时找到的位置是什么?

Where do I place the the debug information file on Debian/Ubuntu? What is the location so the debugger finds them when debugging the executable?

这是一个不同平台的相关问题: 红帽/ Fedora的调试信息文件约定对于OS X来说,知道相同的操作也是有帮助的,因为我在

Here's a related question for a different platform: Debug information file conventions for Red Hat/Fedora? It would also be helpful to know the same for OS X since I work on it on occasion.

推荐答案

Fedora和Ubuntu都遵循单独文件中的调试信息

Both Fedora and Ubuntu follow the convention described in Debugging Information in Separate Files.

Gdb首先检索文件名在可执行文件的 .gnu_debuglink 部分。 .gnu_debuglink 不包含任何目录名称。然后,Gdb会查找一个名为(如果我可以使用shell语法)的文件,$ code> $(dirname $ executable)/ $ debuglink ,然后 / usr / lib / debug / $(dirname $ executable)/ $ debuglink ,用于调试信息。 (它实际上看起来在几个替代位置;与上面链接的文档有更多的信息。)

Gdb first retrieves the filename present in the executable's .gnu_debuglink section. .gnu_debuglink doesn't include any directory names. Gdb then looks for a file named (if I may use shell syntax) $(dirname $executable)/$debuglink, then /usr/lib/debug/$(dirname $executable)/$debuglink, for the debugging information. (It actually looks in a couple alternative locations; the documentation linked to above has more info.)

发行版提供的可执行文件的调试信息可以在例如,在Ubuntu上的
/ usr / lib / debug / usr / sbin / apache2 / usr / lib / debug / usr / sbin /httpd.debug 在Fedora上。 (Fedora添加了一个 .debug 扩展名,使您可以轻松地将具有调试信息的文件放在与可执行文件相同的目录中。)

The debugging information for a distro-supplied executable can be found in, for example, /usr/lib/debug/usr/sbin/apache2 on Ubuntu or /usr/lib/debug/usr/sbin/httpd.debug on Fedora. (Fedora adds a .debug extension, making it easy to place the file with the debugging information in the same directory as the executable, if you wish.)

目录 / usr / lib / debug 在构建时被编译成gdb,但gdb用户可以使用 set debug-file-directory dirpath1:dirpath2:... 命令。

The directory /usr/lib/debug is compiled into gdb at build time, but the gdb user can change it using the set debug-file-directory dirpath1:dirpath2:... command.

如果您也有兴趣制作可用于gdb的源代码:

If you're also interested in making the source code available to gdb:

Gdb在编译目录中查找源代码(它从调试信息的 DW_AT_comp_dir 属性)或当前工作目录。用户可以使用指定源目录中描述的各种gdb命令调整这个。

Gdb looks for the source code in the compilation directory (which it retrieves from the debugging information's DW_AT_comp_dir attributes) or the current working directory. The user can use a variety of gdb commands described in Specifying Source Directories to adjust this.

Fedora的 * - debuginfo 包含调试信息和源代码。源代码安装在 / usr / src / debug 下,文件中的调试信息位于 / usr / lib / debug 包含具有目录路径名的 DW_AT_comp_dir 属性,例如 /usr/src/debug/httpd-2.4.10 。如果可执行文件是从多个编译单元构建的,则可以有多个 DW_AT_comp_dir 属性。

Fedora's *-debuginfo packages include both the debugging information and the source code. The source code gets installed under /usr/src/debug, and the debugging information in the file under /usr/lib/debug includes a DW_AT_comp_dir attribute with the directory pathname, such as /usr/src/debug/httpd-2.4.10. There can be multiple DW_AT_comp_dir attributes if the executable was built from multiple compilation units.

Ubuntu的 * - dbg 包不包含源代码,根据我的经验,用户可以使用命令 apt-get source将源下载到当前工作目录中。。调试信息的 DW_AT_comp_dir 属性类似于 /build/buildd/apache2-2.4.7

Ubuntu's *-dbg packages don't include the source code, in my experience, but users can download the source into the current working directory with the command apt-get source .... The debugging information's DW_AT_comp_dir attribute is something like /build/buildd/apache2-2.4.7.

这篇关于Debian / Ubuntu的Debug信息文件约定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆