From 5a8f54a2291c4583cea28d285cfdeb8c60986b2a Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 4 Jul 2021 00:32:05 +0100 Subject: [PATCH] Added event listener for thread state changed events from the DebugServer, within Insight. This covers cases where the DebugServer has unexpectedly shutdown and Insight should follow. --- src/Insight/Insight.cpp | 11 +++++++++++ src/Insight/Insight.hpp | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index 8437d06f..5c5a3492 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -45,6 +45,10 @@ void Insight::startup() { std::bind(&Insight::onTargetControllerThreadStateChangedEvent, this, std::placeholders::_1) ); + this->eventListener->registerCallbackForEventType( + std::bind(&Insight::onDebugServerThreadStateChangedEvent, this, std::placeholders::_1) + ); + auto targetDescriptor = this->targetControllerConsole.getTargetDescriptor(); #ifndef BLOOM_DEBUG_BUILD @@ -132,3 +136,10 @@ void Insight::onTargetControllerThreadStateChangedEvent(const Events::TargetCont this->shutdown(); } } + +void Insight::onDebugServerThreadStateChangedEvent(const Events::DebugServerThreadStateChanged& event) { + if (event.getState() == ThreadState::STOPPED) { + // Something horrible has happened with the DebugServer + this->shutdown(); + } +} diff --git a/src/Insight/Insight.hpp b/src/Insight/Insight.hpp index 8d90ff30..b07518c0 100644 --- a/src/Insight/Insight.hpp +++ b/src/Insight/Insight.hpp @@ -90,6 +90,14 @@ namespace Bloom */ void onTargetControllerThreadStateChangedEvent(const Events::TargetControllerThreadStateChanged& event); + /** + * If the something horrible was to happen and the DebugServer dies unexpectedly, Insight will shutdown + * in response. + * + * @param event + */ + void onDebugServerThreadStateChangedEvent(const Events::DebugServerThreadStateChanged& event); + /** * Dispatches any events currently in the queue. *