summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-03-24 21:50:58 +0100
committerGitHub <noreply@github.com>2020-03-24 21:50:58 +0100
commitf8382c9d9df5cbbfc37f0e4e3952b162d3cdd1ae (patch)
tree278f7cdcbd0ceca35c041e833f0dcbd5b7e3e895
parentMerge pull request #3543 from ReinUsesLisp/gl-depth-range (diff)
parentgdbstub: small logic bug fix with defer_start (diff)
downloadyuzu-f8382c9d9df5cbbfc37f0e4e3952b162d3cdd1ae.tar
yuzu-f8382c9d9df5cbbfc37f0e4e3952b162d3cdd1ae.tar.gz
yuzu-f8382c9d9df5cbbfc37f0e4e3952b162d3cdd1ae.tar.bz2
yuzu-f8382c9d9df5cbbfc37f0e4e3952b162d3cdd1ae.tar.lz
yuzu-f8382c9d9df5cbbfc37f0e4e3952b162d3cdd1ae.tar.xz
yuzu-f8382c9d9df5cbbfc37f0e4e3952b162d3cdd1ae.tar.zst
yuzu-f8382c9d9df5cbbfc37f0e4e3952b162d3cdd1ae.zip
-rw-r--r--src/core/core.cpp2
-rw-r--r--src/core/gdbstub/gdbstub.cpp9
-rw-r--r--src/core/gdbstub/gdbstub.h7
3 files changed, 17 insertions, 1 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 218508126..d1bc9340d 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -166,7 +166,7 @@ struct System::Impl {
service_manager = std::make_shared<Service::SM::ServiceManager>();
Service::Init(service_manager, system);
- GDBStub::Init();
+ GDBStub::DeferStart();
renderer = VideoCore::CreateRenderer(emu_window, system);
if (!renderer->Init()) {
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp
index e8d8871a7..6d15aeed9 100644
--- a/src/core/gdbstub/gdbstub.cpp
+++ b/src/core/gdbstub/gdbstub.cpp
@@ -141,6 +141,7 @@ constexpr char target_xml[] =
)";
int gdbserver_socket = -1;
+bool defer_start = false;
u8 command_buffer[GDB_BUFFER_SIZE];
u32 command_length;
@@ -1166,6 +1167,9 @@ static void RemoveBreakpoint() {
void HandlePacket() {
if (!IsConnected()) {
+ if (defer_start) {
+ ToggleServer(true);
+ }
return;
}
@@ -1256,6 +1260,10 @@ void ToggleServer(bool status) {
}
}
+void DeferStart() {
+ defer_start = true;
+}
+
static void Init(u16 port) {
if (!server_enabled) {
// Set the halt loop to false in case the user enabled the gdbstub mid-execution.
@@ -1341,6 +1349,7 @@ void Shutdown() {
if (!server_enabled) {
return;
}
+ defer_start = false;
LOG_INFO(Debug_GDBStub, "Stopping GDB ...");
if (gdbserver_socket != -1) {
diff --git a/src/core/gdbstub/gdbstub.h b/src/core/gdbstub/gdbstub.h
index 5a36524b2..8fe3c320b 100644
--- a/src/core/gdbstub/gdbstub.h
+++ b/src/core/gdbstub/gdbstub.h
@@ -43,6 +43,13 @@ void ToggleServer(bool status);
/// Start the gdbstub server.
void Init();
+/**
+ * Defer initialization of the gdbstub to the first packet processing functions.
+ * This avoids a case where the gdbstub thread is frozen after initialization
+ * and fails to respond in time to packets.
+ */
+void DeferStart();
+
/// Stop gdbstub server.
void Shutdown();