Moved GDB supported feature set to DebugSession object
This commit is contained in:
@@ -64,9 +64,6 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
}
|
||||
|
||||
// Respond with a SupportedFeaturesResponse packet, listing all supported GDB features by Bloom
|
||||
debugSession.connection.writePacket(SupportedFeaturesResponse({
|
||||
{Feature::SOFTWARE_BREAKPOINTS, std::nullopt},
|
||||
{Feature::PACKET_SIZE, std::to_string(debugSession.connection.getMaxPacketSize())},
|
||||
}));
|
||||
debugSession.connection.writePacket(SupportedFeaturesResponse(debugSession.supportedFeatures));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,19 @@
|
||||
|
||||
namespace Bloom::DebugServer::Gdb
|
||||
{
|
||||
DebugSession::DebugSession(Connection&& connection, const TargetDescriptor& targetDescriptor)
|
||||
DebugSession::DebugSession(
|
||||
Connection&& connection,
|
||||
const std::set<std::pair<Feature, std::optional<std::string>>>& supportedFeatures,
|
||||
const TargetDescriptor& targetDescriptor
|
||||
)
|
||||
: connection(std::move(connection))
|
||||
, supportedFeatures(supportedFeatures)
|
||||
, gdbTargetDescriptor(targetDescriptor)
|
||||
{}
|
||||
{
|
||||
this->supportedFeatures.insert({
|
||||
Feature::PACKET_SIZE, std::to_string(this->connection.getMaxPacketSize())
|
||||
});
|
||||
}
|
||||
|
||||
void DebugSession::terminate() {
|
||||
|
||||
|
||||
@@ -4,14 +4,27 @@
|
||||
|
||||
#include "TargetDescriptor.hpp"
|
||||
#include "Connection.hpp"
|
||||
#include "Feature.hpp"
|
||||
|
||||
namespace Bloom::DebugServer::Gdb
|
||||
{
|
||||
class DebugSession
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The connection serving this debug session.
|
||||
*/
|
||||
Connection connection;
|
||||
|
||||
/**
|
||||
* A set of all GDB features supported for this debug session, along with any optional values (some GDB
|
||||
* features can be specified with a value, such as Feature::PACKET_SIZE).
|
||||
*/
|
||||
std::set<std::pair<Feature, std::optional<std::string>>> supportedFeatures;
|
||||
|
||||
/**
|
||||
* The GDB target descriptor of the connected target.
|
||||
*/
|
||||
const TargetDescriptor& gdbTargetDescriptor;
|
||||
|
||||
/**
|
||||
@@ -20,7 +33,11 @@ namespace Bloom::DebugServer::Gdb
|
||||
*/
|
||||
bool waitingForBreak = false;
|
||||
|
||||
DebugSession(Connection&& connection, const TargetDescriptor& targetDescriptor);
|
||||
DebugSession(
|
||||
Connection&& connection,
|
||||
const std::set<std::pair<Feature, std::optional<std::string>>>& supportedFeatures,
|
||||
const TargetDescriptor& targetDescriptor
|
||||
);
|
||||
|
||||
void terminate();
|
||||
};
|
||||
|
||||
@@ -146,7 +146,11 @@ namespace Bloom::DebugServer::Gdb
|
||||
Logger::info("Accepted GDP RSP connection from " + connection->getIpAddress());
|
||||
|
||||
this->activeDebugSession.emplace(
|
||||
DebugSession(std::move(connection.value()), this->getGdbTargetDescriptor())
|
||||
DebugSession(
|
||||
std::move(connection.value()),
|
||||
this->getSupportedFeatures(),
|
||||
this->getGdbTargetDescriptor()
|
||||
)
|
||||
);
|
||||
|
||||
EventManager::triggerEvent(std::make_shared<Events::DebugSessionStarted>());
|
||||
@@ -325,6 +329,12 @@ namespace Bloom::DebugServer::Gdb
|
||||
return std::make_unique<CommandPacket>(rawPacket);
|
||||
}
|
||||
|
||||
std::set<std::pair<Feature, std::optional<std::string>>> GdbRspDebugServer::getSupportedFeatures() {
|
||||
return {
|
||||
{Feature::SOFTWARE_BREAKPOINTS, std::nullopt},
|
||||
};
|
||||
}
|
||||
|
||||
void GdbRspDebugServer::terminateActiveDebugSession() {
|
||||
if (!this->activeDebugSession.has_value()) {
|
||||
return;
|
||||
|
||||
@@ -163,6 +163,20 @@ namespace Bloom::DebugServer::Gdb
|
||||
*/
|
||||
virtual std::unique_ptr<CommandPackets::CommandPacket> resolveCommandPacket(const RawPacketType& rawPacket);
|
||||
|
||||
/**
|
||||
* Should return a set of GDB features supported by the GDB server. Each supported feature may come with an
|
||||
* optional value.
|
||||
*
|
||||
* The set of features returned by this function will be stored against the active debug session object.
|
||||
*
|
||||
* Derived GDB server implementations may override this function to include any features that are specific to
|
||||
* those implementations.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual std::set<std::pair<Feature, std::optional<std::string>>> getSupportedFeatures();
|
||||
|
||||
|
||||
/**
|
||||
* Terminates any active debug session (if any) by closing the connection to the GDB client.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user