Tidying CommandPacket base class handle() implementation - removed unnecessary copy and improved const correctness. And some other tidying
This commit is contained in:
@@ -20,26 +20,35 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
using Exceptions::Exception;
|
using Exceptions::Exception;
|
||||||
|
|
||||||
void CommandPacket::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) {
|
void CommandPacket::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) {
|
||||||
auto packetData = this->getData();
|
const auto packetString = std::string(this->data.begin(), this->data.end());
|
||||||
auto packetString = std::string(packetData.begin(), packetData.end());
|
|
||||||
|
if (packetString.empty()) {
|
||||||
|
Logger::error("Empty GDB RSP packet received.");
|
||||||
|
debugSession.connection.writePacket(ErrorResponsePacket());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (packetString[0] == '?') {
|
if (packetString[0] == '?') {
|
||||||
// Status report
|
// Status report
|
||||||
debugSession.connection.writePacket(TargetStopped(Signal::TRAP));
|
debugSession.connection.writePacket(TargetStopped(Signal::TRAP));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (packetString[0] == 'D') {
|
if (packetString[0] == 'D') {
|
||||||
// Detach packet - there's not really anything we need to do here, so just respond with an OK
|
// Detach packet - there's not really anything we need to do here, so just respond with an OK
|
||||||
debugSession.connection.writePacket(OkResponsePacket());
|
debugSession.connection.writePacket(OkResponsePacket());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (packetString.find("qAttached") == 0) {
|
if (packetString.find("qAttached") == 0) {
|
||||||
Logger::debug("Handling qAttached");
|
Logger::debug("Handling qAttached");
|
||||||
debugSession.connection.writePacket(ResponsePacket({1}));
|
debugSession.connection.writePacket(ResponsePacket({1}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
Logger::debug("Unknown GDB RSP packet: " + packetString + " - returning empty response");
|
Logger::debug("Unknown GDB RSP packet: " + packetString + " - returning empty response");
|
||||||
|
|
||||||
// Respond with an empty packet
|
// Respond with an empty packet
|
||||||
debugSession.connection.writePacket(ResponsePacket({0}));
|
debugSession.connection.writePacket(ResponsePacket({0}));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user