Removed EventRef alias for clarity

This commit is contained in:
Nav
2021-06-22 14:44:00 +01:00
parent a7df862d36
commit 69cee4d579
14 changed files with 78 additions and 86 deletions

View File

@@ -323,19 +323,19 @@ void Application::stopDebugServer() {
} }
} }
void Application::onTargetControllerThreadStateChanged(EventRef<Events::TargetControllerThreadStateChanged> event) { void Application::onTargetControllerThreadStateChanged(const 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();
} }
} }
void Application::onShutdownApplicationRequest(EventRef<Events::ShutdownApplication>) { void Application::onShutdownApplicationRequest(const Events::ShutdownApplication&) {
Logger::debug("ShutdownApplication event received."); Logger::debug("ShutdownApplication event received.");
this->shutdown(); this->shutdown();
} }
void Application::onDebugServerThreadStateChanged(EventRef<Events::DebugServerThreadStateChanged> event) { void Application::onDebugServerThreadStateChanged(const 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();

View File

@@ -233,7 +233,7 @@ namespace Bloom
* *
* @param event * @param event
*/ */
void onTargetControllerThreadStateChanged(Events::EventRef<Events::TargetControllerThreadStateChanged> event); void onTargetControllerThreadStateChanged(const 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 onDebugServerThreadStateChanged(Events::EventRef<Events::DebugServerThreadStateChanged> event); void onDebugServerThreadStateChanged(const 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(Events::EventRef<Events::ShutdownApplication>); void onShutdownApplicationRequest(const Events::ShutdownApplication&);
/** /**
* Checks if the current effective user running Bloom has root privileges. * Checks if the current effective user running Bloom has root privileges.

View File

@@ -55,6 +55,6 @@ void DebugServer::shutdown() {
this->eventManager.deregisterListener(this->eventListener->getId()); this->eventManager.deregisterListener(this->eventListener->getId());
} }
void DebugServer::onShutdownDebugServerEvent(EventRef<Events::ShutdownDebugServer> event) { void DebugServer::onShutdownDebugServerEvent(const Events::ShutdownDebugServer& event) {
this->shutdown(); this->shutdown();
} }

View File

@@ -59,7 +59,7 @@ namespace Bloom::DebugServers
* *
* @param event * @param event
*/ */
void onShutdownDebugServerEvent(Events::EventRef<Events::ShutdownDebugServer> event); void onShutdownDebugServerEvent(const Events::ShutdownDebugServer& event);
protected: protected:
/** /**

View File

@@ -201,7 +201,7 @@ void GdbRspDebugServer::waitForConnection() {
} }
} }
void GdbRspDebugServer::onTargetControllerStateReported(Events::EventRef<Events::TargetControllerStateReported> event) { void GdbRspDebugServer::onTargetControllerStateReported(const Events::TargetControllerStateReported& event) {
if (event.state == TargetControllerState::SUSPENDED && this->clientConnection.has_value()) { if (event.state == TargetControllerState::SUSPENDED && this->clientConnection.has_value()) {
Logger::warning("Terminating debug session - TargetController suspended unexpectedly"); Logger::warning("Terminating debug session - TargetController suspended unexpectedly");
this->closeClientConnection(); this->closeClientConnection();
@@ -232,7 +232,7 @@ void GdbRspDebugServer::handleGdbPacket(CommandPacket& packet) {
} }
} }
void GdbRspDebugServer::onTargetExecutionStopped(EventRef<Events::TargetExecutionStopped>) { void GdbRspDebugServer::onTargetExecutionStopped(const Events::TargetExecutionStopped&) {
if (this->clientConnection.has_value() && this->clientConnection->waitingForBreak) { if (this->clientConnection.has_value() && this->clientConnection->waitingForBreak) {
this->clientConnection->writePacket(TargetStopped(Signal::TRAP)); this->clientConnection->writePacket(TargetStopped(Signal::TRAP));
this->clientConnection->waitingForBreak = false; this->clientConnection->waitingForBreak = false;

View File

@@ -169,13 +169,13 @@ namespace Bloom::DebugServers::Gdb
return "GDB Remote Serial Protocol DebugServer"; return "GDB Remote Serial Protocol DebugServer";
}; };
void onTargetControllerStateReported(Events::EventRef<Events::TargetControllerStateReported> event); void onTargetControllerStateReported(const 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.
*/ */
void onTargetExecutionStopped(Events::EventRef<Events::TargetExecutionStopped>); void onTargetExecutionStopped(const Events::TargetExecutionStopped&);
/** /**
* Handles any other GDB command packet that has not been promoted to a more specific type. * Handles any other GDB command packet that has not been promoted to a more specific type.

View File

@@ -70,7 +70,7 @@ namespace Bloom
* we perform a downcast before invoking the callback. See EventListener::registerCallbackForEventType() * we perform a downcast before invoking the callback. See EventListener::registerCallbackForEventType()
* for more) * for more)
*/ */
SyncSafe<std::map<std::string, std::vector<std::function<void(Events::GenericEventRef)>>>> eventTypeToCallbacksMapping; SyncSafe<std::map<std::string, std::vector<std::function<void(const Events::Event&)>>>> eventTypeToCallbacksMapping;
SyncSafe<std::set<std::string>> registeredEventTypes; SyncSafe<std::set<std::string>> registeredEventTypes;
std::shared_ptr<EventNotifier> interruptEventNotifier = nullptr; std::shared_ptr<EventNotifier> interruptEventNotifier = nullptr;
@@ -110,12 +110,12 @@ namespace Bloom
* @param callback * @param callback
*/ */
template<class EventType> template<class EventType>
void registerCallbackForEventType(std::function<void(Events::EventRef<EventType>)> callback) { void registerCallbackForEventType(std::function<void(const EventType&)> callback) {
// We encapsulate the callback in a lambda to handle the downcasting. // We encapsulate the callback in a lambda to handle the downcasting.
std::function<void(Events::GenericEventRef)> parentCallback = std::function<void(const Events::Event&)> parentCallback =
[callback] (Events::GenericEventRef event) { [callback] (const Events::Event& event) {
// Downcast the event to the expected type // Downcast the event to the expected type
callback(dynamic_cast<Events::EventRef<EventType>>(event)); callback(dynamic_cast<const EventType&>(event));
} }
; ;

View File

@@ -46,9 +46,5 @@ namespace Bloom::Events
template <class EventType> template <class EventType>
using SharedEventPointer = std::shared_ptr<const EventType>; using SharedEventPointer = std::shared_ptr<const EventType>;
template <class EventType>
using EventRef = const EventType&;
using SharedGenericEventPointer = SharedEventPointer<Event>; using SharedGenericEventPointer = SharedEventPointer<Event>;
using GenericEventRef = EventRef<Event>;
} }

View File

@@ -9,7 +9,6 @@
#include "src/Targets/TargetState.hpp" #include "src/Targets/TargetState.hpp"
using namespace Bloom; using namespace Bloom;
using namespace Bloom::Events;
using namespace Bloom::Exceptions; using namespace Bloom::Exceptions;
void Insight::run() { void Insight::run() {
@@ -38,11 +37,11 @@ void Insight::startup() {
this->setThreadState(ThreadState::STARTING); this->setThreadState(ThreadState::STARTING);
this->eventManager.registerListener(this->eventListener); this->eventManager.registerListener(this->eventListener);
this->eventListener->registerCallbackForEventType<ShutdownApplication>( this->eventListener->registerCallbackForEventType<Events::ShutdownApplication>(
std::bind(&Insight::onShutdownApplicationEvent, this, std::placeholders::_1) std::bind(&Insight::onShutdownApplicationEvent, this, std::placeholders::_1)
); );
this->eventListener->registerCallbackForEventType<TargetControllerThreadStateChanged>( this->eventListener->registerCallbackForEventType<Events::TargetControllerThreadStateChanged>(
std::bind(&Insight::onTargetControllerThreadStateChangedEvent, this, std::placeholders::_1) std::bind(&Insight::onTargetControllerThreadStateChangedEvent, this, std::placeholders::_1)
); );
@@ -119,7 +118,7 @@ void Insight::shutdown() {
this->setThreadState(ThreadState::STOPPED); this->setThreadState(ThreadState::STOPPED);
} }
void Insight::onShutdownApplicationEvent(EventRef<ShutdownApplication>) { void Insight::onShutdownApplicationEvent(const Events::ShutdownApplication&) {
/* /*
* Once Insight shuts down, control of the main thread will be returned to Application::run(), which * Once Insight shuts down, control of the main thread will be returned to Application::run(), which
* will pickup the ShutdownApplication event and proceed with the shutdown. * will pickup the ShutdownApplication event and proceed with the shutdown.
@@ -127,7 +126,7 @@ void Insight::onShutdownApplicationEvent(EventRef<ShutdownApplication>) {
this->shutdown(); this->shutdown();
} }
void Insight::onTargetControllerThreadStateChangedEvent(EventRef<TargetControllerThreadStateChanged> event) { void Insight::onTargetControllerThreadStateChangedEvent(const Events::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();

View File

@@ -81,16 +81,14 @@ namespace Bloom
* *
* @param event * @param event
*/ */
void onShutdownApplicationEvent(Events::EventRef<Events::ShutdownApplication> event); void onShutdownApplicationEvent(const Events::ShutdownApplication& event);
/** /**
* If the something horrible was to happen and the TC dies unexpectedly, Insight will shutdown in response. * If the something horrible was to happen and the TC dies unexpectedly, Insight will shutdown in response.
* *
* @param event * @param event
*/ */
void onTargetControllerThreadStateChangedEvent( void onTargetControllerThreadStateChangedEvent(const Events::TargetControllerThreadStateChanged& event);
Events::EventRef<Events::TargetControllerThreadStateChanged> event
);
/** /**
* Dispatches any events currently in the queue. * Dispatches any events currently in the queue.

View File

@@ -10,7 +10,6 @@
#include "src/Exceptions/InvalidConfig.hpp" #include "src/Exceptions/InvalidConfig.hpp"
using namespace Bloom; using namespace Bloom;
using namespace Bloom::Events;
using namespace Bloom::Exceptions; using namespace Bloom::Exceptions;
using Bloom::Targets::TargetState; using Bloom::Targets::TargetState;
@@ -19,23 +18,23 @@ void InsightWorker::startup() {
Logger::debug("Starting InsightWorker thread"); Logger::debug("Starting InsightWorker thread");
this->eventManager.registerListener(this->eventListener); this->eventManager.registerListener(this->eventListener);
this->eventListener->registerCallbackForEventType<TargetControllerStateReported>( this->eventListener->registerCallbackForEventType<Events::TargetControllerStateReported>(
std::bind(&InsightWorker::onTargetControllerStateReported, this, std::placeholders::_1) std::bind(&InsightWorker::onTargetControllerStateReported, this, std::placeholders::_1)
); );
this->eventListener->registerCallbackForEventType<TargetExecutionStopped>( this->eventListener->registerCallbackForEventType<Events::TargetExecutionStopped>(
std::bind(&InsightWorker::onTargetStoppedEvent, this, std::placeholders::_1) std::bind(&InsightWorker::onTargetStoppedEvent, this, std::placeholders::_1)
); );
this->eventListener->registerCallbackForEventType<TargetExecutionResumed>( this->eventListener->registerCallbackForEventType<Events::TargetExecutionResumed>(
std::bind(&InsightWorker::onTargetResumedEvent, this, std::placeholders::_1) std::bind(&InsightWorker::onTargetResumedEvent, this, std::placeholders::_1)
); );
this->eventListener->registerCallbackForEventType<TargetPinStatesRetrieved>( this->eventListener->registerCallbackForEventType<Events::TargetPinStatesRetrieved>(
std::bind(&InsightWorker::onTargetPinStatesRetrievedEvent, this, std::placeholders::_1) std::bind(&InsightWorker::onTargetPinStatesRetrievedEvent, this, std::placeholders::_1)
); );
this->eventListener->registerCallbackForEventType<TargetIoPortsUpdated>( this->eventListener->registerCallbackForEventType<Events::TargetIoPortsUpdated>(
std::bind(&InsightWorker::onTargetIoPortsUpdatedEvent, this, std::placeholders::_1) std::bind(&InsightWorker::onTargetIoPortsUpdatedEvent, this, std::placeholders::_1)
); );
@@ -60,7 +59,7 @@ void InsightWorker::requestPinStateUpdate(
this->targetControllerConsole.setPinState(variantId, pinDescriptor, pinState); this->targetControllerConsole.setPinState(variantId, pinDescriptor, pinState);
} }
void InsightWorker::onTargetStoppedEvent(EventRef<TargetExecutionStopped> event) { void InsightWorker::onTargetStoppedEvent(const Events::TargetExecutionStopped& event) {
/* /*
* When we report a target halt to Insight, Insight will immediately seek more data from the target (such as GPIO * When we report a target halt to Insight, Insight will immediately seek more data from the target (such as GPIO
* pin states). This can be problematic for cases where the target had halted due to a conditional breakpoint. * pin states). This can be problematic for cases where the target had halted due to a conditional breakpoint.
@@ -82,7 +81,7 @@ void InsightWorker::onTargetStoppedEvent(EventRef<TargetExecutionStopped> event)
* only way. It would be nice if the debug client gave us some form of indication of whether the breakpoint is a * only way. It would be nice if the debug client gave us some form of indication of whether the breakpoint is a
* conditional one. * conditional one.
*/ */
auto resumedEvent = this->eventListener->waitForEvent<TargetExecutionResumed>( auto resumedEvent = this->eventListener->waitForEvent<Events::TargetExecutionResumed>(
std::chrono::milliseconds(650) std::chrono::milliseconds(650)
); );
@@ -92,19 +91,19 @@ void InsightWorker::onTargetStoppedEvent(EventRef<TargetExecutionStopped> event)
} }
} }
void InsightWorker::onTargetResumedEvent(EventRef<TargetExecutionResumed> event) { void InsightWorker::onTargetResumedEvent(const Events::TargetExecutionResumed& event) {
emit this->targetStateUpdated(TargetState::RUNNING); emit this->targetStateUpdated(TargetState::RUNNING);
} }
void InsightWorker::onTargetPinStatesRetrievedEvent(EventRef<TargetPinStatesRetrieved> event) { void InsightWorker::onTargetPinStatesRetrievedEvent(const Events::TargetPinStatesRetrieved& event) {
emit this->targetPinStatesUpdated(event.variantId, event.pinSatesByNumber); emit this->targetPinStatesUpdated(event.variantId, event.pinSatesByNumber);
} }
void InsightWorker::onTargetIoPortsUpdatedEvent(EventRef<TargetIoPortsUpdated> event) { void InsightWorker::onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdated& event) {
emit this->targetIoPortsUpdated(); emit this->targetIoPortsUpdated();
} }
void InsightWorker::onTargetControllerStateReported(EventRef<TargetControllerStateReported> event) { void InsightWorker::onTargetControllerStateReported(const Events::TargetControllerStateReported& event) {
if (this->lastTargetControllerState == TargetControllerState::ACTIVE if (this->lastTargetControllerState == TargetControllerState::ACTIVE
&& event.state == TargetControllerState::SUSPENDED && event.state == TargetControllerState::SUSPENDED
) { ) {

View File

@@ -33,11 +33,11 @@ namespace Bloom
QTimer* eventDispatchTimer = nullptr; QTimer* eventDispatchTimer = nullptr;
void onTargetStoppedEvent(Events::EventRef<Events::TargetExecutionStopped> event); void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
void onTargetResumedEvent(Events::EventRef<Events::TargetExecutionResumed> event); void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
void onTargetPinStatesRetrievedEvent(Events::EventRef<Events::TargetPinStatesRetrieved> event); void onTargetPinStatesRetrievedEvent(const Events::TargetPinStatesRetrieved& event);
void onTargetIoPortsUpdatedEvent(Events::EventRef<Events::TargetIoPortsUpdated> event); void onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdated& event);
void onTargetControllerStateReported(Events::EventRef<Events::TargetControllerStateReported> event); void onTargetControllerStateReported(const Events::TargetControllerStateReported& event);
public: public:
explicit InsightWorker(EventManager& eventManager): eventManager(eventManager) {}; explicit InsightWorker(EventManager& eventManager): eventManager(eventManager) {};

View File

@@ -360,17 +360,17 @@ void TargetController::emitErrorEvent(int correlationId) {
this->eventManager.triggerEvent(errorEvent); this->eventManager.triggerEvent(errorEvent);
} }
void TargetController::onShutdownTargetControllerEvent(EventRef<Events::ShutdownTargetController>) { void TargetController::onShutdownTargetControllerEvent(const Events::ShutdownTargetController&) {
this->shutdown(); this->shutdown();
} }
void TargetController::onStateReportRequest(EventRef<Events::ReportTargetControllerState> event) { void TargetController::onStateReportRequest(const Events::ReportTargetControllerState& event) {
auto stateEvent = std::make_shared<TargetControllerStateReported>(this->state); auto stateEvent = std::make_shared<Events::TargetControllerStateReported>(this->state);
stateEvent->correlationId = event.id; stateEvent->correlationId = event.id;
this->eventManager.triggerEvent(stateEvent); this->eventManager.triggerEvent(stateEvent);
} }
void TargetController::onDebugSessionStartedEvent(EventRef<Events::DebugSessionStarted>) { void TargetController::onDebugSessionStartedEvent(const Events::DebugSessionStarted&) {
if (this->state == TargetControllerState::SUSPENDED) { if (this->state == TargetControllerState::SUSPENDED) {
Logger::debug("Waking TargetController"); Logger::debug("Waking TargetController");
@@ -385,7 +385,7 @@ void TargetController::onDebugSessionStartedEvent(EventRef<Events::DebugSessionS
} }
} }
void TargetController::onDebugSessionFinishedEvent(EventRef<DebugSessionFinished>) { void TargetController::onDebugSessionFinishedEvent(const DebugSessionFinished&) {
if (this->target->getState() != TargetState::RUNNING) { if (this->target->getState() != TargetState::RUNNING) {
this->target->run(); this->target->run();
this->fireTargetEvents(); this->fireTargetEvents();
@@ -396,7 +396,7 @@ void TargetController::onDebugSessionFinishedEvent(EventRef<DebugSessionFinished
} }
} }
void TargetController::onExtractTargetDescriptor(EventRef<Events::ExtractTargetDescriptor> event) { void TargetController::onExtractTargetDescriptor(const Events::ExtractTargetDescriptor& event) {
if (!this->cachedTargetDescriptor.has_value()) { if (!this->cachedTargetDescriptor.has_value()) {
this->cachedTargetDescriptor = this->target->getDescriptor(); this->cachedTargetDescriptor = this->target->getDescriptor();
} }
@@ -408,13 +408,13 @@ void TargetController::onExtractTargetDescriptor(EventRef<Events::ExtractTargetD
this->eventManager.triggerEvent(targetDescriptorExtracted); this->eventManager.triggerEvent(targetDescriptorExtracted);
} }
void TargetController::onStopTargetExecutionEvent(EventRef<Events::StopTargetExecution> event) { void TargetController::onStopTargetExecutionEvent(const Events::StopTargetExecution& event) {
if (this->target->getState() != TargetState::STOPPED) { if (this->target->getState() != TargetState::STOPPED) {
this->target->stop(); this->target->stop();
this->lastTargetState = TargetState::STOPPED; this->lastTargetState = TargetState::STOPPED;
} }
auto executionStoppedEvent = std::make_shared<TargetExecutionStopped>( auto executionStoppedEvent = std::make_shared<Events::TargetExecutionStopped>(
this->target->getProgramCounter(), this->target->getProgramCounter(),
TargetBreakCause::UNKNOWN TargetBreakCause::UNKNOWN
); );
@@ -423,7 +423,7 @@ void TargetController::onStopTargetExecutionEvent(EventRef<Events::StopTargetExe
this->eventManager.triggerEvent(executionStoppedEvent); this->eventManager.triggerEvent(executionStoppedEvent);
} }
void TargetController::onStepTargetExecutionEvent(EventRef<Events::StepTargetExecution> event) { void TargetController::onStepTargetExecutionEvent(const Events::StepTargetExecution& event) {
try { try {
if (this->target->getState() != TargetState::STOPPED) { if (this->target->getState() != TargetState::STOPPED) {
// We can't step the target if it's already running. // We can't step the target if it's already running.
@@ -437,7 +437,7 @@ void TargetController::onStepTargetExecutionEvent(EventRef<Events::StepTargetExe
this->target->step(); this->target->step();
this->lastTargetState = TargetState::RUNNING; this->lastTargetState = TargetState::RUNNING;
auto executionResumedEvent = std::make_shared<TargetExecutionResumed>(); auto executionResumedEvent = std::make_shared<Events::TargetExecutionResumed>();
executionResumedEvent->correlationId = event.id; executionResumedEvent->correlationId = event.id;
this->eventManager.triggerEvent(executionResumedEvent); this->eventManager.triggerEvent(executionResumedEvent);
@@ -447,7 +447,7 @@ void TargetController::onStepTargetExecutionEvent(EventRef<Events::StepTargetExe
} }
} }
void TargetController::onResumeTargetExecutionEvent(EventRef<Events::ResumeTargetExecution> event) { void TargetController::onResumeTargetExecutionEvent(const Events::ResumeTargetExecution& event) {
try { try {
if (this->target->getState() != TargetState::RUNNING) { if (this->target->getState() != TargetState::RUNNING) {
if (event.fromProgramCounter.has_value()) { if (event.fromProgramCounter.has_value()) {
@@ -468,7 +468,7 @@ void TargetController::onResumeTargetExecutionEvent(EventRef<Events::ResumeTarge
} }
} }
void TargetController::onReadRegistersEvent(EventRef<Events::RetrieveRegistersFromTarget> event) { void TargetController::onReadRegistersEvent(const Events::RetrieveRegistersFromTarget& event) {
try { try {
auto registers = this->target->readRegisters(event.descriptors); auto registers = this->target->readRegisters(event.descriptors);
@@ -485,7 +485,7 @@ void TargetController::onReadRegistersEvent(EventRef<Events::RetrieveRegistersFr
} }
} }
void TargetController::onWriteRegistersEvent(EventRef<Events::WriteRegistersToTarget> event) { void TargetController::onWriteRegistersEvent(const Events::WriteRegistersToTarget& event) {
try { try {
this->target->writeRegisters(event.registers); this->target->writeRegisters(event.registers);
@@ -499,7 +499,7 @@ void TargetController::onWriteRegistersEvent(EventRef<Events::WriteRegistersToTa
} }
} }
void TargetController::onReadMemoryEvent(EventRef<Events::RetrieveMemoryFromTarget> event) { void TargetController::onReadMemoryEvent(const Events::RetrieveMemoryFromTarget& event) {
try { try {
auto memoryReadEvent = std::make_shared<Events::MemoryRetrievedFromTarget>(); auto memoryReadEvent = std::make_shared<Events::MemoryRetrievedFromTarget>();
memoryReadEvent->correlationId = event.id; memoryReadEvent->correlationId = event.id;
@@ -513,7 +513,7 @@ void TargetController::onReadMemoryEvent(EventRef<Events::RetrieveMemoryFromTarg
} }
} }
void TargetController::onWriteMemoryEvent(EventRef<Events::WriteMemoryToTarget> event) { void TargetController::onWriteMemoryEvent(const Events::WriteMemoryToTarget& event) {
try { try {
this->target->writeMemory(event.memoryType, event.startAddress, event.buffer); this->target->writeMemory(event.memoryType, event.startAddress, event.buffer);
@@ -536,7 +536,7 @@ void TargetController::onWriteMemoryEvent(EventRef<Events::WriteMemoryToTarget>
} }
} }
void TargetController::onSetBreakpointEvent(EventRef<Events::SetBreakpointOnTarget> event) { void TargetController::onSetBreakpointEvent(const Events::SetBreakpointOnTarget& event) {
try { try {
this->target->setBreakpoint(event.breakpoint.address); this->target->setBreakpoint(event.breakpoint.address);
auto breakpointSetEvent = std::make_shared<Events::BreakpointSetOnTarget>(); auto breakpointSetEvent = std::make_shared<Events::BreakpointSetOnTarget>();
@@ -550,7 +550,7 @@ void TargetController::onSetBreakpointEvent(EventRef<Events::SetBreakpointOnTarg
} }
} }
void TargetController::onRemoveBreakpointEvent(EventRef<Events::RemoveBreakpointOnTarget> event) { void TargetController::onRemoveBreakpointEvent(const Events::RemoveBreakpointOnTarget& event) {
try { try {
this->target->removeBreakpoint(event.breakpoint.address); this->target->removeBreakpoint(event.breakpoint.address);
auto breakpointRemovedEvent = std::make_shared<Events::BreakpointRemovedOnTarget>(); auto breakpointRemovedEvent = std::make_shared<Events::BreakpointRemovedOnTarget>();
@@ -564,7 +564,7 @@ void TargetController::onRemoveBreakpointEvent(EventRef<Events::RemoveBreakpoint
} }
} }
void TargetController::onSetProgramCounterEvent(EventRef<Events::SetProgramCounterOnTarget> event) { void TargetController::onSetProgramCounterEvent(const Events::SetProgramCounterOnTarget& event) {
try { try {
if (this->target->getState() != TargetState::STOPPED) { if (this->target->getState() != TargetState::STOPPED) {
throw Exception("Invalid target state - target must be stopped before the program counter can be updated"); throw Exception("Invalid target state - target must be stopped before the program counter can be updated");
@@ -583,7 +583,7 @@ void TargetController::onSetProgramCounterEvent(EventRef<Events::SetProgramCount
} }
// TODO: remove this // TODO: remove this
void TargetController::onInsightStateChangedEvent(EventRef<Events::InsightThreadStateChanged> event) { void TargetController::onInsightStateChangedEvent(const Events::InsightThreadStateChanged& event) {
if (event.getState() == ThreadState::READY) { if (event.getState() == ThreadState::READY) {
/* /*
* Insight has just started up. * Insight has just started up.
@@ -595,7 +595,7 @@ void TargetController::onInsightStateChangedEvent(EventRef<Events::InsightThread
} }
} }
void TargetController::onRetrieveTargetPinStatesEvent(EventRef<Events::RetrieveTargetPinStates> event) { void TargetController::onRetrieveTargetPinStatesEvent(const Events::RetrieveTargetPinStates& event) {
try { try {
if (this->target->getState() != TargetState::STOPPED) { if (this->target->getState() != TargetState::STOPPED) {
throw Exception("Invalid target state - target must be stopped before pin states can be retrieved"); throw Exception("Invalid target state - target must be stopped before pin states can be retrieved");
@@ -614,7 +614,7 @@ void TargetController::onRetrieveTargetPinStatesEvent(EventRef<Events::RetrieveT
} }
} }
void TargetController::onSetPinStateEvent(EventRef<Events::SetTargetPinState> event) { void TargetController::onSetPinStateEvent(const Events::SetTargetPinState& event) {
try { try {
if (this->target->getState() != TargetState::STOPPED) { if (this->target->getState() != TargetState::STOPPED) {
throw Exception("Invalid target state - target must be stopped before pin state can be set"); throw Exception("Invalid target state - target must be stopped before pin state can be set");

View File

@@ -244,70 +244,70 @@ namespace Bloom
* *
* @param event * @param event
*/ */
void onStateReportRequest(Events::EventRef<Events::ReportTargetControllerState> event); void onStateReportRequest(const Events::ReportTargetControllerState& event);
/** /**
* Obtains a TargetDescriptor from the target and includes it in a TargetDescriptorExtracted event. * Obtains a TargetDescriptor from the target and includes it in a TargetDescriptorExtracted event.
* *
* @param event * @param event
*/ */
void onExtractTargetDescriptor(Events::EventRef<Events::ExtractTargetDescriptor> event); void onExtractTargetDescriptor(const Events::ExtractTargetDescriptor& event);
/** /**
* Will attempt to stop execution on the target and emit a TargetExecutionStopped event. * Will attempt to stop execution on the target and emit a TargetExecutionStopped event.
* *
* @param event * @param event
*/ */
void onStopTargetExecutionEvent(Events::EventRef<Events::StopTargetExecution> event); void onStopTargetExecutionEvent(const Events::StopTargetExecution& event);
/** /**
* Will attempt to step execution on the target and emit a TargetExecutionResumed event. * Will attempt to step execution on the target and emit a TargetExecutionResumed event.
* *
* @param event * @param event
*/ */
void onStepTargetExecutionEvent(Events::EventRef<Events::StepTargetExecution> event); void onStepTargetExecutionEvent(const Events::StepTargetExecution& event);
/** /**
* Will attempt to resume execution on the target and emit a TargetExecutionResumed event. * Will attempt to resume execution on the target and emit a TargetExecutionResumed event.
* *
* @param event * @param event
*/ */
void onResumeTargetExecutionEvent(Events::EventRef<Events::ResumeTargetExecution> event); void onResumeTargetExecutionEvent(const Events::ResumeTargetExecution& event);
/** /**
* Invokes a shutdown. * Invokes a shutdown.
* *
* @param event * @param event
*/ */
void onShutdownTargetControllerEvent(Events::EventRef<Events::ShutdownTargetController> event); void onShutdownTargetControllerEvent(const Events::ShutdownTargetController& event);
/** /**
* Will attempt to read the requested registers and emit a RegistersRetrievedFromTarget event. * Will attempt to read the requested registers and emit a RegistersRetrievedFromTarget event.
* *
* @param event * @param event
*/ */
void onReadRegistersEvent(Events::EventRef<Events::RetrieveRegistersFromTarget> event); void onReadRegistersEvent(const Events::RetrieveRegistersFromTarget& event);
/** /**
* Will attempt to write the specified register values and emit a RegistersWrittenToTarget event. * Will attempt to write the specified register values and emit a RegistersWrittenToTarget event.
* *
* @param event * @param event
*/ */
void onWriteRegistersEvent(Events::EventRef<Events::WriteRegistersToTarget> event); void onWriteRegistersEvent(const Events::WriteRegistersToTarget& event);
/** /**
* Will attempt to read memory from the target and include the data in a MemoryRetrievedFromTarget event. * Will attempt to read memory from the target and include the data in a MemoryRetrievedFromTarget event.
* *
* @param event * @param event
*/ */
void onReadMemoryEvent(Events::EventRef<Events::RetrieveMemoryFromTarget> event); void onReadMemoryEvent(const Events::RetrieveMemoryFromTarget& event);
/** /**
* Will attempt to write memory to the target. On success, a MemoryWrittenToTarget event is emitted. * Will attempt to write memory to the target. On success, a MemoryWrittenToTarget event is emitted.
* *
* @param event * @param event
*/ */
void onWriteMemoryEvent(Events::EventRef<Events::WriteMemoryToTarget> event); void onWriteMemoryEvent(const Events::WriteMemoryToTarget& event);
/** /**
* Will attempt to set the specific breakpoint on the target. On success, the BreakpointSetOnTarget event will * Will attempt to set the specific breakpoint on the target. On success, the BreakpointSetOnTarget event will
@@ -315,7 +315,7 @@ namespace Bloom
* *
* @param event * @param event
*/ */
void onSetBreakpointEvent(Events::EventRef<Events::SetBreakpointOnTarget> event); void onSetBreakpointEvent(const Events::SetBreakpointOnTarget& event);
/** /**
* Will attempt to remove a breakpoint at the specified address, on the target. On success, the * Will attempt to remove a breakpoint at the specified address, on the target. On success, the
@@ -323,21 +323,21 @@ namespace Bloom
* *
* @param event * @param event
*/ */
void onRemoveBreakpointEvent(Events::EventRef<Events::RemoveBreakpointOnTarget> event); void onRemoveBreakpointEvent(const Events::RemoveBreakpointOnTarget& event);
/** /**
* Will hold the target stopped at it's current state. * Will hold the target stopped at it's current state.
* *
* @param event * @param event
*/ */
void onDebugSessionStartedEvent(Events::EventRef<Events::DebugSessionStarted> event); void onDebugSessionStartedEvent(const Events::DebugSessionStarted& event);
/** /**
* Will simply kick off execution on the target. * Will simply kick off execution on the target.
* *
* @param event * @param event
*/ */
void onDebugSessionFinishedEvent(Events::EventRef<Events::DebugSessionFinished> event); void onDebugSessionFinishedEvent(const Events::DebugSessionFinished& event);
/** /**
* Will update the program counter value on the target. On success, a ProgramCounterSetOnTarget event is * Will update the program counter value on the target. On success, a ProgramCounterSetOnTarget event is
@@ -345,7 +345,7 @@ namespace Bloom
* *
* @param event * @param event
*/ */
void onSetProgramCounterEvent(Events::EventRef<Events::SetProgramCounterOnTarget> event); void onSetProgramCounterEvent(const Events::SetProgramCounterOnTarget& event);
/** /**
* Will automatically fire a target state update event. * Will automatically fire a target state update event.
@@ -353,14 +353,14 @@ namespace Bloom
* *
* @param event * @param event
*/ */
void onInsightStateChangedEvent(Events::EventRef<Events::InsightThreadStateChanged> event); void onInsightStateChangedEvent(const Events::InsightThreadStateChanged& event);
/** /**
* Will attempt to obtain the pin states from the target. Will emit a TargetPinStatesRetrieved event on success. * Will attempt to obtain the pin states from the target. Will emit a TargetPinStatesRetrieved event on success.
* *
* @param event * @param event
*/ */
void onRetrieveTargetPinStatesEvent(Events::EventRef<Events::RetrieveTargetPinStates> event); void onRetrieveTargetPinStatesEvent(const Events::RetrieveTargetPinStates& event);
/** /**
* Will update a pin state for a particular pin. Will emit a TargetPinStatesRetrieved with the new pin * Will update a pin state for a particular pin. Will emit a TargetPinStatesRetrieved with the new pin
@@ -368,6 +368,6 @@ namespace Bloom
* *
* @param event * @param event
*/ */
void onSetPinStateEvent(Events::EventRef<Events::SetTargetPinState> event); void onSetPinStateEvent(const Events::SetTargetPinState& event);
}; };
} }