2021-04-04 21:04:12 +01:00
|
|
|
#include "SupportedFeaturesResponse.hpp"
|
|
|
|
|
|
2023-08-13 15:47:51 +01:00
|
|
|
namespace DebugServer::Gdb::ResponsePackets
|
2022-02-05 15:32:08 +00:00
|
|
|
{
|
2022-04-06 17:39:21 +01:00
|
|
|
SupportedFeaturesResponse::SupportedFeaturesResponse(
|
|
|
|
|
const std::set<std::pair<Feature, std::optional<std::string>>>& supportedFeatures
|
|
|
|
|
)
|
|
|
|
|
: supportedFeatures(supportedFeatures)
|
|
|
|
|
{
|
|
|
|
|
auto output = std::string("qSupported:");
|
|
|
|
|
static const auto gdbFeatureMapping = getGdbFeatureToNameMapping();
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
for (const auto& supportedFeature : this->supportedFeatures) {
|
2022-04-06 17:39:21 +01:00
|
|
|
const auto featureString = gdbFeatureMapping.valueAt(supportedFeature.first);
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
if (featureString.has_value()) {
|
|
|
|
|
if (supportedFeature.second.has_value()) {
|
|
|
|
|
output.append(featureString.value() + "=" + supportedFeature.second.value() + ";");
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
} else {
|
|
|
|
|
output.append(featureString.value() + "+;");
|
|
|
|
|
}
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
}
|
2021-04-04 21:04:12 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-06 17:39:21 +01:00
|
|
|
this->data = {output.begin(), output.end()};
|
2022-02-05 15:32:08 +00:00
|
|
|
}
|
2021-04-04 21:04:12 +01:00
|
|
|
}
|