Small tweaks to port number extract in GDB RSP debug server.
Also included port and address configuration in template config file
This commit is contained in:
@@ -9,7 +9,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"debugServer": {
|
"debugServer": {
|
||||||
"name": "avr-gdb-rsp"
|
"name": "avr-gdb-rsp",
|
||||||
|
"ipAddress": "127.0.0.1",
|
||||||
|
"port": "1442"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,14 +15,17 @@ using namespace Exceptions;
|
|||||||
|
|
||||||
void GdbRspDebugServer::init() {
|
void GdbRspDebugServer::init() {
|
||||||
auto ipAddress = this->debugServerConfig.jsonObject.find("ipAddress")->toString().toStdString();
|
auto ipAddress = this->debugServerConfig.jsonObject.find("ipAddress")->toString().toStdString();
|
||||||
auto port = static_cast<std::uint16_t>(this->debugServerConfig.jsonObject.find("port")->toInt());
|
auto configPortJsonValue = this->debugServerConfig.jsonObject.find("port");
|
||||||
|
auto configPortValue = configPortJsonValue->isString()
|
||||||
|
? static_cast<std::uint16_t>(configPortJsonValue->toString().toInt(nullptr, 10))
|
||||||
|
: static_cast<std::uint16_t>(configPortJsonValue->toInt());
|
||||||
|
|
||||||
if (!ipAddress.empty()) {
|
if (!ipAddress.empty()) {
|
||||||
this->listeningAddress = ipAddress;
|
this->listeningAddress = ipAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port > 0) {
|
if (configPortValue > 0) {
|
||||||
this->listeningPortNumber = port;
|
this->listeningPortNumber = configPortValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->socketAddress.sin_family = AF_INET;
|
this->socketAddress.sin_family = AF_INET;
|
||||||
@@ -55,7 +58,8 @@ void GdbRspDebugServer::init() {
|
|||||||
sizeof(this->socketAddress)
|
sizeof(this->socketAddress)
|
||||||
) < 0
|
) < 0
|
||||||
) {
|
) {
|
||||||
throw Exception("Failed to bind address.");
|
throw Exception("Failed to bind address. The selected port number ("
|
||||||
|
+ std::to_string(this->listeningPortNumber) + ") may be in use.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this->serverSocketFileDescriptor = socketFileDescriptor;
|
this->serverSocketFileDescriptor = socketFileDescriptor;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Bloom::DebugServers::Gdb
|
|||||||
* This will be pulled from the user's project configuration, if set. Otherwise it will default to whatever is
|
* This will be pulled from the user's project configuration, if set. Otherwise it will default to whatever is
|
||||||
* set here.
|
* set here.
|
||||||
*/
|
*/
|
||||||
std::uint16_t listeningPortNumber = 1055;
|
std::uint16_t listeningPortNumber = 1442;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The address for the GDB server to listen on.
|
* The address for the GDB server to listen on.
|
||||||
|
|||||||
Reference in New Issue
Block a user