你可以用display
命令來做這種事情。
display/i $pc
將拆卸提示 每次印刷之前的當前指令:
(gdb) b main
Breakpoint 1 at 0x80483b5: file hw.c, line 5.
(gdb) display/i $pc
(gdb) r
Starting program: /tmp/hw
Breakpoint 1, main() at hw.c:5
5 puts("Hello world");
1: x/i $pc
0x80483b5 <main+17>: movl $0x8048490,(%esp)
現在步驟的指令(當時只是不停按下回車鍵重複):
(gdb) si
0x080483bc 5 puts("Hello world");
1: x/i $pc
0x80483bc <main+24>: call 0x80482d4 <[email protected]>
(gdb)
0x080482d4 in [email protected]()
1: x/i $pc
0x80482d4 <[email protected]>: jmp *0x804959c
Current language: auto; currently asm
(gdb)
0x080482da in [email protected]()
1: x/i $pc
0x80482da <[email protected]+6>: push $0x10
(gdb)
0x080482df in [email protected]()
1: x/i $pc
0x80482df <[email protected]+11>: jmp 0x80482a4 <_init+48>
它仍然當我們到達這一點時,作品:
(gdb)
0x080482a4 in ??()
1: x/i $pc
0x80482a4 <_init+48>: pushl 0x804958c
(gdb)
0x080482aa in ??()
1: x/i $pc
0x80482aa <_init+54>: jmp *0x8049590
(gdb)
0xb7f052d0 in _dl_runtime_resolve() from /lib/ld-linux.so.2
1: x/i $pc
0xb7f052d0 <_dl_runtime_resolve>: push %eax
不止一個display
表達式可以立即生效(使用undisplay <number>
刪除它們)。例如,看會發生什麼情況%eax
:
(gdb) display/x $eax
2: /x $eax = 0xbf90ab34
(gdb) si
0xb7f052d1 in _dl_runtime_resolve() from /lib/ld-linux.so.2
2: /x $eax = 0xbf90ab34
1: x/i $pc
0xb7f052d1 <_dl_runtime_resolve+1>: push %ecx
(gdb)
0xb7f052d2 in _dl_runtime_resolve() from /lib/ld-linux.so.2
2: /x $eax = 0xbf90ab34
1: x/i $pc
0xb7f052d2 <_dl_runtime_resolve+2>: push %edx
(gdb)
0xb7f052d3 in _dl_runtime_resolve() from /lib/ld-linux.so.2
2: /x $eax = 0xbf90ab34
1: x/i $pc
0xb7f052d3 <_dl_runtime_resolve+3>: mov 0x10(%esp),%edx
(gdb)
0xb7f052d7 in _dl_runtime_resolve() from /lib/ld-linux.so.2
2: /x $eax = 0xbf90ab34
1: x/i $pc
0xb7f052d7 <_dl_runtime_resolve+7>: mov 0xc(%esp),%eax
...這裏在%eax
的變化可以看出:
(gdb)
0xb7f052db in _dl_runtime_resolve() from /lib/ld-linux.so.2
2: /x $eax = 0xb7f0d668
1: x/i $pc
0xb7f052db <_dl_runtime_resolve+11>: call 0xb7eff780 <_dl_fixup>
(gdb)
比其他更好,但它不與TUI上工作。一段時間後,我仍會將此標記爲公認的答案,因爲我意識到可能沒有任何真正的解決方案。 – jbcreix 2010-01-31 02:42:48