New GDB Monitor command packet class, for "qRcmd" command packets

This commit is contained in:
Nav
2022-04-08 22:18:52 +01:00
parent 908f1c42c9
commit 583b01fa34
4 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#include "Monitor.hpp"
#include "src/DebugServer/Gdb/ResponsePackets/EmptyResponsePacket.hpp"
#include "src/Logger/Logger.hpp"
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using ResponsePackets::EmptyResponsePacket;
Monitor::Monitor(const std::vector<unsigned char>& rawPacket)
: CommandPacket(rawPacket)
{
if (this->data.size() > 6) {
const auto decodedCommand = Packet::hexToData(
std::string(this->data.begin() + 6, this->data.end())
);
this->command = std::string(decodedCommand.begin(), decodedCommand.end());
}
}
void Monitor::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) {
Logger::error("Unknown custom GDB command (" + this->command + ") received.");
debugSession.connection.writePacket(EmptyResponsePacket());
}
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include <cstdint>
#include "CommandPacket.hpp"
namespace Bloom::DebugServer::Gdb::CommandPackets
{
/**
* This is a base class for 'qRcmd' packets - invoked by the GDB 'monitor' command.
*/
class Monitor: public CommandPacket
{
public:
/**
* The decoded command string which was input by the GDB user.
*/
std::string command;
explicit Monitor(const std::vector<unsigned char>& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
};
}