Tidied GDB RSP debug server

This commit is contained in:
Nav
2022-04-05 18:49:54 +01:00
parent e3beea6b40
commit b8e34b87d3
2 changed files with 67 additions and 43 deletions

View File

@@ -25,20 +25,16 @@
#include "src/EventManager/Events/TargetControllerStateReported.hpp"
#include "src/EventManager/Events/TargetExecutionStopped.hpp"
#include "src/Helpers/BiMap.hpp"
namespace Bloom::DebugServer::Gdb
{
/**
* The GdbRspDebugServer is an implementation of a GDB server using the GDB Remote Serial Protocol.
* The GdbRspDebugServer is an implementation of the GDB Remote Serial Protocol.
*
* This DebugServer employs TCP/IP sockets to interface with GDB clients. The listening address can be configured
* in the user's project config file.
* This server employs TCP/IP sockets to interface with GDB clients. The listening address and port can be
* configured in the user's project config file.
*
* See https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html for more info on the GDB Remote
* Serial Protocol.
*
* @TODO: This could do with some cleaning.
* See https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html for more info on the GDB Remote Serial
* Protocol.
*/
class GdbRspDebugServer: public ServerInterface
{
@@ -48,6 +44,15 @@ namespace Bloom::DebugServer::Gdb
EventListener& eventListener
);
GdbRspDebugServer() = delete;
virtual ~GdbRspDebugServer() = default;
GdbRspDebugServer(const GdbRspDebugServer& other) = delete;
GdbRspDebugServer(GdbRspDebugServer&& other) = delete;
GdbRspDebugServer& operator = (const GdbRspDebugServer& other) = delete;
GdbRspDebugServer& operator = (GdbRspDebugServer&& other) = delete;
[[nodiscard]] std::string getName() const override {
return "GDB Remote Serial Protocol DebugServer";
};
@@ -70,24 +75,25 @@ namespace Bloom::DebugServer::Gdb
void run() override;
protected:
std::optional<GdbDebugServerConfig> debugServerConfig;
/**
* User project configuration specific to the GDB RSP debug server.
*/
GdbDebugServerConfig debugServerConfig;
/**
* The DebugServerComponent's event listener.
*/
EventListener& eventListener;
/**
* EventNotifier object for interrupting blocking I/O operations.
*
* Extracted from this->eventListener.
*
* See documentation in src/DebugServer/README.md for more.
*/
EventNotifier* interruptEventNotifier = nullptr;
TargetControllerConsole targetControllerConsole = TargetControllerConsole(this->eventListener);
/**
* Listening socket address
*/
struct sockaddr_in socketAddress = {};
/**
* Listening socket file descriptor
*/
int serverSocketFileDescriptor = -1;
/**
* When waiting for a connection, we don't listen on the this->serverSocketFileDescriptor directly. Instead,
* we use an EpollInstance to monitor both this->serverSocketFileDescriptor and this->interruptEventNotifier.
@@ -102,9 +108,21 @@ namespace Bloom::DebugServer::Gdb
EpollInstance epollInstance = EpollInstance();
/**
* SO_REUSEADDR option value for listening socket.
* Passed to command handlers (see CommandPacket::handle()).
*
* See documentation in src/DebugServer/Gdb/README.md for more on how GDB commands are processed.
*/
int enableReuseAddressSocketOption = 1;
TargetControllerConsole targetControllerConsole = TargetControllerConsole(this->eventListener);
/**
* Listening socket address
*/
struct sockaddr_in socketAddress = {};
/**
* Listening socket file descriptor
*/
std::optional<int> serverSocketFileDescriptor;
/**
* When a connection with a GDB client is established, a new instance of the DebugSession class is created and