From 12be06beb67ed8357b94699a7e0786721c57b0eb Mon Sep 17 00:00:00 2001 From: Jakly <102590697+Jaklyy@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:48:52 -0400 Subject: [PATCH] fix gdb stub causing the emulator to hang on undefined instructions (#2054) * dont hang on undefined instruction * Add spaces --------- Co-authored-by: Kemal Afzal --- src/ARMInterpreter.cpp | 4 ++-- src/debug/GdbStub.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ARMInterpreter.cpp b/src/ARMInterpreter.cpp index 6fb86ef5..f5bf7713 100644 --- a/src/ARMInterpreter.cpp +++ b/src/ARMInterpreter.cpp @@ -38,7 +38,7 @@ void A_UNK(ARM* cpu) { Log(LogLevel::Warn, "undefined ARM%d instruction %08X @ %08X\n", cpu->Num?7:9, cpu->CurInstr, cpu->R[15]-8); #ifdef GDBSTUB_ENABLED - cpu->GdbStub.Enter(true, Gdb::TgtStatus::FaultInsn, cpu->R[15]-8); + cpu->GdbStub.Enter(cpu->GdbStub.IsConnected(), Gdb::TgtStatus::FaultInsn, cpu->R[15]-8); #endif //for (int i = 0; i < 16; i++) printf("R%d: %08X\n", i, cpu->R[i]); //NDS::Halt(); @@ -56,7 +56,7 @@ void T_UNK(ARM* cpu) { Log(LogLevel::Warn, "undefined THUMB%d instruction %04X @ %08X\n", cpu->Num?7:9, cpu->CurInstr, cpu->R[15]-4); #ifdef GDBSTUB_ENABLED - cpu->GdbStub.Enter(true, Gdb::TgtStatus::FaultInsn, cpu->R[15]-4); + cpu->GdbStub.Enter(cpu->GdbStub.IsConnected(), Gdb::TgtStatus::FaultInsn, cpu->R[15]-4); #endif //NDS::Halt(); u32 oldcpsr = cpu->CPSR; diff --git a/src/debug/GdbStub.h b/src/debug/GdbStub.h index 99b88158..6461a354 100644 --- a/src/debug/GdbStub.h +++ b/src/debug/GdbStub.h @@ -152,6 +152,7 @@ public: int RespFmt(const char* fmt, ...); int RespStr(const char* str); + inline bool IsConnected() { return ConnFd > 0; } private: void Disconnect();