diff --git a/src/DebugServer/Gdb/GdbRspDebugServer.hpp b/src/DebugServer/Gdb/GdbRspDebugServer.hpp index 6e5964bd..b32aa8a0 100644 --- a/src/DebugServer/Gdb/GdbRspDebugServer.hpp +++ b/src/DebugServer/Gdb/GdbRspDebugServer.hpp @@ -493,11 +493,11 @@ namespace DebugServer::Gdb return std::make_unique(std::move(*(monitorCommand.release()))); } - #ifndef EXCLUDE_INSIGHT +#ifndef EXCLUDE_INSIGHT if (monitorCommand->command.find("insight") == 0) { return std::make_unique(std::move(*(monitorCommand.release()))); } - #endif +#endif return monitorCommand; } diff --git a/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.cpp b/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.cpp index 47367828..49fe6793 100644 --- a/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.cpp +++ b/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.cpp @@ -25,6 +25,8 @@ #include "TriggerModule/Registers/TriggerData1.hpp" #include "TriggerModule/Registers/MatchControl.hpp" +#include "src/Helpers/Array.hpp" + #include "src/Exceptions/Exception.hpp" #include "src/Exceptions/InvalidConfig.hpp" #include "src/Exceptions/InternalFatalErrorException.hpp" @@ -526,9 +528,10 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec return; } - this->writeProgramBuffer( - std::vector(this->debugModuleDescriptor.programBufferSize, Opcodes::Ebreak) - ); + static constexpr auto clearedBuffer = Array::repeat(Opcodes::Ebreak); + + assert(this->debugModuleDescriptor.programBufferSize <= DebugTranslator::MAX_PROGRAM_BUFFER_SIZE); + this->writeProgramBuffer({clearedBuffer.begin(), this->debugModuleDescriptor.programBufferSize}); } void DebugTranslator::executeFenceProgram() { diff --git a/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.hpp b/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.hpp index 43697ef8..0ab1ee8f 100644 --- a/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.hpp +++ b/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.hpp @@ -107,6 +107,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec private: static constexpr auto DEBUG_MODULE_RESPONSE_DELAY = std::chrono::microseconds{10}; static constexpr auto WORD_BYTE_SIZE = ::Targets::TargetMemorySize{4}; + static constexpr auto MAX_PROGRAM_BUFFER_SIZE = std::uint8_t{16}; DebugTransportModuleInterface& dtmInterface; const DebugTranslatorConfig& config; diff --git a/src/Helpers/Array.hpp b/src/Helpers/Array.hpp new file mode 100644 index 00000000..09eb12c9 --- /dev/null +++ b/src/Helpers/Array.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include +#include +#include + +class Array +{ +public: + template + static constexpr auto repeat(const ValueType& value) { + auto output = std::array{}; + output.fill(value); + return output; + } +};