2021-04-04 21:04:12 +01:00
|
|
|
#include "WriteGeneralRegisters.hpp"
|
|
|
|
|
#include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp"
|
2021-05-24 20:58:49 +01:00
|
|
|
#include "src/Exceptions/Exception.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
using namespace Bloom::DebugServers::Gdb::CommandPackets;
|
2021-05-24 20:58:49 +01:00
|
|
|
using namespace Bloom::Exceptions;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
void WriteGeneralRegisters::init() {
|
|
|
|
|
// The P packet updates a single register
|
|
|
|
|
auto packet = std::string(this->data.begin(), this->data.end());
|
|
|
|
|
|
|
|
|
|
if (packet.size() < 6) {
|
|
|
|
|
throw Exception("Invalid P command packet - insufficient data in packet.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (packet.find("=") == std::string::npos) {
|
|
|
|
|
throw Exception("Invalid P command packet - unexpected format");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto packetSegments = QString::fromStdString(packet).split("=");
|
|
|
|
|
this->registerNumber = packetSegments.front().mid(1).toUInt(nullptr, 16);
|
|
|
|
|
this->registerValue = this->hexToData(packetSegments.back().toStdString());
|
|
|
|
|
std::reverse(this->registerValue.begin(), this->registerValue.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WriteGeneralRegisters::dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) {
|
|
|
|
|
gdbRspDebugServer.handleGdbPacket(*this);
|
|
|
|
|
}
|