[Linux] 在Fedora中使用debuginfo进行调试
Fedora发行的RPM包中,一般都带有可用于调试的debuginfo包。以wget为例:
http://koji.fedoraproject.org/koji/buildinfo?buildID=291804
可以看到wget-1.13.4-2.fc17.i686.rpm同时配有wget-debuginfo-1.13.4-2.fc17.i686.rpm。
一般情况下,使用yum安装相关软件时,是不会自动安装相应的debuginfo包的。假设我们的机器上安装了wget:
yum install wget
此时的使用gdb调试的话:
-bash-4.2$ gdb wget GNU gdb (GDB) Fedora (7.3.50.20110722-9.fc16) ... Reading symbols from /usr/bin/wget...(no debugging symbols found)...done. Missing separate debuginfos, use: debuginfo-install wget-1.12-4.fc16.i686
可以看到gdb提示我们wget缺少debuginfos。此时如果相查看代码:
(gdb) list No symbol table is loaded. Use the "file" command.
会发现缺少调试信息。因此我们可以用debuginfo来安装wget的调试信息:
sudo debuginfo-install wget-1.12-4.fc16.i686
安装完成后,再次使用gdb调试:
-bash-4.2$ gdb wget ... Reading symbols from /usr/bin/wget...Reading symbols from /usr/lib/debug/usr/bin/wget.debug...done.
发现gdb读入了wget.debug中的调试数据,此时查看代码:
(gdb) list 858 fputs (_("Please send bug reports and questions to <bug-wget@gnu.org>.\n"), 859 stdout); 860 exit (0); 861 } 862 863 char *program_name; /* Needed by lib/error.c. */ 864 865 int 866 main (int argc, char **argv) 867 {
发现已经可以直接进行源代码的调试了。
更多有关debuginfo以及Fedora下面调试的内容,可以参考:
http://fedoraproject.org/wiki/Packaging:Debuginfo
http://fedoraproject.org/wiki/StackTraces