summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authoraldelaro5 <aldelaro5@gmail.com>2021-09-29 12:57:46 -0400
committeraldelaro5 <aldelaro5@gmail.com>2021-10-21 08:26:16 -0400
commite03ddc2116193a2b16f4264aedadba000a0496fa (patch)
treeb60922791ba1cf5704d529b00ffea601dbf8ab72 /Source/Core
parent39569ed1f860c8233a5eecb67852c8fb630b1ff2 (diff)
Let the GDB stub listen for commands while running
This is needed to send ctrl+C signals while the CPU thread is running.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/PowerPC/GDBStub.cpp22
-rw-r--r--Source/Core/Core/PowerPC/GDBStub.h10
-rw-r--r--Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp2
3 files changed, 30 insertions, 4 deletions
diff --git a/Source/Core/Core/PowerPC/GDBStub.cpp b/Source/Core/Core/PowerPC/GDBStub.cpp
index 39fc4e5e79..cdf9de19e0 100644
--- a/Source/Core/Core/PowerPC/GDBStub.cpp
+++ b/Source/Core/Core/PowerPC/GDBStub.cpp
@@ -55,6 +55,8 @@ static u32 sig = 0;
static u32 send_signal = 0;
static u32 step_break = 0;
+static CoreTiming::EventType* m_gdbStubUpdateEvent;
+
typedef struct
{
u32 active;
@@ -114,6 +116,12 @@ static void hex2mem(u8* dst, u8* src, u32 len)
}
}
+void GDBStubUpdateCallback(u64 userdata, s64 cycles_late)
+{
+ gdb_handle_exception(false);
+ CoreTiming::ScheduleEvent(GDB_UPDATE_CYCLES, m_gdbStubUpdateEvent);
+}
+
static u8 gdb_read_byte()
{
u8 c = '+';
@@ -732,13 +740,20 @@ static void gdb_remove_bp()
gdb_reply("OK");
}
-void gdb_handle_exception()
+
+void gdb_handle_exception(bool loop_until_continue)
{
while (gdb_active())
{
if (!gdb_data_available())
- continue;
+ {
+ if (loop_until_continue)
+ continue;
+ else
+ return;
+ }
gdb_read_command();
+ // No more commands
if (cmd_len == 0)
continue;
@@ -868,6 +883,9 @@ static void gdb_init_generic(int domain, const sockaddr* server_addr, socklen_t
close(tmpsock);
#endif
tmpsock = -1;
+
+ m_gdbStubUpdateEvent = CoreTiming::RegisterEvent("GDBStubUpdate", GDBStubUpdateCallback);
+ CoreTiming::ScheduleEvent(GDB_UPDATE_CYCLES, m_gdbStubUpdateEvent);
}
void gdb_deinit()
diff --git a/Source/Core/Core/PowerPC/GDBStub.h b/Source/Core/Core/PowerPC/GDBStub.h
index deb0133a77..9cbea6a50c 100644
--- a/Source/Core/Core/PowerPC/GDBStub.h
+++ b/Source/Core/Core/PowerPC/GDBStub.h
@@ -6,6 +6,7 @@
#pragma once
#include "Common/CommonTypes.h"
+#include "Core/CoreTiming.h"
#ifndef MSG_WAITALL
#define MSG_WAITALL (8)
@@ -26,13 +27,17 @@ typedef enum
GDB_BP_TYPE_A
} gdb_bp_type;
+const s64 GDB_UPDATE_CYCLES = 100000;
+
+void GDBStubUpdateCallback(u64 userdata, s64 cycles_late);
+
void gdb_init(u32 port);
void gdb_init_local(const char* socket);
void gdb_deinit();
bool gdb_active();
void gdb_break();
-void gdb_handle_exception();
+void gdb_handle_exception(bool loopUntilContinue);
int gdb_signal(u32 signal);
int gdb_bp_x(u32 addr);
@@ -41,3 +46,6 @@ int gdb_bp_w(u32 addr);
int gdb_bp_a(u32 addr);
bool gdb_add_bp(u32 type, u32 addr, u32 len);
+void gdb_handle_exception(bool loop_until_continue);
+void SendSignal(u32 signal);
+} // namespace GDBStub
diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp
index 32b4eb09cc..029a8f35d7 100644
--- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp
+++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp
@@ -158,7 +158,7 @@ int Interpreter::SingleStepInner()
Host_UpdateDisasmDialog();
gdb_signal(GDB_SIGTRAP);
- gdb_handle_exception();
+ gdb_handle_exception(true);
}
#endif