From d17ab5cd912ecd75dbb5127c21674ee4b013efb3 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Mon, 6 Apr 2020 21:24:54 +0100 Subject: [PATCH] gdbstub: Fix some gdbstub jankiness 1. Ensure that register information available to gdbstub is most up-to-date. 2. There's no reason to check for current_thread == thread when emitting a trap. Doing this results in random hangs whenever a step happens upon a thread switch. --- src/core/core.cpp | 4 ++++ src/core/gdbstub/gdbstub.cpp | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index c1d635afe..995c0f295 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -50,6 +50,10 @@ System::ResultStatus System::RunLoop(bool tight_loop) { } if (GDBStub::IsServerEnabled()) { + Kernel::Thread* thread = kernel->GetCurrentThreadManager().GetCurrentThread(); + if (thread && running_core) { + running_core->SaveContext(thread->context); + } GDBStub::HandlePacket(); // If the loop is halted and we want to step, use a tiny (1) number of instructions to diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 1e42ff5e4..8093e7328 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -1264,10 +1264,9 @@ void SendTrap(Kernel::Thread* thread, int trap) { return; } - if (!halt_loop || current_thread == thread) { - current_thread = thread; - SendSignal(thread, trap); - } + current_thread = thread; + SendSignal(thread, trap); + halt_loop = true; send_trap = false; }