Made VCont step/continue command handlers generic (non-target-specific)

This commit is contained in:
Nav
2024-10-25 23:12:04 +01:00
parent 8be311cbc0
commit 9df41ccfc5
7 changed files with 22 additions and 24 deletions

View File

@@ -0,0 +1,34 @@
#include "VContContinueExecution.hpp"
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
namespace DebugServer::Gdb::CommandPackets
{
using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket;
using ::Exceptions::Exception;
VContContinueExecution::VContContinueExecution(const RawPacket& rawPacket)
: CommandPacket(rawPacket)
{}
void VContContinueExecution::handle(
DebugSession& debugSession,
const TargetDescriptor& gdbTargetDescriptor,
const Targets::TargetDescriptor& targetDescriptor,
TargetControllerService& targetControllerService
) {
Logger::info("Handling VContContinueExecution packet");
try {
targetControllerService.resumeTargetExecution();
debugSession.waitingForBreak = true;
} catch (const Exception& exception) {
Logger::error("Failed to continue execution on target - " + exception.getMessage());
debugSession.connection.writePacket(ErrorResponsePacket{});
}
}
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include <cstdint>
#include "CommandPacket.hpp"
namespace DebugServer::Gdb::CommandPackets
{
/**
* The VContContinueExecution class implements a structure for "vCont;c" and "vCont;C" packets. These packets
* instruct the server to continue execution on the target.
*/
class VContContinueExecution: public CommandPacket
{
public:
explicit VContContinueExecution(const RawPacket& rawPacket);
void handle(
DebugSession& debugSession,
const TargetDescriptor& gdbTargetDescriptor,
const Targets::TargetDescriptor& targetDescriptor,
Services::TargetControllerService& targetControllerService
) override;
};
}

View File

@@ -0,0 +1,34 @@
#include "VContStepExecution.hpp"
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
namespace DebugServer::Gdb::CommandPackets
{
using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket;
using ::Exceptions::Exception;
VContStepExecution::VContStepExecution(const RawPacket& rawPacket)
: CommandPacket(rawPacket)
{}
void VContStepExecution::handle(
DebugSession& debugSession,
const TargetDescriptor& gdbTargetDescriptor,
const Targets::TargetDescriptor& targetDescriptor,
TargetControllerService& targetControllerService
) {
Logger::info("Handling VContStepExecution packet");
try {
targetControllerService.stepTargetExecution();
debugSession.waitingForBreak = true;
} catch (const Exception& exception) {
Logger::error("Failed to step execution on target - " + exception.getMessage());
debugSession.connection.writePacket(ErrorResponsePacket{});
}
}
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include <cstdint>
#include "CommandPacket.hpp"
namespace DebugServer::Gdb::CommandPackets
{
/**
* The VContStepExecution class implements a structure for "vCont;s" and "vCont;S" packets.
*/
class VContStepExecution: public CommandPacket
{
public:
explicit VContStepExecution(const RawPacket& rawPacket);
void handle(
DebugSession& debugSession,
const TargetDescriptor& gdbTargetDescriptor,
const Targets::TargetDescriptor& targetDescriptor,
Services::TargetControllerService& targetControllerService
) override;
};
}