Re: [PATCH] Displaced stepping (non-stop debugging) support for ARM Linux

Ulrich Weigand
2009-09-24T19:35:23Z

Julian Brown wrote:

> --- .pc/displaced-stepping-always/gdb/infrun.c 2009-07-30 15:33:13.000000000 -0700
> +++ gdb/infrun.c 2009-07-30 15:33:31.000000000 -0700
> @@ -1105,15 +1111,19 @@ maybe_software_singlestep (struct gdbarc
> {
> int hw_step = 1;
>
> - if (gdbarch_software_single_step_p (gdbarch)
> - && gdbarch_software_single_step (gdbarch, get_current_frame ()))
> + if (gdbarch_software_single_step_p (gdbarch))
> {
> - hw_step = 0;
> - /* Do not pull these breakpoints until after a `wait' in
> - `wait_for_inferior' */
> - singlestep_breakpoints_inserted_p = 1;
> - singlestep_ptid = inferior_ptid;
> - singlestep_pc = pc;
> + if (use_displaced_stepping (gdbarch))
> + hw_step = 0;
> + else if (gdbarch_software_single_step (gdbarch, get_current_frame ()))
> + {
> + hw_step = 0;
> + /* Do not pull these breakpoints until after a `wait' in
> + `wait_for_inferior' */
> + singlestep_breakpoints_inserted_p = 1;
> + singlestep_ptid = inferior_ptid;
> + singlestep_pc = pc;
> + }
> }
> return hw_step;
> }

It seems this change broke displaced stepping on PowerPC.

The problem is that on PowerPC, we do have a gdbarch_software_single_step
routine (ppc_deal_with_atomic_sequence), but this is only used in very
specific circumstances. Usually, it returns zero and lets GDB use hardware
single stepping.

We also have a displaced stepping implementation, which assumes GDB will
use hardware single-stepping to step over the displaced copy (in particular,
the gdbarch_software_single_step routine should always return 0 when
looking at the displaced copy).

However, with the patch, GDB will simply always use "continue" to run
the displaced copy, which generally breaks.

I'm not sure I understand the rationale behind these changes to the
displaced stepping logic in infrun.c in the first place. Why is
everything conditioned on gdbarch_software_single_step_p, which just
says whether or not the architecture has installed a single-stepping
routine -- but this alone doesn't say whether software stepping is
actually needed in any given situation ...

Bye,
Ulrich

--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com