gdbstub: Ensure gdbstub doesn't drop packets crucial to initialization

This commit is contained in:
Gauvain "GovanifY" Roussel-Tarbouriech 2020-02-23 21:33:49 +01:00
parent 2a616fcc5e
commit d8bb37fc2f
3 changed files with 16 additions and 2 deletions

View file

@ -121,6 +121,7 @@ constexpr char target_xml[] =
)";
int gdbserver_socket = -1;
bool defer_start = false;
u8 command_buffer[GDB_BUFFER_SIZE];
u32 command_length;
@ -1042,7 +1043,8 @@ static void RemoveBreakpoint() {
}
void HandlePacket() {
if (!IsConnected()) {
if (!IsConnected() && defer_start) {
ToggleServer(true);
return;
}
@ -1133,6 +1135,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.
@ -1216,6 +1222,7 @@ void Shutdown() {
if (!server_enabled) {
return;
}
defer_start = false;
LOG_INFO(Debug_GDBStub, "Stopping GDB ...");
if (gdbserver_socket != -1) {