diff --git a/CMakeLists.txt b/CMakeLists.txt index ec29d95e..5b2b4f23 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,7 @@ add_executable(Bloom # Debug servers src/DebugServers/DebugServer.cpp src/DebugServers/GdbRsp/GdbRspDebugServer.cpp + src/DebugServers/GdbRsp/GdbDebugServerConfig.cpp src/DebugServers/GdbRsp/AvrGdbRsp/AvrGdbRsp.cpp src/DebugServers/GdbRsp/Connection.cpp src/DebugServers/GdbRsp/CommandPackets/CommandPacket.cpp diff --git a/src/DebugServers/GdbRsp/GdbDebugServerConfig.cpp b/src/DebugServers/GdbRsp/GdbDebugServerConfig.cpp new file mode 100644 index 00000000..3d244013 --- /dev/null +++ b/src/DebugServers/GdbRsp/GdbDebugServerConfig.cpp @@ -0,0 +1,19 @@ +#include "GdbDebugServerConfig.hpp" + +namespace Bloom::DebugServers::Gdb +{ + GdbDebugServerConfig::GdbDebugServerConfig(const DebugServerConfig& debugServerConfig) + : DebugServerConfig(debugServerConfig) + { + if (debugServerConfig.jsonObject.contains("ipAddress")) { + this->listeningAddress = debugServerConfig.jsonObject.value("ipAddress").toString().toStdString(); + } + + if (debugServerConfig.jsonObject.contains("port")) { + const auto portValue = debugServerConfig.jsonObject.value("port"); + this->listeningPortNumber = static_cast( + portValue.isString() ? portValue.toString().toInt(nullptr, 10) : portValue.toInt() + ); + } + } +} diff --git a/src/DebugServers/GdbRsp/GdbDebugServerConfig.hpp b/src/DebugServers/GdbRsp/GdbDebugServerConfig.hpp new file mode 100644 index 00000000..e9814e88 --- /dev/null +++ b/src/DebugServers/GdbRsp/GdbDebugServerConfig.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "src/ProjectConfig.hpp" + +namespace Bloom::DebugServers::Gdb +{ + /** + * Extending the generic DebugServerConfig struct to accommodate GDB debug server configuration parameters. + */ + class GdbDebugServerConfig: public DebugServerConfig + { + public: + /** + * The port number for the GDB server to listen on. + * + * This parameter is optional. If not specified, the default value set here will be used. + */ + std::uint16_t listeningPortNumber = 1442; + + /** + * The address for the GDB server to listen on. + * + * This parameter is optional. If not specified, the default value set here will be used. + */ + std::string listeningAddress = "127.0.0.1"; + + explicit GdbDebugServerConfig(const DebugServerConfig& debugServerConfig); + }; +}