Refactored GDB server base class, making it a template class, allowing for much more flexibility for derived target-specific implementations
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
namespace DebugServer::Gdb::AvrGdb
|
||||
{
|
||||
using namespace Exceptions;
|
||||
using namespace ::Exceptions;
|
||||
|
||||
using Targets::TargetRegisterDescriptor;
|
||||
using Targets::TargetRegisterType;
|
||||
@@ -33,33 +34,16 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
EventListener& eventListener,
|
||||
EventFdNotifier& eventNotifier
|
||||
)
|
||||
: GdbRspDebugServer(debugServerConfig, targetDescriptor, eventListener, eventNotifier)
|
||||
, gdbTargetDescriptor(targetDescriptor)
|
||||
: GdbRspDebugServer(
|
||||
debugServerConfig,
|
||||
targetDescriptor,
|
||||
AvrGdbTargetDescriptor{targetDescriptor},
|
||||
eventListener,
|
||||
eventNotifier
|
||||
)
|
||||
{}
|
||||
|
||||
DebugSession* AvrGdbRsp::startDebugSession(Connection&& connection) {
|
||||
this->activeDebugSession.emplace(
|
||||
std::move(connection),
|
||||
this->getSupportedFeatures(),
|
||||
this->debugServerConfig
|
||||
);
|
||||
|
||||
return &*(this->activeDebugSession);
|
||||
}
|
||||
|
||||
void AvrGdbRsp::endDebugSession() {
|
||||
this->activeDebugSession.reset();
|
||||
}
|
||||
|
||||
const Gdb::TargetDescriptor& AvrGdbRsp::getGdbTargetDescriptor() {
|
||||
return this->gdbTargetDescriptor;
|
||||
}
|
||||
|
||||
DebugSession* AvrGdbRsp::getActiveDebugSession() {
|
||||
return this->activeDebugSession.has_value() ? &*(this->activeDebugSession) : nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<Gdb::CommandPackets::CommandPacket> AvrGdbRsp::resolveCommandPacket(const RawPacket& rawPacket) {
|
||||
std::unique_ptr<CommandPackets::CommandPacket> AvrGdbRsp::rawPacketToCommandPacket(const RawPacket& rawPacket) {
|
||||
using Gdb::CommandPackets::Monitor;
|
||||
|
||||
using CommandPackets::ReadRegister;
|
||||
@@ -86,7 +70,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
}
|
||||
|
||||
if (rawPacket[1] == 'g') {
|
||||
return std::make_unique<ReadRegisters>(rawPacket, this->gdbTargetDescriptor);
|
||||
return std::make_unique<ReadRegisters>(rawPacket);
|
||||
}
|
||||
|
||||
if (rawPacket[1] == 'P') {
|
||||
@@ -105,11 +89,11 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
const auto rawPacketString = std::string{rawPacket.begin() + 1, rawPacket.end()};
|
||||
|
||||
if (rawPacketString.find("qXfer:memory-map:read::") == 0) {
|
||||
return std::make_unique<ReadMemoryMap>(rawPacket, this->gdbTargetDescriptor);
|
||||
return std::make_unique<ReadMemoryMap>(rawPacket);
|
||||
}
|
||||
|
||||
if (rawPacketString.find("vFlashErase") == 0) {
|
||||
return std::make_unique<FlashErase>(rawPacket, this->gdbTargetDescriptor);
|
||||
return std::make_unique<FlashErase>(rawPacket);
|
||||
}
|
||||
|
||||
if (rawPacketString.find("vFlashWrite") == 0) {
|
||||
@@ -117,7 +101,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
}
|
||||
|
||||
if (rawPacketString.find("vFlashDone") == 0) {
|
||||
return std::make_unique<FlashDone>(rawPacket, this->gdbTargetDescriptor);
|
||||
return std::make_unique<FlashDone>(rawPacket);
|
||||
}
|
||||
|
||||
if (rawPacketString.find("vCont?") == 0) {
|
||||
@@ -134,7 +118,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
|
||||
if (this->debugServerConfig.rangeStepping) {
|
||||
if (rawPacketString.find("vCont;r") == 0) {
|
||||
return std::make_unique<VContRangeStep>(rawPacket, this->gdbTargetDescriptor);
|
||||
return std::make_unique<VContRangeStep>(rawPacket);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,15 +127,12 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
auto monitorCommand = std::make_unique<Monitor>(rawPacket);
|
||||
|
||||
if (monitorCommand->command.find("eeprom fill") == 0) {
|
||||
return std::make_unique<EepromFill>(
|
||||
std::move(*(monitorCommand.release())),
|
||||
this->gdbTargetDescriptor
|
||||
);
|
||||
return std::make_unique<EepromFill>(std::move(*(monitorCommand.release())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GdbRspDebugServer::resolveCommandPacket(rawPacket);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::set<std::pair<Feature, std::optional<std::string>>> AvrGdbRsp::getSupportedFeatures() {
|
||||
@@ -174,7 +155,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
|
||||
Logger::debug("Target stopped at byte address: 0x" + StringService::toHex(programAddress));
|
||||
|
||||
auto& activeRangeSteppingSession = this->activeDebugSession->activeRangeSteppingSession;
|
||||
auto& activeRangeSteppingSession = this->debugSession->activeRangeSteppingSession;
|
||||
|
||||
if (
|
||||
activeRangeSteppingSession.has_value()
|
||||
@@ -186,7 +167,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
*
|
||||
* We need to figure out why, and determine whether the stop should be reported to GDB.
|
||||
*/
|
||||
if (this->activeDebugSession->externalBreakpointsByAddress.contains(programAddress)) {
|
||||
if (this->debugSession->externalBreakpointsByAddress.contains(programAddress)) {
|
||||
/*
|
||||
* The target stopped due to an external breakpoint, set by GDB.
|
||||
*
|
||||
@@ -194,7 +175,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
*/
|
||||
Logger::debug("Reached external breakpoint within stepping range");
|
||||
|
||||
this->activeDebugSession->terminateRangeSteppingSession(this->targetControllerService);
|
||||
this->debugSession->terminateRangeSteppingSession(this->targetControllerService);
|
||||
return GdbRspDebugServer::handleTargetStoppedGdbResponse(programAddress);
|
||||
}
|
||||
|
||||
@@ -236,7 +217,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
* We have to end the range stepping session and report the stop to GDB.
|
||||
*/
|
||||
Logger::debug("Target stopped within stepping range, but for an unknown reason");
|
||||
this->activeDebugSession->terminateRangeSteppingSession(this->targetControllerService);
|
||||
this->debugSession->terminateRangeSteppingSession(this->targetControllerService);
|
||||
}
|
||||
|
||||
// Report the stop to GDB
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "TargetDescriptor.hpp"
|
||||
#include "DebugSession.hpp"
|
||||
#include "AvrGdbTargetDescriptor.hpp"
|
||||
#include "CommandPackets/CommandPacket.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/GdbRspDebugServer.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb
|
||||
{
|
||||
class AvrGdbRsp: public GdbRspDebugServer
|
||||
class AvrGdbRsp: public GdbRspDebugServer<AvrGdbTargetDescriptor, Gdb::DebugSession, CommandPackets::CommandPacket>
|
||||
{
|
||||
public:
|
||||
AvrGdbRsp(
|
||||
@@ -24,37 +24,8 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
}
|
||||
|
||||
protected:
|
||||
DebugSession* startDebugSession(Connection&& connection) override;
|
||||
|
||||
void endDebugSession() override;
|
||||
|
||||
const Gdb::TargetDescriptor& getGdbTargetDescriptor() override;
|
||||
|
||||
DebugSession* getActiveDebugSession() override;
|
||||
|
||||
std::unique_ptr<Gdb::CommandPackets::CommandPacket> resolveCommandPacket(
|
||||
const RawPacket& rawPacket
|
||||
) override;
|
||||
|
||||
/**
|
||||
* Should return a set of GDB features supported by the AVR GDB server. Each supported feature may come with an
|
||||
* optional value.
|
||||
*
|
||||
* The set of features returned by this function will be stored against the active debug session object.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
std::set<std::pair<Feature, std::optional<std::string>>> getSupportedFeatures();
|
||||
|
||||
std::unique_ptr<CommandPackets::CommandPacket> rawPacketToCommandPacket(const RawPacket& rawPacket) override;
|
||||
std::set<std::pair<Feature, std::optional<std::string>>> getSupportedFeatures() override;
|
||||
void handleTargetStoppedGdbResponse(Targets::TargetMemoryAddress programAddress) override;
|
||||
|
||||
private:
|
||||
TargetDescriptor gdbTargetDescriptor;
|
||||
|
||||
/**
|
||||
* When a connection with a GDB client is established, a new instance of the DebugSession class is created and
|
||||
* held here. A value of std::nullopt means there is no active debug session present.
|
||||
*/
|
||||
std::optional<DebugSession> activeDebugSession;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "TargetDescriptor.hpp"
|
||||
#include "AvrGdbTargetDescriptor.hpp"
|
||||
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
|
||||
using Exceptions::Exception;
|
||||
|
||||
TargetDescriptor::TargetDescriptor(const Targets::TargetDescriptor& targetDescriptor)
|
||||
AvrGdbTargetDescriptor::AvrGdbTargetDescriptor(const Targets::TargetDescriptor& targetDescriptor)
|
||||
: programAddressSpaceDescriptor(targetDescriptor.getAddressSpaceDescriptor("prog"))
|
||||
, eepromAddressSpaceDescriptor(targetDescriptor.getFirstAddressSpaceDescriptorContainingMemorySegment("internal_eeprom"))
|
||||
, sramAddressSpaceDescriptor(targetDescriptor.getAddressSpaceDescriptor("data"))
|
||||
@@ -45,11 +45,11 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
}
|
||||
|
||||
this->gdbRegisterDescriptorsById.emplace(
|
||||
TargetDescriptor::STATUS_GDB_REGISTER_ID,
|
||||
RegisterDescriptor{TargetDescriptor::STATUS_GDB_REGISTER_ID, 1}
|
||||
AvrGdbTargetDescriptor::STATUS_GDB_REGISTER_ID,
|
||||
RegisterDescriptor{AvrGdbTargetDescriptor::STATUS_GDB_REGISTER_ID, 1}
|
||||
);
|
||||
this->targetRegisterDescriptorsByGdbId.emplace(
|
||||
TargetDescriptor::STATUS_GDB_REGISTER_ID,
|
||||
AvrGdbTargetDescriptor::STATUS_GDB_REGISTER_ID,
|
||||
&(targetDescriptor.getPeripheralDescriptor("cpu").getRegisterGroupDescriptor("cpu")
|
||||
.getRegisterDescriptor("sreg"))
|
||||
);
|
||||
@@ -60,45 +60,45 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
* CommandPackets::WriteRegister, etc for more.
|
||||
*/
|
||||
this->gdbRegisterDescriptorsById.emplace(
|
||||
TargetDescriptor::STACK_POINTER_GDB_REGISTER_ID,
|
||||
RegisterDescriptor{TargetDescriptor::STACK_POINTER_GDB_REGISTER_ID, 2}
|
||||
AvrGdbTargetDescriptor::STACK_POINTER_GDB_REGISTER_ID,
|
||||
RegisterDescriptor{AvrGdbTargetDescriptor::STACK_POINTER_GDB_REGISTER_ID, 2}
|
||||
);
|
||||
|
||||
this->gdbRegisterDescriptorsById.emplace(
|
||||
TargetDescriptor::PROGRAM_COUNTER_GDB_REGISTER_ID,
|
||||
RegisterDescriptor{TargetDescriptor::PROGRAM_COUNTER_GDB_REGISTER_ID, 4}
|
||||
AvrGdbTargetDescriptor::PROGRAM_COUNTER_GDB_REGISTER_ID,
|
||||
RegisterDescriptor{AvrGdbTargetDescriptor::PROGRAM_COUNTER_GDB_REGISTER_ID, 4}
|
||||
);
|
||||
}
|
||||
|
||||
const Targets::TargetAddressSpaceDescriptor& TargetDescriptor::addressSpaceDescriptorFromGdbAddress(
|
||||
const Targets::TargetAddressSpaceDescriptor& AvrGdbTargetDescriptor::addressSpaceDescriptorFromGdbAddress(
|
||||
GdbMemoryAddress address
|
||||
) const {
|
||||
if ((address & TargetDescriptor::EEPROM_ADDRESS_MASK) == TargetDescriptor::EEPROM_ADDRESS_MASK) {
|
||||
if ((address & AvrGdbTargetDescriptor::EEPROM_ADDRESS_MASK) == AvrGdbTargetDescriptor::EEPROM_ADDRESS_MASK) {
|
||||
return this->eepromAddressSpaceDescriptor;
|
||||
}
|
||||
|
||||
if ((address & TargetDescriptor::SRAM_ADDRESS_MASK) == TargetDescriptor::SRAM_ADDRESS_MASK) {
|
||||
if ((address & AvrGdbTargetDescriptor::SRAM_ADDRESS_MASK) == AvrGdbTargetDescriptor::SRAM_ADDRESS_MASK) {
|
||||
return this->sramAddressSpaceDescriptor;
|
||||
}
|
||||
|
||||
return this->programAddressSpaceDescriptor;
|
||||
}
|
||||
|
||||
Targets::TargetMemoryAddress TargetDescriptor::translateGdbAddress(GdbMemoryAddress address) const {
|
||||
if ((address & TargetDescriptor::EEPROM_ADDRESS_MASK) == TargetDescriptor::EEPROM_ADDRESS_MASK) {
|
||||
Targets::TargetMemoryAddress AvrGdbTargetDescriptor::translateGdbAddress(GdbMemoryAddress address) const {
|
||||
if ((address & AvrGdbTargetDescriptor::EEPROM_ADDRESS_MASK) == AvrGdbTargetDescriptor::EEPROM_ADDRESS_MASK) {
|
||||
// GDB sends EEPROM addresses in relative form - convert them to absolute form.
|
||||
return this->eepromMemorySegmentDescriptor.addressRange.startAddress
|
||||
+ (address & ~(TargetDescriptor::EEPROM_ADDRESS_MASK));
|
||||
+ (address & ~(AvrGdbTargetDescriptor::EEPROM_ADDRESS_MASK));
|
||||
}
|
||||
|
||||
if ((address & TargetDescriptor::SRAM_ADDRESS_MASK) == TargetDescriptor::SRAM_ADDRESS_MASK) {
|
||||
return address & ~(TargetDescriptor::SRAM_ADDRESS_MASK);
|
||||
if ((address & AvrGdbTargetDescriptor::SRAM_ADDRESS_MASK) == AvrGdbTargetDescriptor::SRAM_ADDRESS_MASK) {
|
||||
return address & ~(AvrGdbTargetDescriptor::SRAM_ADDRESS_MASK);
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
GdbMemoryAddress TargetDescriptor::translateTargetMemoryAddress(
|
||||
GdbMemoryAddress AvrGdbTargetDescriptor::translateTargetMemoryAddress(
|
||||
Targets::TargetMemoryAddress address,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor
|
||||
@@ -110,10 +110,10 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
if (memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::EEPROM) {
|
||||
// GDB expects EEPROM addresses in relative form
|
||||
return (address - memorySegmentDescriptor.addressRange.startAddress)
|
||||
| TargetDescriptor::EEPROM_ADDRESS_MASK;
|
||||
| AvrGdbTargetDescriptor::EEPROM_ADDRESS_MASK;
|
||||
}
|
||||
|
||||
// We assume everything else is SRAM
|
||||
return address | TargetDescriptor::SRAM_ADDRESS_MASK;
|
||||
return address | AvrGdbTargetDescriptor::SRAM_ADDRESS_MASK;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb
|
||||
{
|
||||
class TargetDescriptor: public DebugServer::Gdb::TargetDescriptor
|
||||
class AvrGdbTargetDescriptor: public DebugServer::Gdb::TargetDescriptor
|
||||
{
|
||||
public:
|
||||
static constexpr auto SRAM_ADDRESS_MASK = 0x00800000U;
|
||||
@@ -33,7 +33,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
const Targets::TargetPeripheralDescriptor& cpuGpPeripheralDescriptor;
|
||||
const Targets::TargetRegisterGroupDescriptor& cpuGpRegisterGroupDescriptor;
|
||||
|
||||
explicit TargetDescriptor(const Targets::TargetDescriptor& targetDescriptor);
|
||||
explicit AvrGdbTargetDescriptor(const Targets::TargetDescriptor& targetDescriptor);
|
||||
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptorFromGdbAddress(
|
||||
GdbMemoryAddress address
|
||||
39
src/DebugServer/Gdb/AvrGdb/CommandPackets/CommandPacket.hpp
Normal file
39
src/DebugServer/Gdb/AvrGdb/CommandPackets/CommandPacket.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "src/DebugServer/Gdb/DebugSession.hpp"
|
||||
#include "src/DebugServer/Gdb/AvrGdb/AvrGdbTargetDescriptor.hpp"
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
#include "src/Services/TargetControllerService.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
class CommandPacket: public Gdb::CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
explicit CommandPacket(const RawPacket& rawPacket)
|
||||
: 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.
|
||||
*
|
||||
* @param debugSession
|
||||
* The current active debug session.
|
||||
*
|
||||
* @param TargetControllerService
|
||||
*/
|
||||
virtual void handle(
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) = 0;
|
||||
};
|
||||
}
|
||||
@@ -23,33 +23,31 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
using ::Exceptions::Exception;
|
||||
using Exceptions::InvalidCommandOption;
|
||||
|
||||
EepromFill::EepromFill(Monitor&& monitorPacket, const TargetDescriptor& gdbTargetDescriptor)
|
||||
: Monitor(std::move(monitorPacket))
|
||||
, eepromAddressSpaceDescriptor(gdbTargetDescriptor.eepromAddressSpaceDescriptor)
|
||||
, eepromMemorySegmentDescriptor(gdbTargetDescriptor.eepromMemorySegmentDescriptor)
|
||||
EepromFill::EepromFill(Gdb::CommandPackets::Monitor&& monitorPacket)
|
||||
: CommandPacket(monitorPacket)
|
||||
, rawFillValue(monitorPacket.commandArguments.size() >= 3 ? monitorPacket.commandArguments[2] : std::string{})
|
||||
{}
|
||||
|
||||
void EepromFill::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
Logger::info("Handling EepromFill packet");
|
||||
|
||||
try {
|
||||
if (this->commandArguments.size() < 3 || this->commandArguments[2].empty()) {
|
||||
if (this->rawFillValue.empty()) {
|
||||
throw InvalidCommandOption{"Fill value required"};
|
||||
}
|
||||
|
||||
const auto eepromSize = this->eepromMemorySegmentDescriptor.size();
|
||||
const auto& rawFillValue = this->commandArguments[2];
|
||||
const auto eepromSize = gdbTargetDescriptor.eepromMemorySegmentDescriptor.size();
|
||||
|
||||
const auto fillValue = Services::StringService::dataFromHex(
|
||||
rawFillValue.size() >= 3 && rawFillValue[0] == '0'
|
||||
&& (rawFillValue[1] == 'X' || rawFillValue[1] == 'x')
|
||||
? rawFillValue.substr(2)
|
||||
: rawFillValue
|
||||
this->rawFillValue.size() >= 3 && this->rawFillValue[0] == '0'
|
||||
&& (this->rawFillValue[1] == 'X' || this->rawFillValue[1] == 'x')
|
||||
? this->rawFillValue.substr(2)
|
||||
: this->rawFillValue
|
||||
);
|
||||
const auto fillValueSize = fillValue.size();
|
||||
|
||||
@@ -87,9 +85,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
Logger::debug("Filling EEPROM with values: " + hexValues);
|
||||
|
||||
targetControllerService.writeMemory(
|
||||
this->eepromAddressSpaceDescriptor,
|
||||
this->eepromMemorySegmentDescriptor,
|
||||
this->eepromMemorySegmentDescriptor.addressRange.startAddress,
|
||||
gdbTargetDescriptor.eepromAddressSpaceDescriptor,
|
||||
gdbTargetDescriptor.eepromMemorySegmentDescriptor,
|
||||
gdbTargetDescriptor.eepromMemorySegmentDescriptor.addressRange.startAddress,
|
||||
std::move(data)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/Monitor.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
/**
|
||||
@@ -16,17 +14,16 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
*
|
||||
* This command fills the target's EEPROM with the given value.
|
||||
*/
|
||||
class EepromFill: public Gdb::CommandPackets::Monitor
|
||||
class EepromFill: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
const Targets::TargetAddressSpaceDescriptor& eepromAddressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& eepromMemorySegmentDescriptor;
|
||||
std::string rawFillValue;
|
||||
|
||||
explicit EepromFill(Monitor&& monitorPacket, const TargetDescriptor& gdbTargetDescriptor);
|
||||
explicit EepromFill(Gdb::CommandPackets::Monitor&& monitorPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -15,15 +15,13 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
|
||||
using namespace Exceptions;
|
||||
|
||||
FlashDone::FlashDone(const RawPacket& rawPacket, const TargetDescriptor& targetDescriptor)
|
||||
FlashDone::FlashDone(const RawPacket& rawPacket)
|
||||
: CommandPacket(rawPacket)
|
||||
, programMemoryAddressSpaceDescriptor(targetDescriptor.programAddressSpaceDescriptor)
|
||||
, programMemorySegmentDescriptor(targetDescriptor.programMemorySegmentDescriptor)
|
||||
{}
|
||||
|
||||
void FlashDone::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
@@ -42,8 +40,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
targetControllerService.enableProgrammingMode();
|
||||
|
||||
targetControllerService.writeMemory(
|
||||
this->programMemoryAddressSpaceDescriptor,
|
||||
this->programMemorySegmentDescriptor,
|
||||
gdbTargetDescriptor.programAddressSpaceDescriptor,
|
||||
gdbTargetDescriptor.programMemorySegmentDescriptor,
|
||||
debugSession.programmingSession->startAddress,
|
||||
std::move(debugSession.programmingSession->buffer)
|
||||
);
|
||||
|
||||
@@ -3,28 +3,21 @@
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
/**
|
||||
* The FlashDone class implements the structure for the "vFlashDone" packet.
|
||||
*/
|
||||
class FlashDone: public Gdb::CommandPackets::CommandPacket
|
||||
class FlashDone: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
const Targets::TargetAddressSpaceDescriptor& programMemoryAddressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& programMemorySegmentDescriptor;
|
||||
|
||||
explicit FlashDone(const RawPacket& rawPacket, const TargetDescriptor& targetDescriptor);
|
||||
explicit FlashDone(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -16,10 +16,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
|
||||
using namespace Exceptions;
|
||||
|
||||
FlashErase::FlashErase(const RawPacket& rawPacket, const TargetDescriptor& targetDescriptor)
|
||||
FlashErase::FlashErase(const RawPacket& rawPacket)
|
||||
: CommandPacket(rawPacket)
|
||||
, programMemoryAddressSpaceDescriptor(targetDescriptor.programAddressSpaceDescriptor)
|
||||
, programMemorySegmentDescriptor(targetDescriptor.programMemorySegmentDescriptor)
|
||||
{
|
||||
using Services::StringService;
|
||||
|
||||
@@ -45,8 +43,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
}
|
||||
|
||||
void FlashErase::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
@@ -59,8 +57,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
|
||||
// We don't erase a specific address range - we just erase the entire program memory.
|
||||
targetControllerService.eraseMemory(
|
||||
this->programMemoryAddressSpaceDescriptor,
|
||||
this->programMemorySegmentDescriptor
|
||||
gdbTargetDescriptor.programAddressSpaceDescriptor,
|
||||
gdbTargetDescriptor.programMemorySegmentDescriptor
|
||||
);
|
||||
|
||||
debugSession.connection.writePacket(OkResponsePacket{});
|
||||
|
||||
@@ -3,11 +3,7 @@
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
@@ -15,19 +11,17 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
* 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.
|
||||
*/
|
||||
class FlashErase: public Gdb::CommandPackets::CommandPacket
|
||||
class FlashErase: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
std::uint32_t startAddress = 0;
|
||||
std::uint32_t bytes = 0;
|
||||
const Targets::TargetAddressSpaceDescriptor& programMemoryAddressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& programMemorySegmentDescriptor;
|
||||
|
||||
explicit FlashErase(const RawPacket& rawPacket, const TargetDescriptor& targetDescriptor);
|
||||
explicit FlashErase(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
}
|
||||
|
||||
void FlashWrite::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "src/DebugServer/Gdb/TargetDescriptor.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
@@ -14,17 +13,17 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
* 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.
|
||||
*/
|
||||
class FlashWrite: public Gdb::CommandPackets::CommandPacket
|
||||
class FlashWrite: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
std::uint32_t startAddress = 0;
|
||||
Targets::TargetMemoryAddress startAddress;
|
||||
Targets::TargetMemoryBuffer buffer;
|
||||
|
||||
explicit FlashWrite(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -19,13 +19,13 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
|
||||
using Exceptions::Exception;
|
||||
|
||||
ReadMemory::ReadMemory(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor)
|
||||
ReadMemory::ReadMemory(const RawPacket& rawPacket, const AvrGdbTargetDescriptor& gdbTargetDescriptor)
|
||||
: ReadMemory(rawPacket, gdbTargetDescriptor, ReadMemory::extractPacketData(rawPacket))
|
||||
{}
|
||||
|
||||
void ReadMemory::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
@@ -147,7 +147,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
|
||||
ReadMemory::ReadMemory(
|
||||
const RawPacket& rawPacket,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
ReadMemory::PacketData&& packetData
|
||||
)
|
||||
: CommandPacket(rawPacket)
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
@@ -15,7 +14,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
* 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.
|
||||
*/
|
||||
class ReadMemory: public Gdb::CommandPackets::CommandPacket
|
||||
class ReadMemory: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
@@ -23,11 +22,11 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
Targets::TargetMemoryAddress startAddress;
|
||||
Targets::TargetMemorySize bytes;
|
||||
|
||||
ReadMemory(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor);
|
||||
ReadMemory(const RawPacket& rawPacket, const AvrGdbTargetDescriptor& gdbTargetDescriptor);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
@@ -42,7 +41,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
static PacketData extractPacketData(const RawPacket& rawPacket);
|
||||
ReadMemory(
|
||||
const RawPacket& rawPacket,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
PacketData&& packetData
|
||||
);
|
||||
};
|
||||
|
||||
@@ -13,11 +13,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
|
||||
using Exceptions::Exception;
|
||||
|
||||
ReadMemoryMap::ReadMemoryMap(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor)
|
||||
ReadMemoryMap::ReadMemoryMap(const RawPacket& rawPacket)
|
||||
: CommandPacket(rawPacket)
|
||||
, eepromAddressSpaceDescriptor(gdbTargetDescriptor.eepromAddressSpaceDescriptor)
|
||||
, programMemorySegmentDescriptor(gdbTargetDescriptor.programMemorySegmentDescriptor)
|
||||
, eepromMemorySegmentDescriptor(gdbTargetDescriptor.eepromMemorySegmentDescriptor)
|
||||
{
|
||||
using Services::StringService;
|
||||
|
||||
@@ -41,8 +38,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
}
|
||||
|
||||
void ReadMemoryMap::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
@@ -53,18 +50,18 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
* data via memory read/write packets.
|
||||
*/
|
||||
const auto ramSectionEndAddress = gdbTargetDescriptor.translateTargetMemoryAddress(
|
||||
this->eepromMemorySegmentDescriptor.addressRange.endAddress,
|
||||
this->eepromAddressSpaceDescriptor,
|
||||
this->eepromMemorySegmentDescriptor
|
||||
gdbTargetDescriptor.eepromMemorySegmentDescriptor.addressRange.endAddress,
|
||||
gdbTargetDescriptor.eepromAddressSpaceDescriptor,
|
||||
gdbTargetDescriptor.eepromMemorySegmentDescriptor
|
||||
);
|
||||
const auto ramSectionStartAddress = TargetDescriptor::SRAM_ADDRESS_MASK;
|
||||
const auto ramSectionStartAddress = AvrGdbTargetDescriptor::SRAM_ADDRESS_MASK;
|
||||
const auto ramSectionSize = ramSectionEndAddress - ramSectionStartAddress + 1;
|
||||
|
||||
const auto memoryMap =
|
||||
std::string{"<memory-map>"}
|
||||
+ "<memory type=\"ram\" start=\"" + std::to_string(ramSectionStartAddress) + "\" length=\"" + std::to_string(ramSectionSize) + "\"/>"
|
||||
+ "<memory type=\"flash\" start=\"0\" length=\"" + std::to_string(this->programMemorySegmentDescriptor.size()) + "\">"
|
||||
+ "<property name=\"blocksize\">" + std::to_string(this->programMemorySegmentDescriptor.pageSize.value()) + "</property>"
|
||||
+ "<memory type=\"flash\" start=\"0\" length=\"" + std::to_string(gdbTargetDescriptor.programMemorySegmentDescriptor.size()) + "\">"
|
||||
+ "<property name=\"blocksize\">" + std::to_string(gdbTargetDescriptor.programMemorySegmentDescriptor.pageSize.value()) + "</property>"
|
||||
+ "</memory>"
|
||||
+ "</memory-map>";
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
@@ -14,13 +10,9 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
* 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.
|
||||
*/
|
||||
class ReadMemoryMap: public Gdb::CommandPackets::CommandPacket
|
||||
class ReadMemoryMap: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
const Targets::TargetAddressSpaceDescriptor& eepromAddressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& programMemorySegmentDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& eepromMemorySegmentDescriptor;
|
||||
|
||||
/**
|
||||
* The offset of the memory map, from which to read.
|
||||
*/
|
||||
@@ -31,11 +23,11 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
*/
|
||||
std::uint32_t length = 0;
|
||||
|
||||
explicit ReadMemoryMap(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor);
|
||||
explicit ReadMemoryMap(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "src/Targets/TargetRegisterDescriptor.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
#include "src/Services/StringService.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
@@ -36,8 +35,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
}
|
||||
|
||||
void ReadRegister::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
@@ -46,7 +45,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
try {
|
||||
Logger::debug("Reading GDB register ID: " + std::to_string(this->registerId));
|
||||
|
||||
if (this->registerId == TargetDescriptor::PROGRAM_COUNTER_GDB_REGISTER_ID) {
|
||||
if (this->registerId == AvrGdbTargetDescriptor::PROGRAM_COUNTER_GDB_REGISTER_ID) {
|
||||
/*
|
||||
* GDB has requested the program counter. We can't access this in the same way as we do with other
|
||||
* registers.
|
||||
@@ -65,7 +64,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->registerId == TargetDescriptor::STACK_POINTER_GDB_REGISTER_ID) {
|
||||
if (this->registerId == AvrGdbTargetDescriptor::STACK_POINTER_GDB_REGISTER_ID) {
|
||||
/*
|
||||
* GDB has requested the program counter. We can't access this in the same way as we do with other
|
||||
* registers.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/RegisterDescriptor.hpp"
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
* 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.
|
||||
*/
|
||||
class ReadRegister: public Gdb::CommandPackets::CommandPacket
|
||||
class ReadRegister: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
GdbRegisterId registerId;
|
||||
@@ -18,8 +18,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
explicit ReadRegister(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -22,14 +22,13 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
|
||||
using Exceptions::Exception;
|
||||
|
||||
ReadRegisters::ReadRegisters(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor)
|
||||
ReadRegisters::ReadRegisters(const RawPacket& rawPacket)
|
||||
: CommandPacket(rawPacket)
|
||||
, gpRegistersMemorySegmentDescriptor(gdbTargetDescriptor.gpRegistersMemorySegmentDescriptor)
|
||||
{}
|
||||
|
||||
void ReadRegisters::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
@@ -60,7 +59,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
}
|
||||
|
||||
const auto bufferOffset = regDesc.startAddress
|
||||
- this->gpRegistersMemorySegmentDescriptor.addressRange.startAddress;
|
||||
- gdbTargetDescriptor.gpRegistersMemorySegmentDescriptor.addressRange.startAddress;
|
||||
|
||||
assert((buffer.size() - bufferOffset) >= regVal.size());
|
||||
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/RegisterDescriptor.hpp"
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
@@ -14,16 +12,14 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
* 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.
|
||||
*/
|
||||
class ReadRegisters: public Gdb::CommandPackets::CommandPacket
|
||||
class ReadRegisters: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
const Targets::TargetMemorySegmentDescriptor& gpRegistersMemorySegmentDescriptor;
|
||||
|
||||
explicit ReadRegisters(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor);
|
||||
explicit ReadRegisters(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{}
|
||||
|
||||
void VContContinueExecution::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
@@ -10,14 +10,14 @@ namespace DebugServer::Gdb::AvrGdb::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 Gdb::CommandPackets::CommandPacket
|
||||
class VContContinueExecution: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
explicit VContContinueExecution(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -17,10 +17,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
using ResponsePackets::ErrorResponsePacket;
|
||||
using ::Exceptions::Exception;
|
||||
|
||||
VContRangeStep::VContRangeStep(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor)
|
||||
VContRangeStep::VContRangeStep(const RawPacket& rawPacket)
|
||||
: CommandPacket(rawPacket)
|
||||
, programAddressSpaceDescriptor(gdbTargetDescriptor.programAddressSpaceDescriptor)
|
||||
, programMemorySegmentDescriptor(gdbTargetDescriptor.programMemorySegmentDescriptor)
|
||||
{
|
||||
using Services::StringService;
|
||||
|
||||
@@ -44,8 +42,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
}
|
||||
|
||||
void VContRangeStep::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
@@ -61,7 +59,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
try {
|
||||
const auto stepAddressRange = Targets::TargetMemoryAddressRange{this->startAddress, this->endAddress};
|
||||
const auto stepByteSize = stepAddressRange.size() - 1; // -1 because the end address is exclusive
|
||||
const auto& programMemoryAddressRange = this->programMemorySegmentDescriptor.addressRange;
|
||||
const auto& programMemoryAddressRange = gdbTargetDescriptor.programMemorySegmentDescriptor.addressRange;
|
||||
|
||||
if (
|
||||
stepAddressRange.startAddress > stepAddressRange.endAddress
|
||||
@@ -91,8 +89,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
const auto instructionsByAddress = Decoder::decode(
|
||||
stepAddressRange.startAddress,
|
||||
targetControllerService.readMemory(
|
||||
this->programAddressSpaceDescriptor,
|
||||
this->programMemorySegmentDescriptor,
|
||||
gdbTargetDescriptor.programAddressSpaceDescriptor,
|
||||
gdbTargetDescriptor.programMemorySegmentDescriptor,
|
||||
stepAddressRange.startAddress,
|
||||
stepByteSize
|
||||
)
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
@@ -16,20 +13,17 @@ 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
|
||||
* external breakpoint has been reached.
|
||||
*/
|
||||
class VContRangeStep: public Gdb::CommandPackets::CommandPacket
|
||||
class VContRangeStep: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
const Targets::TargetAddressSpaceDescriptor& programAddressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& programMemorySegmentDescriptor;
|
||||
|
||||
Targets::TargetMemoryAddress startAddress;
|
||||
Targets::TargetMemoryAddress endAddress;
|
||||
|
||||
explicit VContRangeStep(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor);
|
||||
explicit VContRangeStep(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{}
|
||||
|
||||
void VContStepExecution::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
/**
|
||||
* The VContStepExecution class implements a structure for "vCont;s" and "vCont;S" packets.
|
||||
*/
|
||||
class VContStepExecution: public Gdb::CommandPackets::CommandPacket
|
||||
class VContStepExecution: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
explicit VContStepExecution(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{}
|
||||
|
||||
void VContSupportedActionsQuery::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
@@ -13,14 +13,14 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
*
|
||||
* Responses to this command packet should take the form of a ResponsePackets::SupportedFeaturesResponse.
|
||||
*/
|
||||
class VContSupportedActionsQuery: public Gdb::CommandPackets::CommandPacket
|
||||
class VContSupportedActionsQuery: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
explicit VContSupportedActionsQuery(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -16,13 +16,13 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
|
||||
using namespace Exceptions;
|
||||
|
||||
WriteMemory::WriteMemory(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor)
|
||||
WriteMemory::WriteMemory(const RawPacket& rawPacket, const AvrGdbTargetDescriptor& gdbTargetDescriptor)
|
||||
: WriteMemory(rawPacket, gdbTargetDescriptor, WriteMemory::extractPacketData(rawPacket))
|
||||
{}
|
||||
|
||||
void WriteMemory::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
@@ -116,7 +116,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
|
||||
WriteMemory::WriteMemory(
|
||||
const RawPacket& rawPacket,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
PacketData&& packetData
|
||||
)
|
||||
: CommandPacket(rawPacket)
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
{
|
||||
@@ -15,7 +14,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
* 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.
|
||||
*/
|
||||
class WriteMemory: public Gdb::CommandPackets::CommandPacket
|
||||
class WriteMemory: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
@@ -23,11 +22,11 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
Targets::TargetMemorySize bytes;
|
||||
Targets::TargetMemoryBuffer buffer;
|
||||
|
||||
explicit WriteMemory(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor);
|
||||
explicit WriteMemory(const RawPacket& rawPacket, const AvrGdbTargetDescriptor& gdbTargetDescriptor);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
@@ -41,6 +40,6 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
};
|
||||
|
||||
static PacketData extractPacketData(const RawPacket& rawPacket);
|
||||
WriteMemory(const RawPacket& rawPacket, const Gdb::TargetDescriptor& gdbTargetDescriptor, PacketData&& packetData);
|
||||
WriteMemory(const RawPacket& rawPacket, const AvrGdbTargetDescriptor& gdbTargetDescriptor, PacketData&& packetData);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,15 +46,15 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
}
|
||||
|
||||
void WriteRegister::handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
Logger::info("Handling WriteRegister packet");
|
||||
|
||||
try {
|
||||
if (this->registerId == TargetDescriptor::PROGRAM_COUNTER_GDB_REGISTER_ID) {
|
||||
if (this->registerId == AvrGdbTargetDescriptor::PROGRAM_COUNTER_GDB_REGISTER_ID) {
|
||||
if (this->registerValue.size() != 4) {
|
||||
throw Exception{"Invalid PC value register size"};
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->registerId == TargetDescriptor::STACK_POINTER_GDB_REGISTER_ID) {
|
||||
if (this->registerId == AvrGdbTargetDescriptor::STACK_POINTER_GDB_REGISTER_ID) {
|
||||
if (this->registerValue.size() != 2) {
|
||||
throw Exception{"Invalid SP register value size"};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/RegisterDescriptor.hpp"
|
||||
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
@@ -12,7 +11,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
/**
|
||||
* The WriteRegister class implements the structure for "P" packets.
|
||||
*/
|
||||
class WriteRegister: public Gdb::CommandPackets::CommandPacket
|
||||
class WriteRegister: public CommandPackets::CommandPacket
|
||||
{
|
||||
public:
|
||||
GdbRegisterId registerId;
|
||||
@@ -21,8 +20,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
||||
explicit WriteRegister(const RawPacket& rawPacket);
|
||||
|
||||
void handle(
|
||||
Gdb::DebugSession& debugSession,
|
||||
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
||||
DebugSession& debugSession,
|
||||
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#include "DebugSession.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb
|
||||
{
|
||||
DebugSession::DebugSession(
|
||||
Connection&& connection,
|
||||
const std::set<std::pair<Feature, std::optional<std::string>>>& supportedFeatures,
|
||||
const GdbDebugServerConfig& serverConfig
|
||||
)
|
||||
: Gdb::DebugSession(std::move(connection), supportedFeatures, serverConfig)
|
||||
{}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "src/DebugServer/Gdb/DebugSession.hpp"
|
||||
|
||||
#include "TargetDescriptor.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::AvrGdb
|
||||
{
|
||||
class DebugSession final: public Gdb::DebugSession
|
||||
{
|
||||
public:
|
||||
DebugSession(
|
||||
Connection&& connection,
|
||||
const std::set<std::pair<Feature, std::optional<std::string>>>& supportedFeatures,
|
||||
const GdbDebugServerConfig& serverConfig
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user