Do not respond to GDB's interrupt requests, if we failed to interrupt target execution

This commit is contained in:
Nav
2023-08-30 20:47:11 +01:00
parent 370112c4c7
commit 1c12200c18
2 changed files with 8 additions and 11 deletions

View File

@@ -27,20 +27,14 @@ namespace DebugServer::Gdb::CommandPackets
try {
targetControllerService.stopTargetExecution();
debugSession.connection.writePacket(TargetStopped(Signal::INTERRUPTED));
debugSession.waitingForBreak = false;
} catch (const Exception& exception) {
Logger::error("Failed to interrupt execution - " + exception.getMessage());
debugSession.connection.writePacket(ErrorResponsePacket());
/*
* We don't send an error response to GDB here, as GDB will behave as if the target is stopped. By not
* responding, GDB will just assume the interrupt request was ignored, keeping it in-sync with Bloom.
*/
}
/*
* Whenever we respond to an interrupt signal, GDB always assumes that target execution has stopped. Even if we
* respond with an error packet.
*
* Because of this, we always set the DebugSession::waitingForBreak flag to false, even if we failed to
* interrupt target execution. This way, we won't end up sending an unexpected stop reply packet to GDB, when
* the target does eventually stop (for some other reason).
*/
debugSession.waitingForBreak = false;
}
}

View File

@@ -380,6 +380,9 @@ namespace DebugServer::Gdb
// Server was interrupted
Logger::debug("GDB RSP interrupted");
return;
} catch (const Exception& exception) {
Logger::error("Failed to interrupt execution - " + exception.getMessage());
}
}
}