Troskyvs Troskyvs - 9 months ago 53
C Question

How to use gdb to debug into a C program's corresponding disassembly?

Using VC can bring up disassembly window and travel across it. But using gdb seems not so direct:

E.g. I've got a myadd.c

void main(){
int i=0;
int j=i+1;

gcc -g myadd.c

gdb a.out

b 2 //set break point at int j=1+1;

Now I can use "disassemble" command to see disassembly code. My requirement is to debug "into" this disassembly code like VC could. I tried 's' command, it directly goes into next "C" statement, not disassembly statement.

How to do that?


To jump to the next assembly instruction, use stepi (short si) instead.

See this for more information, especially how to use display/i to show the next machine instruction.