Reputation: 1519
Say I want to disassemble lines m-n of file x, where file x is not in the current context. Is this operation possible, and if so, how? Note: I am working on x86 Linux.
Upvotes: 5
Views: 7336
Reputation: 4556
As a quite late and maybe redundant answer, but hopefully useful for someone like me, I would like to put together a complete response to this and your other question on getting the address of a line number.
The disassemble
command can disassemble address ranges: disassemble [Start],[End]
. But you want to disassemble line ranges.
To get the addresses of the source code lines you can use the info line
command: info line [File]:[Line]
.
Upvotes: 3
Reputation: 548
You can use the disassemble command with the /m
key to display original C lines in front of their assembly counterparts:
disassemble /m 'my_file.c'::my_function
This does not require any preliminary steps, although it doesn't seem to accept source line ranges as you asked.
Upvotes: 9
Reputation: 14721
Here's a kludgy way to do it: set a breakpoint on the line you're interested in, and the breakpoint acknowledgement gives you an address. Then clear the breakpoint and run disas
or x/20i
on that address.
Upvotes: 1