Skip to content

Commit 6d12dab

Browse files
committed
Review feedback.
1 parent b7bdac8 commit 6d12dab

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/stub/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub(crate) enum InternalError<T, C> {
4444
TracepointFeatureUnimplemented(u8),
4545
TracepointUnsupportedSourceEnumeration,
4646
MissingMultiThreadSchedulerLocking,
47+
MissingToRawId,
4748

4849
// Internal - A non-fatal error occurred (with errno-style error code)
4950
//
@@ -149,6 +150,7 @@ where
149150
TracepointFeatureUnimplemented(feat) => write!(f, "GDB client sent us a tracepoint packet using feature {}, but `gdbstub` doesn't implement it. If this is something you require, please file an issue at https://github.com/daniel5151/gdbstub/issues", *feat as char),
150151
TracepointUnsupportedSourceEnumeration => write!(f, "The target doesn't support the gdbstub TracepointSource extension, but attempted to transition to enumerating tracepoint sources"),
151152
MissingMultiThreadSchedulerLocking => write!(f, "GDB requested Scheduler Locking, but the Target does not implement the `MultiThreadSchedulerLocking` IDET"),
153+
MissingToRawId => write!(f, "A RegId was used with an API that requires raw register IDs to be available (e.g. `report_stop_with_regs`) but returned `None` from `to_raw_id()`"),
152154

153155
NonFatalError(_) => write!(f, "Internal non-fatal error. You should never see this! Please file an issue if you do!"),
154156
}

src/stub/state_machine.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,13 @@ impl<'a, T: Target, C: Connection> GdbStubStateMachineInner<'a, state::Running,
301301
if let Some(regs) = regs {
302302
if reason.is_t_packet() {
303303
for (reg_id, value) in regs {
304-
if let Some(reg) = reg_id.to_raw_id() {
305-
res.write_num(reg).map_err(InternalError::from)?;
306-
res.write_str(":").map_err(InternalError::from)?;
307-
res.write_hex_buf(value).map_err(InternalError::from)?;
308-
res.write_str(";").map_err(InternalError::from)?;
309-
}
304+
let reg = reg_id
305+
.to_raw_id()
306+
.ok_or(InternalError::MissingToRawId)?;
307+
res.write_num(reg).map_err(InternalError::from)?;
308+
res.write_str(":").map_err(InternalError::from)?;
309+
res.write_hex_buf(value).map_err(InternalError::from)?;
310+
res.write_str(";").map_err(InternalError::from)?;
310311
}
311312
}
312313
}

0 commit comments

Comments
 (0)