This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: [discuss] Support for reverse-execution
Disclaimer: I have not looked at the code at all; I want to get the
copyright assignment rolling first.
On Fri, May 20, 2005 at 01:32:47PM +0300, Eli Zaretskii wrote:
> > To implement "rnext" I had to add a new target-specific function that
> > tries to figure out the address of the call instruction based on the
> > last executed instruction and the instruction to be executed, IF the
> > current instruction can be identified as a return insn.
Johan, when I sketched out some algorithms for implementing these
commands, I got the feeling that this was not a good way to do it.
There are just too many ways to jump, and they can be pretty tricky to
recognize on some architectures. PowerPC is easy, but it's a little
more complicated to disassemble starting from the end of an instruction
on ia32. Here's another one that requires absolutely no target support:
- Detect reverse-step into a function
- Set breakpoints at all entry points of the function; GDB doesn't
support multiple entry points yet, really, so a breakpoint at
the first instruction and a big fat comment is all this takes.
- When you hit an entry point breakpoint, reverse-step once more.
- If you have entered a different function, for instance via a
reversed tail call, and you can still see the desired frame
on the stack, then repeat.
i.e. build reverse-next on top of reverse-finish. reverse-finish
should take you to the intermediate caller in a tail call situation,
not to the previous frame on the stack.
Of course neither algorithm is robust in the case of stray jumps.
Bookmarks and single-steps for that are the best we're going to get.
> > + add_com ("rnext", class_run, rnext_command,
> > + "Step program until it reaches the previous source line.\n\
>
> "Go backwards until the program reaches the source line before the
> current one."
Johan used previous, you used backwards; let's figure out what we're
calling the commands first :-P
> > + add_com_alias ("rn", "rnext", class_run, 1);
>
> Do we want another alias called "previous"?
I have no objection.
> I'd prefer that target_resume accepted the direction argument. Is
> there something that I'm missing that makes this hard or impossible?
It should either be an argument, or a separate target hook as Michael
proposed. No existing target supports it, so it would save us updating
all targets to reject it. Which is just mechanical, so I don't feel
strongly either way.
--
Daniel Jacobowitz
CodeSourcery, LLC