Moved GDB command packet handling to individual CommandPacket classes

This commit is contained in:
Nav
2022-03-24 19:17:41 +00:00
parent df5a904a43
commit 2b3a6fd27f
31 changed files with 582 additions and 583 deletions

View File

@@ -1,14 +1,15 @@
#include "StepExecution.hpp"
#include <cstdint>
#include "src/DebugServers/GdbRsp/ResponsePackets/ErrorResponsePacket.hpp"
#include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp"
#include "src/Logger/Logger.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::DebugServers::Gdb::CommandPackets
{
void StepExecution::dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) {
gdbRspDebugServer.handleGdbPacket(*this);
}
using ResponsePackets::ErrorResponsePacket;
using Exceptions::Exception;
void StepExecution::init() {
if (this->data.size() > 1) {
@@ -17,4 +18,17 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
);
}
}
void StepExecution::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) {
Logger::debug("Handling StepExecution packet");
try {
targetControllerConsole.stepTargetExecution(this->fromProgramCounter);
debugSession.waitingForBreak = true;
} catch (const Exception& exception) {
Logger::error("Failed to step execution on target - " + exception.getMessage());
debugSession.connection.writePacket(ErrorResponsePacket());
}
}
}