LLDB mainline
|
#include <ConnectionFileDescriptorPosix.h>
Public Types | |
typedef llvm::function_ref< void(llvm::StringRef local_socket_id)> | socket_id_callback_type |
Public Member Functions | |
ConnectionFileDescriptor () | |
ConnectionFileDescriptor (int fd, bool owns_fd) | |
ConnectionFileDescriptor (std::unique_ptr< Socket > socket_up) | |
~ConnectionFileDescriptor () override | |
bool | IsConnected () const override |
Check if the connection is valid. | |
lldb::ConnectionStatus | Connect (llvm::StringRef url, Status *error_ptr) override |
Connect using the connect string url. | |
lldb::ConnectionStatus | Connect (llvm::StringRef url, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | Disconnect (Status *error_ptr) override |
Disconnect the communications connection if one is currently connected. | |
size_t | Read (void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr) override |
The read function that attempts to read from the connection. | |
size_t | Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr) override |
The actual write function that attempts to write to the communications protocol. | |
std::string | GetURI () override |
Returns a URI that describes this connection object. | |
lldb::ConnectionStatus | BytesAvailable (const Timeout< std::micro > &timeout, Status *error_ptr) |
bool | InterruptRead () override |
Interrupts an ongoing Read() operation. | |
lldb::IOObjectSP | GetReadObject () override |
Returns the underlying IOObject used by the Connection. | |
Public Member Functions inherited from lldb_private::Connection | |
Connection ()=default | |
Default constructor. | |
virtual | ~Connection () |
Virtual destructor since this class gets subclassed and handed to a Communication object. |
Protected Member Functions | |
void | OpenCommandPipe () |
void | CloseCommandPipe () |
lldb::ConnectionStatus | AcceptSocket (Socket::SocketProtocol socket_protocol, llvm::StringRef socket_name, llvm::function_ref< void(Socket &)> post_listen_callback, Status *error_ptr) |
lldb::ConnectionStatus | ConnectSocket (Socket::SocketProtocol socket_protocol, llvm::StringRef socket_name, Status *error_ptr) |
lldb::ConnectionStatus | AcceptTCP (llvm::StringRef host_and_port, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | ConnectTCP (llvm::StringRef host_and_port, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | ConnectUDP (llvm::StringRef args, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | ConnectNamedSocket (llvm::StringRef socket_name, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | AcceptNamedSocket (llvm::StringRef socket_name, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | AcceptAbstractSocket (llvm::StringRef socket_name, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | ConnectAbstractSocket (llvm::StringRef socket_name, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | ConnectFD (llvm::StringRef args, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | ConnectFile (llvm::StringRef args, socket_id_callback_type socket_id_callback, Status *error_ptr) |
lldb::ConnectionStatus | ConnectSerialPort (llvm::StringRef args, socket_id_callback_type socket_id_callback, Status *error_ptr) |
Protected Attributes | |
lldb::IOObjectSP | m_io_sp |
Pipe | m_pipe |
std::recursive_mutex | m_mutex |
std::atomic< bool > | m_shutting_down |
std::string | m_uri |
Private Member Functions | |
ConnectionFileDescriptor (const ConnectionFileDescriptor &)=delete | |
const ConnectionFileDescriptor & | operator= (const ConnectionFileDescriptor &)=delete |
Definition at line 26 of file ConnectionFileDescriptorPosix.h.
typedef llvm::function_ref<void(llvm::StringRef local_socket_id)> lldb_private::ConnectionFileDescriptor::socket_id_callback_type |
Definition at line 29 of file ConnectionFileDescriptorPosix.h.
ConnectionFileDescriptor::ConnectionFileDescriptor | ( | ) |
Definition at line 55 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection::Connection(), lldb_private::Connection, lldb_private::GetLog(), LLDB_LOGF, m_mutex, m_pipe, m_shutting_down, and lldb_private::Object.
Referenced by Connect(), ConnectionFileDescriptor(), and operator=().
ConnectionFileDescriptor::ConnectionFileDescriptor | ( | int | fd, |
bool | owns_fd ) |
Definition at line 62 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection::Connection(), lldb_private::Connection, lldb_private::File::eOpenOptionReadWrite, lldb_private::GetLog(), LLDB_LOGF, m_io_sp, m_mutex, m_pipe, m_shutting_down, lldb_private::Object, and OpenCommandPipe().
ConnectionFileDescriptor::ConnectionFileDescriptor | ( | std::unique_ptr< Socket > | socket_up | ) |
Definition at line 75 of file ConnectionFileDescriptorPosix.cpp.
References m_io_sp, m_shutting_down, and m_uri.
|
override |
Definition at line 82 of file ConnectionFileDescriptorPosix.cpp.
References CloseCommandPipe(), lldb_private::Connection, Disconnect(), lldb_private::GetLog(), LLDB_LOGF, and lldb_private::Object.
|
privatedelete |
References ConnectionFileDescriptor().
|
protected |
Definition at line 592 of file ConnectionFileDescriptorPosix.cpp.
References AcceptSocket(), and lldb_private::Socket::ProtocolUnixAbstract.
Referenced by Connect().
|
protected |
Definition at line 575 of file ConnectionFileDescriptorPosix.cpp.
References AcceptSocket(), and lldb_private::Socket::ProtocolUnixDomain.
Referenced by Connect().
|
protected |
Definition at line 526 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Socket::Create(), lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, error(), m_io_sp, and m_uri.
Referenced by AcceptAbstractSocket(), AcceptNamedSocket(), and AcceptTCP().
|
protected |
Definition at line 610 of file ConnectionFileDescriptorPosix.cpp.
References AcceptSocket(), lldb::eConnectionStatusSuccess, lldb_private::TCPSocket::GetRemoteConnectionURI(), m_io_sp, m_uri, and lldb_private::Socket::ProtocolTcp.
Referenced by Connect().
ConnectionStatus ConnectionFileDescriptor::BytesAvailable | ( | const Timeout< std::micro > & | timeout, |
Status * | error_ptr ) |
Definition at line 430 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection, lldb::eConnectionStatusEndOfFile, lldb::eConnectionStatusError, lldb::eConnectionStatusInterrupted, lldb::eConnectionStatusLostConnection, lldb::eConnectionStatusSuccess, lldb::eConnectionStatusTimedOut, error(), SelectHelper::FDIsSetRead(), SelectHelper::FDSetRead(), lldb_private::Status::FromErrorString(), lldb_private::GetLog(), lldb_private::IOObject::kInvalidHandleValue, LLDB_LOG, LLDB_LOGF, m_io_sp, m_pipe, SelectHelper::Select(), SelectHelper::SetTimeout(), and UNUSED_IF_ASSERT_DISABLED.
Referenced by Read().
|
protected |
Definition at line 110 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection, lldb_private::GetLog(), LLDB_LOGF, and m_pipe.
Referenced by OpenCommandPipe(), and ~ConnectionFileDescriptor().
ConnectionStatus ConnectionFileDescriptor::Connect | ( | llvm::StringRef | url, |
socket_id_callback_type | socket_id_callback, | ||
Status * | error_ptr ) |
Definition at line 128 of file ConnectionFileDescriptorPosix.cpp.
References AcceptAbstractSocket(), AcceptNamedSocket(), AcceptTCP(), ConnectAbstractSocket(), ConnectFD(), ConnectFile(), lldb_private::Connection, ConnectionFileDescriptor(), ConnectNamedSocket(), ConnectSerialPort(), ConnectTCP(), ConnectUDP(), lldb::eConnectionStatusError, lldb_private::Status::FromErrorString(), lldb_private::Status::FromErrorStringWithFormat(), lldb_private::GetLog(), LLDB_LOGF, m_mutex, OpenCommandPipe(), and lldb_private::Status.
|
overridevirtual |
Connect using the connect string url.
[in] | url | A string that contains all information needed by the subclass to connect to another client. |
[out] | error_ptr | A pointer to an error object that should be given an appropriate error value if this method returns false. This value can be NULL if the error value should be ignored. |
Implements lldb_private::Connection.
Definition at line 122 of file ConnectionFileDescriptorPosix.cpp.
References Connect().
Referenced by Connect().
|
protected |
Definition at line 603 of file ConnectionFileDescriptorPosix.cpp.
References ConnectSocket(), and lldb_private::Socket::ProtocolUnixAbstract.
Referenced by Connect().
|
protected |
Definition at line 655 of file ConnectionFileDescriptorPosix.cpp.
References lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, lldb_private::File::eOpenOptionReadWrite, lldb_private::Status::FromErrorStringWithFormat(), m_io_sp, and m_uri.
Referenced by Connect().
|
protected |
Definition at line 710 of file ConnectionFileDescriptorPosix.cpp.
References lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, lldb_private::File::eOpenOptionReadWrite, lldb_private::Status::FromErrno(), lldb_private::FileSystem::Instance(), m_io_sp, and lldb_private::FileSystem::Open().
Referenced by Connect().
|
protected |
Definition at line 586 of file ConnectionFileDescriptorPosix.cpp.
References ConnectSocket(), and lldb_private::Socket::ProtocolUnixDomain.
Referenced by Connect().
|
protected |
Definition at line 758 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::SerialPort::Create(), lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, lldb_private::File::eOpenOptionReadWrite, lldb_private::Status::FromErrno(), lldb_private::Status::FromError(), lldb_private::FileSystem::Instance(), m_io_sp, lldb_private::FileSystem::Open(), and lldb_private::SerialPort::OptionsFromURL().
Referenced by Connect().
|
protected |
Definition at line 555 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Socket::Create(), lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, error(), m_io_sp, and m_uri.
Referenced by ConnectAbstractSocket(), ConnectNamedSocket(), and ConnectTCP().
|
protected |
Definition at line 628 of file ConnectionFileDescriptorPosix.cpp.
References ConnectSocket(), and lldb_private::Socket::ProtocolTcp.
Referenced by Connect().
|
protected |
Definition at line 635 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection, lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, lldb_private::Status::FromError(), lldb_private::GetLog(), LLDB_LOG_ERROR, m_io_sp, m_uri, lldb_private::Status, and lldb_private::Socket::UdpConnect().
Referenced by Connect().
|
overridevirtual |
Disconnect the communications connection if one is currently connected.
[out] | error_ptr | A pointer to an error object that should be given an appropriate error value if this method returns false. This value can be NULL if the error value should be ignored. |
Implements lldb_private::Connection.
Definition at line 186 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection, lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, error(), lldb_private::GetLog(), IsConnected(), LLDB_LOG, LLDB_LOGF, m_io_sp, m_mutex, m_pipe, m_shutting_down, and m_uri.
Referenced by ~ConnectionFileDescriptor().
|
inlineoverridevirtual |
Returns the underlying IOObject used by the Connection.
The IOObject can be used to wait for data to become available on the connection. If the Connection does not use IOObjects (and hence does not support waiting) this function should return a null pointer.
Reimplemented from lldb_private::Connection.
Definition at line 63 of file ConnectionFileDescriptorPosix.h.
References m_io_sp.
|
overridevirtual |
Returns a URI that describes this connection object.
Subclasses may override this function.
Implements lldb_private::Connection.
Definition at line 412 of file ConnectionFileDescriptorPosix.cpp.
References m_uri.
|
overridevirtual |
Interrupts an ongoing Read() operation.
If there is an ongoing read operation in another thread, this operation return with status == eConnectionStatusInterrupted. Note that if there data waiting to be read and an interrupt request is issued, the Read() function will return the data immediately without processing the interrupt request (which will remain queued for the next Read() operation).
Implements lldb_private::Connection.
Definition at line 182 of file ConnectionFileDescriptorPosix.cpp.
References m_pipe.
|
overridevirtual |
Check if the connection is valid.
Implements lldb_private::Connection.
Definition at line 118 of file ConnectionFileDescriptorPosix.cpp.
References m_io_sp.
Referenced by Disconnect(), and Write().
|
protected |
Definition at line 90 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Status::AsCString(), CloseCommandPipe(), lldb_private::Connection, lldb_private::GetLog(), LLDB_LOGF, m_pipe, and lldb_private::Status::Success().
Referenced by Connect(), and ConnectionFileDescriptor().
|
privatedelete |
References ConnectionFileDescriptor().
|
overridevirtual |
The read function that attempts to read from the connection.
[in] | dst | A destination buffer that must be at least dst_len bytes long. |
[in] | dst_len | The number of bytes to attempt to read, and also the max number of bytes that can be placed into dst. |
[in] | timeout | The number of microseconds to wait for the data. |
[out] | status | On return, indicates whether the call was successful or terminated due to some error condition. |
[out] | error_ptr | A pointer to an error object that should be given an appropriate error value if this method returns zero. This value can be NULL if the error value should be ignored. |
Implements lldb_private::Connection.
Definition at line 239 of file ConnectionFileDescriptorPosix.cpp.
References BytesAvailable(), lldb_private::Connection, lldb::eConnectionStatusEndOfFile, lldb::eConnectionStatusError, lldb::eConnectionStatusLostConnection, lldb::eConnectionStatusSuccess, lldb::eConnectionStatusTimedOut, lldb_private::IOObject::eFDTypeSocket, error(), lldb_private::Status::FromErrorString(), lldb_private::GetLog(), LLDB_LOG, LLDB_LOGF, m_io_sp, m_mutex, and m_shutting_down.
|
overridevirtual |
The actual write function that attempts to write to the communications protocol.
Subclasses must override this function.
[in] | dst | A destination buffer that must be at least dst_len bytes long. |
[in] | dst_len | The number of bytes to attempt to write, and also the number of bytes are currently available in dst. |
[out] | error_ptr | A pointer to an error object that should be given an appropriate error value if this method returns zero. This value can be NULL if the error value should be ignored. |
Implements lldb_private::Connection.
Definition at line 347 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection, lldb::eConnectionStatusError, lldb::eConnectionStatusLostConnection, lldb::eConnectionStatusNoConnection, lldb::eConnectionStatusSuccess, error(), lldb_private::Status::FromErrorString(), lldb_private::GetLog(), IsConnected(), LLDB_LOG, LLDB_LOGF, m_io_sp, and m_shutting_down.
|
protected |
Definition at line 125 of file ConnectionFileDescriptorPosix.h.
Referenced by AcceptSocket(), AcceptTCP(), BytesAvailable(), ConnectFD(), ConnectFile(), ConnectionFileDescriptor(), ConnectionFileDescriptor(), ConnectSerialPort(), ConnectSocket(), ConnectUDP(), Disconnect(), GetReadObject(), IsConnected(), Read(), and Write().
|
protected |
Definition at line 128 of file ConnectionFileDescriptorPosix.h.
Referenced by Connect(), ConnectionFileDescriptor(), ConnectionFileDescriptor(), Disconnect(), and Read().
|
protected |
Definition at line 127 of file ConnectionFileDescriptorPosix.h.
Referenced by BytesAvailable(), CloseCommandPipe(), ConnectionFileDescriptor(), ConnectionFileDescriptor(), Disconnect(), InterruptRead(), and OpenCommandPipe().
|
protected |
Definition at line 129 of file ConnectionFileDescriptorPosix.h.
Referenced by ConnectionFileDescriptor(), ConnectionFileDescriptor(), ConnectionFileDescriptor(), Disconnect(), Read(), and Write().
|
protected |
Definition at line 133 of file ConnectionFileDescriptorPosix.h.
Referenced by AcceptSocket(), AcceptTCP(), ConnectFD(), ConnectionFileDescriptor(), ConnectSocket(), ConnectUDP(), Disconnect(), and GetURI().