I want to disassemble only one particular line of code in gdb; to do this, I need the memory address of said line. How can I get the address of a particular line of code in gdb? Or better yet, is there a command in gdb to disassemble by line number?
Asked
Active
Viewed 2,546 times
2 Answers
3
Put a break on the line you want to disassemble and then, you could try to get the current instruction with.
disp/i $pc
This always works for me, when I debug binaries with no debug info. Also one could simply get the current pc
either by print $pc
or info registers
or simply use the x
instruction.
e.g.:
x/10i address //displays the first 10 instructions in assembly starting from address
or
x/10i register //displays the first 10 instructions starting from address stored in register

skyel
- 713
- 1
- 6
- 20
2
You can use: set disassemble-next-line on
to diassemble by line number. Then use whatever technique you want to set a breakpoint at the specific line you want to view.

Gabriel Southern
- 9,602
- 12
- 56
- 95