This is the mail archive of the
mailing list for the GDB project.
Re: [RFC][patch] Allow to disassemble line.
On Thu, Oct 1, 2009 at 11:52 PM, Joel Brobecker <firstname.lastname@example.org> wrote:
>> Attached patch makes it so 'disas/l' will disassemble current line, and
>> 'disas/l foo.c:22' will disassemble line 22 of foo.c
> Without looking at the implementation itself for now, I have to say that
> I have been missing this feature very badly.
> 1. What should we do if there are more than one match for the given SAL?
I only ever needed this feature while single-stepping through the code
(i.e. this line crashes, but why?).
Perhaps it is reasonable to get rid of the parameter, and just say that
'disas/l' always disassembles current line, thus eliminating the ambiguity.
Alternatively, if there are two code segments matching 'foo.c:22', but
one of them is inlined into the current function and the other is inlined
somewhere else, then clearly the user is interested in the "current" one
(same for templates).
> 2. A little trickier: How do we want to handle the case where a line
> of code is split in more than one block of instructions. This happens
> really often when debugging optimized code.
> Right now, the easy solution is to only disassemble the first
> block. It'd be nice to have them all, though. Perhaps printing
> the instructions for each block one after the other, with something
> like a little sign in between indicating the next instruction is
> part of another block?
> 0x... <fun_name+nn> bla bla bla
> 0x... <fun_name+mm> bla bla bla
> 0x... <fun_name+oo> bla bla bla
A) determine min(low), max(high) core address for all SALs, then disassemble
that entire range, but there are discontinuous source lines turn on
DISASSEMBLY_SOURCE automatically, so it becomes clear which instructions
come from which line(s).
The trouble with this approach is that the two blocks could be quite
far apart. I haven't see GCC do that, but under MSVC I've seen wildly
discontinuous blocks of code. I think GCC may soon start doing hot/cold
code splitting as well, especially with FDO.
B) disassemble only the SAL which "covers" current $pc (as that's likely
what the user is looking for). This would be consistent with proposed
elimination of parameter, so 'disas/l' always implies 'current $pc'.