I'm running the stepi and nexti commands in GDB. Currently they print the address like this:
(gdb) stepi
0x08043ae7 in ?? ()
(gdb) nexti
0x08043ae8 in ?? ()
Instead of that, I'd like to get the current instruction printed:
(gdb) stepi
=> 0x8043ae7: push %eax
(gdb) nexti
=> 0x8043ae8: push %ebx
I know that I can get the desired lines by running x/i $pc
. How do I get them automatically after stepi
and nexti
?
How do I get them automatically after
stepi
andnexti
?
This will do almost what you want:
(gdb) display/i $pc
The difference is that it will display the next instruction every time GDB stops, not just after stepi
and nexti
.
You should also be able to use hook-nexti
and hook-stepi
if you really want the x/i
to only fire for these two commands. Documentation.