From 6c21530e4316e4295e41b7a1d2930d22238309a2 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Thu, 9 Apr 2026 19:58:15 +0200 Subject: [PATCH] Save JIT context on exit so the debugger reads up-to-date registers --- src/core/hle/kernel/physical_core.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 8286c23a69..f394122764 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -50,6 +50,14 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) { }; const auto ExitContext = [&]() { + // Save the JIT context back to the thread so the debugger can + // read the current register state. Debug halt paths (step, + // breakpoint, watchpoint) return from RunThread without going + // through the scheduler's Unload/SaveContext. + if (system.DebuggerEnabled()) { + interface->GetContext(thread->GetContext()); + } + // Unlock the thread. interface->UnlockThread(thread); @@ -116,6 +124,11 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) { if (breakpoint || prefetch_abort) { if (breakpoint) { interface->RewindBreakpointInstruction(); + // RewindBreakpointInstruction sets the JIT state to the + // saved breakpoint context. Update the thread context to + // match, since ExitContext already saved the post-execution + // state. + interface->GetContext(thread->GetContext()); } if (system.DebuggerEnabled()) { system.GetDebugger().NotifyThreadStopped(thread);