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

@@ -2,15 +2,22 @@
#include <QtCore/QString>
#include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp"
#include "src/DebugServers/GdbRsp/ResponsePackets/OkResponsePacket.hpp"
#include "src/DebugServers/GdbRsp/ResponsePackets/ErrorResponsePacket.hpp"
#include "src/Targets/TargetBreakpoint.hpp"
#include "src/Logger/Logger.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::DebugServers::Gdb::CommandPackets
{
using namespace Bloom::Exceptions;
using Targets::TargetBreakpoint;
void RemoveBreakpoint::dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) {
gdbRspDebugServer.handleGdbPacket(*this);
}
using ResponsePackets::OkResponsePacket;
using ResponsePackets::ErrorResponsePacket;
using Exceptions::Exception;
void RemoveBreakpoint::init() {
if (data.size() < 6) {
@@ -38,4 +45,20 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
throw Exception("Failed to convert address hex value from RemoveBreakpoint packet.");
}
}
void RemoveBreakpoint::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) {
Logger::debug("Removing breakpoint at address " + std::to_string(this->address));
try {
auto breakpoint = TargetBreakpoint();
breakpoint.address = this->address;
targetControllerConsole.removeBreakpoint(breakpoint);
debugSession.connection.writePacket(OkResponsePacket());
} catch (const Exception& exception) {
Logger::error("Failed to remove breakpoint on target - " + exception.getMessage());
debugSession.connection.writePacket(ErrorResponsePacket());
}
}
}