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

Dave Korn
2009-12-04T20:58:48Z

Hi all,

I have a GDB port for a custom target, a sim-based simulator, and a gdbstub
for use on the real thing. GDB can single step the simulator of course, since
the support for simulated hardware-single-step is built in, but I'd like to
save bytes in the gdbstub by not implementing support for the "s" command.

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?

cheers,
DaveK