diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 2 | ||||
| -rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 9 | ||||
| -rw-r--r-- | src/core/gdbstub/gdbstub.h | 7 |
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 { | |||
| 166 | service_manager = std::make_shared<Service::SM::ServiceManager>(); | 166 | service_manager = std::make_shared<Service::SM::ServiceManager>(); |
| 167 | 167 | ||
| 168 | Service::Init(service_manager, system); | 168 | Service::Init(service_manager, system); |
| 169 | GDBStub::Init(); | 169 | GDBStub::DeferStart(); |
| 170 | 170 | ||
| 171 | renderer = VideoCore::CreateRenderer(emu_window, system); | 171 | renderer = VideoCore::CreateRenderer(emu_window, system); |
| 172 | if (!renderer->Init()) { | 172 | 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[] = | |||
| 141 | )"; | 141 | )"; |
| 142 | 142 | ||
| 143 | int gdbserver_socket = -1; | 143 | int gdbserver_socket = -1; |
| 144 | bool defer_start = false; | ||
| 144 | 145 | ||
| 145 | u8 command_buffer[GDB_BUFFER_SIZE]; | 146 | u8 command_buffer[GDB_BUFFER_SIZE]; |
| 146 | u32 command_length; | 147 | u32 command_length; |
| @@ -1166,6 +1167,9 @@ static void RemoveBreakpoint() { | |||
| 1166 | 1167 | ||
| 1167 | void HandlePacket() { | 1168 | void HandlePacket() { |
| 1168 | if (!IsConnected()) { | 1169 | if (!IsConnected()) { |
| 1170 | if (defer_start) { | ||
| 1171 | ToggleServer(true); | ||
| 1172 | } | ||
| 1169 | return; | 1173 | return; |
| 1170 | } | 1174 | } |
| 1171 | 1175 | ||
| @@ -1256,6 +1260,10 @@ void ToggleServer(bool status) { | |||
| 1256 | } | 1260 | } |
| 1257 | } | 1261 | } |
| 1258 | 1262 | ||
| 1263 | void DeferStart() { | ||
| 1264 | defer_start = true; | ||
| 1265 | } | ||
| 1266 | |||
| 1259 | static void Init(u16 port) { | 1267 | static void Init(u16 port) { |
| 1260 | if (!server_enabled) { | 1268 | if (!server_enabled) { |
| 1261 | // Set the halt loop to false in case the user enabled the gdbstub mid-execution. | 1269 | // Set the halt loop to false in case the user enabled the gdbstub mid-execution. |
| @@ -1341,6 +1349,7 @@ void Shutdown() { | |||
| 1341 | if (!server_enabled) { | 1349 | if (!server_enabled) { |
| 1342 | return; | 1350 | return; |
| 1343 | } | 1351 | } |
| 1352 | defer_start = false; | ||
| 1344 | 1353 | ||
| 1345 | LOG_INFO(Debug_GDBStub, "Stopping GDB ..."); | 1354 | LOG_INFO(Debug_GDBStub, "Stopping GDB ..."); |
| 1346 | if (gdbserver_socket != -1) { | 1355 | 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); | |||
| 43 | /// Start the gdbstub server. | 43 | /// Start the gdbstub server. |
| 44 | void Init(); | 44 | void Init(); |
| 45 | 45 | ||
| 46 | /** | ||
| 47 | * Defer initialization of the gdbstub to the first packet processing functions. | ||
| 48 | * This avoids a case where the gdbstub thread is frozen after initialization | ||
| 49 | * and fails to respond in time to packets. | ||
| 50 | */ | ||
| 51 | void DeferStart(); | ||
| 52 | |||
| 46 | /// Stop gdbstub server. | 53 | /// Stop gdbstub server. |
| 47 | void Shutdown(); | 54 | void Shutdown(); |
| 48 | 55 | ||