More tidying in GDB command packet classes
This commit is contained in:
@@ -17,10 +17,10 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* The "c" packet can contain an address which defines the point from which the execution should be resumed on
|
* The "c" packet can contain an address which specifies the point from which the execution should be resumed on
|
||||||
* the target.
|
* the target.
|
||||||
*
|
*
|
||||||
* Although the packet *can* contain this address, it is not required, hence the optional.
|
* Although the packet *can* contain this address, it is not required, hence the std::optional type.
|
||||||
*/
|
*/
|
||||||
std::optional<std::uint32_t> fromProgramCounter;
|
std::optional<std::uint32_t> fromProgramCounter;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "ReadRegisters.hpp"
|
#include "ReadRegisters.hpp"
|
||||||
|
|
||||||
#include "src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp"
|
|
||||||
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
|
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
|
||||||
|
|
||||||
#include "src/Targets/TargetRegister.hpp"
|
#include "src/Targets/TargetRegister.hpp"
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
using Exceptions::Exception;
|
using Exceptions::Exception;
|
||||||
|
|
||||||
void RemoveBreakpoint::init() {
|
void RemoveBreakpoint::init() {
|
||||||
if (data.size() < 6) {
|
if (this->data.size() < 6) {
|
||||||
throw Exception("Unexpected RemoveBreakpoint packet size");
|
throw Exception("Unexpected RemoveBreakpoint packet size");
|
||||||
}
|
}
|
||||||
|
|
||||||
// z0 = SW breakpoint, z1 = HW breakpoint
|
// z0 = SW breakpoint, z1 = HW breakpoint
|
||||||
this->type = (data[1] == 0) ? BreakpointType::SOFTWARE_BREAKPOINT : (data[1] == 1) ?
|
this->type = (this->data[1] == 0) ? BreakpointType::SOFTWARE_BREAKPOINT : (this->data[1] == 1) ?
|
||||||
BreakpointType::HARDWARE_BREAKPOINT : BreakpointType::UNKNOWN;
|
BreakpointType::HARDWARE_BREAKPOINT : BreakpointType::UNKNOWN;
|
||||||
|
|
||||||
auto packetData = QString::fromLocal8Bit(
|
const auto packetData = QString::fromLocal8Bit(
|
||||||
reinterpret_cast<const char*>(this->data.data() + 2),
|
reinterpret_cast<const char*>(this->data.data() + 2),
|
||||||
static_cast<int>(this->data.size() - 2)
|
static_cast<int>(this->data.size() - 2)
|
||||||
);
|
);
|
||||||
@@ -50,10 +50,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
Logger::debug("Removing breakpoint at address " + std::to_string(this->address));
|
Logger::debug("Removing breakpoint at address " + std::to_string(this->address));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto breakpoint = TargetBreakpoint();
|
targetControllerConsole.removeBreakpoint(TargetBreakpoint(this->address));
|
||||||
breakpoint.address = this->address;
|
|
||||||
targetControllerConsole.removeBreakpoint(breakpoint);
|
|
||||||
|
|
||||||
debugSession.connection.writePacket(OkResponsePacket());
|
debugSession.connection.writePacket(OkResponsePacket());
|
||||||
|
|
||||||
} catch (const Exception& exception) {
|
} catch (const Exception& exception) {
|
||||||
|
|||||||
@@ -26,25 +26,23 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// The "qSupported:" prefix occupies 11 bytes
|
// The "qSupported:" prefix occupies 11 bytes
|
||||||
if (data.size() > 11) {
|
if (this->data.size() > 11) {
|
||||||
auto packetData = QString::fromLocal8Bit(
|
const auto packetData = QString::fromLocal8Bit(
|
||||||
reinterpret_cast<const char*>(this->data.data() + 11),
|
reinterpret_cast<const char*>(this->data.data() + 11),
|
||||||
static_cast<int>(this->data.size() - 11)
|
static_cast<int>(this->data.size() - 11)
|
||||||
);
|
);
|
||||||
|
|
||||||
auto featureList = packetData.split(";");
|
const auto featureList = packetData.split(";");
|
||||||
auto gdbFeatureMapping = getGdbFeatureToNameMapping();
|
static const auto gdbFeatureMapping = getGdbFeatureToNameMapping();
|
||||||
|
|
||||||
for (int i = 0; i < featureList.size(); i++) {
|
|
||||||
auto featureString = featureList.at(i);
|
|
||||||
|
|
||||||
|
for (auto featureName : featureList) {
|
||||||
// We only care about supported features. Supported features will precede a '+' character.
|
// We only care about supported features. Supported features will precede a '+' character.
|
||||||
if (featureString[featureString.size() - 1] == '+') {
|
if (featureName[featureName.size() - 1] == '+') {
|
||||||
featureString.remove('+');
|
featureName.remove('+');
|
||||||
|
|
||||||
auto feature = gdbFeatureMapping.valueAt(featureString.toStdString());
|
const auto feature = gdbFeatureMapping.valueAt(featureName.toStdString());
|
||||||
if (feature.has_value()) {
|
if (feature.has_value()) {
|
||||||
this->supportedFeatures.insert(static_cast<decltype(feature)::value_type>(feature.value()));
|
this->supportedFeatures.insert(feature.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,11 +60,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Respond with a SupportedFeaturesResponse packet, listing all supported GDB features by Bloom
|
// Respond with a SupportedFeaturesResponse packet, listing all supported GDB features by Bloom
|
||||||
auto response = SupportedFeaturesResponse({
|
debugSession.connection.writePacket(SupportedFeaturesResponse({
|
||||||
{Feature::SOFTWARE_BREAKPOINTS, std::nullopt},
|
{Feature::SOFTWARE_BREAKPOINTS, std::nullopt},
|
||||||
{Feature::PACKET_SIZE, std::to_string(debugSession.connection.getMaxPacketSize())},
|
{Feature::PACKET_SIZE, std::to_string(debugSession.connection.getMaxPacketSize())},
|
||||||
});
|
}));
|
||||||
|
|
||||||
debugSession.connection.writePacket(response);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,5 +20,8 @@ namespace Bloom::Targets
|
|||||||
TargetBreakpointAddress address = 0;
|
TargetBreakpointAddress address = 0;
|
||||||
|
|
||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
|
|
||||||
|
TargetBreakpoint() = default;
|
||||||
|
explicit TargetBreakpoint(TargetBreakpointAddress address): address(address) {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user