New GDB Monitor command packet class, for "qRcmd" command packets
This commit is contained in:
27
src/DebugServer/Gdb/CommandPackets/Monitor.cpp
Normal file
27
src/DebugServer/Gdb/CommandPackets/Monitor.cpp
Normal 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());
|
||||
}
|
||||
}
|
||||
24
src/DebugServer/Gdb/CommandPackets/Monitor.hpp
Normal file
24
src/DebugServer/Gdb/CommandPackets/Monitor.hpp
Normal 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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user