Re: [discuss] Support for reverse-execution

Eli Zaretskii
2005-05-20T10:37:41Z

> Date: Thu, 19 May 2005 15:00:52 +0200
> From: Johan Rydberg <jrydberg@virtutech.com>
> Cc: gdb@sources.redhat.com
>
> Here's a patch against CVS that implements the following commands:
>
> - rstep, rstepi
> - rnext, rnexti
>
> The obvious commands "rcontinue" and "rfinished" are not yet
> implemented, and therefor not included in this patch. The command
> names are of course up for discussion.

I don't mind these names; reverse-next etc. seem awkward, but rnext
etc. are okay, I think. However, see my other comments in response to
Daniel.

> What I have done is add a new variable, step_direction, that can either
> be STEP_DIR_FORWARD or STEP_DIR_REVERSE.

I'd prefer STEP_FORWARD and STEP_BACKWARD.

> 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.

Sorry, I'm confused. Isn't it right that if I'm stepping backwards
through code such as this:

i += 1;
foo (i);
=>i = 0;

where "=>" shows the current source line, then typing `rnext' once
will get me to this:

i += 1;
=>foo (i);
i = 0;

which means I'm now before the CALL insn that calls `foo'? If so,
what ``return insn'' were you talking about? If it's the return
instruction that returns from `foo', then that insn is inside the code
generatedfor `foo', which GDB won't see. What am I missing?

> + 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."

> + add_com_alias ("rn", "rnext", class_run, 1);

Do we want another alias called "previous"?

> +extern enum step_direction_kind step_direction;

Yuk! a global variable!

> + if (step_direction == STEP_DIR_FORWARD)
> + target_resume (resume_ptid, step, sig);
> + else
> + {
> + target_reverse (resume_ptid, step);
> + }

I'd prefer that target_resume accepted the direction argument. Is
there something that I'm missing that makes this hard or impossible?