Software-vs-hardware single-step vs. sim/non-sim targets.

Daniel Jacobowitz
Fri Dec 4 22:08:00 GMT 2009

On Fri, Dec 04, 2009 at 09:14:40PM +0000, Dave Korn wrote:
>   So is there a way I can get gdb to use (simulated) hardware single stepping
> for the simulator target and software single stepping for the remote target?
> And dynamically switch when the target changes?  Or do I have to compile two
> different builds, only one of which sets the software single step method in
> the gdbarch?
>   I'm trying not to do anything too hacky or break the architectural layering
> in GDB, but can I perhaps examine the current_target in my arch init function
> and frig the value of the single_step hook in the gdbarch that I either lookup
> or allocate before returning it?  Does the arch init function always get
> called when switching between targets or otherwise altering the layers in the
> stratum stack?

Answering the last question first, no, it does not necessarily get called.

There's no obvious easy solution to this, but the basic problem has
been discussed many times.  It's gotten more complicated since I last
thought about it, too, by the addition of support for software
stepping atomic sequences.  There are several mixed-up questions:

(SSS = software single-step; got tired of typing it.)

* Does my architecture code support SSS for anything?

* Does my architecture require SSS for the current instruction or
instruction sequence?

* Does my target support hardware single-step?

IMO the remote protocol hook you need is already present: implement
vCont, even though it's overkill for an embedded single-threaded
processor.  Report that you don't support s or S in the vCont? reply.

Current GDB will choke.  So you have to somehow separate the above
questions, so that when we ask the architecture whether to
single-step, it knows whether the target needs SSS or not.

Daniel Jacobowitz

More information about the Gdb mailing list