Skip to content

Commit

Permalink
refine error message if GDB sent unsupported step packet
Browse files Browse the repository at this point in the history
related to #132
  • Loading branch information
daniel5151 committed Apr 29, 2023
1 parent 2adbf4c commit 3c7a87c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/stub/core_impl/resume.rs
Expand Up @@ -229,8 +229,16 @@ impl<T: Target, C: Connection> GdbStubImpl<T, C> {
// 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);
}
Expand Down
8 changes: 8 additions & 0 deletions src/stub/error.rs
Expand Up @@ -36,6 +36,13 @@ pub enum GdbStubError<T, C> {
/// `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: <https://sourceware.org/bugzilla/show_bug.cgi?id=28440>.
///
/// 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.
Expand Down Expand Up @@ -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`"),
Expand Down

0 comments on commit 3c7a87c

Please sign in to comment.