Renamed component (DebugServer and TargetController) state changed events to be specific to thread states
This commit is contained in:
@@ -105,12 +105,12 @@ void Application::startup() {
|
|||||||
throw InvalidConfig("Debug server configuration missing.");
|
throw InvalidConfig("Debug server configuration missing.");
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationEventListener->registerCallbackForEventType<Events::TargetControllerStateChanged>(
|
applicationEventListener->registerCallbackForEventType<Events::TargetControllerThreadStateChanged>(
|
||||||
std::bind(&Application::onTargetControllerStateChanged, this, std::placeholders::_1)
|
std::bind(&Application::onTargetControllerThreadStateChanged, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
applicationEventListener->registerCallbackForEventType<Events::DebugServerStateChanged>(
|
applicationEventListener->registerCallbackForEventType<Events::DebugServerThreadStateChanged>(
|
||||||
std::bind(&Application::onDebugServerStateChanged, this, std::placeholders::_1)
|
std::bind(&Application::onDebugServerThreadStateChanged, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
this->startTargetController();
|
this->startTargetController();
|
||||||
@@ -245,7 +245,7 @@ void Application::startTargetController() {
|
|||||||
std::ref(this->targetController)
|
std::ref(this->targetController)
|
||||||
);
|
);
|
||||||
|
|
||||||
auto tcStateChangeEvent = this->applicationEventListener->waitForEvent<Events::TargetControllerStateChanged>();
|
auto tcStateChangeEvent = this->applicationEventListener->waitForEvent<Events::TargetControllerThreadStateChanged>();
|
||||||
|
|
||||||
if (!tcStateChangeEvent.has_value() || tcStateChangeEvent->get()->getState() != ThreadState::READY) {
|
if (!tcStateChangeEvent.has_value() || tcStateChangeEvent->get()->getState() != ThreadState::READY) {
|
||||||
throw Exception("TargetController failed to startup.");
|
throw Exception("TargetController failed to startup.");
|
||||||
@@ -255,9 +255,8 @@ void Application::startTargetController() {
|
|||||||
void Application::stopTargetController() {
|
void Application::stopTargetController() {
|
||||||
auto targetControllerState = this->targetController.getState();
|
auto targetControllerState = this->targetController.getState();
|
||||||
if (targetControllerState == ThreadState::STARTING || targetControllerState == ThreadState::READY) {
|
if (targetControllerState == ThreadState::STARTING || targetControllerState == ThreadState::READY) {
|
||||||
// this->applicationEventListener->clearEventsOfType(Events::TargetControllerStateChanged::name);
|
|
||||||
this->eventManager.triggerEvent(std::make_shared<Events::ShutdownTargetController>());
|
this->eventManager.triggerEvent(std::make_shared<Events::ShutdownTargetController>());
|
||||||
this->applicationEventListener->waitForEvent<Events::TargetControllerStateChanged>(
|
this->applicationEventListener->waitForEvent<Events::TargetControllerThreadStateChanged>(
|
||||||
std::chrono::milliseconds(10000)
|
std::chrono::milliseconds(10000)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -287,7 +286,7 @@ void Application::startDebugServer() {
|
|||||||
this->debugServer.get()
|
this->debugServer.get()
|
||||||
);
|
);
|
||||||
|
|
||||||
auto dsStateChangeEvent = this->applicationEventListener->waitForEvent<Events::DebugServerStateChanged>();
|
auto dsStateChangeEvent = this->applicationEventListener->waitForEvent<Events::DebugServerThreadStateChanged>();
|
||||||
|
|
||||||
if (!dsStateChangeEvent.has_value() || dsStateChangeEvent->get()->getState() != ThreadState::READY) {
|
if (!dsStateChangeEvent.has_value() || dsStateChangeEvent->get()->getState() != ThreadState::READY) {
|
||||||
throw Exception("DebugServer failed to startup.");
|
throw Exception("DebugServer failed to startup.");
|
||||||
@@ -303,7 +302,7 @@ void Application::stopDebugServer() {
|
|||||||
auto debugServerState = this->debugServer->getState();
|
auto debugServerState = this->debugServer->getState();
|
||||||
if (debugServerState == ThreadState::STARTING || debugServerState == ThreadState::READY) {
|
if (debugServerState == ThreadState::STARTING || debugServerState == ThreadState::READY) {
|
||||||
this->eventManager.triggerEvent(std::make_shared<Events::ShutdownDebugServer>());
|
this->eventManager.triggerEvent(std::make_shared<Events::ShutdownDebugServer>());
|
||||||
this->applicationEventListener->waitForEvent<Events::DebugServerStateChanged>(
|
this->applicationEventListener->waitForEvent<Events::DebugServerThreadStateChanged>(
|
||||||
std::chrono::milliseconds(5000)
|
std::chrono::milliseconds(5000)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -315,7 +314,7 @@ void Application::stopDebugServer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::onTargetControllerStateChanged(EventPointer<Events::TargetControllerStateChanged> event) {
|
void Application::onTargetControllerThreadStateChanged(EventPointer<Events::TargetControllerThreadStateChanged> event) {
|
||||||
if (event->getState() == ThreadState::STOPPED || event->getState() == ThreadState::SHUTDOWN_INITIATED) {
|
if (event->getState() == ThreadState::STOPPED || event->getState() == ThreadState::SHUTDOWN_INITIATED) {
|
||||||
// TargetController has unexpectedly shutdown - it must have encountered a fatal error.
|
// TargetController has unexpectedly shutdown - it must have encountered a fatal error.
|
||||||
this->shutdown();
|
this->shutdown();
|
||||||
@@ -327,7 +326,7 @@ void Application::onShutdownApplicationRequest(EventPointer<Events::ShutdownAppl
|
|||||||
this->shutdown();
|
this->shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::onDebugServerStateChanged(EventPointer<Events::DebugServerStateChanged> event) {
|
void Application::onDebugServerThreadStateChanged(EventPointer<Events::DebugServerThreadStateChanged> event) {
|
||||||
if (event->getState() == ThreadState::STOPPED || event->getState() == ThreadState::SHUTDOWN_INITIATED) {
|
if (event->getState() == ThreadState::STOPPED || event->getState() == ThreadState::SHUTDOWN_INITIATED) {
|
||||||
// DebugServer has unexpectedly shutdown - it must have encountered a fatal error.
|
// DebugServer has unexpectedly shutdown - it must have encountered a fatal error.
|
||||||
this->shutdown();
|
this->shutdown();
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ namespace Bloom
|
|||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
void onTargetControllerStateChanged(EventPointer<Events::TargetControllerStateChanged> event);
|
void onTargetControllerThreadStateChanged(Events::EventPointer<Events::TargetControllerThreadStateChanged> event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same goes for the DebugServer - it should never shutdown unless a shutdown request was issued. If it does,
|
* Same goes for the DebugServer - it should never shutdown unless a shutdown request was issued. If it does,
|
||||||
@@ -241,12 +241,12 @@ namespace Bloom
|
|||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
void onDebugServerStateChanged(EventPointer<Events::DebugServerStateChanged> event);
|
void onDebugServerThreadStateChanged(Events::EventPointer<Events::DebugServerThreadStateChanged> event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers a shutdown of Bloom and all of its components.
|
* Triggers a shutdown of Bloom and all of its components.
|
||||||
*/
|
*/
|
||||||
void onShutdownApplicationRequest(EventPointer<Events::ShutdownApplication>);
|
void onShutdownApplicationRequest(Events::EventPointer<Events::ShutdownApplication>);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path to the directory in which the Bloom binary resides.
|
* Returns the path to the directory in which the Bloom binary resides.
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace Bloom::DebugServers
|
|||||||
void setStateAndEmitEvent(ThreadState state) {
|
void setStateAndEmitEvent(ThreadState state) {
|
||||||
Thread::setState(state);
|
Thread::setState(state);
|
||||||
this->eventManager.triggerEvent(
|
this->eventManager.triggerEvent(
|
||||||
std::make_shared<Events::DebugServerStateChanged>(state)
|
std::make_shared<Events::DebugServerThreadStateChanged>(state)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ namespace Bloom::DebugServers
|
|||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
void onShutdownDebugServerEvent(EventPointer<Events::ShutdownDebugServer> event);
|
void onShutdownDebugServerEvent(Events::EventPointer<Events::ShutdownDebugServer> event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,17 +5,17 @@
|
|||||||
|
|
||||||
namespace Bloom::Events
|
namespace Bloom::Events
|
||||||
{
|
{
|
||||||
class DebugServerStateChanged: public Event
|
class DebugServerThreadStateChanged: public Event
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ThreadState state;
|
ThreadState state;
|
||||||
public:
|
public:
|
||||||
DebugServerStateChanged(ThreadState state): state(state) {};
|
DebugServerThreadStateChanged(ThreadState state): state(state) {};
|
||||||
|
|
||||||
static inline const std::string name = "DebugServerStateChanged";
|
static inline const std::string name = "DebugServerThreadStateChanged";
|
||||||
|
|
||||||
std::string getName() const override {
|
std::string getName() const override {
|
||||||
return DebugServerStateChanged::name;
|
return DebugServerThreadStateChanged::name;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadState getState() const {
|
ThreadState getState() const {
|
||||||
@@ -8,12 +8,12 @@
|
|||||||
#include "ResetTarget.hpp"
|
#include "ResetTarget.hpp"
|
||||||
#include "DebugSessionStarted.hpp"
|
#include "DebugSessionStarted.hpp"
|
||||||
#include "DebugSessionFinished.hpp"
|
#include "DebugSessionFinished.hpp"
|
||||||
#include "TargetControllerStateChanged.hpp"
|
#include "TargetControllerThreadStateChanged.hpp"
|
||||||
#include "TargetControllerStopped.hpp"
|
#include "TargetControllerStopped.hpp"
|
||||||
#include "ShutdownTargetController.hpp"
|
#include "ShutdownTargetController.hpp"
|
||||||
#include "TargetControllerErrorOccurred.hpp"
|
#include "TargetControllerErrorOccurred.hpp"
|
||||||
#include "ShutdownApplication.hpp"
|
#include "ShutdownApplication.hpp"
|
||||||
#include "DebugServerStateChanged.hpp"
|
#include "DebugServerThreadStateChanged.hpp"
|
||||||
#include "ShutdownDebugServer.hpp"
|
#include "ShutdownDebugServer.hpp"
|
||||||
#include "RetrieveRegistersFromTarget.hpp"
|
#include "RetrieveRegistersFromTarget.hpp"
|
||||||
#include "RegistersRetrievedFromTarget.hpp"
|
#include "RegistersRetrievedFromTarget.hpp"
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Event.hpp"
|
|
||||||
#include "src/Helpers/Thread.hpp"
|
|
||||||
|
|
||||||
namespace Bloom::Events
|
|
||||||
{
|
|
||||||
|
|
||||||
class TargetControllerStateChanged: public Event
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ThreadState state;
|
|
||||||
public:
|
|
||||||
TargetControllerStateChanged(ThreadState state): state(state) {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline const std::string name = "TargetControllerStateChanged";
|
|
||||||
|
|
||||||
std::string getName() const override {
|
|
||||||
return TargetControllerStateChanged::name;
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadState getState() const {
|
|
||||||
return this->state;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -43,8 +43,8 @@ void Insight::startup() {
|
|||||||
std::bind(&Insight::onShutdownApplicationEvent, this, std::placeholders::_1)
|
std::bind(&Insight::onShutdownApplicationEvent, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<TargetControllerStateChanged>(
|
this->eventListener->registerCallbackForEventType<TargetControllerThreadStateChanged>(
|
||||||
std::bind(&Insight::onTargetControllerStateChangedEvent, this, std::placeholders::_1)
|
std::bind(&Insight::onTargetControllerThreadStateChangedEvent, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
auto targetDescriptor = this->targetControllerConsole.getTargetDescriptor();
|
auto targetDescriptor = this->targetControllerConsole.getTargetDescriptor();
|
||||||
@@ -123,7 +123,7 @@ void Insight::onShutdownApplicationEvent(EventPointer<ShutdownApplication>) {
|
|||||||
this->shutdown();
|
this->shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Insight::onTargetControllerStateChangedEvent(EventPointer<TargetControllerStateChanged> event) {
|
void Insight::onTargetControllerThreadStateChangedEvent(EventPointer<TargetControllerThreadStateChanged> event) {
|
||||||
if (event->getState() == ThreadState::STOPPED) {
|
if (event->getState() == ThreadState::STOPPED) {
|
||||||
// Something horrible has happened with the TargetController - Insight is useless without the TargetController
|
// Something horrible has happened with the TargetController - Insight is useless without the TargetController
|
||||||
this->shutdown();
|
this->shutdown();
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ namespace Bloom
|
|||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
void onTargetControllerStateChangedEvent(EventPointer<TargetControllerStateChanged> event);
|
void onTargetControllerThreadStateChangedEvent(
|
||||||
|
Events::EventPointer<Events::TargetControllerThreadStateChanged> event
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatches any events currently in the queue.
|
* Dispatches any events currently in the queue.
|
||||||
|
|||||||
Reference in New Issue
Block a user