Debugger: surface Core_RequestCPUStep() failure on cpu.stepInto instead of silently hanging

Into()'s same-thread branch called Core_RequestCPUStep(CPUStepType::Into, 1)
without checking its return value. Core_RequestCPUStep() can genuinely
fail (a step/run request is already queued this host frame - see its own
"Can't submit two steps in one host frame" ERROR_LOG) - on failure, no
step happens and no cpu.stepping event ever fires, but cpu.stepInto's own
contract is "no immediate response, a cpu.stepping event follows", so a
rejected request looked identical to a request still in flight: nothing
to distinguish "wait longer" from "this silently failed, nothing is ever
coming." This is part of the same failure family as the delay-slot race
just fixed in PrepareResume() (previous commit) - Core_RequestCPUStep()'s
one-at-a-time guard rejecting a step no caller in this file checked for.

Now calls req.Fail() on rejection so the client gets an explicit answer
instead of an indefinite wait. Updated the cpu.stepInto doc comment to
note the new (retryable) failure mode.

Verified via UnitTest.exe all (49/49).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
Henrik RydgårdandClaude Sonnet 5 committed 2026-08-14 11:04:32 +02:00
1 parent 0c63905095
commit be236d47c8
1 file changed
+13 -2
+13 -2
View File
@@ -82,7 +82,9 @@ static DebugInterface *CPUFromRequest(DebuggerRequest &req, uint32_t *threadID =
// Parameters:
// - thread: optional number indicating the thread id to plan stepping on.
//
// No immediate response. A cpu.stepping event will be sent once complete.
// No immediate response on success. A cpu.stepping event will be sent once complete.
// May fail (same-thread case only) if another step/run request is already pending this host
// frame - safe to retry shortly after.
//
// Note: any thread can wake the cpu when it hits the next instruction currently.
void WebSocketSteppingState::Into(DebuggerRequest &req) {
@@ -108,7 +110,16 @@ void WebSocketSteppingState::Into(DebuggerRequest &req) {
// If the current PC is on a breakpoint, the user doesn't want to do nothing.
g_breakpoints.SetSkipFirst(currentMIPS->pc);
Core_RequestCPUStep(CPUStepType::Into, 1);
// Core_RequestCPUStep() can fail (a step or run request is already queued this host
// frame - see its own "Can't submit two steps in one host frame" log). Previously
// unchecked here: on failure, no step ever happens and no cpu.stepping event ever
// fires, but the client got no response either (this event's contract is "no
// immediate response, a cpu.stepping event follows") - so a rejected step looked
// identical to one that's just still in flight, indefinitely. Surface it instead.
if (!Core_RequestCPUStep(CPUStepType::Into, 1)) {
req.Fail("Could not step: a step or run request is already pending");
return;
}
} else {
uint32_t breakpointAddress = cpuDebug->GetPC();
PrepareResume();