diff --git a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp index cc03acd4..a056eb7f 100644 --- a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp @@ -17,10 +17,10 @@ namespace Bloom::DebugServer::Gdb::CommandPackets { 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. * - * 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 fromProgramCounter; diff --git a/src/DebugServer/Gdb/CommandPackets/ReadRegisters.cpp b/src/DebugServer/Gdb/CommandPackets/ReadRegisters.cpp index 5467f558..9fdb48bc 100644 --- a/src/DebugServer/Gdb/CommandPackets/ReadRegisters.cpp +++ b/src/DebugServer/Gdb/CommandPackets/ReadRegisters.cpp @@ -1,6 +1,5 @@ #include "ReadRegisters.hpp" -#include "src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp" #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" #include "src/Targets/TargetRegister.hpp" diff --git a/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.cpp b/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.cpp index 904b49f0..4b7acef7 100644 --- a/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.cpp +++ b/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.cpp @@ -20,15 +20,15 @@ namespace Bloom::DebugServer::Gdb::CommandPackets using Exceptions::Exception; void RemoveBreakpoint::init() { - if (data.size() < 6) { + if (this->data.size() < 6) { throw Exception("Unexpected RemoveBreakpoint packet size"); } // 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; - auto packetData = QString::fromLocal8Bit( + const auto packetData = QString::fromLocal8Bit( reinterpret_cast(this->data.data() + 2), static_cast(this->data.size() - 2) ); @@ -50,10 +50,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets Logger::debug("Removing breakpoint at address " + std::to_string(this->address)); try { - auto breakpoint = TargetBreakpoint(); - breakpoint.address = this->address; - targetControllerConsole.removeBreakpoint(breakpoint); - + targetControllerConsole.removeBreakpoint(TargetBreakpoint(this->address)); debugSession.connection.writePacket(OkResponsePacket()); } catch (const Exception& exception) { diff --git a/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.cpp b/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.cpp index 9bef4c1d..f16a319e 100644 --- a/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.cpp +++ b/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.cpp @@ -26,25 +26,23 @@ namespace Bloom::DebugServer::Gdb::CommandPackets */ // The "qSupported:" prefix occupies 11 bytes - if (data.size() > 11) { - auto packetData = QString::fromLocal8Bit( + if (this->data.size() > 11) { + const auto packetData = QString::fromLocal8Bit( reinterpret_cast(this->data.data() + 11), static_cast(this->data.size() - 11) ); - auto featureList = packetData.split(";"); - auto gdbFeatureMapping = getGdbFeatureToNameMapping(); - - for (int i = 0; i < featureList.size(); i++) { - auto featureString = featureList.at(i); + const auto featureList = packetData.split(";"); + static const auto gdbFeatureMapping = getGdbFeatureToNameMapping(); + for (auto featureName : featureList) { // We only care about supported features. Supported features will precede a '+' character. - if (featureString[featureString.size() - 1] == '+') { - featureString.remove('+'); + if (featureName[featureName.size() - 1] == '+') { + featureName.remove('+'); - auto feature = gdbFeatureMapping.valueAt(featureString.toStdString()); + const auto feature = gdbFeatureMapping.valueAt(featureName.toStdString()); if (feature.has_value()) { - this->supportedFeatures.insert(static_cast(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 - auto response = SupportedFeaturesResponse({ + debugSession.connection.writePacket(SupportedFeaturesResponse({ {Feature::SOFTWARE_BREAKPOINTS, std::nullopt}, {Feature::PACKET_SIZE, std::to_string(debugSession.connection.getMaxPacketSize())}, - }); - - debugSession.connection.writePacket(response); + })); } } diff --git a/src/Targets/TargetBreakpoint.hpp b/src/Targets/TargetBreakpoint.hpp index 1f7d8827..3bce157c 100644 --- a/src/Targets/TargetBreakpoint.hpp +++ b/src/Targets/TargetBreakpoint.hpp @@ -20,5 +20,8 @@ namespace Bloom::Targets TargetBreakpointAddress address = 0; bool disabled = false; + + TargetBreakpoint() = default; + explicit TargetBreakpoint(TargetBreakpointAddress address): address(address) {}; }; }