From b05b3454e97cb930ab3fd86a30d278885f669e90 Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 16 Apr 2022 21:21:29 +0100 Subject: [PATCH] Handled GDB exceptions in TargetExecutionStopped event handler, to prevent them from propagating to the DebugServerComponent::run() and causing Bloom to shutdown. --- src/DebugServer/Gdb/GdbRspDebugServer.cpp | 27 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/DebugServer/Gdb/GdbRspDebugServer.cpp b/src/DebugServer/Gdb/GdbRspDebugServer.cpp index a82263d8..32f5e1b9 100644 --- a/src/DebugServer/Gdb/GdbRspDebugServer.cpp +++ b/src/DebugServer/Gdb/GdbRspDebugServer.cpp @@ -304,11 +304,30 @@ namespace Bloom::DebugServer::Gdb } void GdbRspDebugServer::onTargetExecutionStopped(const Events::TargetExecutionStopped&) { - if (this->activeDebugSession.has_value() && this->activeDebugSession->waitingForBreak) { - this->activeDebugSession->connection.writePacket( - ResponsePackets::TargetStopped(Signal::TRAP) + try { + if (this->activeDebugSession.has_value() && this->activeDebugSession->waitingForBreak) { + this->activeDebugSession->connection.writePacket( + ResponsePackets::TargetStopped(Signal::TRAP) + ); + this->activeDebugSession->waitingForBreak = false; + } + + } catch (const ClientDisconnected&) { + Logger::info("GDB RSP client disconnected"); + this->terminateActiveDebugSession(); + return; + + } catch (const ClientCommunicationError& exception) { + Logger::error( + "GDB RSP client communication error - " + exception.getMessage() + " - closing connection" ); - this->activeDebugSession->waitingForBreak = false; + this->terminateActiveDebugSession(); + return; + + } catch (const DebugServerInterrupted&) { + // Server was interrupted + Logger::debug("GDB RSP interrupted"); + return; } } }