diff --git a/src/stub/core_impl/resume.rs b/src/stub/core_impl/resume.rs index e829aff..a053025 100644 --- a/src/stub/core_impl/resume.rs +++ b/src/stub/core_impl/resume.rs @@ -229,8 +229,16 @@ impl GdbStubImpl { // TODO: update this case when non-stop mode is implemented VContKind::Stop => return Err(Error::PacketUnexpected), + // GDB doesn't always respect `vCont?` responses that omit `;s;S`, and will try to + // send step packets regardless. Inform the user of this bug by issuing a + // `UnexpectedStepPacket` error, which is more useful than a generic + // `PacketUnexpected` error. + VContKind::Step | VContKind::StepWithSig(..) => { + return Err(Error::UnexpectedStepPacket) + } + // Instead of using `_ =>`, explicitly list out any remaining unguarded cases. - VContKind::RangeStep(..) | VContKind::Step | VContKind::StepWithSig(..) => { + VContKind::RangeStep(..) => { error!("GDB client sent resume action not reported by `vCont?`"); return Err(Error::PacketUnexpected); } diff --git a/src/stub/error.rs b/src/stub/error.rs index 53414de..a8efc90 100644 --- a/src/stub/error.rs +++ b/src/stub/error.rs @@ -36,6 +36,13 @@ pub enum GdbStubError { /// `StopReason::HwBreak` if the hardware breakpoints IDET hasn't been /// implemented. UnsupportedStopReason, + /// GDB client sent an unexpected `step` request, most-likely due to this + /// GDB client bug: . + /// + /// Unfortunately, there's nothing `gdbstub` can do to work around this bug, + /// so if you've encountered this error, you'll need to implement + /// single-step support for your target. + UnexpectedStepPacket, /// The target has not opted into using implicit software breakpoints. /// See [`Target::guard_rail_implicit_sw_breakpoints`] for more information. @@ -93,6 +100,7 @@ where TargetMismatch => write!(f, "GDB client sent a packet with too much data for the given target."), TargetError(e) => write!(f, "Target threw a fatal error: {:?}", e), UnsupportedStopReason => write!(f, "Target responded with an unsupported stop reason."), + UnexpectedStepPacket => write!(f, "GDB client sent an unexpected `step` request. This is most-likely due to this GDB client bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28440"), ImplicitSwBreakpoints => write!(f, "Warning: The target has not opted into using implicit software breakpoints. See `Target::guard_rail_implicit_sw_breakpoints` for more information."), MissingCurrentActivePidImpl => write!(f, "GDB client attempted to attach to a new process, but the target has not implemented support for `ExtendedMode::support_current_active_pid`"),