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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With