- 我的机器运行Ubuntu 22.04*
我创建了这样的核心文件:
$ sleep 10 & killall -SIGNEGV sleep
字符串
我还下载了调试符号睡眠通过
- debuginfod(由gdb自动)
- Ubuntu的ddeb库(以及coreutils的源代码)
当我开始使用GDB调试核心文件时,bt
显示源文件的文件名:
$ gdb -q /bin/sleep -c sleep-core-dump
Reading symbols from /bin/sleep...
Reading symbols from /home/gordiig/.cache/debuginfod_client/9605b84bc84dab0a28a772dcebed48b0b98ec3a9/debuginfo...
[New LWP 438331]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by 'sleep 10'.
Program terminated with signal SIGSEGV, Segmentation fault.
(gdb) bt
#0 0x00007f4f90fea7fa in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7ffccf5a9880, rem=rem@entry=0x7ffccf5a9870) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
#1 0x00007f4f90fef6e7 in __GI___nanosleep (req=req@entry=0x7ffccf5a9880, rem=rem@entry=0x7ffccf5a9870) at ../sysdeps/unix/sysv/linux/nanosleep.c:25
#2 0x000055a5b5eb9a00 in rpl_nanosleep (remaining_delay=0x7ffccf5a9870, requested_delay=0x7ffccf5a9870) at lib/nanosleep.c:85
#3 xnanosleep (seconds=<optimized out>) at lib/xnanosleep.c:69
#4 main (argc=<optimized out>, argv=<optimized out>) at src/sleep.c:142
型
但是当我用lldb调试时,它不显示文件,所以它不显示源代码:
$ lldb /bin/sleep -c sleep-core-dump
(lldb) target create "/bin/sleep" --core "sleep-core-dump"
Core file '/home/gorin_d/work/playing-with-dumps/src/dumps-generator/sleep-core-dump' (x86_64) was loaded.
(lldb) target symbols add /home/gordiig/.cache/debuginfod_client/9605b84bc84dab0a28a772dcebed48b0b98ec3a9/debuginfo
warning: (x86_64) /bin/sleep unsupported DW_FORM values: 0x1f20 0x1f21
warning: failed to set breakpoint site at 0x55a5b5eb9b90 for breakpoint -2.1: error: elf-core does not support enabling breakpoints
symbol file '/home/gordiig/.cache/debuginfod_client/9605b84bc84dab0a28a772dcebed48b0b98ec3a9/debuginfo' has been added to '/bin/sleep'
(lldb) bt
* thread #1, name = 'sleep', stop reason = signal SIGSEGV
* frame #0: 0x00007f4f90fea7fa libc.so.6`clock_nanosleep + 90
frame #1: 0x00007f4f90fef6e7 libc.so.6`__nanosleep + 23
frame #2: 0x000055a5b5eb9a00 sleep`main + 1024
frame #3: 0x00007f4f90f2ed90 libc.so.6`___lldb_unnamed_symbol3139 + 128
frame #4: 0x00007f4f90f2ee40 libc.so.6`__libc_start_main + 128
frame #5: 0x000055a5b5eb9bb5 sleep`_start + 37
(lldb) f 2
frame #2: 0x000055a5b5eb9a00 sleep`main + 1024
sleep`main:
-> 0x55a5b5eb9a00 <+1024>: testl %eax, %eax
0x55a5b5eb9a02 <+1026>: jne 0x29d6 ; <+982>
0x55a5b5eb9a04 <+1028>: movq 0x58(%rsp), %rax
0x55a5b5eb9a09 <+1033>: subq %fs:0x28, %rax
型
如果我使用来自ddebs的调试符号而不是debuginfod,情况会稍微好一点,但并不完美。lldb显示了一些文件的名称,但没有显示sleep的主文件:
$ find-dbgsym-packages --install ./sleep-core-dump
runs sudo apt install --no-install-recommends coreutils-dbgsym libc6-dbg
$ lldb /bin/sleep -c sleep-core-dump
(lldb) target create "/bin/sleep" --core "sleep-core-dump"
warning: (x86_64) /bin/sleep unsupported DW_FORM values: 0x1f20 0x1f21
Core file '/home/gordiig/work/playing-with-dumps/src/dumps-generator/sleep-core-dump' (x86_64) was loaded.
(lldb) target symbols add /usr/lib/debug/.build-id/96/05b84bc84dab0a28a772dcebed48b0b98ec3a9.debug
warning: failed to set breakpoint site at 0x55a5b5eb9b90 for breakpoint -2.1: error: elf-core does not support enabling breakpoints
symbol file '/usr/lib/debug/.build-id/96/05b84bc84dab0a28a772dcebed48b0b98ec3a9.debug' has been added to '/bin/sleep'
(lldb) bt
* thread #1, name = 'sleep', stop reason = signal SIGSEGV
* frame #0: 0x00007f4f90fea7fa libc.so.6`__GI___clock_nanosleep(clock_id=0, flags=0, req=0x00007ffccf5a9880, rem=0x00007ffccf5a9870) at clock_nanosleep.c:78:7
frame #1: 0x00007f4f90fef6e7 libc.so.6`__GI___nanosleep(req=<unavailable>, rem=<unavailable>) at nanosleep.c:25:13
frame #2: 0x000055a5b5eb9a00 sleep`main + 1024
frame #3: 0x00007f4f90f2ed90 libc.so.6`__libc_start_call_main(main=(sleep`main), argc=2, argv=0x00007ffccf5a99e8) at libc_start_call_main.h:58:16
frame #4: 0x00007f4f90f2ee40 libc.so.6`__libc_start_main_impl(main=(sleep`main), argc=2, argv=0x00007ffccf5a99e8, init=(_rtld_global), fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007ffccf5a99d8) at libc-start.c:392:3
frame #5: 0x000055a5b5eb9bb5 sleep`_start + 37
(lldb) f 2
frame #2: 0x000055a5b5eb9a00 sleep`main + 1024
sleep`main:
-> 0x55a5b5eb9a00 <+1024>: testl %eax, %eax
0x55a5b5eb9a02 <+1026>: jne 0x29d6 ; <+982>
0x55a5b5eb9a04 <+1028>: movq 0x58(%rsp), %rax
0x55a5b5eb9a09 <+1033>: subq %fs:0x28, %rax
型
我的问题是:
1.为什么lldb看不到或显示一些帧的源文件名(尤其是sleep的主帧),而gdb可以?
1.来自gdb和lldb的帧不匹配。例如,gdb中的main frame被标记为fourth,而lldb中的main frame被标记为second。为什么会这样?
1条答案
按热度按时间tquggr8v1#
为什么lldb看不到或显示某些帧的源文件名
这是一个
lldb
bug。来自gdb和lldb的帧不匹配。
GDB显示显示内联函数(注意
xnanosleep
和main
没有程序计数器)。显示内联函数需要访问调试信息(这里是主二进制文件的调试信息),GDB找到了,而LLDB没有(可能是由于上面的bug,这也是LLDB下的
main
没有文件/行信息的原因)。