Changed AVR-GDB command packet class to a bare interface class

This commit is contained in:
Nav
2024-10-26 16:19:05 +01:00
parent 5be3ab4503
commit b6cbdf5a0d
27 changed files with 83 additions and 52 deletions

View File

@@ -45,7 +45,9 @@ namespace DebugServer::Gdb::AvrGdb
return "AVR GDB Remote Serial Protocol Debug Server"; return "AVR GDB Remote Serial Protocol Debug Server";
} }
std::unique_ptr<CommandPackets::CommandPacket> AvrGdbRsp::rawPacketToCommandPacket(const RawPacket& rawPacket) { std::unique_ptr<CommandPackets::AvrGdbCommandPacketInterface> AvrGdbRsp::rawPacketToCommandPacket(
const RawPacket& rawPacket
) {
using Gdb::CommandPackets::Monitor; using Gdb::CommandPackets::Monitor;
using CommandPackets::ReadRegister; using CommandPackets::ReadRegister;

View File

@@ -5,11 +5,12 @@
#include "src/DebugServer/Gdb/GdbRspDebugServer.hpp" #include "src/DebugServer/Gdb/GdbRspDebugServer.hpp"
#include "AvrGdbTargetDescriptor.hpp" #include "AvrGdbTargetDescriptor.hpp"
#include "CommandPackets/CommandPacket.hpp" #include "CommandPackets/AvrGdbCommandPacketInterface.hpp"
namespace DebugServer::Gdb::AvrGdb namespace DebugServer::Gdb::AvrGdb
{ {
class AvrGdbRsp: public GdbRspDebugServer<AvrGdbTargetDescriptor, DebugSession, CommandPackets::CommandPacket> class AvrGdbRsp
: public GdbRspDebugServer<AvrGdbTargetDescriptor, DebugSession, CommandPackets::AvrGdbCommandPacketInterface>
{ {
public: public:
AvrGdbRsp( AvrGdbRsp(
@@ -22,7 +23,9 @@ namespace DebugServer::Gdb::AvrGdb
std::string getName() const override; std::string getName() const override;
protected: protected:
std::unique_ptr<CommandPackets::CommandPacket> rawPacketToCommandPacket(const RawPacket& rawPacket) override; std::unique_ptr<CommandPackets::AvrGdbCommandPacketInterface> rawPacketToCommandPacket(
const RawPacket& rawPacket
) override;
std::set<std::pair<Feature, std::optional<std::string>>> getSupportedFeatures() override; std::set<std::pair<Feature, std::optional<std::string>>> getSupportedFeatures() override;
void handleTargetStoppedGdbResponse(Targets::TargetMemoryAddress programAddress) override; void handleTargetStoppedGdbResponse(Targets::TargetMemoryAddress programAddress) override;
}; };

View File

@@ -8,18 +8,10 @@
namespace DebugServer::Gdb::AvrGdb::CommandPackets namespace DebugServer::Gdb::AvrGdb::CommandPackets
{ {
class CommandPacket: public Gdb::CommandPackets::CommandPacket class AvrGdbCommandPacketInterface
{ {
public: public:
explicit CommandPacket(const RawPacket& rawPacket) virtual ~AvrGdbCommandPacketInterface() = default;
: Gdb::CommandPackets::CommandPacket(rawPacket)
{}
explicit CommandPacket(const Gdb::CommandPackets::CommandPacket& commandPacket)
: Gdb::CommandPackets::CommandPacket(commandPacket)
{}
virtual ~CommandPacket() = default;
/** /**
* Should handle the command for the current active debug session. * Should handle the command for the current active debug session.

View File

@@ -24,8 +24,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using Exceptions::InvalidCommandOption; using Exceptions::InvalidCommandOption;
EepromFill::EepromFill(Gdb::CommandPackets::Monitor&& monitorPacket) EepromFill::EepromFill(Gdb::CommandPackets::Monitor&& monitorPacket)
: CommandPacket(monitorPacket) : Gdb::CommandPackets::Monitor(std::move(monitorPacket))
, rawFillValue(monitorPacket.commandArguments.size() >= 3 ? monitorPacket.commandArguments[2] : std::string{}) , rawFillValue(this->commandArguments.size() >= 3 ? this->commandArguments[2] : std::string{})
{} {}
void EepromFill::handle( void EepromFill::handle(

View File

@@ -3,8 +3,7 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/Monitor.hpp" #include "src/DebugServer/Gdb/CommandPackets/Monitor.hpp"
namespace DebugServer::Gdb::AvrGdb::CommandPackets namespace DebugServer::Gdb::AvrGdb::CommandPackets
@@ -14,7 +13,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* *
* This command fills the target's EEPROM with the given value. * This command fills the target's EEPROM with the given value.
*/ */
class EepromFill: public CommandPackets::CommandPacket class EepromFill
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::Monitor
{ {
public: public:
std::string rawFillValue; std::string rawFillValue;

View File

@@ -16,7 +16,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using namespace Exceptions; using namespace Exceptions;
FlashDone::FlashDone(const RawPacket& rawPacket) FlashDone::FlashDone(const RawPacket& rawPacket)
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
{} {}
void FlashDone::handle( void FlashDone::handle(

View File

@@ -3,14 +3,17 @@
#include <cstdint> #include <cstdint>
#include <optional> #include <optional>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
namespace DebugServer::Gdb::AvrGdb::CommandPackets namespace DebugServer::Gdb::AvrGdb::CommandPackets
{ {
/** /**
* The FlashDone class implements the structure for the "vFlashDone" packet. * The FlashDone class implements the structure for the "vFlashDone" packet.
*/ */
class FlashDone: public CommandPackets::CommandPacket class FlashDone
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
explicit FlashDone(const RawPacket& rawPacket); explicit FlashDone(const RawPacket& rawPacket);

View File

@@ -17,7 +17,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using namespace Exceptions; using namespace Exceptions;
FlashErase::FlashErase(const RawPacket& rawPacket) FlashErase::FlashErase(const RawPacket& rawPacket)
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
{ {
using Services::StringService; using Services::StringService;

View File

@@ -3,7 +3,8 @@
#include <cstdint> #include <cstdint>
#include <optional> #include <optional>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
namespace DebugServer::Gdb::AvrGdb::CommandPackets namespace DebugServer::Gdb::AvrGdb::CommandPackets
{ {
@@ -11,7 +12,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* The FlashErase class implements the structure for the "vFlashErase" packet. Upon receiving this packet, the * The FlashErase class implements the structure for the "vFlashErase" packet. Upon receiving this packet, the
* server is expected to erase a particular region of the target's flash memory. * server is expected to erase a particular region of the target's flash memory.
*/ */
class FlashErase: public CommandPackets::CommandPacket class FlashErase
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
std::uint32_t startAddress = 0; std::uint32_t startAddress = 0;

View File

@@ -17,7 +17,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using namespace Exceptions; using namespace Exceptions;
FlashWrite::FlashWrite(const RawPacket& rawPacket) FlashWrite::FlashWrite(const RawPacket& rawPacket)
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
{ {
using Services::StringService; using Services::StringService;

View File

@@ -3,7 +3,8 @@
#include <cstdint> #include <cstdint>
#include <optional> #include <optional>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
#include "src/Targets/TargetMemory.hpp" #include "src/Targets/TargetMemory.hpp"
@@ -13,7 +14,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* The FlashWrite class implements the structure for the "vFlashWrite" packet. Upon receiving this packet, the * The FlashWrite class implements the structure for the "vFlashWrite" packet. Upon receiving this packet, the
* server is expected to write to a particular region of the target's flash memory. * server is expected to write to a particular region of the target's flash memory.
*/ */
class FlashWrite: public CommandPackets::CommandPacket class FlashWrite
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
Targets::TargetMemoryAddress startAddress; Targets::TargetMemoryAddress startAddress;

View File

@@ -150,7 +150,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
const AvrGdbTargetDescriptor& gdbTargetDescriptor, const AvrGdbTargetDescriptor& gdbTargetDescriptor,
ReadMemory::PacketData&& packetData ReadMemory::PacketData&& packetData
) )
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
, addressSpaceDescriptor(gdbTargetDescriptor.addressSpaceDescriptorFromGdbAddress(packetData.gdbStartAddress)) , addressSpaceDescriptor(gdbTargetDescriptor.addressSpaceDescriptorFromGdbAddress(packetData.gdbStartAddress))
, startAddress(gdbTargetDescriptor.translateGdbAddress(packetData.gdbStartAddress)) , startAddress(gdbTargetDescriptor.translateGdbAddress(packetData.gdbStartAddress))
, bytes(packetData.bytes) , bytes(packetData.bytes)

View File

@@ -3,7 +3,8 @@
#include <cstdint> #include <cstdint>
#include <optional> #include <optional>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
#include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp"
#include "src/Targets/TargetMemory.hpp" #include "src/Targets/TargetMemory.hpp"
@@ -14,7 +15,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* The ReadMemory class implements a structure for "m" packets. Upon receiving these packets, the server is * The ReadMemory class implements a structure for "m" packets. Upon receiving these packets, the server is
* expected to read memory from the target and send it the client. * expected to read memory from the target and send it the client.
*/ */
class ReadMemory: public CommandPackets::CommandPacket class ReadMemory
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor; const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;

View File

@@ -14,7 +14,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using Exceptions::Exception; using Exceptions::Exception;
ReadMemoryMap::ReadMemoryMap(const RawPacket& rawPacket) ReadMemoryMap::ReadMemoryMap(const RawPacket& rawPacket)
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
{ {
using Services::StringService; using Services::StringService;

View File

@@ -2,7 +2,8 @@
#include <cstdint> #include <cstdint>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
namespace DebugServer::Gdb::AvrGdb::CommandPackets namespace DebugServer::Gdb::AvrGdb::CommandPackets
{ {
@@ -10,7 +11,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* The ReadMemoryMap class implements a structure for the "qXfer:memory-map:read::..." packet. Upon receiving this * The ReadMemoryMap class implements a structure for the "qXfer:memory-map:read::..." packet. Upon receiving this
* packet, the server is expected to respond with the target's memory map. * packet, the server is expected to respond with the target's memory map.
*/ */
class ReadMemoryMap: public CommandPackets::CommandPacket class ReadMemoryMap
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
/** /**

View File

@@ -21,7 +21,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using Exceptions::Exception; using Exceptions::Exception;
ReadRegister::ReadRegister(const RawPacket& rawPacket) ReadRegister::ReadRegister(const RawPacket& rawPacket)
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
{ {
using Services::StringService; using Services::StringService;

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
#include "src/DebugServer/Gdb/RegisterDescriptor.hpp" #include "src/DebugServer/Gdb/RegisterDescriptor.hpp"
@@ -10,7 +11,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* The ReadRegister class implements a structure for the "p" command packet. In response to this packet, the server * The ReadRegister class implements a structure for the "p" command packet. In response to this packet, the server
* is expected to send register values for the requested register. * is expected to send register values for the requested register.
*/ */
class ReadRegister: public CommandPackets::CommandPacket class ReadRegister
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
GdbRegisterId registerId; GdbRegisterId registerId;

View File

@@ -23,7 +23,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using Exceptions::Exception; using Exceptions::Exception;
ReadRegisters::ReadRegisters(const RawPacket& rawPacket) ReadRegisters::ReadRegisters(const RawPacket& rawPacket)
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
{} {}
void ReadRegisters::handle( void ReadRegisters::handle(

View File

@@ -2,7 +2,8 @@
#include <optional> #include <optional>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
#include "src/DebugServer/Gdb/RegisterDescriptor.hpp" #include "src/DebugServer/Gdb/RegisterDescriptor.hpp"
@@ -12,7 +13,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* The ReadRegisters class implements a structure for the "g" command packet. In response to this packet, the * The ReadRegisters class implements a structure for the "g" command packet. In response to this packet, the
* server is expected to send register values for all registers. * server is expected to send register values for all registers.
*/ */
class ReadRegisters: public CommandPackets::CommandPacket class ReadRegisters
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
explicit ReadRegisters(const RawPacket& rawPacket); explicit ReadRegisters(const RawPacket& rawPacket);

View File

@@ -18,7 +18,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using ::Exceptions::Exception; using ::Exceptions::Exception;
VContRangeStep::VContRangeStep(const RawPacket& rawPacket) VContRangeStep::VContRangeStep(const RawPacket& rawPacket)
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
{ {
using Services::StringService; using Services::StringService;

View File

@@ -2,7 +2,8 @@
#include <cstdint> #include <cstdint>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
#include "src/Targets/TargetMemory.hpp" #include "src/Targets/TargetMemory.hpp"
@@ -13,7 +14,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* step through a particular address range, and only report back to GDB when execution leaves that range, or when an * step through a particular address range, and only report back to GDB when execution leaves that range, or when an
* external breakpoint has been reached. * external breakpoint has been reached.
*/ */
class VContRangeStep: public CommandPackets::CommandPacket class VContRangeStep
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
Targets::TargetMemoryAddress startAddress; Targets::TargetMemoryAddress startAddress;

View File

@@ -9,7 +9,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using Services::TargetControllerService; using Services::TargetControllerService;
VContSupportedActionsQuery::VContSupportedActionsQuery(const RawPacket& rawPacket) VContSupportedActionsQuery::VContSupportedActionsQuery(const RawPacket& rawPacket)
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
{} {}
void VContSupportedActionsQuery::handle( void VContSupportedActionsQuery::handle(

View File

@@ -3,7 +3,8 @@
#include <string> #include <string>
#include <set> #include <set>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
namespace DebugServer::Gdb::AvrGdb::CommandPackets namespace DebugServer::Gdb::AvrGdb::CommandPackets
{ {
@@ -13,7 +14,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* *
* Responses to this command packet should take the form of a ResponsePackets::SupportedFeaturesResponse. * Responses to this command packet should take the form of a ResponsePackets::SupportedFeaturesResponse.
*/ */
class VContSupportedActionsQuery: public CommandPackets::CommandPacket class VContSupportedActionsQuery
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
explicit VContSupportedActionsQuery(const RawPacket& rawPacket); explicit VContSupportedActionsQuery(const RawPacket& rawPacket);

View File

@@ -119,7 +119,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
const AvrGdbTargetDescriptor& gdbTargetDescriptor, const AvrGdbTargetDescriptor& gdbTargetDescriptor,
PacketData&& packetData PacketData&& packetData
) )
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
, addressSpaceDescriptor(gdbTargetDescriptor.addressSpaceDescriptorFromGdbAddress(packetData.gdbStartAddress)) , addressSpaceDescriptor(gdbTargetDescriptor.addressSpaceDescriptorFromGdbAddress(packetData.gdbStartAddress))
, startAddress(gdbTargetDescriptor.translateGdbAddress(packetData.gdbStartAddress)) , startAddress(gdbTargetDescriptor.translateGdbAddress(packetData.gdbStartAddress))
, bytes(packetData.bytes) , bytes(packetData.bytes)

View File

@@ -3,7 +3,8 @@
#include <cstdint> #include <cstdint>
#include <optional> #include <optional>
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
#include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp"
#include "src/Targets/TargetMemory.hpp" #include "src/Targets/TargetMemory.hpp"
@@ -14,7 +15,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
* The WriteMemory class implements the structure for "M" packets. Upon receiving this packet, the server is * The WriteMemory class implements the structure for "M" packets. Upon receiving this packet, the server is
* expected to write data to the target's memory, at the specified start address. * expected to write data to the target's memory, at the specified start address.
*/ */
class WriteMemory: public CommandPackets::CommandPacket class WriteMemory
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor; const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;

View File

@@ -18,7 +18,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
using Exceptions::Exception; using Exceptions::Exception;
WriteRegister::WriteRegister(const RawPacket& rawPacket) WriteRegister::WriteRegister(const RawPacket& rawPacket)
: CommandPacket(rawPacket) : Gdb::CommandPackets::CommandPacket(rawPacket)
{ {
using Services::StringService; using Services::StringService;

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include "CommandPacket.hpp" #include "AvrGdbCommandPacketInterface.hpp"
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
#include "src/DebugServer/Gdb/RegisterDescriptor.hpp" #include "src/DebugServer/Gdb/RegisterDescriptor.hpp"
@@ -11,7 +12,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
/** /**
* The WriteRegister class implements the structure for "P" packets. * The WriteRegister class implements the structure for "P" packets.
*/ */
class WriteRegister: public CommandPackets::CommandPacket class WriteRegister
: public CommandPackets::AvrGdbCommandPacketInterface
, private Gdb::CommandPackets::CommandPacket
{ {
public: public:
GdbRegisterId registerId; GdbRegisterId registerId;