Fixed bug with GDB RSP debug server handling stale packets

This commit is contained in:
Nav
2021-05-31 00:03:18 +01:00
parent 635f908a45
commit f7944ac6b4

View File

@@ -123,6 +123,10 @@ void GdbRspDebugServer::serve() {
this->waitForConnection();
}
this->clientConnection->accept(this->serverSocketFileDescriptor);
Logger::info("Accepted GDP RSP connection from " + this->clientConnection->getIpAddress());
this->eventManager.triggerEvent(std::make_shared<Events::DebugSessionStarted>());
/*
* Before proceeding with a new debug session, we must ensure that the TargetController is able to
* service it.
@@ -135,9 +139,10 @@ void GdbRspDebugServer::serve() {
auto packets = this->clientConnection->readPackets();
for (auto& packet : packets) {
// Only process the last packet - any others will likely be duplicates from an impatient client
if (!packets.empty()) {
// Double-dispatch to appropriate handler
packet->dispatchToHandler(*this);
packets.back()->dispatchToHandler(*this);
}
} catch (const ClientDisconnected&) {
@@ -192,10 +197,6 @@ void GdbRspDebugServer::waitForConnection() {
}
this->clientConnection = Connection(this->interruptEventNotifier);
this->clientConnection->accept(this->serverSocketFileDescriptor);
this->eventManager.triggerEvent(std::make_shared<Events::DebugSessionStarted>());
Logger::info("Accepted GDP RSP connection from " + this->clientConnection->getIpAddress());
}
}