tags:

views:

855

answers:

3

I'm doing some assembly-level debugging in gdb. Is there a way to get gdb to show me the current assembly instruction in the same way that it shows the current source line? The default output after every command looks like this:

0x0001433f      990         Foo::bar(p);

This gives me the address of the current instruction, but I have to keep referring back to the output of disassemble in order to see which instruction I'm currently executing.

+3  A: 

The command

x/i $pc

can be set to run all the time using the usual configuration mechanism.

bmargulies
And `x/ni $pc` to view the next n instructions, which is often quite useful.
Stephen Canon
+2  A: 

You can do

display/i $pc

and every time GDB stops, it will display the disassembly of the next instruction.

GDB-7.0 also supports set disassemble-next-line on, which will disassemble the entire next line, and give you more of the disassembly context.

Employed Russian
+1  A: 

You can switch to asm layout in gdb:

(gdb) layout asm

See here for more information.

The current assembly instruction will be shown in assembler window.

ks1322