Closed xobs closed 1 year ago
This is a manifestation of an upstream GDB client bug, where on some targets, it doesn't respect the fact that vCont?
only returns support for continue (via the vCont;c;C
response), and opts to send a s
command as part of its vCont
packet regardless.
This is def not OK from the spec's perspective, but since upstream gdbserver
(and likely most third-party project-specific gdbstubs) support both continue and single-step, no-one ever noticed this issue.
There is a different guard-rail (guard_rail_single_step_gdb_behavior
) that attempts to work-around this upstream bug, by having Arch
implementations declare how upstream GDB decides to send/not-send single-step commands to those targets.
...but it seems to be the case that this guard rail isn't working too well, and might not be tenable to maintain in the long-term. See https://github.com/daniel5151/gdbstub/issues/117#issuecomment-1464130901
All that is to say: it seems that for rv32, you're going to have to implement explicit support for single-stepping, as GDB will try and single-step your target regardless if it's declared support for single stepping. A bit of a bummer... but that's GDB for ya ¯\_(ツ)_/¯
P.S: this doesn't have anything to do with guard_rail_implicit_sw_breakpoints
. That's an orthogonal guard-rail, which is there to prevent GDB from implicitly overwriting a guest's instruction stream in emulator-level gdbstub implementations.
And indeed, for your kernel implementation, it might even be beneficial to leave the nitty-gritty details of inserting software breakpoints to the GDB client itself (tho ofc, this is something for you to decide)
It looks like the risc-v target is set to SingleStepGdbBehavior::Ignored
when it should be SingleStepGdbBehavior::Required
, which is why the guard rail didn't activate on my target.
That's a bummer about having to manually single-step. I was hoping to avoid having to inspect opcodes in the kernel, but what can you do?
Closed via #128
When issuing a
stepi
command, gdbstub reportsPacketUnexpcted
:Note that this uses the
mon pr 2
command to set Process #2, which simply sets which process is currently being debugged.This occurs even if I have GDB use implicit breakpoints by using guard_rail_implicit_sw_breakpoints and not implementing breakpoints myself.