Massive refactor to accommodate RISC-V targets
- Refactored entire codebase (excluding the Insight component) to accommodate multiple target architectures (no longer specific to AVR) - Deleted 'generate SVD' GDB monitor command - I will eventually move this functionality to the Bloom website - Added unit size property to address spaces - Many other changes which I couldn't be bothered to describe here
This commit is contained in:
41
src/DebugServer/Gdb/ResponsePackets/ResponsePacket.cpp
Normal file
41
src/DebugServer/Gdb/ResponsePackets/ResponsePacket.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "ResponsePacket.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::ResponsePackets
|
||||
{
|
||||
RawPacket ResponsePacket::toRawPacket() const {
|
||||
std::vector<unsigned char> packet = {'$'};
|
||||
|
||||
for (const auto& byte : this->data) {
|
||||
// Escape $ and # characters
|
||||
switch (byte) {
|
||||
case '$':
|
||||
case '#': {
|
||||
packet.push_back('}');
|
||||
packet.push_back(byte ^ 0x20);
|
||||
}
|
||||
default: {
|
||||
packet.push_back(byte);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto dataSum = std::accumulate(packet.begin() + 1, packet.end(), 0);
|
||||
packet.push_back('#');
|
||||
auto checkSum = QStringLiteral("%1").arg(dataSum % 256, 2, 16, QLatin1Char{'0'}).toStdString();
|
||||
|
||||
if (checkSum.size() < 2) {
|
||||
packet.push_back('0');
|
||||
|
||||
if (checkSum.size() < 1) {
|
||||
packet.push_back('0');
|
||||
} else {
|
||||
packet.push_back(static_cast<unsigned char>(checkSum[0]));
|
||||
}
|
||||
}
|
||||
|
||||
packet.push_back(static_cast<unsigned char>(checkSum[0]));
|
||||
packet.push_back(static_cast<unsigned char>(checkSum[1]));
|
||||
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,14 @@ namespace DebugServer::Gdb::ResponsePackets
|
||||
}
|
||||
|
||||
explicit ResponsePacket(const std::string& data) {
|
||||
this->data = std::vector<unsigned char>(data.begin(), data.end());
|
||||
this->data = std::vector<unsigned char>{data.begin(), data.end()};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a raw packet.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] RawPacket toRawPacket() const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace DebugServer::Gdb::ResponsePackets
|
||||
)
|
||||
: supportedFeatures(supportedFeatures)
|
||||
{
|
||||
auto output = std::string("qSupported:");
|
||||
auto output = std::string{"qSupported:"};
|
||||
static const auto gdbFeatureMapping = getGdbFeatureToNameMapping();
|
||||
|
||||
for (const auto& supportedFeature : this->supportedFeatures) {
|
||||
|
||||
@@ -25,7 +25,9 @@ namespace DebugServer::Gdb::ResponsePackets
|
||||
: signal(signal)
|
||||
, stopReason(stopReason)
|
||||
{
|
||||
std::string packetData = "T" + Services::StringService::toHex(static_cast<unsigned char>(this->signal));
|
||||
auto packetData = std::string{"T"} + Services::StringService::toHex(
|
||||
static_cast<unsigned char>(this->signal)
|
||||
);
|
||||
|
||||
if (this->stopReason.has_value()) {
|
||||
static const auto stopReasonMapping = getStopReasonToNameMapping();
|
||||
|
||||
Reference in New Issue
Block a user