General tidying, addressing issues found by static analysis tool.
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include <QtCore>
|
||||
#include <thread>
|
||||
#include <QJsonDocument>
|
||||
#include <QCoreApplication>
|
||||
#include <unistd.h>
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <variant>
|
||||
#include <cstdint>
|
||||
|
||||
#include "DebugServer.hpp"
|
||||
#include "src/Exceptions/InvalidConfig.hpp"
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Bloom::DebugServers
|
||||
virtual void close() = 0;
|
||||
|
||||
public:
|
||||
DebugServer(EventManager& eventManager): eventManager(eventManager) {};
|
||||
explicit DebugServer(EventManager& eventManager): eventManager(eventManager) {};
|
||||
|
||||
void setApplicationConfig(const ApplicationConfig& applicationConfig) {
|
||||
this->applicationConfig = applicationConfig;
|
||||
|
||||
@@ -116,10 +116,10 @@ namespace Bloom::DebugServers::Gdb
|
||||
};
|
||||
|
||||
public:
|
||||
AvrGdbRsp(EventManager& eventManager): GdbRspDebugServer(eventManager) {};
|
||||
explicit AvrGdbRsp(EventManager& eventManager): GdbRspDebugServer(eventManager) {};
|
||||
|
||||
std::string getName() const override {
|
||||
return "AVR GDB Remote Serial Protocol Debug Server";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
class CommandPacket: public Packet
|
||||
{
|
||||
public:
|
||||
CommandPacket(const std::vector<unsigned char>& rawPacket): Packet(rawPacket) {}
|
||||
explicit CommandPacket(const std::vector<unsigned char>& rawPacket): Packet(rawPacket) {}
|
||||
|
||||
/**
|
||||
* Double dispatches the packet to the appropriate overload of handleGdbPacket(), within the passed instance of
|
||||
|
||||
@@ -8,7 +8,6 @@ using namespace Bloom::DebugServers::Gdb;
|
||||
using namespace Bloom::DebugServers::Gdb::CommandPackets;
|
||||
|
||||
std::unique_ptr<CommandPacket> CommandPacketFactory::create(std::vector<unsigned char> rawPacket) {
|
||||
|
||||
if (rawPacket.size() == 5 && rawPacket[1] == 0x03) {
|
||||
// This is an interrupt request - create a fake packet for it
|
||||
return std::make_unique<CommandPackets::InterruptExecution>(rawPacket);
|
||||
@@ -27,8 +26,8 @@ std::unique_ptr<CommandPacket> CommandPacketFactory::create(std::vector<unsigned
|
||||
} else if (rawPacketString[1] == 'g' || rawPacketString[1] == 'p') {
|
||||
return std::make_unique<CommandPackets::ReadGeneralRegisters>(rawPacket);
|
||||
|
||||
} else if (rawPacketString[1] == 'G' || rawPacketString[1] == 'P') {
|
||||
return std::make_unique<CommandPackets::WriteGeneralRegisters>(rawPacket);
|
||||
} else if (rawPacketString[1] == 'P') {
|
||||
return std::make_unique<CommandPackets::WriteGeneralRegister>(rawPacket);
|
||||
|
||||
} else if (rawPacketString[1] == 'c') {
|
||||
return std::make_unique<CommandPackets::ContinueExecution>(rawPacket);
|
||||
@@ -127,4 +126,4 @@ std::vector<std::vector<unsigned char>> CommandPacketFactory::extractRawPackets(
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "InterruptExecution.hpp"
|
||||
#include "SupportedFeaturesQuery.hpp"
|
||||
#include "ReadGeneralRegisters.hpp"
|
||||
#include "WriteGeneralRegisters.hpp"
|
||||
#include "WriteGeneralRegister.hpp"
|
||||
#include "ReadMemory.hpp"
|
||||
#include "WriteMemory.hpp"
|
||||
#include "StepExecution.hpp"
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
*/
|
||||
std::optional<std::uint32_t> fromProgramCounter;
|
||||
|
||||
ContinueExecution(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {
|
||||
explicit ContinueExecution(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
||||
init();
|
||||
}
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
class InterruptExecution: public CommandPacket
|
||||
{
|
||||
public:
|
||||
InterruptExecution(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {}
|
||||
explicit InterruptExecution(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {}
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
*/
|
||||
std::optional<int> registerNumber;
|
||||
|
||||
ReadGeneralRegisters(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {
|
||||
explicit ReadGeneralRegisters(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
||||
init();
|
||||
};
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,17 +24,17 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
*
|
||||
* For an example of where GDB does this, see the AvrGdbRsp class.
|
||||
*/
|
||||
std::uint32_t startAddress;
|
||||
std::uint32_t startAddress = 0;
|
||||
|
||||
/**
|
||||
* Number of bytes to read.
|
||||
*/
|
||||
std::uint32_t bytes;
|
||||
std::uint32_t bytes = 0;
|
||||
|
||||
ReadMemory(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {
|
||||
explicit ReadMemory(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
||||
init();
|
||||
};
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
/**
|
||||
* Address at which the breakpoint should be located.
|
||||
*/
|
||||
std::uint32_t address;
|
||||
std::uint32_t address = 0;
|
||||
|
||||
RemoveBreakpoint(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {
|
||||
explicit RemoveBreakpoint(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
||||
this->init();
|
||||
};
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
/**
|
||||
* Address at which the breakpoint should be located.
|
||||
*/
|
||||
std::uint32_t address;
|
||||
std::uint32_t address = 0;
|
||||
|
||||
SetBreakpoint(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {
|
||||
explicit SetBreakpoint(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
||||
this->init();
|
||||
};
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
*/
|
||||
std::optional<size_t> fromProgramCounter;
|
||||
|
||||
StepExecution(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {
|
||||
explicit StepExecution(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
||||
init();
|
||||
};
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,18 +27,18 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
void init();
|
||||
|
||||
public:
|
||||
SupportedFeaturesQuery(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {
|
||||
explicit SupportedFeaturesQuery(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
||||
this->init();
|
||||
};
|
||||
|
||||
bool isFeatureSupported(const Feature& feature) const {
|
||||
[[nodiscard]] bool isFeatureSupported(const Feature& feature) const {
|
||||
return this->supportedFeatures.find(feature) != this->supportedFeatures.end();
|
||||
}
|
||||
|
||||
const std::set<Feature>& getSupportedFeatures() const {
|
||||
[[nodiscard]] const std::set<Feature>& getSupportedFeatures() const {
|
||||
return this->supportedFeatures;
|
||||
}
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "WriteGeneralRegisters.hpp"
|
||||
#include "WriteGeneralRegister.hpp"
|
||||
#include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
using namespace Bloom::DebugServers::Gdb::CommandPackets;
|
||||
using namespace Bloom::Exceptions;
|
||||
|
||||
void WriteGeneralRegisters::init() {
|
||||
void WriteGeneralRegister::init() {
|
||||
// The P packet updates a single register
|
||||
auto packet = std::string(this->data.begin(), this->data.end());
|
||||
|
||||
@@ -13,16 +13,16 @@ void WriteGeneralRegisters::init() {
|
||||
throw Exception("Invalid P command packet - insufficient data in packet.");
|
||||
}
|
||||
|
||||
if (packet.find("=") == std::string::npos) {
|
||||
if (packet.find('=') == std::string::npos) {
|
||||
throw Exception("Invalid P command packet - unexpected format");
|
||||
}
|
||||
|
||||
auto packetSegments = QString::fromStdString(packet).split("=");
|
||||
this->registerNumber = packetSegments.front().mid(1).toUInt(nullptr, 16);
|
||||
this->registerValue = this->hexToData(packetSegments.back().toStdString());
|
||||
this->registerNumber = static_cast<int>(packetSegments.front().midRef(1).toUInt(nullptr, 16));
|
||||
this->registerValue = Packet::hexToData(packetSegments.back().toStdString());
|
||||
std::reverse(this->registerValue.begin(), this->registerValue.end());
|
||||
}
|
||||
|
||||
void WriteGeneralRegisters::dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) {
|
||||
void WriteGeneralRegister::dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) {
|
||||
gdbRspDebugServer.handleGdbPacket(*this);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "CommandPacket.hpp"
|
||||
#include "src/Targets/TargetRegister.hpp"
|
||||
|
||||
namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
{
|
||||
/**
|
||||
* The WriteGeneralRegisters class implements the structure for "P" packets. Upon receiving this packet,
|
||||
* server is expected to update a register value to the target.
|
||||
*/
|
||||
class WriteGeneralRegister: public CommandPacket
|
||||
{
|
||||
private:
|
||||
void init();
|
||||
|
||||
public:
|
||||
int registerNumber = 0;
|
||||
std::vector<unsigned char> registerValue;
|
||||
|
||||
explicit WriteGeneralRegister(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
||||
init();
|
||||
};
|
||||
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "CommandPacket.hpp"
|
||||
#include "src/Targets/TargetRegister.hpp"
|
||||
|
||||
namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
{
|
||||
/**
|
||||
* The WriteGeneralRegisters class implements the structure for "G" and "P" packets. Upon receiving this packet,
|
||||
* server is expected to write register values to the target.
|
||||
*/
|
||||
class WriteGeneralRegisters: public CommandPacket
|
||||
{
|
||||
private:
|
||||
void init();
|
||||
|
||||
public:
|
||||
Bloom::Targets::TargetRegisterMap registerMap;
|
||||
int registerNumber;
|
||||
std::vector<unsigned char> registerValue;
|
||||
|
||||
WriteGeneralRegisters(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {
|
||||
init();
|
||||
};
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
@@ -40,7 +40,7 @@ void WriteMemory::init() {
|
||||
throw Exception("Failed to parse write length from write memory packet data");
|
||||
}
|
||||
|
||||
this->buffer = this->hexToData(lengthAndBufferSegments.at(1).toStdString());
|
||||
this->buffer = Packet::hexToData(lengthAndBufferSegments.at(1).toStdString());
|
||||
|
||||
if (this->buffer.size() != bufferSize) {
|
||||
throw Exception("Buffer size does not match length value given in write memory packet");
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
||||
* Like with the ReadMemory command packet, the start address carries additional bits that indicate
|
||||
* the memory type.
|
||||
*/
|
||||
std::uint32_t startAddress;
|
||||
std::uint32_t startAddress = 0;
|
||||
|
||||
Targets::TargetMemoryBuffer buffer;
|
||||
|
||||
WriteMemory(std::vector<unsigned char> rawPacket): CommandPacket(rawPacket) {
|
||||
explicit WriteMemory(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
||||
init();
|
||||
};
|
||||
|
||||
virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <errno.h>
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "src/Logger/Logger.hpp"
|
||||
@@ -117,7 +117,7 @@ void Connection::writePacket(const ResponsePacket& packet) {
|
||||
std::vector<unsigned char> Connection::read(size_t bytes, bool interruptible, std::optional<int> msTimeout) {
|
||||
auto output = std::vector<unsigned char>();
|
||||
constexpr size_t bufferSize = 1024;
|
||||
std::array<unsigned char, bufferSize> buffer;
|
||||
std::array<unsigned char, bufferSize> buffer = {};
|
||||
ssize_t bytesRead;
|
||||
|
||||
if (interruptible) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <netinet/in.h>
|
||||
#include <queue>
|
||||
@@ -83,8 +84,8 @@ namespace Bloom::DebugServers::Gdb
|
||||
*/
|
||||
bool waitingForBreak = false;
|
||||
|
||||
Connection(std::shared_ptr<EventNotifier> interruptEventNotifier)
|
||||
: interruptEventNotifier(interruptEventNotifier) {};
|
||||
explicit Connection(std::shared_ptr<EventNotifier> interruptEventNotifier)
|
||||
: interruptEventNotifier(std::move(interruptEventNotifier)) {};
|
||||
|
||||
/**
|
||||
* Accepts a connection on serverSocketFileDescriptor.
|
||||
@@ -104,7 +105,7 @@ namespace Bloom::DebugServers::Gdb
|
||||
* @return
|
||||
*/
|
||||
std::string getIpAddress() {
|
||||
std::array<char, INET_ADDRSTRLEN> ipAddress;
|
||||
std::array<char, INET_ADDRSTRLEN> ipAddress = {};
|
||||
|
||||
if (::inet_ntop(AF_INET, &(socketAddress.sin_addr), ipAddress.data(), INET_ADDRSTRLEN) == nullptr) {
|
||||
throw Exceptions::Exception("Failed to convert client IP address to text form.");
|
||||
@@ -127,7 +128,7 @@ namespace Bloom::DebugServers::Gdb
|
||||
*/
|
||||
void writePacket(const ResponsePackets::ResponsePacket& packet);
|
||||
|
||||
int getMaxPacketSize() {
|
||||
[[nodiscard]] int getMaxPacketSize() const {
|
||||
return this->maxPacketSize;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -330,7 +330,7 @@ void GdbRspDebugServer::handleGdbPacket(CommandPackets::ReadGeneralRegisters& pa
|
||||
}
|
||||
}
|
||||
|
||||
void GdbRspDebugServer::handleGdbPacket(CommandPackets::WriteGeneralRegisters& packet) {
|
||||
void GdbRspDebugServer::handleGdbPacket(CommandPackets::WriteGeneralRegister& packet) {
|
||||
Logger::debug("Handling WriteGeneralRegisters packet");
|
||||
|
||||
try {
|
||||
|
||||
@@ -200,11 +200,11 @@ namespace Bloom::DebugServers::Gdb
|
||||
virtual void handleGdbPacket(CommandPackets::ReadGeneralRegisters& packet);
|
||||
|
||||
/**
|
||||
* Handles the write general registers ("G" and "P") command packet.
|
||||
* Handles the write general register ("P") command packet.
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
virtual void handleGdbPacket(CommandPackets::WriteGeneralRegisters& packet);
|
||||
virtual void handleGdbPacket(CommandPackets::WriteGeneralRegister& packet);
|
||||
|
||||
/**
|
||||
* Handles the continue execution ("c") command packet.
|
||||
|
||||
@@ -28,11 +28,11 @@ namespace Bloom::DebugServers::Gdb
|
||||
}
|
||||
public:
|
||||
Packet() = default;
|
||||
Packet(const std::vector<unsigned char>& rawPacket) {
|
||||
explicit Packet(const std::vector<unsigned char>& rawPacket) {
|
||||
this->init(rawPacket);
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getData() const {
|
||||
[[nodiscard]] virtual std::vector<unsigned char> getData() const {
|
||||
return this->data;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Bloom::DebugServers::Gdb
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
std::vector<unsigned char> toRawPacket() const {
|
||||
[[nodiscard]] std::vector<unsigned char> toRawPacket() const {
|
||||
std::vector<unsigned char> packet = {'$'};
|
||||
auto data = this->getData();
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Bloom::DebugServers::Gdb
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
static std::string dataToHex(std::vector<unsigned char> data) {
|
||||
static std::string dataToHex(const std::vector<unsigned char>& data) {
|
||||
std::stringstream stream;
|
||||
stream << std::hex << std::setfill('0');
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets
|
||||
public:
|
||||
Ok() = default;
|
||||
|
||||
std::vector<unsigned char> getData() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getData() const override {
|
||||
return {'O', 'K'};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
#include "ResponsePacket.hpp"
|
||||
#include "../Feature.hpp"
|
||||
@@ -17,9 +18,9 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets
|
||||
|
||||
public:
|
||||
SupportedFeaturesResponse() = default;
|
||||
SupportedFeaturesResponse(const std::set<std::pair<Feature, std::optional<std::string>>>& supportedFeatures)
|
||||
: supportedFeatures(supportedFeatures) {};
|
||||
explicit SupportedFeaturesResponse(std::set<std::pair<Feature, std::optional<std::string>>> supportedFeatures)
|
||||
: supportedFeatures(std::move(supportedFeatures)) {};
|
||||
|
||||
std::vector<unsigned char> getData() const override;
|
||||
[[nodiscard]] std::vector<unsigned char> getData() const override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets
|
||||
std::optional<Targets::TargetRegisterMap> registerMap;
|
||||
std::optional<StopReason> stopReason;
|
||||
|
||||
TargetStopped(Signal signal): signal(signal) {}
|
||||
explicit TargetStopped(Signal signal): signal(signal) {}
|
||||
|
||||
std::vector<unsigned char> getData() const override {
|
||||
std::string output = "T" + this->dataToHex({static_cast<unsigned char>(this->signal)});
|
||||
[[nodiscard]] std::vector<unsigned char> getData() const override {
|
||||
std::string output = "T" + Packet::dataToHex({static_cast<unsigned char>(this->signal)});
|
||||
|
||||
if (this->stopReason.has_value()) {
|
||||
auto stopReasonMapping = getStopReasonToNameMapping();
|
||||
@@ -34,8 +34,8 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets
|
||||
|
||||
if (this->registerMap.has_value()) {
|
||||
for (const auto& [registerId, registerValue] : this->registerMap.value()) {
|
||||
output += this->dataToHex({static_cast<unsigned char>(registerId)});
|
||||
output += ":" + this->dataToHex(registerValue.value) + ";";
|
||||
output += Packet::dataToHex({static_cast<unsigned char>(registerId)});
|
||||
output += ":" + Packet::dataToHex(registerValue.value) + ";";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Bloom
|
||||
}
|
||||
|
||||
public:
|
||||
bool isInitialised() const {
|
||||
[[nodiscard]] bool isInitialised() const {
|
||||
return this->initialised;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap;
|
||||
|
||||
Command::operator std::vector<unsigned char> () const
|
||||
{
|
||||
Command::operator std::vector<unsigned char> () const {
|
||||
auto rawCommand = std::vector<unsigned char>(1, this->getCommandId());
|
||||
auto commandData = this->getData();
|
||||
rawCommand.insert(rawCommand.end(), commandData.begin(), commandData.end());
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
std::vector<unsigned char> data;
|
||||
|
||||
public:
|
||||
unsigned char getCommandId() const {
|
||||
[[nodiscard]] unsigned char getCommandId() const {
|
||||
return this->commandId;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
this->commandId = commandId;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getData() const {
|
||||
[[nodiscard]] virtual std::vector<unsigned char> getData() const {
|
||||
return this->data;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
return (int) (1 + this->getData().size());
|
||||
}
|
||||
|
||||
std::uint16_t getDataSize() const {
|
||||
[[nodiscard]] std::uint16_t getDataSize() const {
|
||||
return (std::uint16_t) this->getData().size();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,5 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
explicit virtual operator std::vector<unsigned char>() const;
|
||||
|
||||
virtual ~Command() = default;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
|
||||
using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap;
|
||||
|
||||
void Response::init(const std::vector<unsigned char>& rawResponse)
|
||||
{
|
||||
if (rawResponse.size() < 1) {
|
||||
void Response::init(const std::vector<unsigned char>& rawResponse) {
|
||||
if (rawResponse.empty()) {
|
||||
throw Exceptions::Exception("Failed to process CMSIS-DAP response - invalid response");
|
||||
}
|
||||
|
||||
this->setResponseId(rawResponse[0]);
|
||||
this->setData(std::vector<unsigned char>(rawResponse.begin() + 1, rawResponse.end()));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
Response() = default;
|
||||
virtual void init(const std::vector<unsigned char>& rawResponse);
|
||||
|
||||
unsigned char getResponseId() const {
|
||||
[[nodiscard]] unsigned char getResponseId() const {
|
||||
return this->responseId;
|
||||
}
|
||||
|
||||
virtual const std::vector<unsigned char>& getData() const {
|
||||
[[nodiscard]] virtual const std::vector<unsigned char>& getData() const {
|
||||
return this->data;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr;
|
||||
|
||||
std::vector<unsigned char> AvrCommand::getData() const
|
||||
{
|
||||
std::vector<unsigned char> AvrCommand::getData() const {
|
||||
std::vector<unsigned char> data;
|
||||
auto commandPacket = this->getCommandPacket();
|
||||
std::size_t commandPacketSize = commandPacket.size();
|
||||
@@ -21,4 +20,3 @@ std::vector<unsigned char> AvrCommand::getData() const
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
std::vector<unsigned char> getData() const override;
|
||||
[[nodiscard]] std::vector<unsigned char> getData() const override;
|
||||
|
||||
size_t getFragmentNumber() const {
|
||||
[[nodiscard]] size_t getFragmentNumber() const {
|
||||
return this->fragmentNumber;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->fragmentNumber = fragmentNumber;
|
||||
}
|
||||
|
||||
size_t getFragmentCount() const {
|
||||
[[nodiscard]] size_t getFragmentCount() const {
|
||||
return this->fragmentCount;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->fragmentCount = fragmentCount;
|
||||
}
|
||||
|
||||
const std::vector<unsigned char>& getCommandPacket() const {
|
||||
[[nodiscard]] const std::vector<unsigned char>& getCommandPacket() const {
|
||||
return this->commandPacket;
|
||||
}
|
||||
|
||||
@@ -50,5 +50,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->commandPacket = commandPacket;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ void AvrEvent::init(const std::vector<unsigned char>& rawResponse) {
|
||||
}
|
||||
|
||||
// Response size is two bytes, MSB
|
||||
size_t responsePacketSize = static_cast<size_t>((responseData[0] << 8) | responseData[1]);
|
||||
auto responsePacketSize = static_cast<size_t>((responseData[0] << 8) | responseData[1]);
|
||||
|
||||
if (responseData.size() < 2) {
|
||||
// All AVR_EVT responses should consist of at least two bytes (excluding the AVR_EVT ID)
|
||||
@@ -42,8 +42,7 @@ void AvrEvent::init(const std::vector<unsigned char>& rawResponse) {
|
||||
|
||||
this->setEventData(eventData);
|
||||
|
||||
if (eventData.size() >= 1) {
|
||||
if (!eventData.empty()) {
|
||||
this->eventId = eventData[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
class AvrEvent: public Response
|
||||
{
|
||||
private:
|
||||
unsigned char eventId;
|
||||
unsigned char eventId = 0;
|
||||
|
||||
std::vector<unsigned char> eventData;
|
||||
|
||||
@@ -48,15 +48,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
|
||||
void init(const std::vector<unsigned char>& rawResponse) override;
|
||||
|
||||
const std::vector<unsigned char>& getEventData() const {
|
||||
[[nodiscard]] const std::vector<unsigned char>& getEventData() const {
|
||||
return this->eventData;
|
||||
}
|
||||
|
||||
size_t getEventDataSize() const {
|
||||
[[nodiscard]] size_t getEventDataSize() const {
|
||||
return this->eventData.size();
|
||||
}
|
||||
|
||||
AvrEventId getEventId() {
|
||||
[[nodiscard]] AvrEventId getEventId() const {
|
||||
return static_cast<AvrEventId>(this->eventId);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,15 +44,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
|
||||
void init(const std::vector<unsigned char>& rawResponse) override;
|
||||
|
||||
std::uint8_t getFragmentNumber() const {
|
||||
[[nodiscard]] std::uint8_t getFragmentNumber() const {
|
||||
return this->fragmentNumber;
|
||||
}
|
||||
|
||||
std::uint8_t getFragmentCount() const {
|
||||
[[nodiscard]] std::uint8_t getFragmentCount() const {
|
||||
return this->fragmentCount;
|
||||
}
|
||||
|
||||
const std::vector<unsigned char>& getResponsePacket() const {
|
||||
[[nodiscard]] const std::vector<unsigned char>& getResponsePacket() const {
|
||||
return this->responsePacket;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
|
||||
public:
|
||||
ActivatePhysical() = default;
|
||||
ActivatePhysical(bool reset): reset(reset) {};
|
||||
explicit ActivatePhysical(bool reset): reset(reset) {};
|
||||
|
||||
void setReset(bool reset) {
|
||||
this->reset = reset;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The activate physical command consists of 3 bytes:
|
||||
* 1. Command ID (0x10)
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
|
||||
public:
|
||||
Attach() = default;
|
||||
Attach(bool breakAfterAttach): breakAfterAttach(breakAfterAttach) {};
|
||||
explicit Attach(bool breakAfterAttach): breakAfterAttach(breakAfterAttach) {};
|
||||
|
||||
void setBreadAfterAttach(bool breakAfterAttach) {
|
||||
this->breakAfterAttach = breakAfterAttach;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The attach command consists of 3 bytes:
|
||||
* 1. Command ID (0x13)
|
||||
|
||||
@@ -13,8 +13,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
using ResponseFrameType = ResponseFrames::Avr8Generic::Avr8GenericResponseFrame;
|
||||
|
||||
Avr8GenericCommandFrame() {
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::Avr8Generic);
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::AVR8_GENERIC);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
#include "Avr8GenericCommandFrame.hpp"
|
||||
|
||||
@@ -14,13 +15,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
public:
|
||||
ClearSoftwareBreakpoints() = default;
|
||||
|
||||
ClearSoftwareBreakpoints(const std::vector<std::uint32_t>& addresses): addresses(addresses) {}
|
||||
explicit ClearSoftwareBreakpoints(std::vector<std::uint32_t> addresses): addresses(std::move(addresses)) {}
|
||||
|
||||
void setAddresses(const std::vector<std::uint32_t>& addresses) {
|
||||
this->addresses = addresses;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The clear software breakpoints command consists of 2 bytes + 4*n bytes, where n is the number
|
||||
* of breakpoints to clear:
|
||||
@@ -43,5 +44,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,5 +27,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
{
|
||||
private:
|
||||
Avr8EdbgParameter parameter;
|
||||
std::uint8_t size;
|
||||
std::uint8_t size = 0;
|
||||
|
||||
public:
|
||||
GetParameter() = default;
|
||||
|
||||
GetParameter(const Avr8EdbgParameter& parameter) {
|
||||
explicit GetParameter(const Avr8EdbgParameter& parameter) {
|
||||
this->setParameter(parameter);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->size = size;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The get param command consists of 5 bytes:
|
||||
* 1. Command ID (0x02)
|
||||
@@ -50,5 +50,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,5 +27,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class ReadMemory: public Avr8GenericCommandFrame
|
||||
{
|
||||
private:
|
||||
Avr8MemoryType type;
|
||||
Avr8MemoryType type = Avr8MemoryType::SRAM;
|
||||
std::uint32_t address = 0;
|
||||
std::uint32_t bytes = 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->bytes = bytes;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The read memory command consists of 11 bytes:
|
||||
* 1. Command ID (0x21)
|
||||
@@ -56,5 +56,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
|
||||
public:
|
||||
Reset() = default;
|
||||
Reset(bool stopAtMainAddress): stopAtMainAddress(stopAtMainAddress) {};
|
||||
explicit Reset(bool stopAtMainAddress): stopAtMainAddress(stopAtMainAddress) {};
|
||||
|
||||
void setStopAtMainAddress(bool stopAtMainAddress) {
|
||||
this->stopAtMainAddress = stopAtMainAddress;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The reset command consists of 3 bytes:
|
||||
* 1. Command ID (0x30)
|
||||
@@ -32,5 +32,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class RunTo: public Avr8GenericCommandFrame
|
||||
{
|
||||
private:
|
||||
std::uint32_t address;
|
||||
std::uint32_t address = 0;
|
||||
|
||||
public:
|
||||
RunTo() = default;
|
||||
|
||||
RunTo(const std::uint32_t& address): address(address) {}
|
||||
explicit RunTo(const std::uint32_t& address): address(address) {}
|
||||
|
||||
void setAddress(const std::uint32_t& address) {
|
||||
this->address = address;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The run-to command consists of 6 bytes:
|
||||
*
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
public:
|
||||
SetParameter() = default;
|
||||
|
||||
SetParameter(const Avr8EdbgParameter& parameter) {
|
||||
explicit SetParameter(const Avr8EdbgParameter& parameter) {
|
||||
this->setParameter(parameter);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->value.resize(1, value);
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The set param command consists of this->value.size() + 5 bytes. The first five bytes consist of:
|
||||
* 1. Command ID (0x01)
|
||||
@@ -58,5 +58,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
std::uint32_t programCounter = 0;
|
||||
|
||||
public:
|
||||
SetProgramCounter(std::uint32_t programCounter): programCounter(programCounter) {}
|
||||
explicit SetProgramCounter(std::uint32_t programCounter): programCounter(programCounter) {}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The PC write command consists of 6 bytes:
|
||||
* 1. Command ID (0x01)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
#include "Avr8GenericCommandFrame.hpp"
|
||||
|
||||
@@ -14,13 +15,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
public:
|
||||
SetSoftwareBreakpoints() = default;
|
||||
|
||||
SetSoftwareBreakpoints(const std::vector<std::uint32_t>& addresses): addresses(addresses) {}
|
||||
explicit SetSoftwareBreakpoints(std::vector<std::uint32_t> addresses): addresses(std::move(addresses)) {}
|
||||
|
||||
void setAddresses(const std::vector<std::uint32_t>& addresses) {
|
||||
this->addresses = addresses;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The set software breakpoint command consists of 2 bytes + 4*n bytes, where n is the number
|
||||
* of breakpoints to set:
|
||||
@@ -43,5 +44,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class SetXmegaSoftwareBreakpoint: public Avr8GenericCommandFrame
|
||||
{
|
||||
private:
|
||||
std::uint32_t address;
|
||||
std::uint32_t address = 0;
|
||||
|
||||
public:
|
||||
SetXmegaSoftwareBreakpoint() = default;
|
||||
|
||||
SetXmegaSoftwareBreakpoint(std::uint32_t address): address(address) {}
|
||||
explicit SetXmegaSoftwareBreakpoint(std::uint32_t address): address(address) {}
|
||||
|
||||
void setAddress(std::uint32_t address) {
|
||||
this->address = address;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The set software breakpoint command consists of 6 bytes bytes
|
||||
*
|
||||
@@ -41,5 +41,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
public:
|
||||
Step() = default;
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The step command consists of 4 bytes:
|
||||
* 1. Command ID (0x34)
|
||||
@@ -26,5 +26,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
|
||||
public:
|
||||
Stop() = default;
|
||||
Stop(bool stopImmediately): stopImmediately(stopImmediately) {};
|
||||
explicit Stop(bool stopImmediately): stopImmediately(stopImmediately) {};
|
||||
|
||||
void setStopImmediately(bool stopImmediately) {
|
||||
this->stopImmediately = stopImmediately;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The stop command consists of 3 bytes:
|
||||
* 1. Command ID (0x31)
|
||||
@@ -32,5 +32,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class WriteMemory: public Avr8GenericCommandFrame
|
||||
{
|
||||
private:
|
||||
Avr8MemoryType type;
|
||||
Avr8MemoryType type = Avr8MemoryType::SRAM;
|
||||
std::uint32_t address = 0;
|
||||
Targets::TargetMemoryBuffer buffer;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->buffer = buffer;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The write memory command consists of 12 bytes + the buffer size:
|
||||
* 1. Command ID (0x23)
|
||||
@@ -63,5 +63,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr;
|
||||
std::vector<AvrCommand> AvrCommandFrame::generateAvrCommands(std::size_t maximumCommandPacketSize) const {
|
||||
auto rawCommandFrame = static_cast<std::vector<unsigned char>>(*this);
|
||||
std::size_t commandFrameSize = rawCommandFrame.size();
|
||||
std::size_t commandsRequired = static_cast<std::size_t>(ceil(static_cast<float>(commandFrameSize) / static_cast<float>(maximumCommandPacketSize)));
|
||||
auto commandsRequired = static_cast<std::size_t>(
|
||||
ceil(static_cast<float>(commandFrameSize) / static_cast<float>(maximumCommandPacketSize))
|
||||
);
|
||||
|
||||
std::vector<AvrCommand> avrCommands;
|
||||
std::size_t copiedPacketSize = 0;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
/**
|
||||
* Destination sub-protocol handler ID
|
||||
*/
|
||||
ProtocolHandlerId protocolHandlerID;
|
||||
ProtocolHandlerId protocolHandlerID = ProtocolHandlerId::DISCOVERY;
|
||||
|
||||
std::vector<unsigned char> payload;
|
||||
|
||||
@@ -36,16 +36,16 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
using ResponseFrameType = AvrResponseFrame;
|
||||
|
||||
AvrCommandFrame() {
|
||||
if (this->lastSequenceId < std::numeric_limits<decltype(this->lastSequenceId)>::max()) {
|
||||
this->sequenceId = ++(this->lastSequenceId);
|
||||
if (AvrCommandFrame::lastSequenceId < std::numeric_limits<decltype(AvrCommandFrame::lastSequenceId)>::max()) {
|
||||
this->sequenceId = ++(AvrCommandFrame::lastSequenceId);
|
||||
|
||||
} else {
|
||||
this->sequenceId = 0;
|
||||
this->lastSequenceId = 0;
|
||||
AvrCommandFrame::lastSequenceId = 0;
|
||||
}
|
||||
};
|
||||
|
||||
unsigned char getProtocolVersion() const {
|
||||
[[nodiscard]] unsigned char getProtocolVersion() const {
|
||||
return this->protocolVersion;
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
std::uint16_t getSequenceId() const {
|
||||
[[nodiscard]] std::uint16_t getSequenceId() const {
|
||||
return this->sequenceId;
|
||||
}
|
||||
|
||||
ProtocolHandlerId getProtocolHandlerId() const {
|
||||
[[nodiscard]] ProtocolHandlerId getProtocolHandlerId() const {
|
||||
return this->protocolHandlerID;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->protocolHandlerID = static_cast<ProtocolHandlerId>(protocolHandlerId);
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const {
|
||||
[[nodiscard]] virtual std::vector<unsigned char> getPayload() const {
|
||||
return this->payload;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @return
|
||||
* A vector of sequenced AVRCommands, each containing a segment of the AvrCommandFrame.
|
||||
*/
|
||||
std::vector<AvrCommand> generateAvrCommands(std::size_t maximumCommandPacketSize) const;
|
||||
[[nodiscard]] std::vector<AvrCommand> generateAvrCommands(std::size_t maximumCommandPacketSize) const;
|
||||
|
||||
/**
|
||||
* Converts instance of a CMSIS Command to an unsigned char, for sending to the Atmel ICE device.
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
using ResponseFrameType = ResponseFrames::DiscoveryResponseFrame;
|
||||
|
||||
DiscoveryCommandFrame() {
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::Discovery);
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::DISCOVERY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class Query: public DiscoveryCommandFrame
|
||||
{
|
||||
private:
|
||||
QueryContext context;
|
||||
QueryContext context = QueryContext::COMMAND_HANDLERS;
|
||||
|
||||
public:
|
||||
Query(): DiscoveryCommandFrame() {}
|
||||
|
||||
Query(QueryContext context): DiscoveryCommandFrame() {
|
||||
explicit Query(QueryContext context): DiscoveryCommandFrame() {
|
||||
this->setContext(context);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->context = context;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The payload for the Query command consists of three bytes. A command ID (0x00), version (0x00) and a
|
||||
* query context.
|
||||
|
||||
@@ -27,5 +27,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->init();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
{
|
||||
public:
|
||||
HouseKeepingCommandFrame() {
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::HouseKeeping);
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::HOUSE_KEEPING);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,5 +26,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->init();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ using Bloom::Targets::TargetState;
|
||||
using Bloom::Targets::TargetMemoryType;
|
||||
using Bloom::Targets::TargetMemoryBuffer;
|
||||
using Bloom::Targets::TargetRegister;
|
||||
using Bloom::Targets::TargetRegisterDescriptor;
|
||||
using Bloom::Targets::TargetRegisterType;
|
||||
using Bloom::Targets::TargetRegisters;
|
||||
|
||||
@@ -554,7 +555,7 @@ std::uint32_t EdbgAvr8Interface::getProgramCounter() {
|
||||
}
|
||||
|
||||
TargetRegister EdbgAvr8Interface::getStackPointerRegister() {
|
||||
return TargetRegister(TargetRegisterType::STACK_POINTER, this->readMemory(
|
||||
return TargetRegister(TargetRegisterDescriptor(TargetRegisterType::STACK_POINTER), this->readMemory(
|
||||
Avr8MemoryType::SRAM,
|
||||
this->targetParameters.stackPointerRegisterStartAddress.value(),
|
||||
this->targetParameters.stackPointerRegisterSize.value()
|
||||
@@ -562,7 +563,7 @@ TargetRegister EdbgAvr8Interface::getStackPointerRegister() {
|
||||
}
|
||||
|
||||
TargetRegister EdbgAvr8Interface::getStatusRegister() {
|
||||
return TargetRegister(TargetRegisterType::STATUS_REGISTER, this->readMemory(
|
||||
return TargetRegister(TargetRegisterDescriptor(TargetRegisterType::STATUS_REGISTER), this->readMemory(
|
||||
Avr8MemoryType::SRAM,
|
||||
this->targetParameters.statusRegisterStartAddress.value(),
|
||||
this->targetParameters.statusRegisterSize.value()
|
||||
@@ -840,7 +841,7 @@ TargetMemoryBuffer EdbgAvr8Interface::readMemory(Avr8MemoryType type, std::uint3
|
||||
return response.getMemoryBuffer();
|
||||
}
|
||||
|
||||
void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t address, TargetMemoryBuffer buffer) {
|
||||
void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t address, const TargetMemoryBuffer& buffer) {
|
||||
if (type == Avr8MemoryType::FLASH_PAGE) {
|
||||
// TODO: Implement support for writing to flash
|
||||
throw Exception("Cannot write to flash");
|
||||
@@ -855,8 +856,6 @@ void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t address,
|
||||
if (response.getResponseId() == Avr8ResponseId::FAILED) {
|
||||
throw Avr8CommandFailure("Write memory AVR8 from target command failed", response);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
TargetRegisters EdbgAvr8Interface::readGeneralPurposeRegisters(std::set<std::size_t> registerIds) {
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param address
|
||||
* @param buffer
|
||||
*/
|
||||
void writeMemory(Avr8MemoryType type, std::uint32_t address, Targets::TargetMemoryBuffer buffer);
|
||||
void writeMemory(Avr8MemoryType type, std::uint32_t address, const Targets::TargetMemoryBuffer& buffer);
|
||||
|
||||
/**
|
||||
* Fetches the current target state.
|
||||
@@ -413,7 +413,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
void waitForStoppedEvent();
|
||||
|
||||
public:
|
||||
EdbgAvr8Interface(EdbgInterface& edbgInterface)
|
||||
explicit EdbgAvr8Interface(EdbgInterface& edbgInterface)
|
||||
: edbgInterface(edbgInterface) {};
|
||||
|
||||
/*
|
||||
@@ -427,7 +427,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* @param targetConfig
|
||||
*/
|
||||
virtual void configure(const TargetConfig& targetConfig) override;
|
||||
void configure(const TargetConfig& targetConfig) override;
|
||||
|
||||
/**
|
||||
* Configures the target family. For some physical interfaces, the target family is required in order
|
||||
@@ -445,22 +445,22 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
virtual void setTargetParameters(const Targets::Microchip::Avr::Avr8Bit::TargetParameters& config) override;
|
||||
void setTargetParameters(const Targets::Microchip::Avr::Avr8Bit::TargetParameters& config) override;
|
||||
|
||||
/**
|
||||
* Initialises the AVR8 Generic protocol interface by setting the appropriate parameters on the debug tool.
|
||||
*/
|
||||
virtual void init() override;
|
||||
void init() override;
|
||||
|
||||
/**
|
||||
* Issues the "stop" command to the debug tool, halting target execution.
|
||||
*/
|
||||
virtual void stop() override;
|
||||
void stop() override;
|
||||
|
||||
/**
|
||||
* Issues the "run" command to the debug tool, resuming execution on the target.
|
||||
*/
|
||||
virtual void run() override;
|
||||
void run() override;
|
||||
|
||||
/**
|
||||
* Issues the "run to" command to the debug tool, resuming execution on the target, up to a specific byte
|
||||
@@ -469,65 +469,65 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param address
|
||||
* The (byte) address to run to.
|
||||
*/
|
||||
virtual void runTo(std::uint32_t address) override;
|
||||
void runTo(std::uint32_t address) override;
|
||||
|
||||
/**
|
||||
* Issues the "step" command to the debug tool, stepping the execution on the target. The stepping can be
|
||||
* configured to step in, out or over. But currently we only support stepping in. The target will dispatch
|
||||
* an AVR BREAK event once it reaches the next instruction.
|
||||
*/
|
||||
virtual void step() override;
|
||||
void step() override;
|
||||
|
||||
/**
|
||||
* Issues the "reset" command to the debug tool, resetting target execution.
|
||||
*/
|
||||
virtual void reset() override;
|
||||
void reset() override;
|
||||
|
||||
/**
|
||||
* Activates the physical interface and starts a debug session on the target (via attach()).
|
||||
*/
|
||||
virtual void activate() override;
|
||||
void activate() override;
|
||||
|
||||
/**
|
||||
* Terminates any active debug session on the target and severs the connection between the debug tool and
|
||||
* the target (by deactivating the physical interface).
|
||||
*/
|
||||
virtual void deactivate() override;
|
||||
void deactivate() override;
|
||||
|
||||
/**
|
||||
* Issues the "PC Read" command to the debug tool, to extract the current program counter.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual std::uint32_t getProgramCounter() override;
|
||||
std::uint32_t getProgramCounter() override;
|
||||
|
||||
/**
|
||||
* Reads the stack pointer register from the target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetRegister getStackPointerRegister() override;
|
||||
Targets::TargetRegister getStackPointerRegister() override;
|
||||
|
||||
/**
|
||||
* Reads the status register from the target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetRegister getStatusRegister() override;
|
||||
Targets::TargetRegister getStatusRegister() override;
|
||||
|
||||
/**
|
||||
* Updates the stack pointer register on ther target.
|
||||
*
|
||||
* @param stackPointerRegister
|
||||
*/
|
||||
virtual void setStackPointerRegister(const Targets::TargetRegister& stackPointerRegister) override;
|
||||
void setStackPointerRegister(const Targets::TargetRegister& stackPointerRegister) override;
|
||||
|
||||
/**
|
||||
* Updates the status register on the target.
|
||||
*
|
||||
* @param statusRegister
|
||||
*/
|
||||
virtual void setStatusRegister(const Targets::TargetRegister& statusRegister) override;
|
||||
void setStatusRegister(const Targets::TargetRegister& statusRegister) override;
|
||||
|
||||
/**
|
||||
* Issues the "PC Write" command to the debug tool, setting the program counter on the target.
|
||||
@@ -535,14 +535,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param programCounter
|
||||
* The byte address to set as the program counter.
|
||||
*/
|
||||
virtual void setProgramCounter(std::uint32_t programCounter) override;
|
||||
void setProgramCounter(std::uint32_t programCounter) override;
|
||||
|
||||
/**
|
||||
* Issues the "Get ID" command to the debug tool, to extract the signature from the target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::Microchip::Avr::TargetSignature getDeviceId() override;
|
||||
Targets::Microchip::Avr::TargetSignature getDeviceId() override;
|
||||
|
||||
/**
|
||||
* Issues the "Software Breakpoint Set" command to the debug tool, setting a software breakpoint at the given
|
||||
@@ -551,7 +551,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param address
|
||||
* The byte address to position the breakpoint.
|
||||
*/
|
||||
virtual void setBreakpoint(std::uint32_t address) override;
|
||||
void setBreakpoint(std::uint32_t address) override;
|
||||
|
||||
/**
|
||||
* Issues the "Software Breakpoint Clear" command to the debug tool, clearing any breakpoint at the given
|
||||
@@ -560,7 +560,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param address
|
||||
* The byte address of the breakpoint to clear.
|
||||
*/
|
||||
virtual void clearBreakpoint(std::uint32_t address) override;
|
||||
void clearBreakpoint(std::uint32_t address) override;
|
||||
|
||||
/**
|
||||
* Issues the "Software Breakpoint Clear All" command to the debug tool, clearing all software breakpoints
|
||||
@@ -568,7 +568,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* If the debug session ended before any of the set breakpoints were cleared, this will *not* clear them.
|
||||
*/
|
||||
virtual void clearAllBreakpoints() override;
|
||||
void clearAllBreakpoints() override;
|
||||
|
||||
/**
|
||||
* Reads gernal purpose registers from the target.
|
||||
@@ -576,14 +576,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param registerIds
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetRegisters readGeneralPurposeRegisters(std::set<std::size_t> registerIds) override;
|
||||
Targets::TargetRegisters readGeneralPurposeRegisters(std::set<std::size_t> registerIds) override;
|
||||
|
||||
/**
|
||||
* Writes general purpose registers to target.
|
||||
*
|
||||
* @param registers
|
||||
*/
|
||||
virtual void writeGeneralPurposeRegisters(const Targets::TargetRegisters& registers) override;
|
||||
void writeGeneralPurposeRegisters(const Targets::TargetRegisters& registers) override;
|
||||
|
||||
/**
|
||||
* This is an overloaded method.
|
||||
@@ -595,7 +595,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param bytes
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetMemoryBuffer readMemory(
|
||||
Targets::TargetMemoryBuffer readMemory(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
std::uint32_t startAddress,
|
||||
std::uint32_t bytes
|
||||
@@ -610,7 +610,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param startAddress
|
||||
* @param buffer
|
||||
*/
|
||||
virtual void writeMemory(
|
||||
void writeMemory(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
std::uint32_t startAddress,
|
||||
const Targets::TargetMemoryBuffer& buffer
|
||||
@@ -621,6 +621,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetState getTargetState() override;
|
||||
Targets::TargetState getTargetState() override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,21 +10,21 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
class BreakEvent: public AvrEvent
|
||||
{
|
||||
private:
|
||||
std::uint32_t programCounter;
|
||||
Targets::TargetBreakCause breakCause;
|
||||
std::uint32_t programCounter = 0;
|
||||
Targets::TargetBreakCause breakCause = Targets::TargetBreakCause::UNKNOWN;
|
||||
|
||||
void init(const AvrEvent& event);
|
||||
|
||||
public:
|
||||
BreakEvent(const AvrEvent& event) {
|
||||
explicit BreakEvent(const AvrEvent& event) {
|
||||
this->init(event);
|
||||
}
|
||||
|
||||
std::uint32_t getProgramCounter() {
|
||||
[[nodiscard]] std::uint32_t getProgramCounter() const {
|
||||
return this->programCounter;
|
||||
}
|
||||
|
||||
Targets::TargetBreakCause getBreakCause() {
|
||||
[[nodiscard]] Targets::TargetBreakCause getBreakCause() const {
|
||||
return this->breakCause;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,13 +7,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class Avr8GenericResponseFrame: public AvrResponseFrame
|
||||
{
|
||||
public:
|
||||
Avr8GenericResponseFrame(const std::vector<AvrResponse>& AVRResponses): AvrResponseFrame(AVRResponses) {}
|
||||
Avr8GenericResponseFrame() {}
|
||||
Avr8GenericResponseFrame() = default;
|
||||
explicit Avr8GenericResponseFrame(const std::vector<AvrResponse>& AVRResponses)
|
||||
: AvrResponseFrame(AVRResponses) {}
|
||||
|
||||
/**
|
||||
* See parent method.
|
||||
*/
|
||||
std::vector<unsigned char> getPayloadData() override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayloadData() override {
|
||||
/*
|
||||
* AVR8 data payloads are in little endian form and include two bytes before the data (response ID and
|
||||
* version byte) as well as an additional byte after the data, known as the 'status code'.
|
||||
@@ -27,5 +28,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class GetDeviceId: public Avr8GenericResponseFrame
|
||||
{
|
||||
public:
|
||||
GetDeviceId(const std::vector<AvrResponse>& AvrResponses): Avr8GenericResponseFrame(AvrResponses) {}
|
||||
GetDeviceId() {}
|
||||
GetDeviceId() = default;
|
||||
explicit GetDeviceId(const std::vector<AvrResponse>& AvrResponses): Avr8GenericResponseFrame(AvrResponses) {}
|
||||
|
||||
Targets::Microchip::Avr::TargetSignature extractSignature(Avr8PhysicalInterface physicalInterface) {
|
||||
auto payloadData = this->getPayloadData();
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class GetProgramCounter: public Avr8GenericResponseFrame
|
||||
{
|
||||
public:
|
||||
GetProgramCounter(const std::vector<AvrResponse>& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {}
|
||||
GetProgramCounter() {}
|
||||
GetProgramCounter() = default;
|
||||
explicit GetProgramCounter(const std::vector<AvrResponse>& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {}
|
||||
|
||||
std::uint32_t extractProgramCounter() {
|
||||
/*
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class ReadMemory: public Avr8GenericResponseFrame
|
||||
{
|
||||
public:
|
||||
ReadMemory(const std::vector<AvrResponse>& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {}
|
||||
ReadMemory() {}
|
||||
ReadMemory() = default;
|
||||
explicit ReadMemory(const std::vector<AvrResponse>& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {}
|
||||
|
||||
Targets::TargetMemoryBuffer getMemoryBuffer() {
|
||||
/*
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -35,4 +35,4 @@ void AvrResponseFrame::initFromRawFrame(const std::vector<unsigned char>& rawFra
|
||||
|
||||
auto& payload = this->getPayload();
|
||||
payload.insert(payload.begin(), rawFrame.begin() + 4, rawFrame.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
/**
|
||||
* Destination sub-protocol handler ID
|
||||
*/
|
||||
ProtocolHandlerId protocolHandlerID;
|
||||
ProtocolHandlerId protocolHandlerID = ProtocolHandlerId::AVR8_GENERIC;
|
||||
|
||||
std::vector<unsigned char> payload;
|
||||
|
||||
@@ -48,12 +48,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
}
|
||||
|
||||
public:
|
||||
explicit AvrResponseFrame() = default;
|
||||
|
||||
explicit AvrResponseFrame(const std::vector<AvrResponse>& AVRResponses) {
|
||||
this->initFromAvrResponses(AVRResponses);
|
||||
}
|
||||
|
||||
explicit AvrResponseFrame() {}
|
||||
|
||||
/**
|
||||
* An AVRResponse contains a single fragment of an AvrResponseFrame.
|
||||
*
|
||||
@@ -63,11 +63,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*/
|
||||
void initFromAvrResponses(const std::vector<AvrResponse>& avrResponses);
|
||||
|
||||
std::uint16_t getSequenceId() const {
|
||||
[[nodiscard]] std::uint16_t getSequenceId() const {
|
||||
return this->sequenceID;
|
||||
}
|
||||
|
||||
ProtocolHandlerId getProtocolHandlerId() const {
|
||||
[[nodiscard]] ProtocolHandlerId getProtocolHandlerId() const {
|
||||
return this->protocolHandlerID;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
return this->payload[0];
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayloadData() {
|
||||
return this->getPayload();
|
||||
[[nodiscard]] virtual std::vector<unsigned char> getPayloadData() {
|
||||
return this->payload;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class DiscoveryResponseFrame: public AvrResponseFrame
|
||||
{
|
||||
public:
|
||||
DiscoveryResponseFrame(const std::vector<AvrResponse>& AVRResponses): AvrResponseFrame(AVRResponses) {}
|
||||
DiscoveryResponseFrame() {}
|
||||
DiscoveryResponseFrame() = default;
|
||||
explicit DiscoveryResponseFrame(const std::vector<AvrResponse>& AVRResponses): AvrResponseFrame(AVRResponses) {}
|
||||
|
||||
/**
|
||||
* See parent method.
|
||||
@@ -25,5 +25,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg
|
||||
{
|
||||
enum class ProtocolHandlerId: unsigned char
|
||||
{
|
||||
Discovery = 0x00,
|
||||
HouseKeeping = 0x01,
|
||||
Avr8Generic = 0x12,
|
||||
Avr32Generic = 0x13,
|
||||
DISCOVERY = 0x00,
|
||||
HOUSE_KEEPING = 0x01,
|
||||
AVR8_GENERIC = 0x12,
|
||||
AVR32_GENERIC = 0x13,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +89,4 @@ std::vector<Protocols::CmsisDap::Edbg::Avr::AvrResponse> EdbgInterface::requestA
|
||||
}
|
||||
|
||||
return responses;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Bloom::Usb
|
||||
}
|
||||
|
||||
public:
|
||||
std::size_t getInputReportSize() {
|
||||
std::size_t getInputReportSize() const {
|
||||
return this->inputReportSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
*
|
||||
* https://github.com/signal11/hidapi
|
||||
*/
|
||||
struct hid_device_ {
|
||||
struct hid_device_
|
||||
{
|
||||
// Handle to the actual device.
|
||||
libusb_device_handle* device_handle;
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "Interface.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
using namespace Bloom::Usb;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Bloom::Usb
|
||||
std::uint16_t productId = 0;
|
||||
|
||||
std::uint8_t number = 0;
|
||||
std::string name = "";
|
||||
std::string name;
|
||||
|
||||
bool initialised = false;
|
||||
bool claimed = false;
|
||||
@@ -52,11 +52,11 @@ namespace Bloom::Usb
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
bool isClaimed() {
|
||||
bool isClaimed() const {
|
||||
return this->claimed;
|
||||
}
|
||||
|
||||
bool isInitialised() {
|
||||
bool isInitialised() const {
|
||||
return this->initialised;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@ namespace Bloom::Usb
|
||||
void close();
|
||||
|
||||
public:
|
||||
void init();
|
||||
|
||||
UsbDevice(std::uint16_t vendorId, std::uint16_t productId) {
|
||||
this->vendorId = vendorId;
|
||||
this->productId = productId;
|
||||
@@ -35,6 +33,8 @@ namespace Bloom::Usb
|
||||
|
||||
~UsbDevice() = default;
|
||||
|
||||
void init();
|
||||
|
||||
[[nodiscard]] libusb_device* getLibUsbDevice() const {
|
||||
return this->libUsbDevice;
|
||||
}
|
||||
@@ -43,11 +43,11 @@ namespace Bloom::Usb
|
||||
this->libUsbDevice = libUsbDevice;
|
||||
}
|
||||
|
||||
std::uint16_t getVendorId() const {
|
||||
[[nodiscard]] std::uint16_t getVendorId() const {
|
||||
return this->vendorId;
|
||||
}
|
||||
|
||||
std::uint16_t getProductId() const {
|
||||
[[nodiscard]] std::uint16_t getProductId() const {
|
||||
return this->productId;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ void EventListener::waitAndDispatch(int msTimeout) {
|
||||
|
||||
if (msTimeout > 0) {
|
||||
this->eventQueueByEventTypeCV.wait_for(queueLock, std::chrono::milliseconds(msTimeout), eventsFound);
|
||||
|
||||
} else {
|
||||
this->eventQueueByEventTypeCV.wait(queueLock, eventsFound);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using namespace Bloom;
|
||||
|
||||
void EventManager::registerListener(std::shared_ptr<EventListener> listener) {
|
||||
auto registerListenersLock = std::unique_lock(this->registerListenerMutex);
|
||||
this->registeredListeners.insert(std::pair(listener->getId(), listener));
|
||||
this->registeredListeners.insert(std::pair(listener->getId(), std::move(listener)));
|
||||
}
|
||||
|
||||
void EventManager::deregisterListener(size_t listenerId) {
|
||||
@@ -12,10 +12,11 @@ void EventManager::deregisterListener(size_t listenerId) {
|
||||
this->registeredListeners.erase(listenerId);
|
||||
}
|
||||
|
||||
void EventManager::triggerEvent(std::shared_ptr<const Events::Event> event) {
|
||||
void EventManager::triggerEvent(const std::shared_ptr<const Events::Event>& event) {
|
||||
auto registerListenersLock = std::unique_lock(this->registerListenerMutex);
|
||||
for(auto const& [listenerId, listener] : this->registeredListeners) {
|
||||
auto registeredEventTypes = listener->getRegisteredEventTypeNames();
|
||||
|
||||
if (registeredEventTypes.contains(event->getName())) {
|
||||
listener->registerEvent(event);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace Bloom
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
void triggerEvent(Events::SharedGenericEventPointer event);
|
||||
void triggerEvent(const Events::SharedGenericEventPointer& event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Bloom::Events
|
||||
public:
|
||||
static inline const std::string name = "BreakpointRemovedOnTarget";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return BreakpointRemovedOnTarget::name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Bloom::Events
|
||||
public:
|
||||
static inline const std::string name = "BreakpointSetOnTarget";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return BreakpointSetOnTarget::name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,15 +12,15 @@ namespace Bloom::Events
|
||||
private:
|
||||
ThreadState state;
|
||||
public:
|
||||
DebugServerThreadStateChanged(ThreadState state): state(state) {};
|
||||
explicit DebugServerThreadStateChanged(ThreadState state): state(state) {};
|
||||
|
||||
static inline const std::string name = "DebugServerThreadStateChanged";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return DebugServerThreadStateChanged::name;
|
||||
}
|
||||
|
||||
ThreadState getState() const {
|
||||
[[nodiscard]] ThreadState getState() const {
|
||||
return this->state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Bloom::Events
|
||||
public:
|
||||
static inline const std::string name = "DebugSessionFinished";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return DebugSessionFinished::name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Bloom::Events
|
||||
public:
|
||||
static inline const std::string name = "DebugSessionStarted";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return DebugSessionStarted::name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Bloom::Events
|
||||
public:
|
||||
static inline const std::string name = "ExtractTargetDescriptor";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ExtractTargetDescriptor::name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace Bloom::Events
|
||||
private:
|
||||
ThreadState state;
|
||||
public:
|
||||
InsightThreadStateChanged(ThreadState state): state(state) {};
|
||||
explicit InsightThreadStateChanged(ThreadState state): state(state) {};
|
||||
|
||||
static inline const std::string name = "InsightThreadStateChanged";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return InsightThreadStateChanged::name;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Bloom::Events
|
||||
static inline const std::string name = "MemoryRetrievedFromTarget";
|
||||
Targets::TargetMemoryBuffer data;
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return MemoryRetrievedFromTarget::name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Bloom::Events
|
||||
public:
|
||||
static inline const std::string name = "MemoryWrittenToTarget";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return MemoryWrittenToTarget::name;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Bloom::Events
|
||||
public:
|
||||
static inline const std::string name = "ProgramCounterSetOnTarget";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ProgramCounterSetOnTarget::name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Bloom::Events
|
||||
static inline const std::string name = "RegistersRetrievedFromTarget";
|
||||
Targets::TargetRegisters registers;
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RegistersRetrievedFromTarget::name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Bloom::Events
|
||||
public:
|
||||
static inline const std::string name = "RegistersWrittenToTarget";
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RegistersWrittenToTarget::name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,10 +12,9 @@ namespace Bloom::Events
|
||||
{
|
||||
public:
|
||||
static inline const std::string name = "RemoveBreakpointOnTarget";
|
||||
std::uint32_t address;
|
||||
Targets::TargetBreakpoint breakpoint;
|
||||
|
||||
std::string getName() const override {
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RemoveBreakpointOnTarget::name;
|
||||
}
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user