Renamed GdbRsp directory to Gdb

This commit is contained in:
Nav
2022-03-31 21:52:46 +01:00
parent 01d52bb130
commit 2aa240a680
57 changed files with 64 additions and 64 deletions

View File

@@ -0,0 +1,19 @@
#pragma once
#include "ResponsePacket.hpp"
namespace Bloom::DebugServer::Gdb::ResponsePackets
{
/**
* Error response packet expected by the GDB client, to indicate an error, in response to certain commands.
*/
class ErrorResponsePacket: public ResponsePacket
{
public:
ErrorResponsePacket() = default;
[[nodiscard]] std::vector<unsigned char> getData() const override {
return {'E', '0', '1'};
}
};
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include "ResponsePacket.hpp"
namespace Bloom::DebugServer::Gdb::ResponsePackets
{
/**
* OK response packet expected by the GDB client, in response to certain commands.
*/
class OkResponsePacket: public ResponsePacket
{
public:
OkResponsePacket() = default;
[[nodiscard]] std::vector<unsigned char> getData() const override {
return {'O', 'K'};
}
};
}

View File

@@ -0,0 +1,22 @@
#pragma once
#include <vector>
#include <memory>
#include "src/DebugServer/Gdb/Packet.hpp"
namespace Bloom::DebugServer::Gdb::ResponsePackets
{
/**
* Upon receiving a CommandPacket from the connected GDB RSP client, the server is expected to respond with a
* response packet.
*/
class ResponsePacket: public Packet
{
public:
ResponsePacket() = default;
explicit ResponsePacket(const std::vector<unsigned char>& data) {
this->data = data;
}
};
}

View File

@@ -0,0 +1,25 @@
#include "SupportedFeaturesResponse.hpp"
namespace Bloom::DebugServer::Gdb::ResponsePackets
{
std::vector<unsigned char> SupportedFeaturesResponse::getData() const {
std::string output = "qSupported:";
auto gdbFeatureMapping = getGdbFeatureToNameMapping();
for (const auto& supportedFeature : this->supportedFeatures) {
auto featureString = gdbFeatureMapping.valueAt(supportedFeature.first);
if (featureString.has_value()) {
if (supportedFeature.second.has_value()) {
output.append(featureString.value() + "=" + supportedFeature.second.value() + ";");
} else {
output.append(featureString.value() + "+;");
}
}
}
return std::vector<unsigned char>(output.begin(), output.end());
}
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include <set>
#include <utility>
#include "ResponsePacket.hpp"
#include "../Feature.hpp"
namespace Bloom::DebugServer::Gdb::ResponsePackets
{
/**
* The SupportedFeaturesResponse class implements the response packet structure for the "qSupported" command.
*/
class SupportedFeaturesResponse: public ResponsePacket
{
public:
SupportedFeaturesResponse() = default;
explicit SupportedFeaturesResponse(std::set<std::pair<Feature, std::optional<std::string>>> supportedFeatures)
: supportedFeatures(std::move(supportedFeatures)) {};
[[nodiscard]] std::vector<unsigned char> getData() const override;
protected:
std::set<std::pair<Feature, std::optional<std::string>>> supportedFeatures;
};
}

View File

@@ -0,0 +1,37 @@
#pragma once
#include "ResponsePacket.hpp"
#include "../Signal.hpp"
#include "../StopReason.hpp"
#include "src/Targets/TargetRegister.hpp"
namespace Bloom::DebugServer::Gdb::ResponsePackets
{
/**
* The TargetStopped class implements the response packet structure for any commands that expect a "StopReply"
* packet in response.
*/
class TargetStopped: public ResponsePacket
{
public:
Signal signal;
std::optional<StopReason> stopReason;
explicit TargetStopped(Signal signal): signal(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();
auto stopReasonName = stopReasonMapping.valueAt(this->stopReason.value());
if (stopReasonName.has_value()) {
output += stopReasonName.value() + ":;";
}
}
return std::vector<unsigned char>(output.begin(), output.end());
}
};
}