Skip to content

Commit ef3da45

Browse files
committed
Clarify comment.
1 parent 5e40dc5 commit ef3da45

File tree

1 file changed

+18
-3
lines changed
  • kernel/src/arch/x86_64/gdb

1 file changed

+18
-3
lines changed

kernel/src/arch/x86_64/gdb/mod.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,18 @@ pub fn event_loop(reason: KCoreStopReason) -> Result<(), KError> {
127127
}
128128
GdbStubStateMachine::CtrlCInterrupt(gdb_stm_inner) => {
129129
trace!("GdbStubStateMachine::CtrlCInterrupt");
130-
let reason = stop_reason.take();
131-
assert_eq!(reason, Some(ThreadStopReason::Signal(Signal::SIGINT)));
132-
match gdb_stm_inner.interrupt_handled(target, reason) {
130+
let _reason = stop_reason.take();
131+
// Ideally, this would hole: assert_eq!(reason,
132+
// Some(ThreadStopReason::Signal(Signal::SIGINT)));
133+
//
134+
// But, turns out `reason` can be `StepDone` too if we are
135+
// single-stepping through things and the ctrl+c packet arrives
136+
// while we're in this file.
137+
//
138+
// So we just consume `reason` and report SIGINT unconditionally.
139+
match gdb_stm_inner
140+
.interrupt_handled(target, Some(ThreadStopReason::Signal(Signal::SIGINT)))
141+
{
133142
Ok(gdb) => gdb,
134143
Err(e) => {
135144
error!("gdbstub error {:?}", e);
@@ -152,6 +161,8 @@ pub fn event_loop(reason: KCoreStopReason) -> Result<(), KError> {
152161
let data_to_read = conn.peek().unwrap().is_some();
153162

154163
if data_to_read {
164+
trace!("GdbStubStateMachine::Running data_to_read");
165+
155166
let byte = gdb_stm_inner.borrow_conn().read().unwrap();
156167
match gdb_stm_inner.incoming_data(target, byte) {
157168
Ok(pumped_stm) => pumped_stm,
@@ -165,6 +176,8 @@ pub fn event_loop(reason: KCoreStopReason) -> Result<(), KError> {
165176
}
166177
}
167178
} else if let Some(reason) = stop_reason.take() {
179+
trace!("GdbStubStateMachine::Running stop_reason");
180+
168181
match gdb_stm_inner.report_stop(target, reason) {
169182
Ok(gdb_stm_new) => gdb_stm_new,
170183
Err(GdbStubError::TargetError(e)) => {
@@ -177,6 +190,8 @@ pub fn event_loop(reason: KCoreStopReason) -> Result<(), KError> {
177190
}
178191
}
179192
} else if target.resume_with.is_some() {
193+
trace!("GdbStubStateMachine::Running target.resume_with.is_some");
194+
180195
// We don't have a `stop_reason` and we don't have something
181196
// to read on the line. This probably means we're done and
182197
// we should run again.

0 commit comments

Comments
 (0)