Tidying
This commit is contained in:
@@ -28,6 +28,10 @@ namespace Bloom::DebugServers::Gdb
|
|||||||
Connection() = delete;
|
Connection() = delete;
|
||||||
Connection(const Connection&) = delete;
|
Connection(const Connection&) = delete;
|
||||||
Connection& operator = (Connection&) = delete;
|
Connection& operator = (Connection&) = delete;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: Implement this. For now, use the move constructor.
|
||||||
|
*/
|
||||||
Connection& operator = (Connection&&) = delete;
|
Connection& operator = (Connection&&) = delete;
|
||||||
|
|
||||||
Connection(Connection&& other) noexcept
|
Connection(Connection&& other) noexcept
|
||||||
@@ -69,16 +73,24 @@ namespace Bloom::DebugServers::Gdb
|
|||||||
private:
|
private:
|
||||||
std::optional<int> socketFileDescriptor;
|
std::optional<int> socketFileDescriptor;
|
||||||
|
|
||||||
EpollInstance epollInstance = EpollInstance();
|
|
||||||
|
|
||||||
struct sockaddr_in socketAddress = {};
|
struct sockaddr_in socketAddress = {};
|
||||||
int maxPacketSize = 1024;
|
int maxPacketSize = 1024;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The interruptEventNotifier allows us to interrupt blocking IO calls on the GDB debug server.
|
* The interruptEventNotifier (instance of EventNotifier) allows us to interrupt blocking I/O calls on this
|
||||||
* Under the hood, this is just a wrapper for a Linux event notifier. See the EventNotifier class for more.
|
* connection's socket. Under the hood, the EventNotifier 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
|
||||||
|
* an RAII wrapper for a Linux epoll instance). The EpollInstance object is then used to wait for events on
|
||||||
|
* 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.
|
||||||
*/
|
*/
|
||||||
EventNotifier& interruptEventNotifier;
|
EventNotifier& interruptEventNotifier;
|
||||||
|
EpollInstance epollInstance = EpollInstance();
|
||||||
|
|
||||||
bool readInterruptEnabled = false;
|
bool readInterruptEnabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,8 +144,16 @@ namespace Bloom::DebugServers::Gdb
|
|||||||
*/
|
*/
|
||||||
void write(const std::vector<unsigned char>& buffer);
|
void write(const std::vector<unsigned char>& buffer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes this->interruptEventNotifier's file descriptor from the EpollInstance (this->epollInstance),
|
||||||
|
* preventing subsequent I/O operations on this->socketFileDescriptor from being interrupted.
|
||||||
|
*/
|
||||||
void disableReadInterrupts();
|
void disableReadInterrupts();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts this->interruptEventNotifier's file descriptor into the EpollInstance (this->epollInstance),
|
||||||
|
* allowing for subsequent I/O operations on this->socketFileDescriptor to be interrupted.
|
||||||
|
*/
|
||||||
void enableReadInterrupts();
|
void enableReadInterrupts();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,12 +89,14 @@ namespace Bloom::DebugServers::Gdb
|
|||||||
int serverSocketFileDescriptor = -1;
|
int serverSocketFileDescriptor = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We don't listen on the this->serverSocketFileDescriptor directly. Instead, we use an EpollInstance to
|
* When waiting for a connection, we don't listen on the this->serverSocketFileDescriptor directly. Instead,
|
||||||
* monitor both this->serverSocketFileDescriptor and this->interruptEventNotifier. This allows us to interrupt
|
* we use an EpollInstance to monitor both this->serverSocketFileDescriptor and this->interruptEventNotifier.
|
||||||
* any blocking socket IO calls when EventNotifier::notify() is called on this->interruptEventNotifier.
|
* This allows us to interrupt any blocking socket IO calls when EventNotifier::notify() is called on
|
||||||
|
* this->interruptEventNotifier.
|
||||||
*
|
*
|
||||||
* See GdbRspDebugServer::init()
|
* See GdbRspDebugServer::init()
|
||||||
* See DebugServer::interruptEventNotifier
|
* See DebugServer::interruptEventNotifier
|
||||||
|
* See EpollInstance
|
||||||
* See EventNotifier
|
* See EventNotifier
|
||||||
*/
|
*/
|
||||||
EpollInstance epollInstance = EpollInstance();
|
EpollInstance epollInstance = EpollInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user