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. *