Tidied GDB response packet classes
This commit is contained in:
@@ -10,10 +10,8 @@ namespace Bloom::DebugServer::Gdb::ResponsePackets
|
|||||||
class ErrorResponsePacket: public ResponsePacket
|
class ErrorResponsePacket: public ResponsePacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ErrorResponsePacket() = default;
|
ErrorResponsePacket()
|
||||||
|
: ResponsePacket(std::vector<unsigned char>{'E', '0', '1'})
|
||||||
[[nodiscard]] std::vector<unsigned char> getData() const override {
|
{};
|
||||||
return {'E', '0', '1'};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,8 @@ namespace Bloom::DebugServer::Gdb::ResponsePackets
|
|||||||
class OkResponsePacket: public ResponsePacket
|
class OkResponsePacket: public ResponsePacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OkResponsePacket() = default;
|
OkResponsePacket()
|
||||||
|
: ResponsePacket(std::vector<unsigned char>{'O', 'K'})
|
||||||
[[nodiscard]] std::vector<unsigned char> getData() const override {
|
{}
|
||||||
return {'O', 'K'};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <string>
|
||||||
|
|
||||||
#include "src/DebugServer/Gdb/Packet.hpp"
|
#include "src/DebugServer/Gdb/Packet.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
namespace Bloom::DebugServer::Gdb::ResponsePackets
|
namespace Bloom::DebugServer::Gdb::ResponsePackets
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> SupportedFeaturesResponse::getData() const {
|
SupportedFeaturesResponse::SupportedFeaturesResponse(
|
||||||
std::string output = "qSupported:";
|
const std::set<std::pair<Feature, std::optional<std::string>>>& supportedFeatures
|
||||||
auto gdbFeatureMapping = getGdbFeatureToNameMapping();
|
)
|
||||||
|
: supportedFeatures(supportedFeatures)
|
||||||
|
{
|
||||||
|
auto output = std::string("qSupported:");
|
||||||
|
static const auto gdbFeatureMapping = getGdbFeatureToNameMapping();
|
||||||
|
|
||||||
for (const auto& supportedFeature : this->supportedFeatures) {
|
for (const auto& supportedFeature : this->supportedFeatures) {
|
||||||
auto featureString = gdbFeatureMapping.valueAt(supportedFeature.first);
|
const auto featureString = gdbFeatureMapping.valueAt(supportedFeature.first);
|
||||||
|
|
||||||
if (featureString.has_value()) {
|
if (featureString.has_value()) {
|
||||||
if (supportedFeature.second.has_value()) {
|
if (supportedFeature.second.has_value()) {
|
||||||
@@ -20,6 +24,6 @@ namespace Bloom::DebugServer::Gdb::ResponsePackets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::vector<unsigned char>(output.begin(), output.end());
|
this->data = {output.begin(), output.end()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "ResponsePacket.hpp"
|
#include "ResponsePacket.hpp"
|
||||||
#include "../Feature.hpp"
|
|
||||||
|
#include "src/DebugServer/Gdb/Feature.hpp"
|
||||||
|
|
||||||
namespace Bloom::DebugServer::Gdb::ResponsePackets
|
namespace Bloom::DebugServer::Gdb::ResponsePackets
|
||||||
{
|
{
|
||||||
@@ -14,13 +15,11 @@ namespace Bloom::DebugServer::Gdb::ResponsePackets
|
|||||||
class SupportedFeaturesResponse: public ResponsePacket
|
class SupportedFeaturesResponse: public ResponsePacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SupportedFeaturesResponse() = default;
|
explicit SupportedFeaturesResponse(
|
||||||
explicit SupportedFeaturesResponse(std::set<std::pair<Feature, std::optional<std::string>>> supportedFeatures)
|
const std::set<std::pair<Feature, std::optional<std::string>>>& supportedFeatures
|
||||||
: supportedFeatures(std::move(supportedFeatures)) {};
|
);
|
||||||
|
|
||||||
[[nodiscard]] std::vector<unsigned char> getData() const override;
|
private:
|
||||||
|
|
||||||
protected:
|
|
||||||
std::set<std::pair<Feature, std::optional<std::string>>> supportedFeatures;
|
std::set<std::pair<Feature, std::optional<std::string>>> supportedFeatures;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ResponsePacket.hpp"
|
#include "ResponsePacket.hpp"
|
||||||
#include "../Signal.hpp"
|
|
||||||
#include "../StopReason.hpp"
|
#include "src/DebugServer/Gdb/Signal.hpp"
|
||||||
#include "src/Targets/TargetRegister.hpp"
|
#include "src/DebugServer/Gdb/StopReason.hpp"
|
||||||
|
|
||||||
namespace Bloom::DebugServer::Gdb::ResponsePackets
|
namespace Bloom::DebugServer::Gdb::ResponsePackets
|
||||||
{
|
{
|
||||||
@@ -17,21 +17,22 @@ namespace Bloom::DebugServer::Gdb::ResponsePackets
|
|||||||
Signal signal;
|
Signal signal;
|
||||||
std::optional<StopReason> stopReason;
|
std::optional<StopReason> stopReason;
|
||||||
|
|
||||||
explicit TargetStopped(Signal signal): signal(signal) {}
|
explicit TargetStopped(Signal signal, const std::optional<StopReason>& stopReason = std::nullopt)
|
||||||
|
: signal(signal)
|
||||||
[[nodiscard]] std::vector<unsigned char> getData() const override {
|
, stopReason(stopReason)
|
||||||
std::string output = "T" + Packet::toHex(std::vector({static_cast<unsigned char>(this->signal)}));
|
{
|
||||||
|
std::string packetData = "T" + Packet::toHex(std::vector({static_cast<unsigned char>(this->signal)}));
|
||||||
|
|
||||||
if (this->stopReason.has_value()) {
|
if (this->stopReason.has_value()) {
|
||||||
auto stopReasonMapping = getStopReasonToNameMapping();
|
static const auto stopReasonMapping = getStopReasonToNameMapping();
|
||||||
auto stopReasonName = stopReasonMapping.valueAt(this->stopReason.value());
|
const auto stopReasonName = stopReasonMapping.valueAt(this->stopReason.value());
|
||||||
|
|
||||||
if (stopReasonName.has_value()) {
|
if (stopReasonName.has_value()) {
|
||||||
output += stopReasonName.value() + ":;";
|
packetData += stopReasonName.value() + ":;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::vector<unsigned char>(output.begin(), output.end());
|
this->data = {packetData.begin(), packetData.end()};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user