From f848fdfc40303ff837f53d10ef6ad30a84894d6e Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 27 Mar 2022 18:33:34 +0100 Subject: [PATCH] Removed EventNotifier object management from GDB Connection class --- src/DebugServers/GdbRsp/Connection.cpp | 12 ++++++------ src/DebugServers/GdbRsp/Connection.hpp | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/DebugServers/GdbRsp/Connection.cpp b/src/DebugServers/GdbRsp/Connection.cpp index 8ee1b4d5..b8b878dc 100644 --- a/src/DebugServers/GdbRsp/Connection.cpp +++ b/src/DebugServers/GdbRsp/Connection.cpp @@ -116,7 +116,7 @@ namespace Bloom::DebugServers::Gdb } else { // Clear any previous interrupts that are still hanging around - this->interruptEventNotifier->clear(); + this->interruptEventNotifier.clear(); } } @@ -135,11 +135,11 @@ namespace Bloom::DebugServers::Gdb if (eventCount > 0) { for (size_t i = 0; i < eventCount; i++) { - auto fileDescriptor = events[i].data.fd; + auto fileDescriptor = events.at(i).data.fd; - if (fileDescriptor == this->interruptEventNotifier->getFileDescriptor()) { + if (fileDescriptor == this->interruptEventNotifier.getFileDescriptor()) { // Interrupted - this->interruptEventNotifier->clear(); + this->interruptEventNotifier.clear(); throw DebugServerInterrupted(); } } @@ -195,7 +195,7 @@ namespace Bloom::DebugServers::Gdb if (::epoll_ctl( this->eventFileDescriptor, EPOLL_CTL_DEL, - this->interruptEventNotifier->getFileDescriptor(), + this->interruptEventNotifier.getFileDescriptor(), NULL) != 0 ) { throw Exception("Failed to disable GDB client connection read interrupts - epoll_ctl failed"); @@ -205,7 +205,7 @@ namespace Bloom::DebugServers::Gdb } void Connection::enableReadInterrupts() { - auto interruptFileDescriptor = this->interruptEventNotifier->getFileDescriptor(); + auto interruptFileDescriptor = this->interruptEventNotifier.getFileDescriptor(); struct epoll_event event = {}; event.events = EPOLLIN; event.data.fd = interruptFileDescriptor; diff --git a/src/DebugServers/GdbRsp/Connection.hpp b/src/DebugServers/GdbRsp/Connection.hpp index 5721c391..7bf11305 100644 --- a/src/DebugServers/GdbRsp/Connection.hpp +++ b/src/DebugServers/GdbRsp/Connection.hpp @@ -23,8 +23,9 @@ namespace Bloom::DebugServers::Gdb class Connection { public: - explicit Connection(std::shared_ptr interruptEventNotifier) - : interruptEventNotifier(std::move(interruptEventNotifier)) + + explicit Connection(EventNotifier& interruptEventNotifier) + : interruptEventNotifier(interruptEventNotifier) {}; /** @@ -83,7 +84,7 @@ namespace Bloom::DebugServers::Gdb * The interruptEventNotifier allows us to interrupt blocking IO calls on the GDB debug server. * Under the hood, this is just a wrapper for a Linux event notifier. See the EventNotifier class for more. */ - std::shared_ptr interruptEventNotifier = nullptr; + EventNotifier& interruptEventNotifier; bool readInterruptEnabled = false; /**