Debugging 如何在ubuntu上使用调试库
我目前的问题是libwebkitgtk-3.0-0,但我想这个问题已经足够普遍了 我的应用程序在webkit代码的某个地方崩溃了。我的假设是我们正在做一些愚蠢的事情,想知道是什么。最简单的方法是设置断点或使用库的调试版本Debugging 如何在ubuntu上使用调试库,debugging,ubuntu,webkit,gtk,Debugging,Ubuntu,Webkit,Gtk,我目前的问题是libwebkitgtk-3.0-0,但我想这个问题已经足够普遍了 我的应用程序在webkit代码的某个地方崩溃了。我的假设是我们正在做一些愚蠢的事情,想知道是什么。最简单的方法是设置断点或使用库的调试版本 如何获得构建库的确切源代码?在转储内核之后,我得到了堆栈跟踪,但行号gdb表示与我在代码中看到的不匹配。换言之,如果我安装libwebkitgtk-3.0-0,我希望获得确切的源代码 我已经安装了webkit库的调试版本。这些调试版本是否具有与使用--enable debug标
祝你好运;DR:安装,然后您就有了必要的调试符号 对于调试符号,通常不必从源代码安装。 如您所知,要为您自己构建的软件获取调试符号,您可以使用
-g
运行GCC
对于通过操作系统的软件包管理器(此处包括libwebkitgtk-3.0-0
)安装的软件,至少对于官方软件包,通常还有提供调试符号的软件包
实际上,在gdb
中获得符号堆栈跟踪不需要程序或库的调试版本gdb
还支持在/usr/lib/debug
中提供“附加”调试符号的文件
根据你问题上的标签,你使用Ubuntu。在Ubuntu上,调试符号包有两种类型:-dbg
和-dbgsym
。位于路径/的程序或库在路径/usr/lib/debug/获取调试符号
-dbg
软件包
这些包的名称通常不同于提供实际可执行文件或库文件的相应包。它们的名称通常类似于-dev
包(提供头文件)和-doc
包。-dbg
包有时名称中的库版本编号少于实际的库包,有时包含多个其他包中提供的二进制文件
例如,'s对应的-dbg
包是
另一方面,有时-dbg
包的名称与它提供符号的包的名称相同(除了-dbg
后缀)。例如,对应的-dbg
包是。这就是您想要的
您可以在软件中心或通过运行以下程序进行安装:
sudo apt-get update && sudo apt-get install libwebkitgtk-3.0-0-dbg
现在,当您调试链接到libwebkitgtk-3.0-0
提供的库的程序时,gdb
将自动从libwebkitgtk-3.0-0-dbg
提供的文件加载符号
-dbgsym
包
有时,官方软件包提供的二进制可执行文件在任何-dbg
软件包中都没有提供符号。发生这种情况时,通常可以安装-dbgsym
包
与-dbg
包不同,-dbgsym
包:
- 几乎总是简单地(可预测地)命名为
X-dbgsym
,其中X
是提供程序或库本身的包
- 由特殊软件源(存储库)提供,而不是提供相应程序的相同软件源
deb http://ddebs.ubuntu.com YOUR_RELEASE main restricted universe multiverse
deb http://ddebs.ubuntu.com YOUR_RELEASE-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com YOUR_RELEASE-security main restricted universe multiverse
deb http://ddebs.ubuntu.com YOUR_RELEASE-proposed main restricted universe multiverse
echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-security main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse
" | sudo tee -a /etc/apt/sources.list.d/ddebs.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 428D7C01
sudo apt-get update
$ objdump -g /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.27.so | sed -n '/<.*>\s\+DW_AT_comp_dir/ {s/\s\+<.*>\s\+//; p;}' | sort | uniq
DW_AT_comp_dir : (indirect string, offset: 0x1127a): /build/glibc-OTsEL5/glibc-2.27/malloc
...
DW_AT_comp_dir : (indirect string, offset: 0xd139): /build/glibc-OTsEL5/glibc-2.27/stdio-common
DW_AT_comp_dir : (indirect string, offset: 0xef40): /build/glibc-OTsEL5/glibc-2.27/libio
$ ls -ld glibc-2.27/{stdio-common,libio}
drwxrwxr-x 3 fusillator fusillator 12288 feb 1 2018 glibc-2.27/libio
drwxrwxr-x 3 fusillator fusillator 4096 feb 1 2018 glibc-2.27/stdio-common
$ gdb ./hello
Reading symbols from ./hello...done.
(gdb) set substitute-path /build/glibc-OTsEL5/glibc-2.27 glibc-2.27
(gdb) b main
Breakpoint 1 at 0x63e: file hello.c, line 10.
(gdb) run
Starting program: hello
Breakpoint 1, main () at hello.c:10
10 printf("hello world\n");
(gdb) s
_IO_puts (str=0x5555555546e4 "hello world") at ioputs.c:33
33 {
(gdb) backtrace
#0 _IO_puts (str=0x5555555546e4 "hello world") at ioputs.c:33
#1 0x000055555555464a in main () at hello.c:10