From d365f6348b34fb82e2612071e7a30e83103b29c6 Mon Sep 17 00:00:00 2001 From: Nav Date: Tue, 22 Jun 2021 23:52:31 +0100 Subject: [PATCH] General tidying, addressing issues found by static analysis tool. --- CMakeLists.txt | 3 +- src/Application.cpp | 1 - src/DebugServers/DebugServer.cpp | 1 - src/DebugServers/DebugServer.hpp | 2 +- .../GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp | 4 +- .../GdbRsp/CommandPackets/CommandPacket.hpp | 2 +- .../CommandPackets/CommandPacketFactory.cpp | 7 ++- .../CommandPackets/CommandPacketFactory.hpp | 2 +- .../CommandPackets/ContinueExecution.hpp | 4 +- .../CommandPackets/InterruptExecution.hpp | 4 +- .../CommandPackets/ReadGeneralRegisters.hpp | 4 +- .../GdbRsp/CommandPackets/ReadMemory.hpp | 8 +-- .../CommandPackets/RemoveBreakpoint.hpp | 6 +-- .../GdbRsp/CommandPackets/SetBreakpoint.hpp | 6 +-- .../GdbRsp/CommandPackets/StepExecution.hpp | 4 +- .../CommandPackets/SupportedFeaturesQuery.hpp | 8 +-- ...Registers.cpp => WriteGeneralRegister.cpp} | 12 ++--- .../CommandPackets/WriteGeneralRegister.hpp | 29 ++++++++++ .../CommandPackets/WriteGeneralRegisters.hpp | 30 ----------- .../GdbRsp/CommandPackets/WriteMemory.cpp | 2 +- .../GdbRsp/CommandPackets/WriteMemory.hpp | 6 +-- src/DebugServers/GdbRsp/Connection.cpp | 4 +- src/DebugServers/GdbRsp/Connection.hpp | 9 ++-- src/DebugServers/GdbRsp/GdbRspDebugServer.cpp | 2 +- src/DebugServers/GdbRsp/GdbRspDebugServer.hpp | 4 +- src/DebugServers/GdbRsp/Packet.hpp | 8 +-- .../GdbRsp/ResponsePackets/Ok.hpp | 2 +- .../SupportedFeaturesResponse.hpp | 7 +-- .../GdbRsp/ResponsePackets/TargetStopped.hpp | 10 ++-- src/DebugToolDrivers/DebugTool.hpp | 2 +- .../Protocols/CMSIS-DAP/Command.cpp | 3 +- .../Protocols/CMSIS-DAP/Command.hpp | 8 ++- .../Protocols/CMSIS-DAP/Response.cpp | 6 +-- .../Protocols/CMSIS-DAP/Response.hpp | 4 +- .../VendorSpecific/EDBG/AVR/AvrCommand.cpp | 4 +- .../VendorSpecific/EDBG/AVR/AvrCommand.hpp | 9 ++-- .../VendorSpecific/EDBG/AVR/AvrEvent.cpp | 5 +- .../VendorSpecific/EDBG/AVR/AvrEvent.hpp | 8 +-- .../VendorSpecific/EDBG/AVR/AvrResponse.hpp | 6 +-- .../AVR8Generic/ActivatePhysical.hpp | 4 +- .../AVR/CommandFrames/AVR8Generic/Attach.hpp | 4 +- .../AVR8Generic/Avr8GenericCommandFrame.hpp | 3 +- .../ClearAllSoftwareBreakpoints.hpp | 1 - .../AVR8Generic/ClearSoftwareBreakpoints.hpp | 6 +-- .../AVR8Generic/DeactivatePhysical.hpp | 1 - .../AVR/CommandFrames/AVR8Generic/Detach.hpp | 1 - .../AVR8Generic/DisableDebugWire.hpp | 1 - .../CommandFrames/AVR8Generic/GetDeviceId.hpp | 1 - .../AVR8Generic/GetParameter.hpp | 7 ++- .../AVR8Generic/GetProgramCounter.hpp | 1 - .../CommandFrames/AVR8Generic/ReadMemory.hpp | 5 +- .../AVR/CommandFrames/AVR8Generic/Reset.hpp | 5 +- .../AVR/CommandFrames/AVR8Generic/Run.hpp | 1 - .../AVR/CommandFrames/AVR8Generic/RunTo.hpp | 6 +-- .../AVR8Generic/SetParameter.hpp | 5 +- .../AVR8Generic/SetProgramCounter.hpp | 4 +- .../AVR8Generic/SetSoftwareBreakpoints.hpp | 6 +-- .../SetXmegaSoftwareBreakpoint.hpp | 7 ++- .../AVR/CommandFrames/AVR8Generic/Step.hpp | 3 +- .../AVR/CommandFrames/AVR8Generic/Stop.hpp | 5 +- .../CommandFrames/AVR8Generic/WriteMemory.hpp | 5 +- .../AVR/CommandFrames/AvrCommandFrame.cpp | 4 +- .../AVR/CommandFrames/AvrCommandFrame.hpp | 18 +++---- .../Discovery/DiscoveryCommandFrame.hpp | 2 +- .../AVR/CommandFrames/Discovery/Query.hpp | 6 +-- .../CommandFrames/HouseKeeping/EndSession.hpp | 1 - .../HouseKeeping/HouseKeepingCommandFrame.hpp | 3 +- .../HouseKeeping/StartSession.hpp | 1 - .../EDBG/AVR/EdbgAvr8Interface.cpp | 9 ++-- .../EDBG/AVR/EdbgAvr8Interface.hpp | 54 +++++++++---------- .../AVR/Events/AVR8Generic/BreakEvent.hpp | 10 ++-- .../AVR8Generic/Avr8GenericResponseFrame.hpp | 8 +-- .../AVR8Generic/GetDeviceId.hpp | 4 +- .../AVR8Generic/GetProgramCounter.hpp | 4 +- .../ResponseFrames/AVR8Generic/ReadMemory.hpp | 5 +- .../AVR/ResponseFrames/AvrResponseFrame.cpp | 2 +- .../AVR/ResponseFrames/AvrResponseFrame.hpp | 14 ++--- .../ResponseFrames/DiscoveryResponseFrame.hpp | 5 +- .../CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp | 10 ++-- .../VendorSpecific/EDBG/EdbgInterface.cpp | 2 +- src/DebugToolDrivers/USB/HID/HidInterface.hpp | 2 +- src/DebugToolDrivers/USB/HID/hidapi.hpp | 3 +- src/DebugToolDrivers/USB/Interface.cpp | 2 - src/DebugToolDrivers/USB/Interface.hpp | 6 +-- src/DebugToolDrivers/USB/UsbDevice.hpp | 8 +-- src/EventManager/EventListener.cpp | 1 + src/EventManager/EventManager.cpp | 5 +- src/EventManager/EventManager.hpp | 3 +- .../Events/BreakpointRemovedOnTarget.hpp | 2 +- .../Events/BreakpointSetOnTarget.hpp | 2 +- .../Events/DebugServerThreadStateChanged.hpp | 6 +-- .../Events/DebugSessionFinished.hpp | 2 +- .../Events/DebugSessionStarted.hpp | 2 +- .../Events/ExtractTargetDescriptor.hpp | 2 +- .../Events/InsightThreadStateChanged.hpp | 4 +- .../Events/MemoryRetrievedFromTarget.hpp | 2 +- .../Events/MemoryWrittenToTarget.hpp | 2 +- .../Events/ProgramCounterSetOnTarget.hpp | 2 +- .../Events/RegistersRetrievedFromTarget.hpp | 2 +- .../Events/RegistersWrittenToTarget.hpp | 2 +- .../Events/RemoveBreakpointOnTarget.hpp | 3 +- .../Events/ReportTargetControllerState.hpp | 2 +- src/EventManager/Events/ResetTarget.hpp | 2 +- .../Events/ResumeTargetExecution.hpp | 4 +- .../Events/RetrieveMemoryFromTarget.hpp | 6 +-- .../Events/RetrieveRegistersFromTarget.hpp | 2 +- .../Events/RetrieveTargetPinStates.hpp | 4 +- .../Events/SetBreakpointOnTarget.hpp | 3 +- .../Events/SetProgramCounterOnTarget.hpp | 4 +- src/EventManager/Events/SetTargetPinState.hpp | 4 +- .../Events/ShutdownApplication.hpp | 2 +- .../Events/ShutdownDebugServer.hpp | 2 +- .../Events/ShutdownTargetController.hpp | 2 +- .../Events/StepTargetExecution.hpp | 4 +- .../Events/StopTargetExecution.hpp | 2 +- .../Events/TargetControllerErrorOccurred.hpp | 2 +- .../Events/TargetControllerStateReported.hpp | 4 +- .../TargetControllerThreadStateChanged.hpp | 4 +- .../Events/TargetDescriptorExtracted.hpp | 2 +- .../Events/TargetExecutionResumed.hpp | 2 +- .../Events/TargetExecutionStopped.hpp | 2 +- .../Events/TargetIoPortsUpdated.hpp | 2 +- .../Events/TargetPinStatesRetrieved.hpp | 4 +- .../Events/WriteMemoryToTarget.hpp | 11 ++-- .../Events/WriteRegistersToTarget.hpp | 5 +- src/Exceptions/DebugServerInterrupted.hpp | 2 +- src/Exceptions/Exception.hpp | 2 +- src/Exceptions/InvalidConfig.hpp | 1 + .../TargetControllerStartupFailure.hpp | 1 + src/Helpers/BiMap.hpp | 6 +-- src/Helpers/EventNotifier.hpp | 2 +- src/Helpers/Paths.hpp | 3 +- src/Helpers/SyncSafe.hpp | 6 +-- src/SignalHandler/SignalHandler.hpp | 4 +- src/TargetController/TargetController.hpp | 2 +- src/Targets/Microchip/AVR/AVR8/Avr8.cpp | 2 +- src/Targets/Microchip/AVR/AVR8/Avr8.hpp | 39 +++++++------- src/Targets/Microchip/AVR/AVR8/Mega/Mega.hpp | 4 +- .../TargetDescriptionFile.cpp | 2 +- .../TargetDescriptionFile.hpp | 44 +++++++-------- src/Targets/Microchip/AVR/AVR8/Tiny/Tiny.hpp | 4 +- .../Microchip/AVR/AVR8/XMega/XMega.hpp | 4 +- src/Targets/Microchip/AVR/Target.hpp | 2 +- src/Targets/Microchip/AVR/TargetSignature.hpp | 4 +- src/Targets/Target.cpp | 2 - src/Targets/Target.hpp | 4 +- src/Targets/TargetBreakpoint.hpp | 3 +- .../TargetDescription/MemorySegment.hpp | 3 +- src/Targets/TargetDescription/README.md | 4 +- src/Targets/TargetRegister.hpp | 21 ++++---- src/Targets/TargetState.hpp | 1 - 151 files changed, 386 insertions(+), 420 deletions(-) rename src/DebugServers/GdbRsp/CommandPackets/{WriteGeneralRegisters.cpp => WriteGeneralRegister.cpp} (64%) create mode 100644 src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegister.hpp delete mode 100644 src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.hpp delete mode 100644 src/Targets/Target.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 246a9eef..042a216b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,6 @@ add_executable(Bloom src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp - src/Targets/Target.cpp src/Targets/TargetDescription/TargetDescriptionFile.cpp src/Targets/Microchip/AVR/AVR8/Avr8.cpp src/Targets/Microchip/AVR/AVR8/Mega/Mega.cpp @@ -96,7 +95,7 @@ add_executable(Bloom src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.cpp src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.cpp src/DebugServers/GdbRsp/CommandPackets/ReadGeneralRegisters.cpp - src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.cpp + src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegister.cpp src/DebugServers/GdbRsp/CommandPackets/ContinueExecution.cpp src/DebugServers/GdbRsp/CommandPackets/StepExecution.cpp src/DebugServers/GdbRsp/CommandPackets/InterruptExecution.cpp diff --git a/src/Application.cpp b/src/Application.cpp index e6b61d84..38efee3a 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include diff --git a/src/DebugServers/DebugServer.cpp b/src/DebugServers/DebugServer.cpp index eb62b2ca..ff527329 100644 --- a/src/DebugServers/DebugServer.cpp +++ b/src/DebugServers/DebugServer.cpp @@ -1,5 +1,4 @@ #include -#include #include "DebugServer.hpp" #include "src/Exceptions/InvalidConfig.hpp" diff --git a/src/DebugServers/DebugServer.hpp b/src/DebugServers/DebugServer.hpp index 2bc3be6b..31e084fe 100644 --- a/src/DebugServers/DebugServer.hpp +++ b/src/DebugServers/DebugServer.hpp @@ -98,7 +98,7 @@ namespace Bloom::DebugServers virtual void close() = 0; public: - DebugServer(EventManager& eventManager): eventManager(eventManager) {}; + explicit DebugServer(EventManager& eventManager): eventManager(eventManager) {}; void setApplicationConfig(const ApplicationConfig& applicationConfig) { this->applicationConfig = applicationConfig; diff --git a/src/DebugServers/GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp b/src/DebugServers/GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp index 0f33fe9d..c29e64ff 100644 --- a/src/DebugServers/GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp +++ b/src/DebugServers/GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp @@ -116,10 +116,10 @@ namespace Bloom::DebugServers::Gdb }; public: - AvrGdbRsp(EventManager& eventManager): GdbRspDebugServer(eventManager) {}; + explicit AvrGdbRsp(EventManager& eventManager): GdbRspDebugServer(eventManager) {}; std::string getName() const override { return "AVR GDB Remote Serial Protocol Debug Server"; } }; -} \ No newline at end of file +} diff --git a/src/DebugServers/GdbRsp/CommandPackets/CommandPacket.hpp b/src/DebugServers/GdbRsp/CommandPackets/CommandPacket.hpp index 6f2d895a..68e680c9 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/CommandPacket.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/CommandPacket.hpp @@ -37,7 +37,7 @@ namespace Bloom::DebugServers::Gdb::CommandPackets class CommandPacket: public Packet { public: - CommandPacket(const std::vector& rawPacket): Packet(rawPacket) {} + explicit CommandPacket(const std::vector& rawPacket): Packet(rawPacket) {} /** * Double dispatches the packet to the appropriate overload of handleGdbPacket(), within the passed instance of diff --git a/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.cpp b/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.cpp index 0ee70891..1972d7bd 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.cpp +++ b/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.cpp @@ -8,7 +8,6 @@ using namespace Bloom::DebugServers::Gdb; using namespace Bloom::DebugServers::Gdb::CommandPackets; std::unique_ptr CommandPacketFactory::create(std::vector rawPacket) { - if (rawPacket.size() == 5 && rawPacket[1] == 0x03) { // This is an interrupt request - create a fake packet for it return std::make_unique(rawPacket); @@ -27,8 +26,8 @@ std::unique_ptr CommandPacketFactory::create(std::vector(rawPacket); - } else if (rawPacketString[1] == 'G' || rawPacketString[1] == 'P') { - return std::make_unique(rawPacket); + } else if (rawPacketString[1] == 'P') { + return std::make_unique(rawPacket); } else if (rawPacketString[1] == 'c') { return std::make_unique(rawPacket); @@ -127,4 +126,4 @@ std::vector> CommandPacketFactory::extractRawPackets( } return output; -} \ No newline at end of file +} diff --git a/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.hpp b/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.hpp index b75339bf..383a0b52 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.hpp @@ -8,7 +8,7 @@ #include "InterruptExecution.hpp" #include "SupportedFeaturesQuery.hpp" #include "ReadGeneralRegisters.hpp" -#include "WriteGeneralRegisters.hpp" +#include "WriteGeneralRegister.hpp" #include "ReadMemory.hpp" #include "WriteMemory.hpp" #include "StepExecution.hpp" diff --git a/src/DebugServers/GdbRsp/CommandPackets/ContinueExecution.hpp b/src/DebugServers/GdbRsp/CommandPackets/ContinueExecution.hpp index 76adcb58..68aef7e8 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/ContinueExecution.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/ContinueExecution.hpp @@ -27,10 +27,10 @@ namespace Bloom::DebugServers::Gdb::CommandPackets */ std::optional fromProgramCounter; - ContinueExecution(std::vector rawPacket): CommandPacket(rawPacket) { + explicit ContinueExecution(const std::vector& rawPacket): CommandPacket(rawPacket) { init(); } - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; }; } diff --git a/src/DebugServers/GdbRsp/CommandPackets/InterruptExecution.hpp b/src/DebugServers/GdbRsp/CommandPackets/InterruptExecution.hpp index f53d8fb8..eab29b9d 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/InterruptExecution.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/InterruptExecution.hpp @@ -15,8 +15,8 @@ namespace Bloom::DebugServers::Gdb::CommandPackets class InterruptExecution: public CommandPacket { public: - InterruptExecution(std::vector rawPacket): CommandPacket(rawPacket) {} + explicit InterruptExecution(const std::vector& rawPacket): CommandPacket(rawPacket) {} - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; }; } diff --git a/src/DebugServers/GdbRsp/CommandPackets/ReadGeneralRegisters.hpp b/src/DebugServers/GdbRsp/CommandPackets/ReadGeneralRegisters.hpp index 42734b14..5735992a 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/ReadGeneralRegisters.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/ReadGeneralRegisters.hpp @@ -26,10 +26,10 @@ namespace Bloom::DebugServers::Gdb::CommandPackets */ std::optional registerNumber; - ReadGeneralRegisters(std::vector rawPacket): CommandPacket(rawPacket) { + explicit ReadGeneralRegisters(const std::vector& rawPacket): CommandPacket(rawPacket) { init(); }; - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; }; } diff --git a/src/DebugServers/GdbRsp/CommandPackets/ReadMemory.hpp b/src/DebugServers/GdbRsp/CommandPackets/ReadMemory.hpp index 04299520..3f46016c 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/ReadMemory.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/ReadMemory.hpp @@ -24,17 +24,17 @@ namespace Bloom::DebugServers::Gdb::CommandPackets * * For an example of where GDB does this, see the AvrGdbRsp class. */ - std::uint32_t startAddress; + std::uint32_t startAddress = 0; /** * Number of bytes to read. */ - std::uint32_t bytes; + std::uint32_t bytes = 0; - ReadMemory(std::vector rawPacket): CommandPacket(rawPacket) { + explicit ReadMemory(const std::vector& rawPacket): CommandPacket(rawPacket) { init(); }; - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; }; } diff --git a/src/DebugServers/GdbRsp/CommandPackets/RemoveBreakpoint.hpp b/src/DebugServers/GdbRsp/CommandPackets/RemoveBreakpoint.hpp index 16035d31..b27e4b53 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/RemoveBreakpoint.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/RemoveBreakpoint.hpp @@ -32,12 +32,12 @@ namespace Bloom::DebugServers::Gdb::CommandPackets /** * Address at which the breakpoint should be located. */ - std::uint32_t address; + std::uint32_t address = 0; - RemoveBreakpoint(std::vector rawPacket): CommandPacket(rawPacket) { + explicit RemoveBreakpoint(const std::vector& rawPacket): CommandPacket(rawPacket) { this->init(); }; - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; }; } diff --git a/src/DebugServers/GdbRsp/CommandPackets/SetBreakpoint.hpp b/src/DebugServers/GdbRsp/CommandPackets/SetBreakpoint.hpp index fae33746..9fc070c2 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/SetBreakpoint.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/SetBreakpoint.hpp @@ -32,12 +32,12 @@ namespace Bloom::DebugServers::Gdb::CommandPackets /** * Address at which the breakpoint should be located. */ - std::uint32_t address; + std::uint32_t address = 0; - SetBreakpoint(std::vector rawPacket): CommandPacket(rawPacket) { + explicit SetBreakpoint(const std::vector& rawPacket): CommandPacket(rawPacket) { this->init(); }; - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; }; } diff --git a/src/DebugServers/GdbRsp/CommandPackets/StepExecution.hpp b/src/DebugServers/GdbRsp/CommandPackets/StepExecution.hpp index 59c139eb..3b6502ff 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/StepExecution.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/StepExecution.hpp @@ -21,10 +21,10 @@ namespace Bloom::DebugServers::Gdb::CommandPackets */ std::optional fromProgramCounter; - StepExecution(std::vector rawPacket): CommandPacket(rawPacket) { + explicit StepExecution(const std::vector& rawPacket): CommandPacket(rawPacket) { init(); }; - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; }; } diff --git a/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.hpp b/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.hpp index e0759450..641ebb48 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.hpp @@ -27,18 +27,18 @@ namespace Bloom::DebugServers::Gdb::CommandPackets void init(); public: - SupportedFeaturesQuery(std::vector rawPacket): CommandPacket(rawPacket) { + explicit SupportedFeaturesQuery(const std::vector& rawPacket): CommandPacket(rawPacket) { this->init(); }; - bool isFeatureSupported(const Feature& feature) const { + [[nodiscard]] bool isFeatureSupported(const Feature& feature) const { return this->supportedFeatures.find(feature) != this->supportedFeatures.end(); } - const std::set& getSupportedFeatures() const { + [[nodiscard]] const std::set& getSupportedFeatures() const { return this->supportedFeatures; } - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; }; } diff --git a/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.cpp b/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegister.cpp similarity index 64% rename from src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.cpp rename to src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegister.cpp index e2578662..81b237ec 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.cpp +++ b/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegister.cpp @@ -1,11 +1,11 @@ -#include "WriteGeneralRegisters.hpp" +#include "WriteGeneralRegister.hpp" #include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp" #include "src/Exceptions/Exception.hpp" using namespace Bloom::DebugServers::Gdb::CommandPackets; using namespace Bloom::Exceptions; -void WriteGeneralRegisters::init() { +void WriteGeneralRegister::init() { // The P packet updates a single register auto packet = std::string(this->data.begin(), this->data.end()); @@ -13,16 +13,16 @@ void WriteGeneralRegisters::init() { throw Exception("Invalid P command packet - insufficient data in packet."); } - if (packet.find("=") == std::string::npos) { + if (packet.find('=') == std::string::npos) { throw Exception("Invalid P command packet - unexpected format"); } auto packetSegments = QString::fromStdString(packet).split("="); - this->registerNumber = packetSegments.front().mid(1).toUInt(nullptr, 16); - this->registerValue = this->hexToData(packetSegments.back().toStdString()); + this->registerNumber = static_cast(packetSegments.front().midRef(1).toUInt(nullptr, 16)); + this->registerValue = Packet::hexToData(packetSegments.back().toStdString()); std::reverse(this->registerValue.begin(), this->registerValue.end()); } -void WriteGeneralRegisters::dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) { +void WriteGeneralRegister::dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) { gdbRspDebugServer.handleGdbPacket(*this); } diff --git a/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegister.hpp b/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegister.hpp new file mode 100644 index 00000000..a5447127 --- /dev/null +++ b/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegister.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include + +#include "CommandPacket.hpp" +#include "src/Targets/TargetRegister.hpp" + +namespace Bloom::DebugServers::Gdb::CommandPackets +{ + /** + * The WriteGeneralRegisters class implements the structure for "P" packets. Upon receiving this packet, + * server is expected to update a register value to the target. + */ + class WriteGeneralRegister: public CommandPacket + { + private: + void init(); + + public: + int registerNumber = 0; + std::vector registerValue; + + explicit WriteGeneralRegister(const std::vector& rawPacket): CommandPacket(rawPacket) { + init(); + }; + + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + }; +} diff --git a/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.hpp b/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.hpp deleted file mode 100644 index d6039ee7..00000000 --- a/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include - -#include "CommandPacket.hpp" -#include "src/Targets/TargetRegister.hpp" - -namespace Bloom::DebugServers::Gdb::CommandPackets -{ - /** - * The WriteGeneralRegisters class implements the structure for "G" and "P" packets. Upon receiving this packet, - * server is expected to write register values to the target. - */ - class WriteGeneralRegisters: public CommandPacket - { - private: - void init(); - - public: - Bloom::Targets::TargetRegisterMap registerMap; - int registerNumber; - std::vector registerValue; - - WriteGeneralRegisters(std::vector rawPacket): CommandPacket(rawPacket) { - init(); - }; - - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; - }; -} diff --git a/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.cpp b/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.cpp index c9f48d8a..b4c53e7e 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.cpp +++ b/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.cpp @@ -40,7 +40,7 @@ void WriteMemory::init() { throw Exception("Failed to parse write length from write memory packet data"); } - this->buffer = this->hexToData(lengthAndBufferSegments.at(1).toStdString()); + this->buffer = Packet::hexToData(lengthAndBufferSegments.at(1).toStdString()); if (this->buffer.size() != bufferSize) { throw Exception("Buffer size does not match length value given in write memory packet"); diff --git a/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.hpp b/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.hpp index 2c64c82f..0b41ec3f 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.hpp @@ -22,14 +22,14 @@ namespace Bloom::DebugServers::Gdb::CommandPackets * Like with the ReadMemory command packet, the start address carries additional bits that indicate * the memory type. */ - std::uint32_t startAddress; + std::uint32_t startAddress = 0; Targets::TargetMemoryBuffer buffer; - WriteMemory(std::vector rawPacket): CommandPacket(rawPacket) { + explicit WriteMemory(const std::vector& rawPacket): CommandPacket(rawPacket) { init(); }; - virtual void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; + void dispatchToHandler(Gdb::GdbRspDebugServer& gdbRspDebugServer) override; }; } diff --git a/src/DebugServers/GdbRsp/Connection.cpp b/src/DebugServers/GdbRsp/Connection.cpp index 348059db..db81a45b 100644 --- a/src/DebugServers/GdbRsp/Connection.cpp +++ b/src/DebugServers/GdbRsp/Connection.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include "src/Logger/Logger.hpp" @@ -117,7 +117,7 @@ void Connection::writePacket(const ResponsePacket& packet) { std::vector Connection::read(size_t bytes, bool interruptible, std::optional msTimeout) { auto output = std::vector(); constexpr size_t bufferSize = 1024; - std::array buffer; + std::array buffer = {}; ssize_t bytesRead; if (interruptible) { diff --git a/src/DebugServers/GdbRsp/Connection.hpp b/src/DebugServers/GdbRsp/Connection.hpp index 18a228c3..85fc4e52 100644 --- a/src/DebugServers/GdbRsp/Connection.hpp +++ b/src/DebugServers/GdbRsp/Connection.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -83,8 +84,8 @@ namespace Bloom::DebugServers::Gdb */ bool waitingForBreak = false; - Connection(std::shared_ptr interruptEventNotifier) - : interruptEventNotifier(interruptEventNotifier) {}; + explicit Connection(std::shared_ptr interruptEventNotifier) + : interruptEventNotifier(std::move(interruptEventNotifier)) {}; /** * Accepts a connection on serverSocketFileDescriptor. @@ -104,7 +105,7 @@ namespace Bloom::DebugServers::Gdb * @return */ std::string getIpAddress() { - std::array ipAddress; + std::array ipAddress = {}; if (::inet_ntop(AF_INET, &(socketAddress.sin_addr), ipAddress.data(), INET_ADDRSTRLEN) == nullptr) { throw Exceptions::Exception("Failed to convert client IP address to text form."); @@ -127,7 +128,7 @@ namespace Bloom::DebugServers::Gdb */ void writePacket(const ResponsePackets::ResponsePacket& packet); - int getMaxPacketSize() { + [[nodiscard]] int getMaxPacketSize() const { return this->maxPacketSize; } }; diff --git a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp index 92c304a6..d0ffd017 100644 --- a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp +++ b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp @@ -330,7 +330,7 @@ void GdbRspDebugServer::handleGdbPacket(CommandPackets::ReadGeneralRegisters& pa } } -void GdbRspDebugServer::handleGdbPacket(CommandPackets::WriteGeneralRegisters& packet) { +void GdbRspDebugServer::handleGdbPacket(CommandPackets::WriteGeneralRegister& packet) { Logger::debug("Handling WriteGeneralRegisters packet"); try { diff --git a/src/DebugServers/GdbRsp/GdbRspDebugServer.hpp b/src/DebugServers/GdbRsp/GdbRspDebugServer.hpp index ced78948..6f1a875b 100644 --- a/src/DebugServers/GdbRsp/GdbRspDebugServer.hpp +++ b/src/DebugServers/GdbRsp/GdbRspDebugServer.hpp @@ -200,11 +200,11 @@ namespace Bloom::DebugServers::Gdb virtual void handleGdbPacket(CommandPackets::ReadGeneralRegisters& packet); /** - * Handles the write general registers ("G" and "P") command packet. + * Handles the write general register ("P") command packet. * * @param packet */ - virtual void handleGdbPacket(CommandPackets::WriteGeneralRegisters& packet); + virtual void handleGdbPacket(CommandPackets::WriteGeneralRegister& packet); /** * Handles the continue execution ("c") command packet. diff --git a/src/DebugServers/GdbRsp/Packet.hpp b/src/DebugServers/GdbRsp/Packet.hpp index d7a130b5..8fffa17c 100644 --- a/src/DebugServers/GdbRsp/Packet.hpp +++ b/src/DebugServers/GdbRsp/Packet.hpp @@ -28,11 +28,11 @@ namespace Bloom::DebugServers::Gdb } public: Packet() = default; - Packet(const std::vector& rawPacket) { + explicit Packet(const std::vector& rawPacket) { this->init(rawPacket); } - virtual std::vector getData() const { + [[nodiscard]] virtual std::vector getData() const { return this->data; } @@ -45,7 +45,7 @@ namespace Bloom::DebugServers::Gdb * * @return */ - std::vector toRawPacket() const { + [[nodiscard]] std::vector toRawPacket() const { std::vector packet = {'$'}; auto data = this->getData(); @@ -90,7 +90,7 @@ namespace Bloom::DebugServers::Gdb * @param data * @return */ - static std::string dataToHex(std::vector data) { + static std::string dataToHex(const std::vector& data) { std::stringstream stream; stream << std::hex << std::setfill('0'); diff --git a/src/DebugServers/GdbRsp/ResponsePackets/Ok.hpp b/src/DebugServers/GdbRsp/ResponsePackets/Ok.hpp index 4945610d..88e364d3 100644 --- a/src/DebugServers/GdbRsp/ResponsePackets/Ok.hpp +++ b/src/DebugServers/GdbRsp/ResponsePackets/Ok.hpp @@ -18,7 +18,7 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets public: Ok() = default; - std::vector getData() const override { + [[nodiscard]] std::vector getData() const override { return {'O', 'K'}; } }; diff --git a/src/DebugServers/GdbRsp/ResponsePackets/SupportedFeaturesResponse.hpp b/src/DebugServers/GdbRsp/ResponsePackets/SupportedFeaturesResponse.hpp index 084936d9..95645b70 100644 --- a/src/DebugServers/GdbRsp/ResponsePackets/SupportedFeaturesResponse.hpp +++ b/src/DebugServers/GdbRsp/ResponsePackets/SupportedFeaturesResponse.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "ResponsePacket.hpp" #include "../Feature.hpp" @@ -17,9 +18,9 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets public: SupportedFeaturesResponse() = default; - SupportedFeaturesResponse(const std::set>>& supportedFeatures) - : supportedFeatures(supportedFeatures) {}; + explicit SupportedFeaturesResponse(std::set>> supportedFeatures) + : supportedFeatures(std::move(supportedFeatures)) {}; - std::vector getData() const override; + [[nodiscard]] std::vector getData() const override; }; } diff --git a/src/DebugServers/GdbRsp/ResponsePackets/TargetStopped.hpp b/src/DebugServers/GdbRsp/ResponsePackets/TargetStopped.hpp index 92ee790c..ea2519e6 100644 --- a/src/DebugServers/GdbRsp/ResponsePackets/TargetStopped.hpp +++ b/src/DebugServers/GdbRsp/ResponsePackets/TargetStopped.hpp @@ -18,10 +18,10 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets std::optional registerMap; std::optional stopReason; - TargetStopped(Signal signal): signal(signal) {} + explicit TargetStopped(Signal signal): signal(signal) {} - std::vector getData() const override { - std::string output = "T" + this->dataToHex({static_cast(this->signal)}); + [[nodiscard]] std::vector getData() const override { + std::string output = "T" + Packet::dataToHex({static_cast(this->signal)}); if (this->stopReason.has_value()) { auto stopReasonMapping = getStopReasonToNameMapping(); @@ -34,8 +34,8 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets if (this->registerMap.has_value()) { for (const auto& [registerId, registerValue] : this->registerMap.value()) { - output += this->dataToHex({static_cast(registerId)}); - output += ":" + this->dataToHex(registerValue.value) + ";"; + output += Packet::dataToHex({static_cast(registerId)}); + output += ":" + Packet::dataToHex(registerValue.value) + ";"; } } diff --git a/src/DebugToolDrivers/DebugTool.hpp b/src/DebugToolDrivers/DebugTool.hpp index 74d6de13..b4b83f99 100644 --- a/src/DebugToolDrivers/DebugTool.hpp +++ b/src/DebugToolDrivers/DebugTool.hpp @@ -23,7 +23,7 @@ namespace Bloom } public: - bool isInitialised() const { + [[nodiscard]] bool isInitialised() const { return this->initialised; } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp index 962a161a..b5070f87 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp @@ -2,8 +2,7 @@ using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap; -Command::operator std::vector () const -{ +Command::operator std::vector () const { auto rawCommand = std::vector(1, this->getCommandId()); auto commandData = this->getData(); rawCommand.insert(rawCommand.end(), commandData.begin(), commandData.end()); diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp index 7fd4b6b0..d9ddd75b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp @@ -12,7 +12,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap std::vector data; public: - unsigned char getCommandId() const { + [[nodiscard]] unsigned char getCommandId() const { return this->commandId; } @@ -20,7 +20,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap this->commandId = commandId; } - virtual std::vector getData() const { + [[nodiscard]] virtual std::vector getData() const { return this->data; } @@ -33,7 +33,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap return (int) (1 + this->getData().size()); } - std::uint16_t getDataSize() const { + [[nodiscard]] std::uint16_t getDataSize() const { return (std::uint16_t) this->getData().size(); } @@ -46,7 +46,5 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap explicit virtual operator std::vector() const; virtual ~Command() = default; - }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.cpp index 0c19da1a..e14e0e23 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.cpp @@ -3,13 +3,11 @@ using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap; -void Response::init(const std::vector& rawResponse) -{ - if (rawResponse.size() < 1) { +void Response::init(const std::vector& rawResponse) { + if (rawResponse.empty()) { throw Exceptions::Exception("Failed to process CMSIS-DAP response - invalid response"); } this->setResponseId(rawResponse[0]); this->setData(std::vector(rawResponse.begin() + 1, rawResponse.end())); } - diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp index b77ab68b..ca73c2f3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp @@ -24,11 +24,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap Response() = default; virtual void init(const std::vector& rawResponse); - unsigned char getResponseId() const { + [[nodiscard]] unsigned char getResponseId() const { return this->responseId; } - virtual const std::vector& getData() const { + [[nodiscard]] virtual const std::vector& getData() const { return this->data; } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.cpp index 52b97e5a..87c838a3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.cpp @@ -2,8 +2,7 @@ using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr; -std::vector AvrCommand::getData() const -{ +std::vector AvrCommand::getData() const { std::vector data; auto commandPacket = this->getCommandPacket(); std::size_t commandPacketSize = commandPacket.size(); @@ -21,4 +20,3 @@ std::vector AvrCommand::getData() const return data; } - diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp index a5bbc2d8..8fdb9f5c 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp @@ -24,9 +24,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * @return */ - std::vector getData() const override; + [[nodiscard]] std::vector getData() const override; - size_t getFragmentNumber() const { + [[nodiscard]] size_t getFragmentNumber() const { return this->fragmentNumber; } @@ -34,7 +34,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr this->fragmentNumber = fragmentNumber; } - size_t getFragmentCount() const { + [[nodiscard]] size_t getFragmentCount() const { return this->fragmentCount; } @@ -42,7 +42,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr this->fragmentCount = fragmentCount; } - const std::vector& getCommandPacket() const { + [[nodiscard]] const std::vector& getCommandPacket() const { return this->commandPacket; } @@ -50,5 +50,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr this->commandPacket = commandPacket; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.cpp index 914b00fa..94f7a77a 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.cpp @@ -20,7 +20,7 @@ void AvrEvent::init(const std::vector& rawResponse) { } // Response size is two bytes, MSB - size_t responsePacketSize = static_cast((responseData[0] << 8) | responseData[1]); + auto responsePacketSize = static_cast((responseData[0] << 8) | responseData[1]); if (responseData.size() < 2) { // All AVR_EVT responses should consist of at least two bytes (excluding the AVR_EVT ID) @@ -42,8 +42,7 @@ void AvrEvent::init(const std::vector& rawResponse) { this->setEventData(eventData); - if (eventData.size() >= 1) { + if (!eventData.empty()) { this->eventId = eventData[0]; } } - diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp index dab8877d..353f9d5f 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp @@ -23,7 +23,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr class AvrEvent: public Response { private: - unsigned char eventId; + unsigned char eventId = 0; std::vector eventData; @@ -48,15 +48,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr void init(const std::vector& rawResponse) override; - const std::vector& getEventData() const { + [[nodiscard]] const std::vector& getEventData() const { return this->eventData; } - size_t getEventDataSize() const { + [[nodiscard]] size_t getEventDataSize() const { return this->eventData.size(); } - AvrEventId getEventId() { + [[nodiscard]] AvrEventId getEventId() const { return static_cast(this->eventId); } }; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.hpp index a5985865..c00bc70a 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.hpp @@ -44,15 +44,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr void init(const std::vector& rawResponse) override; - std::uint8_t getFragmentNumber() const { + [[nodiscard]] std::uint8_t getFragmentNumber() const { return this->fragmentNumber; } - std::uint8_t getFragmentCount() const { + [[nodiscard]] std::uint8_t getFragmentCount() const { return this->fragmentCount; } - const std::vector& getResponsePacket() const { + [[nodiscard]] const std::vector& getResponsePacket() const { return this->responsePacket; } }; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ActivatePhysical.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ActivatePhysical.hpp index a0262845..cfa3a699 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ActivatePhysical.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ActivatePhysical.hpp @@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames public: ActivatePhysical() = default; - ActivatePhysical(bool reset): reset(reset) {}; + explicit ActivatePhysical(bool reset): reset(reset) {}; void setReset(bool reset) { this->reset = reset; } - std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The activate physical command consists of 3 bytes: * 1. Command ID (0x10) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Attach.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Attach.hpp index 736d957e..f45e930f 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Attach.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Attach.hpp @@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames public: Attach() = default; - Attach(bool breakAfterAttach): breakAfterAttach(breakAfterAttach) {}; + explicit Attach(bool breakAfterAttach): breakAfterAttach(breakAfterAttach) {}; void setBreadAfterAttach(bool breakAfterAttach) { this->breakAfterAttach = breakAfterAttach; } - std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The attach command consists of 3 bytes: * 1. Command ID (0x13) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp index c887a34c..58a0cf1c 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp @@ -13,8 +13,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames using ResponseFrameType = ResponseFrames::Avr8Generic::Avr8GenericResponseFrame; Avr8GenericCommandFrame() { - this->setProtocolHandlerId(ProtocolHandlerId::Avr8Generic); + this->setProtocolHandlerId(ProtocolHandlerId::AVR8_GENERIC); } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearAllSoftwareBreakpoints.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearAllSoftwareBreakpoints.hpp index 24c019fd..9b7311be 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearAllSoftwareBreakpoints.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearAllSoftwareBreakpoints.hpp @@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames init(); }; }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearSoftwareBreakpoints.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearSoftwareBreakpoints.hpp index fb0bd0b4..6ffb9bce 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearSoftwareBreakpoints.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearSoftwareBreakpoints.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "Avr8GenericCommandFrame.hpp" @@ -14,13 +15,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames public: ClearSoftwareBreakpoints() = default; - ClearSoftwareBreakpoints(const std::vector& addresses): addresses(addresses) {} + explicit ClearSoftwareBreakpoints(std::vector addresses): addresses(std::move(addresses)) {} void setAddresses(const std::vector& addresses) { this->addresses = addresses; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The clear software breakpoints command consists of 2 bytes + 4*n bytes, where n is the number * of breakpoints to clear: @@ -43,5 +44,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DeactivatePhysical.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DeactivatePhysical.hpp index e34e8802..29fe7c57 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DeactivatePhysical.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DeactivatePhysical.hpp @@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames init(); }; }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Detach.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Detach.hpp index 2f8ac46e..22fdfca1 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Detach.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Detach.hpp @@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames init(); }; }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DisableDebugWire.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DisableDebugWire.hpp index a60cce95..33edc59f 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DisableDebugWire.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DisableDebugWire.hpp @@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames init(); }; }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetDeviceId.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetDeviceId.hpp index 848ed029..ffaccf26 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetDeviceId.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetDeviceId.hpp @@ -27,5 +27,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames init(); }; }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetParameter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetParameter.hpp index 0de804bd..c332ce43 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetParameter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetParameter.hpp @@ -10,12 +10,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames { private: Avr8EdbgParameter parameter; - std::uint8_t size; + std::uint8_t size = 0; public: GetParameter() = default; - GetParameter(const Avr8EdbgParameter& parameter) { + explicit GetParameter(const Avr8EdbgParameter& parameter) { this->setParameter(parameter); } @@ -31,7 +31,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames this->size = size; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The get param command consists of 5 bytes: * 1. Command ID (0x02) @@ -50,5 +50,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetProgramCounter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetProgramCounter.hpp index b1685baa..9b9c02d4 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetProgramCounter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetProgramCounter.hpp @@ -27,5 +27,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames init(); }; }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp index ddcdc34a..cbd1ab19 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp @@ -10,7 +10,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames class ReadMemory: public Avr8GenericCommandFrame { private: - Avr8MemoryType type; + Avr8MemoryType type = Avr8MemoryType::SRAM; std::uint32_t address = 0; std::uint32_t bytes = 0; @@ -31,7 +31,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames this->bytes = bytes; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The read memory command consists of 11 bytes: * 1. Command ID (0x21) @@ -56,5 +56,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Reset.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Reset.hpp index 73a8deb8..206fdb87 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Reset.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Reset.hpp @@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames public: Reset() = default; - Reset(bool stopAtMainAddress): stopAtMainAddress(stopAtMainAddress) {}; + explicit Reset(bool stopAtMainAddress): stopAtMainAddress(stopAtMainAddress) {}; void setStopAtMainAddress(bool stopAtMainAddress) { this->stopAtMainAddress = stopAtMainAddress; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The reset command consists of 3 bytes: * 1. Command ID (0x30) @@ -32,5 +32,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Run.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Run.hpp index 684103d7..b6f42444 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Run.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Run.hpp @@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames init(); }; }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/RunTo.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/RunTo.hpp index 8939ece1..ab9792f1 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/RunTo.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/RunTo.hpp @@ -9,18 +9,18 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames class RunTo: public Avr8GenericCommandFrame { private: - std::uint32_t address; + std::uint32_t address = 0; public: RunTo() = default; - RunTo(const std::uint32_t& address): address(address) {} + explicit RunTo(const std::uint32_t& address): address(address) {} void setAddress(const std::uint32_t& address) { this->address = address; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The run-to command consists of 6 bytes: * diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp index 7dd0d55f..64ec0184 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp @@ -13,7 +13,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames public: SetParameter() = default; - SetParameter(const Avr8EdbgParameter& parameter) { + explicit SetParameter(const Avr8EdbgParameter& parameter) { this->setParameter(parameter); } @@ -37,7 +37,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames this->value.resize(1, value); } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The set param command consists of this->value.size() + 5 bytes. The first five bytes consist of: * 1. Command ID (0x01) @@ -58,5 +58,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp index cf0bc7a3..a935a75c 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp @@ -12,9 +12,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames std::uint32_t programCounter = 0; public: - SetProgramCounter(std::uint32_t programCounter): programCounter(programCounter) {} + explicit SetProgramCounter(std::uint32_t programCounter): programCounter(programCounter) {} - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The PC write command consists of 6 bytes: * 1. Command ID (0x01) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetSoftwareBreakpoints.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetSoftwareBreakpoints.hpp index 7f4d067c..a7a6514c 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetSoftwareBreakpoints.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetSoftwareBreakpoints.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "Avr8GenericCommandFrame.hpp" @@ -14,13 +15,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames public: SetSoftwareBreakpoints() = default; - SetSoftwareBreakpoints(const std::vector& addresses): addresses(addresses) {} + explicit SetSoftwareBreakpoints(std::vector addresses): addresses(std::move(addresses)) {} void setAddresses(const std::vector& addresses) { this->addresses = addresses; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The set software breakpoint command consists of 2 bytes + 4*n bytes, where n is the number * of breakpoints to set: @@ -43,5 +44,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetXmegaSoftwareBreakpoint.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetXmegaSoftwareBreakpoint.hpp index df06017f..ddd02318 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetXmegaSoftwareBreakpoint.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetXmegaSoftwareBreakpoint.hpp @@ -9,18 +9,18 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames class SetXmegaSoftwareBreakpoint: public Avr8GenericCommandFrame { private: - std::uint32_t address; + std::uint32_t address = 0; public: SetXmegaSoftwareBreakpoint() = default; - SetXmegaSoftwareBreakpoint(std::uint32_t address): address(address) {} + explicit SetXmegaSoftwareBreakpoint(std::uint32_t address): address(address) {} void setAddress(std::uint32_t address) { this->address = address; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The set software breakpoint command consists of 6 bytes bytes * @@ -41,5 +41,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Step.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Step.hpp index e2652c85..cf80c0ca 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Step.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Step.hpp @@ -9,7 +9,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames public: Step() = default; - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The step command consists of 4 bytes: * 1. Command ID (0x34) @@ -26,5 +26,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Stop.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Stop.hpp index 5488c4dd..2734d6c6 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Stop.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Stop.hpp @@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames public: Stop() = default; - Stop(bool stopImmediately): stopImmediately(stopImmediately) {}; + explicit Stop(bool stopImmediately): stopImmediately(stopImmediately) {}; void setStopImmediately(bool stopImmediately) { this->stopImmediately = stopImmediately; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The stop command consists of 3 bytes: * 1. Command ID (0x31) @@ -32,5 +32,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp index 62fc0b6b..cc5eda8b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp @@ -10,7 +10,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames class WriteMemory: public Avr8GenericCommandFrame { private: - Avr8MemoryType type; + Avr8MemoryType type = Avr8MemoryType::SRAM; std::uint32_t address = 0; Targets::TargetMemoryBuffer buffer; @@ -29,7 +29,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames this->buffer = buffer; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The write memory command consists of 12 bytes + the buffer size: * 1. Command ID (0x23) @@ -63,5 +63,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames return output; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.cpp index 0206ea9d..828be884 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.cpp @@ -7,7 +7,9 @@ using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr; std::vector AvrCommandFrame::generateAvrCommands(std::size_t maximumCommandPacketSize) const { auto rawCommandFrame = static_cast>(*this); std::size_t commandFrameSize = rawCommandFrame.size(); - std::size_t commandsRequired = static_cast(ceil(static_cast(commandFrameSize) / static_cast(maximumCommandPacketSize))); + auto commandsRequired = static_cast( + ceil(static_cast(commandFrameSize) / static_cast(maximumCommandPacketSize)) + ); std::vector avrCommands; std::size_t copiedPacketSize = 0; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp index 1d441112..658e749e 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp @@ -28,7 +28,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr /** * Destination sub-protocol handler ID */ - ProtocolHandlerId protocolHandlerID; + ProtocolHandlerId protocolHandlerID = ProtocolHandlerId::DISCOVERY; std::vector payload; @@ -36,16 +36,16 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr using ResponseFrameType = AvrResponseFrame; AvrCommandFrame() { - if (this->lastSequenceId < std::numeric_limitslastSequenceId)>::max()) { - this->sequenceId = ++(this->lastSequenceId); + if (AvrCommandFrame::lastSequenceId < std::numeric_limits::max()) { + this->sequenceId = ++(AvrCommandFrame::lastSequenceId); } else { this->sequenceId = 0; - this->lastSequenceId = 0; + AvrCommandFrame::lastSequenceId = 0; } }; - unsigned char getProtocolVersion() const { + [[nodiscard]] unsigned char getProtocolVersion() const { return this->protocolVersion; } @@ -53,11 +53,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr this->protocolVersion = protocolVersion; } - std::uint16_t getSequenceId() const { + [[nodiscard]] std::uint16_t getSequenceId() const { return this->sequenceId; } - ProtocolHandlerId getProtocolHandlerId() const { + [[nodiscard]] ProtocolHandlerId getProtocolHandlerId() const { return this->protocolHandlerID; } @@ -69,7 +69,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr this->protocolHandlerID = static_cast(protocolHandlerId); } - virtual std::vector getPayload() const { + [[nodiscard]] virtual std::vector getPayload() const { return this->payload; } @@ -94,7 +94,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @return * A vector of sequenced AVRCommands, each containing a segment of the AvrCommandFrame. */ - std::vector generateAvrCommands(std::size_t maximumCommandPacketSize) const; + [[nodiscard]] std::vector generateAvrCommands(std::size_t maximumCommandPacketSize) const; /** * Converts instance of a CMSIS Command to an unsigned char, for sending to the Atmel ICE device. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp index 26b9b627..9b89db57 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp @@ -40,7 +40,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames using ResponseFrameType = ResponseFrames::DiscoveryResponseFrame; DiscoveryCommandFrame() { - this->setProtocolHandlerId(ProtocolHandlerId::Discovery); + this->setProtocolHandlerId(ProtocolHandlerId::DISCOVERY); } }; } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/Query.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/Query.hpp index 5c47cedb..97d31f91 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/Query.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/Query.hpp @@ -22,12 +22,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames class Query: public DiscoveryCommandFrame { private: - QueryContext context; + QueryContext context = QueryContext::COMMAND_HANDLERS; public: Query(): DiscoveryCommandFrame() {} - Query(QueryContext context): DiscoveryCommandFrame() { + explicit Query(QueryContext context): DiscoveryCommandFrame() { this->setContext(context); } @@ -35,7 +35,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames this->context = context; } - virtual std::vector getPayload() const override { + [[nodiscard]] std::vector getPayload() const override { /* * The payload for the Query command consists of three bytes. A command ID (0x00), version (0x00) and a * query context. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/EndSession.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/EndSession.hpp index 45c16c75..9274ecc1 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/EndSession.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/EndSession.hpp @@ -27,5 +27,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames this->init(); } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/HouseKeepingCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/HouseKeepingCommandFrame.hpp index b2306790..f5ba1217 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/HouseKeepingCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/HouseKeepingCommandFrame.hpp @@ -25,8 +25,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames { public: HouseKeepingCommandFrame() { - this->setProtocolHandlerId(ProtocolHandlerId::HouseKeeping); + this->setProtocolHandlerId(ProtocolHandlerId::HOUSE_KEEPING); } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/StartSession.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/StartSession.hpp index 1637f3ce..77c24ffb 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/StartSession.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/StartSession.hpp @@ -26,5 +26,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames this->init(); } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp index 9e7f45d2..e812c11a 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -42,6 +42,7 @@ using Bloom::Targets::TargetState; using Bloom::Targets::TargetMemoryType; using Bloom::Targets::TargetMemoryBuffer; using Bloom::Targets::TargetRegister; +using Bloom::Targets::TargetRegisterDescriptor; using Bloom::Targets::TargetRegisterType; using Bloom::Targets::TargetRegisters; @@ -554,7 +555,7 @@ std::uint32_t EdbgAvr8Interface::getProgramCounter() { } TargetRegister EdbgAvr8Interface::getStackPointerRegister() { - return TargetRegister(TargetRegisterType::STACK_POINTER, this->readMemory( + return TargetRegister(TargetRegisterDescriptor(TargetRegisterType::STACK_POINTER), this->readMemory( Avr8MemoryType::SRAM, this->targetParameters.stackPointerRegisterStartAddress.value(), this->targetParameters.stackPointerRegisterSize.value() @@ -562,7 +563,7 @@ TargetRegister EdbgAvr8Interface::getStackPointerRegister() { } TargetRegister EdbgAvr8Interface::getStatusRegister() { - return TargetRegister(TargetRegisterType::STATUS_REGISTER, this->readMemory( + return TargetRegister(TargetRegisterDescriptor(TargetRegisterType::STATUS_REGISTER), this->readMemory( Avr8MemoryType::SRAM, this->targetParameters.statusRegisterStartAddress.value(), this->targetParameters.statusRegisterSize.value() @@ -840,7 +841,7 @@ TargetMemoryBuffer EdbgAvr8Interface::readMemory(Avr8MemoryType type, std::uint3 return response.getMemoryBuffer(); } -void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t address, TargetMemoryBuffer buffer) { +void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t address, const TargetMemoryBuffer& buffer) { if (type == Avr8MemoryType::FLASH_PAGE) { // TODO: Implement support for writing to flash throw Exception("Cannot write to flash"); @@ -855,8 +856,6 @@ void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t address, if (response.getResponseId() == Avr8ResponseId::FAILED) { throw Avr8CommandFailure("Write memory AVR8 from target command failed", response); } - - return; } TargetRegisters EdbgAvr8Interface::readGeneralPurposeRegisters(std::set registerIds) { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp index 00f296f3..9867e1eb 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp @@ -350,7 +350,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param address * @param buffer */ - void writeMemory(Avr8MemoryType type, std::uint32_t address, Targets::TargetMemoryBuffer buffer); + void writeMemory(Avr8MemoryType type, std::uint32_t address, const Targets::TargetMemoryBuffer& buffer); /** * Fetches the current target state. @@ -413,7 +413,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr void waitForStoppedEvent(); public: - EdbgAvr8Interface(EdbgInterface& edbgInterface) + explicit EdbgAvr8Interface(EdbgInterface& edbgInterface) : edbgInterface(edbgInterface) {}; /* @@ -427,7 +427,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * @param targetConfig */ - virtual void configure(const TargetConfig& targetConfig) override; + void configure(const TargetConfig& targetConfig) override; /** * Configures the target family. For some physical interfaces, the target family is required in order @@ -445,22 +445,22 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * @param config */ - virtual void setTargetParameters(const Targets::Microchip::Avr::Avr8Bit::TargetParameters& config) override; + void setTargetParameters(const Targets::Microchip::Avr::Avr8Bit::TargetParameters& config) override; /** * Initialises the AVR8 Generic protocol interface by setting the appropriate parameters on the debug tool. */ - virtual void init() override; + void init() override; /** * Issues the "stop" command to the debug tool, halting target execution. */ - virtual void stop() override; + void stop() override; /** * Issues the "run" command to the debug tool, resuming execution on the target. */ - virtual void run() override; + void run() override; /** * Issues the "run to" command to the debug tool, resuming execution on the target, up to a specific byte @@ -469,65 +469,65 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param address * The (byte) address to run to. */ - virtual void runTo(std::uint32_t address) override; + void runTo(std::uint32_t address) override; /** * Issues the "step" command to the debug tool, stepping the execution on the target. The stepping can be * configured to step in, out or over. But currently we only support stepping in. The target will dispatch * an AVR BREAK event once it reaches the next instruction. */ - virtual void step() override; + void step() override; /** * Issues the "reset" command to the debug tool, resetting target execution. */ - virtual void reset() override; + void reset() override; /** * Activates the physical interface and starts a debug session on the target (via attach()). */ - virtual void activate() override; + void activate() override; /** * Terminates any active debug session on the target and severs the connection between the debug tool and * the target (by deactivating the physical interface). */ - virtual void deactivate() override; + void deactivate() override; /** * Issues the "PC Read" command to the debug tool, to extract the current program counter. * * @return */ - virtual std::uint32_t getProgramCounter() override; + std::uint32_t getProgramCounter() override; /** * Reads the stack pointer register from the target. * * @return */ - virtual Targets::TargetRegister getStackPointerRegister() override; + Targets::TargetRegister getStackPointerRegister() override; /** * Reads the status register from the target. * * @return */ - virtual Targets::TargetRegister getStatusRegister() override; + Targets::TargetRegister getStatusRegister() override; /** * Updates the stack pointer register on ther target. * * @param stackPointerRegister */ - virtual void setStackPointerRegister(const Targets::TargetRegister& stackPointerRegister) override; + void setStackPointerRegister(const Targets::TargetRegister& stackPointerRegister) override; /** * Updates the status register on the target. * * @param statusRegister */ - virtual void setStatusRegister(const Targets::TargetRegister& statusRegister) override; + void setStatusRegister(const Targets::TargetRegister& statusRegister) override; /** * Issues the "PC Write" command to the debug tool, setting the program counter on the target. @@ -535,14 +535,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param programCounter * The byte address to set as the program counter. */ - virtual void setProgramCounter(std::uint32_t programCounter) override; + void setProgramCounter(std::uint32_t programCounter) override; /** * Issues the "Get ID" command to the debug tool, to extract the signature from the target. * * @return */ - virtual Targets::Microchip::Avr::TargetSignature getDeviceId() override; + Targets::Microchip::Avr::TargetSignature getDeviceId() override; /** * Issues the "Software Breakpoint Set" command to the debug tool, setting a software breakpoint at the given @@ -551,7 +551,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param address * The byte address to position the breakpoint. */ - virtual void setBreakpoint(std::uint32_t address) override; + void setBreakpoint(std::uint32_t address) override; /** * Issues the "Software Breakpoint Clear" command to the debug tool, clearing any breakpoint at the given @@ -560,7 +560,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param address * The byte address of the breakpoint to clear. */ - virtual void clearBreakpoint(std::uint32_t address) override; + void clearBreakpoint(std::uint32_t address) override; /** * Issues the "Software Breakpoint Clear All" command to the debug tool, clearing all software breakpoints @@ -568,7 +568,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * If the debug session ended before any of the set breakpoints were cleared, this will *not* clear them. */ - virtual void clearAllBreakpoints() override; + void clearAllBreakpoints() override; /** * Reads gernal purpose registers from the target. @@ -576,14 +576,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param registerIds * @return */ - virtual Targets::TargetRegisters readGeneralPurposeRegisters(std::set registerIds) override; + Targets::TargetRegisters readGeneralPurposeRegisters(std::set registerIds) override; /** * Writes general purpose registers to target. * * @param registers */ - virtual void writeGeneralPurposeRegisters(const Targets::TargetRegisters& registers) override; + void writeGeneralPurposeRegisters(const Targets::TargetRegisters& registers) override; /** * This is an overloaded method. @@ -595,7 +595,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param bytes * @return */ - virtual Targets::TargetMemoryBuffer readMemory( + Targets::TargetMemoryBuffer readMemory( Targets::TargetMemoryType memoryType, std::uint32_t startAddress, std::uint32_t bytes @@ -610,7 +610,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param startAddress * @param buffer */ - virtual void writeMemory( + void writeMemory( Targets::TargetMemoryType memoryType, std::uint32_t startAddress, const Targets::TargetMemoryBuffer& buffer @@ -621,6 +621,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * @return */ - virtual Targets::TargetState getTargetState() override; + Targets::TargetState getTargetState() override; }; } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp index 16399f3e..5fbe5bb1 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp @@ -10,21 +10,21 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr class BreakEvent: public AvrEvent { private: - std::uint32_t programCounter; - Targets::TargetBreakCause breakCause; + std::uint32_t programCounter = 0; + Targets::TargetBreakCause breakCause = Targets::TargetBreakCause::UNKNOWN; void init(const AvrEvent& event); public: - BreakEvent(const AvrEvent& event) { + explicit BreakEvent(const AvrEvent& event) { this->init(event); } - std::uint32_t getProgramCounter() { + [[nodiscard]] std::uint32_t getProgramCounter() const { return this->programCounter; } - Targets::TargetBreakCause getBreakCause() { + [[nodiscard]] Targets::TargetBreakCause getBreakCause() const { return this->breakCause; } }; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp index 06fe7226..653eafe2 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp @@ -7,13 +7,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame class Avr8GenericResponseFrame: public AvrResponseFrame { public: - Avr8GenericResponseFrame(const std::vector& AVRResponses): AvrResponseFrame(AVRResponses) {} - Avr8GenericResponseFrame() {} + Avr8GenericResponseFrame() = default; + explicit Avr8GenericResponseFrame(const std::vector& AVRResponses) + : AvrResponseFrame(AVRResponses) {} /** * See parent method. */ - std::vector getPayloadData() override { + [[nodiscard]] std::vector getPayloadData() override { /* * AVR8 data payloads are in little endian form and include two bytes before the data (response ID and * version byte) as well as an additional byte after the data, known as the 'status code'. @@ -27,5 +28,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame return data; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp index 4a2b642f..cea2eb98 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp @@ -8,8 +8,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame class GetDeviceId: public Avr8GenericResponseFrame { public: - GetDeviceId(const std::vector& AvrResponses): Avr8GenericResponseFrame(AvrResponses) {} - GetDeviceId() {} + GetDeviceId() = default; + explicit GetDeviceId(const std::vector& AvrResponses): Avr8GenericResponseFrame(AvrResponses) {} Targets::Microchip::Avr::TargetSignature extractSignature(Avr8PhysicalInterface physicalInterface) { auto payloadData = this->getPayloadData(); diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp index 55e2e0f0..585d17b8 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp @@ -10,8 +10,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame class GetProgramCounter: public Avr8GenericResponseFrame { public: - GetProgramCounter(const std::vector& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {} - GetProgramCounter() {} + GetProgramCounter() = default; + explicit GetProgramCounter(const std::vector& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {} std::uint32_t extractProgramCounter() { /* diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp index d9efc3ee..0a2f1241 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp @@ -8,8 +8,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame class ReadMemory: public Avr8GenericResponseFrame { public: - ReadMemory(const std::vector& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {} - ReadMemory() {} + ReadMemory() = default; + explicit ReadMemory(const std::vector& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {} Targets::TargetMemoryBuffer getMemoryBuffer() { /* @@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame return data; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.cpp index ea413093..f7b7e538 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.cpp @@ -35,4 +35,4 @@ void AvrResponseFrame::initFromRawFrame(const std::vector& rawFra auto& payload = this->getPayload(); payload.insert(payload.begin(), rawFrame.begin() + 4, rawFrame.end()); -} \ No newline at end of file +} diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp index e004a2d3..8b66b9d3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp @@ -24,7 +24,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr /** * Destination sub-protocol handler ID */ - ProtocolHandlerId protocolHandlerID; + ProtocolHandlerId protocolHandlerID = ProtocolHandlerId::AVR8_GENERIC; std::vector payload; @@ -48,12 +48,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr } public: + explicit AvrResponseFrame() = default; + explicit AvrResponseFrame(const std::vector& AVRResponses) { this->initFromAvrResponses(AVRResponses); } - explicit AvrResponseFrame() {} - /** * An AVRResponse contains a single fragment of an AvrResponseFrame. * @@ -63,11 +63,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr */ void initFromAvrResponses(const std::vector& avrResponses); - std::uint16_t getSequenceId() const { + [[nodiscard]] std::uint16_t getSequenceId() const { return this->sequenceID; } - ProtocolHandlerId getProtocolHandlerId() const { + [[nodiscard]] ProtocolHandlerId getProtocolHandlerId() const { return this->protocolHandlerID; } @@ -79,8 +79,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr return this->payload[0]; } - virtual std::vector getPayloadData() { - return this->getPayload(); + [[nodiscard]] virtual std::vector getPayloadData() { + return this->payload; } }; } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/DiscoveryResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/DiscoveryResponseFrame.hpp index f3599395..ca152494 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/DiscoveryResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/DiscoveryResponseFrame.hpp @@ -7,8 +7,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame class DiscoveryResponseFrame: public AvrResponseFrame { public: - DiscoveryResponseFrame(const std::vector& AVRResponses): AvrResponseFrame(AVRResponses) {} - DiscoveryResponseFrame() {} + DiscoveryResponseFrame() = default; + explicit DiscoveryResponseFrame(const std::vector& AVRResponses): AvrResponseFrame(AVRResponses) {} /** * See parent method. @@ -25,5 +25,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame return data; } }; - } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp index da4357da..6fb3532e 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp @@ -4,9 +4,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg { enum class ProtocolHandlerId: unsigned char { - Discovery = 0x00, - HouseKeeping = 0x01, - Avr8Generic = 0x12, - Avr32Generic = 0x13, + DISCOVERY = 0x00, + HOUSE_KEEPING = 0x01, + AVR8_GENERIC = 0x12, + AVR32_GENERIC = 0x13, }; -} \ No newline at end of file +} diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp index 631d9e4f..d396e3c8 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp @@ -89,4 +89,4 @@ std::vector EdbgInterface::requestA } return responses; -} \ No newline at end of file +} diff --git a/src/DebugToolDrivers/USB/HID/HidInterface.hpp b/src/DebugToolDrivers/USB/HID/HidInterface.hpp index 1919d400..1ff01197 100644 --- a/src/DebugToolDrivers/USB/HID/HidInterface.hpp +++ b/src/DebugToolDrivers/USB/HID/HidInterface.hpp @@ -65,7 +65,7 @@ namespace Bloom::Usb } public: - std::size_t getInputReportSize() { + std::size_t getInputReportSize() const { return this->inputReportSize; } diff --git a/src/DebugToolDrivers/USB/HID/hidapi.hpp b/src/DebugToolDrivers/USB/HID/hidapi.hpp index 0d8bf5b3..d14f3812 100644 --- a/src/DebugToolDrivers/USB/HID/hidapi.hpp +++ b/src/DebugToolDrivers/USB/HID/hidapi.hpp @@ -8,7 +8,8 @@ * * https://github.com/signal11/hidapi */ -struct hid_device_ { +struct hid_device_ +{ // Handle to the actual device. libusb_device_handle* device_handle; diff --git a/src/DebugToolDrivers/USB/Interface.cpp b/src/DebugToolDrivers/USB/Interface.cpp index 94215fac..53b10b9e 100644 --- a/src/DebugToolDrivers/USB/Interface.cpp +++ b/src/DebugToolDrivers/USB/Interface.cpp @@ -1,9 +1,7 @@ #include #include -#include #include "Interface.hpp" -#include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" using namespace Bloom::Usb; diff --git a/src/DebugToolDrivers/USB/Interface.hpp b/src/DebugToolDrivers/USB/Interface.hpp index 2a3fe95f..c2e0cda9 100644 --- a/src/DebugToolDrivers/USB/Interface.hpp +++ b/src/DebugToolDrivers/USB/Interface.hpp @@ -18,7 +18,7 @@ namespace Bloom::Usb std::uint16_t productId = 0; std::uint8_t number = 0; - std::string name = ""; + std::string name; bool initialised = false; bool claimed = false; @@ -52,11 +52,11 @@ namespace Bloom::Usb this->name = name; } - bool isClaimed() { + bool isClaimed() const { return this->claimed; } - bool isInitialised() { + bool isInitialised() const { return this->initialised; } diff --git a/src/DebugToolDrivers/USB/UsbDevice.hpp b/src/DebugToolDrivers/USB/UsbDevice.hpp index ea8d5956..47b948c2 100644 --- a/src/DebugToolDrivers/USB/UsbDevice.hpp +++ b/src/DebugToolDrivers/USB/UsbDevice.hpp @@ -26,8 +26,6 @@ namespace Bloom::Usb void close(); public: - void init(); - UsbDevice(std::uint16_t vendorId, std::uint16_t productId) { this->vendorId = vendorId; this->productId = productId; @@ -35,6 +33,8 @@ namespace Bloom::Usb ~UsbDevice() = default; + void init(); + [[nodiscard]] libusb_device* getLibUsbDevice() const { return this->libUsbDevice; } @@ -43,11 +43,11 @@ namespace Bloom::Usb this->libUsbDevice = libUsbDevice; } - std::uint16_t getVendorId() const { + [[nodiscard]] std::uint16_t getVendorId() const { return this->vendorId; } - std::uint16_t getProductId() const { + [[nodiscard]] std::uint16_t getProductId() const { return this->productId; } diff --git a/src/EventManager/EventListener.cpp b/src/EventManager/EventListener.cpp index 85e7bb59..2d7984e5 100644 --- a/src/EventManager/EventListener.cpp +++ b/src/EventManager/EventListener.cpp @@ -86,6 +86,7 @@ void EventListener::waitAndDispatch(int msTimeout) { if (msTimeout > 0) { this->eventQueueByEventTypeCV.wait_for(queueLock, std::chrono::milliseconds(msTimeout), eventsFound); + } else { this->eventQueueByEventTypeCV.wait(queueLock, eventsFound); } diff --git a/src/EventManager/EventManager.cpp b/src/EventManager/EventManager.cpp index f008d9d1..49061a88 100644 --- a/src/EventManager/EventManager.cpp +++ b/src/EventManager/EventManager.cpp @@ -4,7 +4,7 @@ using namespace Bloom; void EventManager::registerListener(std::shared_ptr listener) { auto registerListenersLock = std::unique_lock(this->registerListenerMutex); - this->registeredListeners.insert(std::pair(listener->getId(), listener)); + this->registeredListeners.insert(std::pair(listener->getId(), std::move(listener))); } void EventManager::deregisterListener(size_t listenerId) { @@ -12,10 +12,11 @@ void EventManager::deregisterListener(size_t listenerId) { this->registeredListeners.erase(listenerId); } -void EventManager::triggerEvent(std::shared_ptr event) { +void EventManager::triggerEvent(const std::shared_ptr& event) { auto registerListenersLock = std::unique_lock(this->registerListenerMutex); for(auto const& [listenerId, listener] : this->registeredListeners) { auto registeredEventTypes = listener->getRegisteredEventTypeNames(); + if (registeredEventTypes.contains(event->getName())) { listener->registerEvent(event); } diff --git a/src/EventManager/EventManager.hpp b/src/EventManager/EventManager.hpp index 10fd2c69..3c18a4dd 100644 --- a/src/EventManager/EventManager.hpp +++ b/src/EventManager/EventManager.hpp @@ -53,7 +53,6 @@ namespace Bloom * * @param event */ - void triggerEvent(Events::SharedGenericEventPointer event); + void triggerEvent(const Events::SharedGenericEventPointer& event); }; - } diff --git a/src/EventManager/Events/BreakpointRemovedOnTarget.hpp b/src/EventManager/Events/BreakpointRemovedOnTarget.hpp index 782c873a..1ff5a95c 100644 --- a/src/EventManager/Events/BreakpointRemovedOnTarget.hpp +++ b/src/EventManager/Events/BreakpointRemovedOnTarget.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "BreakpointRemovedOnTarget"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return BreakpointRemovedOnTarget::name; } }; diff --git a/src/EventManager/Events/BreakpointSetOnTarget.hpp b/src/EventManager/Events/BreakpointSetOnTarget.hpp index 7f5c9bf3..a8ca2615 100644 --- a/src/EventManager/Events/BreakpointSetOnTarget.hpp +++ b/src/EventManager/Events/BreakpointSetOnTarget.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "BreakpointSetOnTarget"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return BreakpointSetOnTarget::name; } }; diff --git a/src/EventManager/Events/DebugServerThreadStateChanged.hpp b/src/EventManager/Events/DebugServerThreadStateChanged.hpp index deffdea8..08922d5f 100644 --- a/src/EventManager/Events/DebugServerThreadStateChanged.hpp +++ b/src/EventManager/Events/DebugServerThreadStateChanged.hpp @@ -12,15 +12,15 @@ namespace Bloom::Events private: ThreadState state; public: - DebugServerThreadStateChanged(ThreadState state): state(state) {}; + explicit DebugServerThreadStateChanged(ThreadState state): state(state) {}; static inline const std::string name = "DebugServerThreadStateChanged"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return DebugServerThreadStateChanged::name; } - ThreadState getState() const { + [[nodiscard]] ThreadState getState() const { return this->state; } }; diff --git a/src/EventManager/Events/DebugSessionFinished.hpp b/src/EventManager/Events/DebugSessionFinished.hpp index ae6c858a..7ef20568 100644 --- a/src/EventManager/Events/DebugSessionFinished.hpp +++ b/src/EventManager/Events/DebugSessionFinished.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "DebugSessionFinished"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return DebugSessionFinished::name; } }; diff --git a/src/EventManager/Events/DebugSessionStarted.hpp b/src/EventManager/Events/DebugSessionStarted.hpp index 29b87752..6a7b5e9e 100644 --- a/src/EventManager/Events/DebugSessionStarted.hpp +++ b/src/EventManager/Events/DebugSessionStarted.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "DebugSessionStarted"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return DebugSessionStarted::name; } }; diff --git a/src/EventManager/Events/ExtractTargetDescriptor.hpp b/src/EventManager/Events/ExtractTargetDescriptor.hpp index 2c1be576..5685dddf 100644 --- a/src/EventManager/Events/ExtractTargetDescriptor.hpp +++ b/src/EventManager/Events/ExtractTargetDescriptor.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "ExtractTargetDescriptor"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return ExtractTargetDescriptor::name; } }; diff --git a/src/EventManager/Events/InsightThreadStateChanged.hpp b/src/EventManager/Events/InsightThreadStateChanged.hpp index 420496ac..559ec6ec 100644 --- a/src/EventManager/Events/InsightThreadStateChanged.hpp +++ b/src/EventManager/Events/InsightThreadStateChanged.hpp @@ -12,11 +12,11 @@ namespace Bloom::Events private: ThreadState state; public: - InsightThreadStateChanged(ThreadState state): state(state) {}; + explicit InsightThreadStateChanged(ThreadState state): state(state) {}; static inline const std::string name = "InsightThreadStateChanged"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return InsightThreadStateChanged::name; } diff --git a/src/EventManager/Events/MemoryRetrievedFromTarget.hpp b/src/EventManager/Events/MemoryRetrievedFromTarget.hpp index ccdebfde..07278e57 100644 --- a/src/EventManager/Events/MemoryRetrievedFromTarget.hpp +++ b/src/EventManager/Events/MemoryRetrievedFromTarget.hpp @@ -13,7 +13,7 @@ namespace Bloom::Events static inline const std::string name = "MemoryRetrievedFromTarget"; Targets::TargetMemoryBuffer data; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return MemoryRetrievedFromTarget::name; } }; diff --git a/src/EventManager/Events/MemoryWrittenToTarget.hpp b/src/EventManager/Events/MemoryWrittenToTarget.hpp index 2554bb1c..9c9b2715 100644 --- a/src/EventManager/Events/MemoryWrittenToTarget.hpp +++ b/src/EventManager/Events/MemoryWrittenToTarget.hpp @@ -12,7 +12,7 @@ namespace Bloom::Events public: static inline const std::string name = "MemoryWrittenToTarget"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return MemoryWrittenToTarget::name; } diff --git a/src/EventManager/Events/ProgramCounterSetOnTarget.hpp b/src/EventManager/Events/ProgramCounterSetOnTarget.hpp index d9eed22d..545aaa54 100644 --- a/src/EventManager/Events/ProgramCounterSetOnTarget.hpp +++ b/src/EventManager/Events/ProgramCounterSetOnTarget.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "ProgramCounterSetOnTarget"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return ProgramCounterSetOnTarget::name; } }; diff --git a/src/EventManager/Events/RegistersRetrievedFromTarget.hpp b/src/EventManager/Events/RegistersRetrievedFromTarget.hpp index 1339e560..6eb483dd 100644 --- a/src/EventManager/Events/RegistersRetrievedFromTarget.hpp +++ b/src/EventManager/Events/RegistersRetrievedFromTarget.hpp @@ -13,7 +13,7 @@ namespace Bloom::Events static inline const std::string name = "RegistersRetrievedFromTarget"; Targets::TargetRegisters registers; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return RegistersRetrievedFromTarget::name; } }; diff --git a/src/EventManager/Events/RegistersWrittenToTarget.hpp b/src/EventManager/Events/RegistersWrittenToTarget.hpp index 5fdd2a57..082b96f1 100644 --- a/src/EventManager/Events/RegistersWrittenToTarget.hpp +++ b/src/EventManager/Events/RegistersWrittenToTarget.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "RegistersWrittenToTarget"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return RegistersWrittenToTarget::name; } }; diff --git a/src/EventManager/Events/RemoveBreakpointOnTarget.hpp b/src/EventManager/Events/RemoveBreakpointOnTarget.hpp index 668d6908..605f5030 100644 --- a/src/EventManager/Events/RemoveBreakpointOnTarget.hpp +++ b/src/EventManager/Events/RemoveBreakpointOnTarget.hpp @@ -12,10 +12,9 @@ namespace Bloom::Events { public: static inline const std::string name = "RemoveBreakpointOnTarget"; - std::uint32_t address; Targets::TargetBreakpoint breakpoint; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return RemoveBreakpointOnTarget::name; } }; diff --git a/src/EventManager/Events/ReportTargetControllerState.hpp b/src/EventManager/Events/ReportTargetControllerState.hpp index 767e4476..547c32a5 100644 --- a/src/EventManager/Events/ReportTargetControllerState.hpp +++ b/src/EventManager/Events/ReportTargetControllerState.hpp @@ -13,7 +13,7 @@ namespace Bloom::Events static inline const std::string name = "ReportTargetControllerState"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return ReportTargetControllerState::name; } }; diff --git a/src/EventManager/Events/ResetTarget.hpp b/src/EventManager/Events/ResetTarget.hpp index db5ac783..eebc72ee 100644 --- a/src/EventManager/Events/ResetTarget.hpp +++ b/src/EventManager/Events/ResetTarget.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "ResetTargetEvent"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return ResetTarget::name; } }; diff --git a/src/EventManager/Events/ResumeTargetExecution.hpp b/src/EventManager/Events/ResumeTargetExecution.hpp index 81753edf..b417313d 100644 --- a/src/EventManager/Events/ResumeTargetExecution.hpp +++ b/src/EventManager/Events/ResumeTargetExecution.hpp @@ -13,11 +13,11 @@ namespace Bloom::Events static inline const std::string name = "ResumeTargetExecutionEvent"; std::optional fromProgramCounter; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return ResumeTargetExecution::name; } ResumeTargetExecution() = default; - ResumeTargetExecution(std::uint32_t fromProgramCounter): fromProgramCounter(fromProgramCounter) {}; + explicit ResumeTargetExecution(std::uint32_t fromProgramCounter): fromProgramCounter(fromProgramCounter) {}; }; } diff --git a/src/EventManager/Events/RetrieveMemoryFromTarget.hpp b/src/EventManager/Events/RetrieveMemoryFromTarget.hpp index cac6a9e3..8e968709 100644 --- a/src/EventManager/Events/RetrieveMemoryFromTarget.hpp +++ b/src/EventManager/Events/RetrieveMemoryFromTarget.hpp @@ -13,10 +13,10 @@ namespace Bloom::Events public: static inline const std::string name = "RetrieveMemoryFromTarget"; Targets::TargetMemoryType memoryType = Targets::TargetMemoryType::RAM; - std::uint32_t startAddress; - std::uint32_t bytes; + std::uint32_t startAddress = 0; + std::uint32_t bytes = 0; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return RetrieveMemoryFromTarget::name; } }; diff --git a/src/EventManager/Events/RetrieveRegistersFromTarget.hpp b/src/EventManager/Events/RetrieveRegistersFromTarget.hpp index bc93e910..4c1e03a0 100644 --- a/src/EventManager/Events/RetrieveRegistersFromTarget.hpp +++ b/src/EventManager/Events/RetrieveRegistersFromTarget.hpp @@ -13,7 +13,7 @@ namespace Bloom::Events static inline const std::string name = "RetrieveRegistersFromTarget"; Targets::TargetRegisterDescriptors descriptors; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return RetrieveRegistersFromTarget::name; } }; diff --git a/src/EventManager/Events/RetrieveTargetPinStates.hpp b/src/EventManager/Events/RetrieveTargetPinStates.hpp index ab38cfec..f0889aa1 100644 --- a/src/EventManager/Events/RetrieveTargetPinStates.hpp +++ b/src/EventManager/Events/RetrieveTargetPinStates.hpp @@ -10,9 +10,9 @@ namespace Bloom::Events { public: static inline const std::string name = "RetrieveTargetPinStates"; - int variantId; + int variantId = 0; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return RetrieveTargetPinStates::name; } }; diff --git a/src/EventManager/Events/SetBreakpointOnTarget.hpp b/src/EventManager/Events/SetBreakpointOnTarget.hpp index 397b1a36..37353367 100644 --- a/src/EventManager/Events/SetBreakpointOnTarget.hpp +++ b/src/EventManager/Events/SetBreakpointOnTarget.hpp @@ -12,10 +12,9 @@ namespace Bloom::Events { public: static inline const std::string name = "SetBreakpointOnTarget"; - std::uint32_t address; Targets::TargetBreakpoint breakpoint; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return SetBreakpointOnTarget::name; } }; diff --git a/src/EventManager/Events/SetProgramCounterOnTarget.hpp b/src/EventManager/Events/SetProgramCounterOnTarget.hpp index 16845e20..db75bc5d 100644 --- a/src/EventManager/Events/SetProgramCounterOnTarget.hpp +++ b/src/EventManager/Events/SetProgramCounterOnTarget.hpp @@ -11,9 +11,9 @@ namespace Bloom::Events { public: static inline const std::string name = "SetProgramCounterOnTarget"; - std::uint32_t address; + std::uint32_t address = 0; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return SetProgramCounterOnTarget::name; } }; diff --git a/src/EventManager/Events/SetTargetPinState.hpp b/src/EventManager/Events/SetTargetPinState.hpp index 3dfcf026..6f96d65d 100644 --- a/src/EventManager/Events/SetTargetPinState.hpp +++ b/src/EventManager/Events/SetTargetPinState.hpp @@ -11,11 +11,11 @@ namespace Bloom::Events { public: static inline const std::string name = "SetTargetPinState"; - int variantId; + int variantId = 0; Targets::TargetPinDescriptor pinDescriptor; Targets::TargetPinState pinState; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return SetTargetPinState::name; } }; diff --git a/src/EventManager/Events/ShutdownApplication.hpp b/src/EventManager/Events/ShutdownApplication.hpp index b210ac1b..b429b244 100644 --- a/src/EventManager/Events/ShutdownApplication.hpp +++ b/src/EventManager/Events/ShutdownApplication.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "ShutdownApplicationEvent"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return ShutdownApplication::name; } }; diff --git a/src/EventManager/Events/ShutdownDebugServer.hpp b/src/EventManager/Events/ShutdownDebugServer.hpp index 7f724cd6..0c8c3922 100644 --- a/src/EventManager/Events/ShutdownDebugServer.hpp +++ b/src/EventManager/Events/ShutdownDebugServer.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "ShutdownDebugServer"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return ShutdownDebugServer::name; } }; diff --git a/src/EventManager/Events/ShutdownTargetController.hpp b/src/EventManager/Events/ShutdownTargetController.hpp index ade0b446..4ce1df57 100644 --- a/src/EventManager/Events/ShutdownTargetController.hpp +++ b/src/EventManager/Events/ShutdownTargetController.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "ShutdownTargetControllerEvent"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return ShutdownTargetController::name; } }; diff --git a/src/EventManager/Events/StepTargetExecution.hpp b/src/EventManager/Events/StepTargetExecution.hpp index 8e316dd6..9ac0d121 100644 --- a/src/EventManager/Events/StepTargetExecution.hpp +++ b/src/EventManager/Events/StepTargetExecution.hpp @@ -13,11 +13,11 @@ namespace Bloom::Events static inline const std::string name = "StepTargetExecution"; std::optional fromProgramCounter; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return StepTargetExecution::name; } StepTargetExecution() = default; - StepTargetExecution(std::uint32_t fromProgramCounter): fromProgramCounter(fromProgramCounter) {}; + explicit StepTargetExecution(std::uint32_t fromProgramCounter): fromProgramCounter(fromProgramCounter) {}; }; } diff --git a/src/EventManager/Events/StopTargetExecution.hpp b/src/EventManager/Events/StopTargetExecution.hpp index eeb5227b..73d82606 100644 --- a/src/EventManager/Events/StopTargetExecution.hpp +++ b/src/EventManager/Events/StopTargetExecution.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "StopTargetEvent"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return StopTargetExecution::name; } }; diff --git a/src/EventManager/Events/TargetControllerErrorOccurred.hpp b/src/EventManager/Events/TargetControllerErrorOccurred.hpp index 30941332..23fa4bda 100644 --- a/src/EventManager/Events/TargetControllerErrorOccurred.hpp +++ b/src/EventManager/Events/TargetControllerErrorOccurred.hpp @@ -13,7 +13,7 @@ namespace Bloom::Events TargetControllerErrorOccurred() = default; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return TargetControllerErrorOccurred::name; } }; diff --git a/src/EventManager/Events/TargetControllerStateReported.hpp b/src/EventManager/Events/TargetControllerStateReported.hpp index 1d848285..98e33e1d 100644 --- a/src/EventManager/Events/TargetControllerStateReported.hpp +++ b/src/EventManager/Events/TargetControllerStateReported.hpp @@ -12,11 +12,11 @@ namespace Bloom::Events public: TargetControllerState state; - TargetControllerStateReported(TargetControllerState state): state(state) {}; + explicit TargetControllerStateReported(TargetControllerState state): state(state) {}; static inline const std::string name = "TargetControllerStateReported"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return TargetControllerStateReported::name; } }; diff --git a/src/EventManager/Events/TargetControllerThreadStateChanged.hpp b/src/EventManager/Events/TargetControllerThreadStateChanged.hpp index 4faea58e..53131872 100644 --- a/src/EventManager/Events/TargetControllerThreadStateChanged.hpp +++ b/src/EventManager/Events/TargetControllerThreadStateChanged.hpp @@ -13,11 +13,11 @@ namespace Bloom::Events ThreadState state; public: - TargetControllerThreadStateChanged(ThreadState state): state(state) {}; + explicit TargetControllerThreadStateChanged(ThreadState state): state(state) {}; static inline const std::string name = "TargetControllerThreadStateChanged"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return TargetControllerThreadStateChanged::name; } diff --git a/src/EventManager/Events/TargetDescriptorExtracted.hpp b/src/EventManager/Events/TargetDescriptorExtracted.hpp index 7fc67c8b..22b89f06 100644 --- a/src/EventManager/Events/TargetDescriptorExtracted.hpp +++ b/src/EventManager/Events/TargetDescriptorExtracted.hpp @@ -13,7 +13,7 @@ namespace Bloom::Events static inline const std::string name = "TargetDescriptorExtracted"; Targets::TargetDescriptor targetDescriptor; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return TargetDescriptorExtracted::name; } }; diff --git a/src/EventManager/Events/TargetExecutionResumed.hpp b/src/EventManager/Events/TargetExecutionResumed.hpp index d1361e6e..ef47a322 100644 --- a/src/EventManager/Events/TargetExecutionResumed.hpp +++ b/src/EventManager/Events/TargetExecutionResumed.hpp @@ -13,7 +13,7 @@ namespace Bloom::Events TargetExecutionResumed() = default; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return TargetExecutionResumed::name; } }; diff --git a/src/EventManager/Events/TargetExecutionStopped.hpp b/src/EventManager/Events/TargetExecutionStopped.hpp index bd0886e7..6b4a81e6 100644 --- a/src/EventManager/Events/TargetExecutionStopped.hpp +++ b/src/EventManager/Events/TargetExecutionStopped.hpp @@ -18,7 +18,7 @@ namespace Bloom::Events TargetExecutionStopped(std::uint32_t programCounter, Targets::TargetBreakCause breakCause) : programCounter(programCounter), breakCause(breakCause) {} - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return TargetExecutionStopped::name; } }; diff --git a/src/EventManager/Events/TargetIoPortsUpdated.hpp b/src/EventManager/Events/TargetIoPortsUpdated.hpp index eb5bd7b9..ed883447 100644 --- a/src/EventManager/Events/TargetIoPortsUpdated.hpp +++ b/src/EventManager/Events/TargetIoPortsUpdated.hpp @@ -11,7 +11,7 @@ namespace Bloom::Events public: static inline const std::string name = "TargetIoPortsUpdated"; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return TargetIoPortsUpdated::name; } }; diff --git a/src/EventManager/Events/TargetPinStatesRetrieved.hpp b/src/EventManager/Events/TargetPinStatesRetrieved.hpp index bf238b9f..cbbd9da8 100644 --- a/src/EventManager/Events/TargetPinStatesRetrieved.hpp +++ b/src/EventManager/Events/TargetPinStatesRetrieved.hpp @@ -12,10 +12,10 @@ namespace Bloom::Events { public: static inline const std::string name = "TargetPinStatesRetrieved"; - int variantId; + int variantId = 0; std::map pinSatesByNumber; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return TargetPinStatesRetrieved::name; } }; diff --git a/src/EventManager/Events/WriteMemoryToTarget.hpp b/src/EventManager/Events/WriteMemoryToTarget.hpp index 434d5f7e..872fca6c 100644 --- a/src/EventManager/Events/WriteMemoryToTarget.hpp +++ b/src/EventManager/Events/WriteMemoryToTarget.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "Event.hpp" #include "src/Targets/TargetMemory.hpp" @@ -12,11 +13,11 @@ namespace Bloom::Events { public: static inline const std::string name = "WriteMemoryToTarget"; - Targets::TargetMemoryType memoryType; - std::uint32_t startAddress; + Targets::TargetMemoryType memoryType = Targets::TargetMemoryType::RAM; + std::uint32_t startAddress = 0; Targets::TargetMemoryBuffer buffer; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return WriteMemoryToTarget::name; } @@ -24,7 +25,7 @@ namespace Bloom::Events WriteMemoryToTarget( Targets::TargetMemoryType memoryType, std::uint32_t startAddress, - const Targets::TargetMemoryBuffer& buffer - ): memoryType(memoryType), startAddress(startAddress), buffer(buffer) {}; + Targets::TargetMemoryBuffer buffer + ): memoryType(memoryType), startAddress(startAddress), buffer(std::move(buffer)) {}; }; } diff --git a/src/EventManager/Events/WriteRegistersToTarget.hpp b/src/EventManager/Events/WriteRegistersToTarget.hpp index 666c5d5e..e67f252f 100644 --- a/src/EventManager/Events/WriteRegistersToTarget.hpp +++ b/src/EventManager/Events/WriteRegistersToTarget.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "Event.hpp" #include "src/Targets/TargetRegister.hpp" @@ -13,11 +14,11 @@ namespace Bloom::Events static inline const std::string name = "WriteRegistersToTarget"; Targets::TargetRegisters registers; - std::string getName() const override { + [[nodiscard]] std::string getName() const override { return WriteRegistersToTarget::name; } WriteRegistersToTarget() = default; - WriteRegistersToTarget(const Targets::TargetRegisters& registers): registers(registers) {}; + explicit WriteRegistersToTarget(Targets::TargetRegisters registers): registers(std::move(registers)) {}; }; } diff --git a/src/Exceptions/DebugServerInterrupted.hpp b/src/Exceptions/DebugServerInterrupted.hpp index 3abe1069..7f08057f 100644 --- a/src/Exceptions/DebugServerInterrupted.hpp +++ b/src/Exceptions/DebugServerInterrupted.hpp @@ -1,12 +1,12 @@ #pragma once #include "Exception.hpp" + namespace Bloom::Exceptions { class DebugServerInterrupted: public Exception { public: explicit DebugServerInterrupted() = default; - }; } diff --git a/src/Exceptions/Exception.hpp b/src/Exceptions/Exception.hpp index 9765e86c..3c0fe02a 100644 --- a/src/Exceptions/Exception.hpp +++ b/src/Exceptions/Exception.hpp @@ -28,4 +28,4 @@ namespace Bloom::Exceptions return this->message; } }; -} \ No newline at end of file +} diff --git a/src/Exceptions/InvalidConfig.hpp b/src/Exceptions/InvalidConfig.hpp index 87907adb..a99e9f3f 100644 --- a/src/Exceptions/InvalidConfig.hpp +++ b/src/Exceptions/InvalidConfig.hpp @@ -1,6 +1,7 @@ #pragma once #include "Exception.hpp" + namespace Bloom::Exceptions { class InvalidConfig: public Exception diff --git a/src/Exceptions/TargetControllerStartupFailure.hpp b/src/Exceptions/TargetControllerStartupFailure.hpp index 2b71fc75..7c4c524c 100644 --- a/src/Exceptions/TargetControllerStartupFailure.hpp +++ b/src/Exceptions/TargetControllerStartupFailure.hpp @@ -1,6 +1,7 @@ #pragma once #include "Exception.hpp" + namespace Bloom::Exceptions { class TargetControllerStartupFailure: public Exception diff --git a/src/Helpers/BiMap.hpp b/src/Helpers/BiMap.hpp index 9a50345a..479fdc55 100644 --- a/src/Helpers/BiMap.hpp +++ b/src/Helpers/BiMap.hpp @@ -20,8 +20,8 @@ namespace Bloom class BiMap { private: - std::unordered_map map; - std::unordered_map::iterator> flippedMap; + std::unordered_map map = {}; + std::unordered_map::iterator> flippedMap = {}; public: BiMap(std::initializer_list> elements) { @@ -68,4 +68,4 @@ namespace Bloom return this->map; } }; -} \ No newline at end of file +} diff --git a/src/Helpers/EventNotifier.hpp b/src/Helpers/EventNotifier.hpp index a9c1bc35..42d685e6 100644 --- a/src/Helpers/EventNotifier.hpp +++ b/src/Helpers/EventNotifier.hpp @@ -56,7 +56,7 @@ namespace Bloom } } - int getFileDescriptor() { + int getFileDescriptor() const { return this->fileDescriptor; } diff --git a/src/Helpers/Paths.hpp b/src/Helpers/Paths.hpp index 6e6f9ce0..bd85a822 100644 --- a/src/Helpers/Paths.hpp +++ b/src/Helpers/Paths.hpp @@ -31,13 +31,12 @@ namespace Bloom * files such as QT stylesheets and UI templates. * @return */ - static inline const std::string compiledResourcesPath() { + static inline std::string compiledResourcesPath() { #ifdef BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE return std::string(BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE); #else return std::string(":/compiled"); #endif } - }; } diff --git a/src/Helpers/SyncSafe.hpp b/src/Helpers/SyncSafe.hpp index b4064a3d..b6856cae 100644 --- a/src/Helpers/SyncSafe.hpp +++ b/src/Helpers/SyncSafe.hpp @@ -20,11 +20,11 @@ namespace Bloom private: std::mutex mutex; Type value; + public: SyncSafe() = default; - explicit SyncSafe(Type value): value(value) { - }; + explicit SyncSafe(Type value): value(value) {}; void setValue(Type value) { auto lock = std::unique_lock(this->mutex); @@ -52,4 +52,4 @@ namespace Bloom return std::unique_lock(this->mutex); }; }; -} \ No newline at end of file +} diff --git a/src/SignalHandler/SignalHandler.hpp b/src/SignalHandler/SignalHandler.hpp index abf20213..860b6a1e 100644 --- a/src/SignalHandler/SignalHandler.hpp +++ b/src/SignalHandler/SignalHandler.hpp @@ -36,7 +36,7 @@ namespace Bloom * * @return */ - sigset_t getRegisteredSignalSet() const; + [[nodiscard]] sigset_t getRegisteredSignalSet() const; /** * Handler for SIGINT, SIGTERM, etc signals. @@ -47,7 +47,7 @@ namespace Bloom void triggerApplicationShutdown(); public: - SignalHandler(EventManager& eventManager): eventManager(eventManager) {}; + explicit SignalHandler(EventManager& eventManager): eventManager(eventManager) {}; /** * Entry point for SignalHandler thread. diff --git a/src/TargetController/TargetController.hpp b/src/TargetController/TargetController.hpp index f053f2de..efa00b74 100644 --- a/src/TargetController/TargetController.hpp +++ b/src/TargetController/TargetController.hpp @@ -224,7 +224,7 @@ namespace Bloom void emitErrorEvent(int correlationId); public: - TargetController(EventManager& eventManager): eventManager(eventManager) {}; + explicit TargetController(EventManager& eventManager): eventManager(eventManager) {}; void setApplicationConfig(const ApplicationConfig& applicationConfig) { this->applicationConfig = applicationConfig; diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index ed0073aa..4af4a5bc 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -669,7 +669,7 @@ std::uint32_t Avr8::getProgramCounter() { TargetRegister Avr8::getProgramCounterRegister() { auto programCounter = this->getProgramCounter(); - return TargetRegister(TargetRegisterType::PROGRAM_COUNTER, { + return TargetRegister(TargetRegisterDescriptor(TargetRegisterType::PROGRAM_COUNTER), { static_cast(programCounter), static_cast(programCounter >> 8), static_cast(programCounter >> 16), diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp index 052a157d..c2051119 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8Interface.hpp" #include "src/Targets/Microchip/AVR/Target.hpp" @@ -22,7 +23,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit { protected: DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface* avr8Interface = nullptr; - std::string name = ""; + std::string name; std::optional family; std::optional targetDescriptionFile; std::optional targetParameters; @@ -60,7 +61,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit public: explicit Avr8() = default; - Avr8(const std::string& name, const TargetSignature& signature): name(name) { + Avr8(std::string name, const TargetSignature& signature): name(std::move(name)) { this->id = signature; this->loadTargetDescriptionFile(); }; @@ -74,7 +75,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit void preActivationConfigure(const TargetConfig& targetConfig) override; void postActivationConfigure() override; - virtual void postPromotionConfigure() override; + void postPromotionConfigure() override; void activate() override; void deactivate() override; @@ -108,13 +109,13 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit * * @return */ - virtual std::unique_ptr promote() override; + std::unique_ptr promote() override; std::string getName() const override { return this->name; } - virtual TargetDescriptor getDescriptor() override; + TargetDescriptor getDescriptor() override; void run() override; void stop() override; @@ -125,38 +126,38 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit void removeBreakpoint(std::uint32_t address) override; void clearAllBreakpoints() override; - virtual TargetRegisters readGeneralPurposeRegisters(std::set registerIds) override; - virtual void writeRegisters(const TargetRegisters& registers) override; - virtual TargetRegisters readRegisters(const TargetRegisterDescriptors& descriptors) override; + TargetRegisters readGeneralPurposeRegisters(std::set registerIds) override; + void writeRegisters(const TargetRegisters& registers) override; + TargetRegisters readRegisters(const TargetRegisterDescriptors& descriptors) override; - virtual TargetMemoryBuffer readMemory( + TargetMemoryBuffer readMemory( TargetMemoryType memoryType, std::uint32_t startAddress, std::uint32_t bytes ) override; - virtual void writeMemory( + void writeMemory( TargetMemoryType memoryType, std::uint32_t startAddress, const TargetMemoryBuffer& buffer ) override; - virtual TargetState getState() override; + TargetState getState() override; - virtual std::uint32_t getProgramCounter() override; - virtual TargetRegister getProgramCounterRegister() override; - virtual void setProgramCounter(std::uint32_t programCounter) override; + std::uint32_t getProgramCounter() override; + TargetRegister getProgramCounterRegister() override; + void setProgramCounter(std::uint32_t programCounter) override; - virtual TargetRegister getStackPointerRegister() override; - virtual TargetRegister getStatusRegister() override; + TargetRegister getStackPointerRegister() override; + TargetRegister getStatusRegister() override; - virtual std::map getPinStates(int variantId) override; - virtual void setPinState( + std::map getPinStates(int variantId) override; + void setPinState( int variantId, const TargetPinDescriptor& pinDescriptor, const TargetPinState& state ) override; - virtual bool memoryAddressRangeClashesWithIoPortRegisters( + bool memoryAddressRangeClashesWithIoPortRegisters( TargetMemoryType memoryType, std::uint32_t startAddress, std::uint32_t endAddress diff --git a/src/Targets/Microchip/AVR/AVR8/Mega/Mega.hpp b/src/Targets/Microchip/AVR/AVR8/Mega/Mega.hpp index 8a89668d..2e7ff0ab 100644 --- a/src/Targets/Microchip/AVR/AVR8/Mega/Mega.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Mega/Mega.hpp @@ -9,9 +9,9 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit protected: public: - Mega(const Avr8& avr8): Avr8(avr8) {}; + explicit Mega(const Avr8& avr8): Avr8(avr8) {}; - virtual bool supportsPromotion() override { + bool supportsPromotion() override { return false; } }; diff --git a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp index f17496d2..909537df 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp @@ -139,7 +139,7 @@ TargetSignature TargetDescriptionFile::getTargetSignature() const { } Family TargetDescriptionFile::getFamily() const { - static auto familyNameToEnums = this->getFamilyNameToEnumMapping(); + static auto familyNameToEnums = TargetDescriptionFile::getFamilyNameToEnumMapping(); auto familyName = this->deviceElement.attributes().namedItem("family").nodeValue().toLower().toStdString(); if (familyName.empty()) { diff --git a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp index 105f9a1a..6024fd69 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp @@ -65,35 +65,35 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription * * @return */ - TargetSignature getTargetSignature() const; + [[nodiscard]] TargetSignature getTargetSignature() const; /** * Extracts the AVR8 target family from the target description XML. * * @return */ - Family getFamily() const; + [[nodiscard]] Family getFamily() const; - std::optional getFlashMemorySegment() const; - std::optional getRamMemorySegment() const; - std::optional getRegisterMemorySegment() const; - std::optional getEepromMemorySegment() const; - std::optional getFirstBootSectionMemorySegment() const; - std::optional getCpuRegisterGroup() const; - std::optional getBootLoadRegisterGroup() const; - std::optional getEepromRegisterGroup() const; + [[nodiscard]] std::optional getFlashMemorySegment() const; + [[nodiscard]] std::optional getRamMemorySegment() const; + [[nodiscard]] std::optional getRegisterMemorySegment() const; + [[nodiscard]] std::optional getEepromMemorySegment() const; + [[nodiscard]] std::optional getFirstBootSectionMemorySegment() const; + [[nodiscard]] std::optional getCpuRegisterGroup() const; + [[nodiscard]] std::optional getBootLoadRegisterGroup() const; + [[nodiscard]] std::optional getEepromRegisterGroup() const; - std::optional getStatusRegister() const; - std::optional getStackPointerRegister() const; - std::optional getStackPointerHighRegister() const; - std::optional getStackPointerLowRegister() const; - std::optional getOscillatorCalibrationRegister() const; - std::optional getSpmcsRegister() const; - std::optional getSpmcRegister() const; - std::optional getEepromAddressRegister() const; - std::optional getEepromAddressLowRegister() const; - std::optional getEepromAddressHighRegister() const; - std::optional getEepromDataRegister() const; - std::optional getEepromControlRegister() const; + [[nodiscard]] std::optional getStatusRegister() const; + [[nodiscard]] std::optional getStackPointerRegister() const; + [[nodiscard]] std::optional getStackPointerHighRegister() const; + [[nodiscard]] std::optional getStackPointerLowRegister() const; + [[nodiscard]] std::optional getOscillatorCalibrationRegister() const; + [[nodiscard]] std::optional getSpmcsRegister() const; + [[nodiscard]] std::optional getSpmcRegister() const; + [[nodiscard]] std::optional getEepromAddressRegister() const; + [[nodiscard]] std::optional getEepromAddressLowRegister() const; + [[nodiscard]] std::optional getEepromAddressHighRegister() const; + [[nodiscard]] std::optional getEepromDataRegister() const; + [[nodiscard]] std::optional getEepromControlRegister() const; }; } diff --git a/src/Targets/Microchip/AVR/AVR8/Tiny/Tiny.hpp b/src/Targets/Microchip/AVR/AVR8/Tiny/Tiny.hpp index 358d2cf8..5944023e 100644 --- a/src/Targets/Microchip/AVR/AVR8/Tiny/Tiny.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Tiny/Tiny.hpp @@ -7,9 +7,9 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit class Tiny: public Avr8 { public: - Tiny(const Avr8& avr8): Avr8(avr8) {}; + explicit Tiny(const Avr8& avr8): Avr8(avr8) {}; - virtual bool supportsPromotion() override { + bool supportsPromotion() override { return false; } }; diff --git a/src/Targets/Microchip/AVR/AVR8/XMega/XMega.hpp b/src/Targets/Microchip/AVR/AVR8/XMega/XMega.hpp index 27013114..3423864b 100644 --- a/src/Targets/Microchip/AVR/AVR8/XMega/XMega.hpp +++ b/src/Targets/Microchip/AVR/AVR8/XMega/XMega.hpp @@ -7,9 +7,9 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit class XMega: public Avr8 { public: - XMega(const Avr8& avr8): Avr8(avr8) {}; + explicit XMega(const Avr8& avr8): Avr8(avr8) {}; - virtual bool supportsPromotion() override { + bool supportsPromotion() override { return false; } }; diff --git a/src/Targets/Microchip/AVR/Target.hpp b/src/Targets/Microchip/AVR/Target.hpp index 4e408a91..a3c060ec 100644 --- a/src/Targets/Microchip/AVR/Target.hpp +++ b/src/Targets/Microchip/AVR/Target.hpp @@ -26,4 +26,4 @@ namespace Bloom::Targets::Microchip::Avr return this->getId().toHex(); } }; -} \ No newline at end of file +} diff --git a/src/Targets/Microchip/AVR/TargetSignature.hpp b/src/Targets/Microchip/AVR/TargetSignature.hpp index 699d3cd8..7a245d40 100644 --- a/src/Targets/Microchip/AVR/TargetSignature.hpp +++ b/src/Targets/Microchip/AVR/TargetSignature.hpp @@ -30,14 +30,14 @@ namespace Bloom::Targets::Microchip::Avr TargetSignature() = default; TargetSignature(unsigned char byteZero, unsigned char byteOne, unsigned char byteTwo) : byteZero(byteZero), byteOne(byteOne), byteTwo(byteTwo) {}; - TargetSignature(std::string hex) { + explicit TargetSignature(const std::string& hex) { auto signature = static_cast(std::stoul(hex, nullptr, 16)); this->byteZero = static_cast(signature >> 16); this->byteOne = static_cast(signature >> 8); this->byteTwo = static_cast(signature); } - std::string toHex() const { + [[nodiscard]] std::string toHex() const { std::stringstream stream; stream << std::hex << std::setfill('0'); stream << std::setw(2) << static_cast(this->byteZero); diff --git a/src/Targets/Target.cpp b/src/Targets/Target.cpp deleted file mode 100644 index 09b79650..00000000 --- a/src/Targets/Target.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "Target.hpp" diff --git a/src/Targets/Target.hpp b/src/Targets/Target.hpp index d34d920e..485dba40 100644 --- a/src/Targets/Target.hpp +++ b/src/Targets/Target.hpp @@ -39,9 +39,9 @@ namespace Bloom::Targets bool activated = false; public: - explicit Target() {} + explicit Target() = default; - bool isActivated() { + bool isActivated() const { return this->activated; } diff --git a/src/Targets/TargetBreakpoint.hpp b/src/Targets/TargetBreakpoint.hpp index dd74f343..1f7d8827 100644 --- a/src/Targets/TargetBreakpoint.hpp +++ b/src/Targets/TargetBreakpoint.hpp @@ -17,9 +17,8 @@ namespace Bloom::Targets /** * Byte address of the breakpoint. */ - TargetBreakpointAddress address; + TargetBreakpointAddress address = 0; bool disabled = false; }; } - diff --git a/src/Targets/TargetDescription/MemorySegment.hpp b/src/Targets/TargetDescription/MemorySegment.hpp index 9fcd4248..c250fb22 100644 --- a/src/Targets/TargetDescription/MemorySegment.hpp +++ b/src/Targets/TargetDescription/MemorySegment.hpp @@ -7,7 +7,8 @@ namespace Bloom::Targets::TargetDescription { - enum MemorySegmentType { + enum MemorySegmentType + { REGISTERS, IO, EEPROM, diff --git a/src/Targets/TargetDescription/README.md b/src/Targets/TargetDescription/README.md index 86def879..71818041 100644 --- a/src/Targets/TargetDescription/README.md +++ b/src/Targets/TargetDescription/README.md @@ -6,10 +6,10 @@ Bloom will have an associated TDF in Bloom's codebase. They can be found in `src The data held by TDFs is fundamental to Bloom's operation. The following is an incomplete list of some of the data extracted from TDFs: -- Target signatures -- Parameters for debug interfaces - Memory address space descriptions (including sections, offsets and sizes) - Register descriptions (including offsets and sizes) +- Parameters for debug interfaces +- Target signatures - Package variant descriptions - Package pinouts diff --git a/src/Targets/TargetRegister.hpp b/src/Targets/TargetRegister.hpp index c0f134ef..d6bd8546 100644 --- a/src/Targets/TargetRegister.hpp +++ b/src/Targets/TargetRegister.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -19,8 +20,8 @@ namespace Bloom::Targets std::optional id; TargetRegisterType type = TargetRegisterType::GENERAL_PURPOSE_REGISTER; - TargetRegisterDescriptor() {}; - TargetRegisterDescriptor(TargetRegisterType type): type(type) {}; + TargetRegisterDescriptor() = default; + explicit TargetRegisterDescriptor(TargetRegisterType type): type(type) {}; TargetRegisterDescriptor(IdType id, TargetRegisterType type): id(id), type(type) {}; bool operator==(const TargetRegisterDescriptor& other) const { @@ -30,27 +31,25 @@ namespace Bloom::Targets struct TargetRegister { - using IdType = size_t; - using ValueType = std::vector; - std::optional id; - ValueType value; + std::optional id; + std::vector value; TargetRegisterDescriptor descriptor; - TargetRegister(const ValueType& value): value(value) {}; + explicit TargetRegister(std::vector value): value(std::move(value)) {}; - TargetRegister(TargetRegisterDescriptor descriptor, const ValueType& value): value(value), + TargetRegister(TargetRegisterDescriptor descriptor, std::vector value): value(std::move(value)), descriptor(descriptor) {}; - TargetRegister(IdType id, const ValueType& value): id(id), value(value) { + TargetRegister(size_t id, std::vector value): id(id), value(std::move(value)) { this->descriptor.id = id; }; - IdType size() const { + [[nodiscard]] size_t size() const { return this->value.size(); } }; - using TargetRegisterMap = std::map; + using TargetRegisterMap = std::map; using TargetRegisters = std::vector; using TargetRegisterDescriptors = std::vector; } diff --git a/src/Targets/TargetState.hpp b/src/Targets/TargetState.hpp index d1294faa..68b8ee17 100644 --- a/src/Targets/TargetState.hpp +++ b/src/Targets/TargetState.hpp @@ -13,4 +13,3 @@ namespace Bloom::Targets } Q_DECLARE_METATYPE(Bloom::Targets::TargetState) -