Files
BloomPatched/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp

86 lines
2.8 KiB
C++
Raw Normal View History

#include "AvrGdbRsp.hpp"
// Command packets
#include "CommandPackets/ReadMemory.hpp"
#include "CommandPackets/WriteMemory.hpp"
#include "CommandPackets/ReadMemoryMap.hpp"
#include "CommandPackets/FlashErase.hpp"
#include "CommandPackets/FlashWrite.hpp"
#include "CommandPackets/FlashDone.hpp"
namespace Bloom::DebugServer::Gdb::AvrGdb
{
using namespace Bloom::Exceptions;
using Bloom::Targets::TargetRegisterDescriptor;
using Bloom::Targets::TargetRegisterType;
AvrGdbRsp::AvrGdbRsp(
const DebugServerConfig& debugServerConfig,
EventListener& eventListener,
EventFdNotifier& eventNotifier
)
: GdbRspDebugServer(debugServerConfig, eventListener, eventNotifier)
{}
void AvrGdbRsp::init() {
DebugServer::Gdb::GdbRspDebugServer::init();
this->gdbTargetDescriptor = TargetDescriptor(
this->targetControllerService.getTargetDescriptor()
);
}
std::unique_ptr<Gdb::CommandPackets::CommandPacket> AvrGdbRsp::resolveCommandPacket(
2022-10-01 21:01:37 +01:00
const RawPacket& rawPacket
) {
using AvrGdb::CommandPackets::ReadMemory;
using AvrGdb::CommandPackets::WriteMemory;
using AvrGdb::CommandPackets::ReadMemoryMap;
using AvrGdb::CommandPackets::FlashErase;
using AvrGdb::CommandPackets::FlashWrite;
using AvrGdb::CommandPackets::FlashDone;
if (rawPacket.size() >= 2) {
if (rawPacket[1] == 'm') {
return std::make_unique<ReadMemory>(rawPacket, this->gdbTargetDescriptor.value());
}
if (rawPacket[1] == 'M') {
return std::make_unique<WriteMemory>(rawPacket, this->gdbTargetDescriptor.value());
}
const auto rawPacketString = std::string(rawPacket.begin() + 1, rawPacket.end());
if (rawPacketString.find("qXfer:memory-map:read::") == 0) {
return std::make_unique<ReadMemoryMap>(rawPacket);
}
if (rawPacketString.find("vFlashErase") == 0) {
return std::make_unique<FlashErase>(rawPacket);
}
if (rawPacketString.find("vFlashWrite") == 0) {
return std::make_unique<FlashWrite>(rawPacket);
}
if (rawPacketString.find("vFlashDone") == 0) {
return std::make_unique<FlashDone>(rawPacket);
}
}
return GdbRspDebugServer::resolveCommandPacket(rawPacket);
}
std::set<std::pair<Feature, std::optional<std::string>>> AvrGdbRsp::getSupportedFeatures() {
auto supportedFeatures = GdbRspDebugServer::getSupportedFeatures();
2022-06-05 17:01:14 +01:00
// The AVR GDB server supports the 'qXfer:memory-map:read' GDB command.
supportedFeatures.insert({
Feature::MEMORY_MAP_READ, std::nullopt
});
return supportedFeatures;
}
}