GDB RSP debug server handling of TC suspension
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include "Exceptions/ClientDisconnected.hpp"
|
#include "Exceptions/ClientDisconnected.hpp"
|
||||||
#include "Exceptions/ClientNotSupported.hpp"
|
#include "Exceptions/ClientNotSupported.hpp"
|
||||||
#include "Exceptions/ClientCommunicationError.hpp"
|
#include "Exceptions/ClientCommunicationError.hpp"
|
||||||
|
#include "Exceptions/DebugSessionAborted.hpp"
|
||||||
#include "src/Exceptions/Exception.hpp"
|
#include "src/Exceptions/Exception.hpp"
|
||||||
#include "src/Exceptions/InvalidConfig.hpp"
|
#include "src/Exceptions/InvalidConfig.hpp"
|
||||||
#include "src/Logger/Logger.hpp"
|
#include "src/Logger/Logger.hpp"
|
||||||
@@ -96,11 +97,23 @@ void GdbRspDebugServer::init() {
|
|||||||
Logger::info("GDB RSP address: " + this->listeningAddress);
|
Logger::info("GDB RSP address: " + this->listeningAddress);
|
||||||
Logger::info("GDB RSP port: " + std::to_string(this->listeningPortNumber));
|
Logger::info("GDB RSP port: " + std::to_string(this->listeningPortNumber));
|
||||||
|
|
||||||
|
this->eventListener->registerCallbackForEventType<Events::TargetControllerStateReported>(
|
||||||
|
std::bind(&GdbRspDebugServer::onTargetControllerStateReported, this, std::placeholders::_1)
|
||||||
|
);
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::TargetExecutionStopped>(
|
this->eventListener->registerCallbackForEventType<Events::TargetExecutionStopped>(
|
||||||
std::bind(&GdbRspDebugServer::onTargetExecutionStopped, this, std::placeholders::_1)
|
std::bind(&GdbRspDebugServer::onTargetExecutionStopped, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GdbRspDebugServer::close() {
|
||||||
|
this->closeClientConnection();
|
||||||
|
|
||||||
|
if (this->serverSocketFileDescriptor > 0) {
|
||||||
|
::close(this->serverSocketFileDescriptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GdbRspDebugServer::serve() {
|
void GdbRspDebugServer::serve() {
|
||||||
try {
|
try {
|
||||||
if (!this->clientConnection.has_value()) {
|
if (!this->clientConnection.has_value()) {
|
||||||
@@ -186,11 +199,10 @@ void GdbRspDebugServer::waitForConnection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbRspDebugServer::close() {
|
void GdbRspDebugServer::onTargetControllerStateReported(Events::EventPointer<Events::TargetControllerStateReported> event) {
|
||||||
this->closeClientConnection();
|
if (event->state == TargetControllerState::SUSPENDED && this->clientConnection.has_value()) {
|
||||||
|
Logger::warning("Terminating debug session - TargetController suspended unexpectedly");
|
||||||
if (this->serverSocketFileDescriptor > 0) {
|
this->closeClientConnection();
|
||||||
::close(this->serverSocketFileDescriptor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,6 +169,8 @@ namespace Bloom::DebugServers::Gdb
|
|||||||
return "GDB Remote Serial Protocol DebugServer";
|
return "GDB Remote Serial Protocol DebugServer";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void onTargetControllerStateReported(Events::EventPointer<Events::TargetControllerStateReported> event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the GDB client is currently waiting for the target execution to stop, this event handler will issue
|
* If the GDB client is currently waiting for the target execution to stop, this event handler will issue
|
||||||
* a "stop reply" packet to the client once the target execution stops.
|
* a "stop reply" packet to the client once the target execution stops.
|
||||||
|
|||||||
Reference in New Issue
Block a user