Moved away from shared pointers in event handlers - didn't make sense to expose the event management implementation to handlers.

Also some other bits of tidying.
This commit is contained in:
Nav
2021-06-22 03:06:20 +01:00
parent 139e880646
commit a7df862d36
19 changed files with 193 additions and 212 deletions

View File

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

View File

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

View File

@@ -201,8 +201,8 @@ void GdbRspDebugServer::waitForConnection() {
}
}
void GdbRspDebugServer::onTargetControllerStateReported(Events::EventPointer<Events::TargetControllerStateReported> event) {
if (event->state == TargetControllerState::SUSPENDED && this->clientConnection.has_value()) {
void GdbRspDebugServer::onTargetControllerStateReported(Events::EventRef<Events::TargetControllerStateReported> event) {
if (event.state == TargetControllerState::SUSPENDED && this->clientConnection.has_value()) {
Logger::warning("Terminating debug session - TargetController suspended unexpectedly");
this->closeClientConnection();
}
@@ -232,7 +232,7 @@ void GdbRspDebugServer::handleGdbPacket(CommandPacket& packet) {
}
}
void GdbRspDebugServer::onTargetExecutionStopped(EventPointer<Events::TargetExecutionStopped>) {
void GdbRspDebugServer::onTargetExecutionStopped(EventRef<Events::TargetExecutionStopped>) {
if (this->clientConnection.has_value() && this->clientConnection->waitingForBreak) {
this->clientConnection->writePacket(TargetStopped(Signal::TRAP));
this->clientConnection->waitingForBreak = false;
@@ -243,7 +243,8 @@ void GdbRspDebugServer::handleGdbPacket(CommandPackets::SupportedFeaturesQuery&
Logger::debug("Handling QuerySupport packet");
if (!packet.isFeatureSupported(Feature::HARDWARE_BREAKPOINTS)
&& !packet.isFeatureSupported(Feature::SOFTWARE_BREAKPOINTS)) {
&& !packet.isFeatureSupported(Feature::SOFTWARE_BREAKPOINTS)
) {
// All GDB clients are expected to support breakpoints!
throw ClientNotSupported("GDB client does not support HW or SW breakpoints");
}

View File

@@ -163,19 +163,19 @@ namespace Bloom::DebugServers::Gdb
}
public:
GdbRspDebugServer(EventManager& eventManager): DebugServer(eventManager) {};
explicit GdbRspDebugServer(EventManager& eventManager): DebugServer(eventManager) {};
std::string getName() const override {
return "GDB Remote Serial Protocol DebugServer";
};
void onTargetControllerStateReported(Events::EventPointer<Events::TargetControllerStateReported> event);
void onTargetControllerStateReported(Events::EventRef<Events::TargetControllerStateReported> event);
/**
* 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.
*/
void onTargetExecutionStopped(Events::EventPointer<Events::TargetExecutionStopped>);
void onTargetExecutionStopped(Events::EventRef<Events::TargetExecutionStopped>);
/**
* Handles any other GDB command packet that has not been promoted to a more specific type.