在 Linux 和 Mac OS XI 中可以使用 stepi 和 nexti 来调试应用程序而无需调试信息。
在 Mac OS X 上,gdb 显示了在库中调用的函数,尽管有时会在每个 stepi 指令中推进几条汇编指令。
在 Linux 上,当我踏入动态库时,gdb 会迷路。例如,对于 puts(),puts() 中有三个汇编指令,一旦 gdb 到达 0x080482bf 处的跳转,它就会失败并显示消息“No function contains program counter for selected frame”。
0x080482ba in puts@plt ()
(gdb) disassemble
Dump of assembler code for function puts@plt:
0x080482b4 <puts@plt+0>: jmp *0x8049580
0x080482ba <puts@plt+6>: push $0x10
0x080482bf <puts@plt+11>: jmp 0x8048284 <_init+48>
End of assembler dump.
(gdb) stepi
0x080482bf in puts@plt ()
(gdb) stepi
0x08048284 in ?? ()
(gdb) disassemble
No function contains program counter for selected frame.
你知道如何用 gdb 调试这些库调用吗?