回溯和反汇编
回溯 (backtrace)
回溯当前线程调用栈
- gdb
- lldb
(gdb) backtrace
(gdb) bt
(lldb) thread backtrace
(lldb) bt
回溯所有线程调用栈
- gdb
- lldb
(gdb) thread apply all bt
(lldb) thread backtrace all
(lldb) bt all
回溯当前线程调用栈的 backtrace 的前几帧
- gdb
- lldb
(gdb) bt 5
(lldb) thread backtrace -c 5
(lldb) bt 5
反汇编 (disassemble)
反汇编当前栈帧函数
- gdb
- lldb
(gdb) disassemble
(gdb) disas
(lldb) disassemble --frame
(lldb) di -f
反汇编任何名为 main 的函数
- gdb
- lldb
(gdb) disassemble main
(lldb) disassemble --name main
(lldb) di -n main
反汇编某个地址范围
- gdb
- lldb
(gdb) disassemble 0x1eb8 0x1ec3
(lldb) disassemble --start-address 0x1eb8 --end-address 0x1ec3
(lldb) di -s 0x1eb8 -e 0x1ec3
从给定地址反汇编若干条指令
- gdb
- lldb
(gdb) x/20i 0x1eb8
(lldb) disassemble --start-address 0x1eb8 --count 20
(lldb) di -s 0x1eb8 -c 20
同时显示当前函数的源代码和反汇编代码
- gdb
- lldb
(lldb) disassemble --frame --mixed
(lldb) di -f -m
反汇编当前函数
- gdb
- lldb
(lldb) disassemble --frame --bytes
(lldb) di -f -b