Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make gdb display assembly instructions instead of C [duplicate]

Possible Duplicate:
Switching to assembly in gdb

I am debugging some code in gdb. When I run the ni (for next instruction) command, it displays the C code. Displaying the executed assembly instructions would make more sense to me.

(gdb) ni
0x0804845a  28          tmp = *lpp;
(gdb) ni
0x0804845c  28          tmp = *lpp;
(gdb) ni
0x0804846a  29          **lpp = (unsigned long) &buf;
(gdb) ni
0x0804846c  29          **lpp = (unsigned long) &buf;

Is there any way to make gdb display the assembly code instead, without calling disassm every time?

EDIT: I know about the layout asm command which displays the code in a readline window. I would like to see the disassembly on the gdb commandline, not in a gdb window.

like image 936
iblue Avatar asked Jun 16 '12 11:06

iblue


2 Answers

When you step via ni, displaying the next handful of assembly instructions is often very useful.

(gdb) display/4i $pc

will show the next 4 instructions every time GDB stops.

like image 120
Employed Russian Avatar answered Oct 22 '22 22:10

Employed Russian


Did you try to use TUI ASM layout?

It's fairly handy.

(gdb) layout asm
like image 27
qdot Avatar answered Oct 23 '22 00:10

qdot