Renamed EventNotifer to EventFdNotifier and employed new NotifierInterface
This commit is contained in:
@@ -13,9 +13,10 @@ namespace Bloom::DebugServer::Gdb::AvrGdb
|
||||
|
||||
AvrGdbRsp::AvrGdbRsp(
|
||||
const DebugServerConfig& debugServerConfig,
|
||||
EventListener& eventListener
|
||||
EventListener& eventListener,
|
||||
EventFdNotifier& eventNotifier
|
||||
)
|
||||
: GdbRspDebugServer(debugServerConfig, eventListener)
|
||||
: GdbRspDebugServer(debugServerConfig, eventListener, eventNotifier)
|
||||
{}
|
||||
|
||||
void AvrGdbRsp::init() {
|
||||
|
||||
@@ -28,7 +28,8 @@ namespace Bloom::DebugServer::Gdb::AvrGdb
|
||||
public:
|
||||
AvrGdbRsp(
|
||||
const DebugServerConfig& debugServerConfig,
|
||||
EventListener& eventListener
|
||||
EventListener& eventListener,
|
||||
EventFdNotifier& eventNotifier
|
||||
);
|
||||
|
||||
std::string getName() const override {
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Bloom::DebugServer::Gdb
|
||||
|
||||
using ResponsePackets::ResponsePacket;
|
||||
|
||||
Connection::Connection(int serverSocketFileDescriptor, EventNotifier& interruptEventNotifier)
|
||||
Connection::Connection(int serverSocketFileDescriptor, EventFdNotifier& interruptEventNotifier)
|
||||
: interruptEventNotifier(interruptEventNotifier)
|
||||
{
|
||||
this->accept(serverSocketFileDescriptor);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
|
||||
#include "src/Helpers/EventNotifier.hpp"
|
||||
#include "src/Helpers/EventFdNotifier.hpp"
|
||||
#include "src/Helpers/EpollInstance.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/Packet.hpp"
|
||||
@@ -23,7 +23,7 @@ namespace Bloom::DebugServer::Gdb
|
||||
class Connection
|
||||
{
|
||||
public:
|
||||
explicit Connection(int serverSocketFileDescriptor, EventNotifier& interruptEventNotifier);
|
||||
explicit Connection(int serverSocketFileDescriptor, EventFdNotifier& interruptEventNotifier);
|
||||
|
||||
Connection() = delete;
|
||||
Connection(const Connection&) = delete;
|
||||
@@ -77,8 +77,8 @@ namespace Bloom::DebugServer::Gdb
|
||||
int maxPacketSize = 1024;
|
||||
|
||||
/**
|
||||
* The interruptEventNotifier (instance of EventNotifier) allows us to interrupt blocking I/O calls on this
|
||||
* connection's socket. Under the hood, the EventNotifier class is just an RAII wrapper for a Linux eventfd
|
||||
* The interruptEventNotifier (instance of EventFdNotifier) allows us to interrupt blocking I/O calls on this
|
||||
* connection's socket. Under the hood, the EventFdNotifier class is just an RAII wrapper for a Linux eventfd
|
||||
* object.
|
||||
*
|
||||
* The file descriptors of the eventfd object and the socket are both added to an EpollInstance (which is just
|
||||
@@ -86,9 +86,9 @@ namespace Bloom::DebugServer::Gdb
|
||||
* either of the two file descriptors. See any of the Connection I/O functions (e.g Connection::read()) for
|
||||
* more on this.
|
||||
*
|
||||
* See the EventNotifier and EpollInstance classes for more.
|
||||
* See the EventFdNotifier and EpollInstance classes for more.
|
||||
*/
|
||||
EventNotifier& interruptEventNotifier;
|
||||
EventFdNotifier& interruptEventNotifier;
|
||||
EpollInstance epollInstance = EpollInstance();
|
||||
|
||||
bool readInterruptEnabled = false;
|
||||
|
||||
@@ -39,14 +39,13 @@ namespace Bloom::DebugServer::Gdb
|
||||
|
||||
GdbRspDebugServer::GdbRspDebugServer(
|
||||
const DebugServerConfig& debugServerConfig,
|
||||
EventListener& eventListener
|
||||
EventListener& eventListener,
|
||||
EventFdNotifier& eventNotifier
|
||||
)
|
||||
: debugServerConfig(GdbDebugServerConfig(debugServerConfig))
|
||||
, eventListener(eventListener)
|
||||
, interruptEventNotifier(eventListener.getInterruptEventNotifier())
|
||||
{
|
||||
assert(this->interruptEventNotifier != nullptr);
|
||||
}
|
||||
, interruptEventNotifier(eventNotifier)
|
||||
{}
|
||||
|
||||
void GdbRspDebugServer::init() {
|
||||
this->socketAddress.sin_family = AF_INET;
|
||||
@@ -102,7 +101,7 @@ namespace Bloom::DebugServer::Gdb
|
||||
);
|
||||
|
||||
this->epollInstance.addEntry(
|
||||
this->interruptEventNotifier->getFileDescriptor(),
|
||||
this->interruptEventNotifier.getFileDescriptor(),
|
||||
static_cast<std::uint16_t>(EpollEvent::READ_READY)
|
||||
);
|
||||
|
||||
@@ -203,15 +202,15 @@ namespace Bloom::DebugServer::Gdb
|
||||
|
||||
if (
|
||||
!eventFileDescriptor.has_value()
|
||||
|| eventFileDescriptor.value() == this->interruptEventNotifier->getFileDescriptor()
|
||||
|| eventFileDescriptor.value() == this->interruptEventNotifier.getFileDescriptor()
|
||||
) {
|
||||
this->interruptEventNotifier->clear();
|
||||
this->interruptEventNotifier.clear();
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return std::make_optional<Connection>(
|
||||
this->serverSocketFileDescriptor.value(),
|
||||
*(this->interruptEventNotifier)
|
||||
this->interruptEventNotifier
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "GdbDebugServerConfig.hpp"
|
||||
#include "src/EventManager/EventListener.hpp"
|
||||
#include "src/Helpers/EpollInstance.hpp"
|
||||
#include "src/Helpers/EventFdNotifier.hpp"
|
||||
#include "src/TargetController/TargetControllerConsole.hpp"
|
||||
|
||||
#include "Connection.hpp"
|
||||
@@ -41,7 +42,8 @@ namespace Bloom::DebugServer::Gdb
|
||||
public:
|
||||
explicit GdbRspDebugServer(
|
||||
const DebugServerConfig& debugServerConfig,
|
||||
EventListener& eventListener
|
||||
EventListener& eventListener,
|
||||
EventFdNotifier& eventNotifier
|
||||
);
|
||||
|
||||
GdbRspDebugServer() = delete;
|
||||
@@ -86,24 +88,24 @@ namespace Bloom::DebugServer::Gdb
|
||||
EventListener& eventListener;
|
||||
|
||||
/**
|
||||
* EventNotifier object for interrupting blocking I/O operations.
|
||||
* EventFdNotifier object for interrupting blocking I/O operations.
|
||||
*
|
||||
* Extracted from this->eventListener.
|
||||
*
|
||||
* See documentation in src/DebugServer/README.md for more.
|
||||
*/
|
||||
EventNotifier* interruptEventNotifier = nullptr;
|
||||
EventFdNotifier& interruptEventNotifier;
|
||||
|
||||
/**
|
||||
* When waiting for a connection, we don't listen on the this->serverSocketFileDescriptor directly. Instead,
|
||||
* we use an EpollInstance to monitor both this->serverSocketFileDescriptor and this->interruptEventNotifier.
|
||||
* This allows us to interrupt any blocking socket IO calls when EventNotifier::notify() is called on
|
||||
* This allows us to interrupt any blocking socket IO calls when EventFdNotifier::notify() is called on
|
||||
* this->interruptEventNotifier.
|
||||
*
|
||||
* See GdbRspDebugServer::init()
|
||||
* See DebugServer::interruptEventNotifier
|
||||
* See EpollInstance
|
||||
* See EventNotifier
|
||||
* See EventFdNotifier
|
||||
*/
|
||||
EpollInstance epollInstance = EpollInstance();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user