diff --git a/Src/BeebWin.cpp b/Src/BeebWin.cpp index b1d0a72b..6382b60f 100644 --- a/Src/BeebWin.cpp +++ b/Src/BeebWin.cpp @@ -5375,6 +5375,9 @@ class _6502SimControl : public ISimulationControl { // Target utilities uint32_t htotl(uint32_t hostVal) override; uint32_t ttohl(uint32_t targetVal) override; + +private: + bool m_serverRunning{ false }; }; @@ -5486,6 +5489,7 @@ bool _6502SimControl::isServerRunning() { void _6502SimControl::setServerRunning(bool status) { // TODO: Implement setServerRunning functionality // ... + m_serverRunning = status; } // Target utilities @@ -5506,7 +5510,7 @@ void BeebWin::GdbStartServer() { static bool serverStarted{ false }; static _6502SimControl simControl = _6502SimControl(); - static GdbServer gdbServer(/*Simulation controller =*/&simControl, /*tcp port=*/51000); + static GdbServer gdbServer(/*Simulation controller =*/&simControl, /*tcp port=*/17901); if (serverStarted == false) { static std::thread gdbThread(&GdbServer::serverThread, gdbServer); diff --git a/Src/gdb_server/headers/rsp_connection.hpp b/Src/gdb_server/headers/rsp_connection.hpp index 03724015..39e7b4a8 100644 --- a/Src/gdb_server/headers/rsp_connection.hpp +++ b/Src/gdb_server/headers/rsp_connection.hpp @@ -65,7 +65,7 @@ class RspConnection { //! The port number to listen on - int portNum; + int m_portNum; //! The service name to listen on const char* serviceName; diff --git a/Src/gdb_server/rsp_connection.cpp b/Src/gdb_server/rsp_connection.cpp index 30773639..5011e106 100644 --- a/Src/gdb_server/rsp_connection.cpp +++ b/Src/gdb_server/rsp_connection.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -66,7 +65,7 @@ using namespace std; //! @param[in] _serviceName The service name to use (if PortNum == 0). //----------------------------------------------------------------------------- void RspConnection::rspInit(int _portNum, const char* _serviceName) { - portNum = _portNum; + m_portNum = _portNum; serviceName = _serviceName; m_clientFd = -1; } // init () @@ -103,8 +102,12 @@ bool RspConnection::rspConnectWindows() hints.ai_protocol = IPPROTO_TCP; hints.ai_flags = AI_PASSIVE; + constexpr uint8_t MAX_PORT_NUMBER_LEN{40}; + static char portNumber[MAX_PORT_NUMBER_LEN]; + snprintf(portNumber,MAX_PORT_NUMBER_LEN,"%d", m_portNum); + // Resolve the server address and port - iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result); + iResult = getaddrinfo("localhost", portNumber, &hints, &result); if (iResult != 0) { printf("getaddrinfo failed with error: %d\n", iResult); WSACleanup();