2021-04-04 21:04:12 +01:00
|
|
|
#include "CommandPacket.hpp"
|
2021-10-02 17:39:27 +01:00
|
|
|
|
2022-03-24 19:17:41 +00:00
|
|
|
#include "src/DebugServers/GdbRsp/ResponsePackets/ResponsePacket.hpp"
|
|
|
|
|
#include "src/DebugServers/GdbRsp/ResponsePackets/OkResponsePacket.hpp"
|
|
|
|
|
#include "src/DebugServers/GdbRsp/ResponsePackets/TargetStopped.hpp"
|
|
|
|
|
#include "src/DebugServers/GdbRsp/ResponsePackets/ErrorResponsePacket.hpp"
|
|
|
|
|
|
|
|
|
|
#include "src/DebugServers/GdbRsp/Signal.hpp"
|
|
|
|
|
|
|
|
|
|
#include "src/Logger/Logger.hpp"
|
|
|
|
|
#include "src/Exceptions/Exception.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
namespace Bloom::DebugServers::Gdb::CommandPackets
|
|
|
|
|
{
|
2022-03-24 19:17:41 +00:00
|
|
|
using ResponsePackets::ResponsePacket;
|
|
|
|
|
using ResponsePackets::OkResponsePacket;
|
|
|
|
|
using ResponsePackets::TargetStopped;
|
|
|
|
|
using ResponsePackets::ErrorResponsePacket;
|
|
|
|
|
|
|
|
|
|
using Exceptions::Exception;
|
|
|
|
|
|
|
|
|
|
void CommandPacket::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) {
|
|
|
|
|
auto packetData = this->getData();
|
|
|
|
|
auto packetString = std::string(packetData.begin(), packetData.end());
|
|
|
|
|
|
|
|
|
|
if (packetString[0] == '?') {
|
|
|
|
|
// Status report
|
|
|
|
|
debugSession.connection.writePacket(TargetStopped(Signal::TRAP));
|
|
|
|
|
|
|
|
|
|
} else if (packetString[0] == 'D') {
|
|
|
|
|
// Detach packet - there's not really anything we need to do here, so just respond with an OK
|
|
|
|
|
debugSession.connection.writePacket(OkResponsePacket());
|
|
|
|
|
|
|
|
|
|
} else if (packetString.find("qAttached") == 0) {
|
|
|
|
|
Logger::debug("Handling qAttached");
|
|
|
|
|
debugSession.connection.writePacket(ResponsePacket({1}));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
Logger::debug("Unknown GDB RSP packet: " + packetString + " - returning empty response");
|
|
|
|
|
|
|
|
|
|
// Respond with an empty packet
|
|
|
|
|
debugSession.connection.writePacket(ResponsePacket({0}));
|
|
|
|
|
}
|
2022-02-05 15:32:08 +00:00
|
|
|
}
|
2021-10-02 17:39:27 +01:00
|
|
|
}
|