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 (Socket *socket) | |
~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. | |
virtual lldb::ConnectionStatus | Connect (llvm::StringRef url, Status *error_ptr)=0 |
Connect using the connect string url. | |
virtual lldb::ConnectionStatus | Disconnect (Status *error_ptr)=0 |
Disconnect the communications connection if one is currently connected. | |
virtual bool | IsConnected () const =0 |
Check if the connection is valid. | |
virtual size_t | Read (void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr)=0 |
The read function that attempts to read from the connection. | |
virtual size_t | Write (const void *dst, size_t dst_len, lldb::ConnectionStatus &status, Status *error_ptr)=0 |
The actual write function that attempts to write to the communications protocol. | |
virtual std::string | GetURI ()=0 |
Returns a URI that describes this connection object. | |
virtual bool | InterruptRead ()=0 |
Interrupts an ongoing Read() operation. | |
virtual lldb::IOObjectSP | GetReadObject () |
Returns the underlying IOObject used by the Connection. | |
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 | |
void | InitializeSocket (Socket *socket) |
ConnectionFileDescriptor (const ConnectionFileDescriptor &)=delete | |
const ConnectionFileDescriptor & | operator= (const ConnectionFileDescriptor &)=delete |
Definition at line 29 of file ConnectionFileDescriptorPosix.h.
typedef llvm::function_ref<void(llvm::StringRef local_socket_id)> lldb_private::ConnectionFileDescriptor::socket_id_callback_type |
Definition at line 32 of file ConnectionFileDescriptorPosix.h.
ConnectionFileDescriptor::ConnectionFileDescriptor | ( | ) |
Definition at line 55 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection, lldb_private::GetLog(), LLDB_LOGF, and lldb_private::Object.
ConnectionFileDescriptor::ConnectionFileDescriptor | ( | int | fd, |
bool | owns_fd | ||
) |
Definition at line 62 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection, lldb_private::File::eOpenOptionReadWrite, lldb_private::GetLog(), LLDB_LOGF, m_io_sp, lldb_private::Object, and OpenCommandPipe().
ConnectionFileDescriptor::ConnectionFileDescriptor | ( | Socket * | socket | ) |
Definition at line 75 of file ConnectionFileDescriptorPosix.cpp.
References InitializeSocket().
|
override |
Definition at line 80 of file ConnectionFileDescriptorPosix.cpp.
References CloseCommandPipe(), lldb_private::Connection, Disconnect(), lldb_private::GetLog(), LLDB_LOGF, and lldb_private::Object.
|
privatedelete |
|
protected |
Definition at line 598 of file ConnectionFileDescriptorPosix.cpp.
References AcceptSocket(), and lldb_private::Socket::ProtocolUnixAbstract.
Referenced by Connect().
|
protected |
Definition at line 581 of file ConnectionFileDescriptorPosix.cpp.
References AcceptSocket(), and lldb_private::Socket::ProtocolUnixDomain.
Referenced by Connect().
|
protected |
Definition at line 532 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 616 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 437 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::PipePosix::GetReadFileDescriptor(), 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 108 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::PipePosix::Close(), 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 127 of file ConnectionFileDescriptorPosix.cpp.
References AcceptAbstractSocket(), AcceptNamedSocket(), AcceptTCP(), ConnectAbstractSocket(), ConnectFD(), ConnectFile(), lldb_private::Connection, ConnectNamedSocket(), ConnectSerialPort(), ConnectTCP(), ConnectUDP(), lldb::eConnectionStatusError, lldb_private::Status::FromErrorString(), lldb_private::Status::FromErrorStringWithFormat(), lldb_private::GetLog(), LLDB_LOGF, m_mutex, and OpenCommandPipe().
|
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 120 of file ConnectionFileDescriptorPosix.cpp.
References Connect().
Referenced by Connect(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::ListenThread().
|
protected |
Definition at line 609 of file ConnectionFileDescriptorPosix.cpp.
References ConnectSocket(), and lldb_private::Socket::ProtocolUnixAbstract.
Referenced by Connect().
|
protected |
Definition at line 661 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 716 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 592 of file ConnectionFileDescriptorPosix.cpp.
References ConnectSocket(), and lldb_private::Socket::ProtocolUnixDomain.
Referenced by Connect().
|
protected |
Definition at line 754 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 561 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 634 of file ConnectionFileDescriptorPosix.cpp.
References ConnectSocket(), and lldb_private::Socket::ProtocolTcp.
Referenced by Connect().
|
protected |
Definition at line 641 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, 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 187 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Status::AsCString(), lldb_private::PipePosix::CanWrite(), lldb_private::PipePosix::Close(), lldb_private::Connection, lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, error(), lldb_private::GetLog(), lldb_private::PipePosix::GetWriteFileDescriptor(), IsConnected(), LLDB_LOGF, m_io_sp, m_mutex, m_pipe, m_shutting_down, m_uri, and lldb_private::PipeBase::Write().
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 66 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 419 of file ConnectionFileDescriptorPosix.cpp.
References m_uri.
|
private |
Definition at line 795 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Socket::GetRemoteConnectionURI(), m_io_sp, and m_uri.
Referenced by ConnectionFileDescriptor().
|
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 181 of file ConnectionFileDescriptorPosix.cpp.
References m_pipe, lldb_private::Status::Success(), and lldb_private::PipeBase::Write().
Referenced by lldb_private::Editline::Cancel(), and lldb_private::Editline::Interrupt().
|
overridevirtual |
Check if the connection is valid.
Implements lldb_private::Connection.
Definition at line 116 of file ConnectionFileDescriptorPosix.cpp.
References m_io_sp.
Referenced by Disconnect(), and Write().
|
protected |
Definition at line 88 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Status::AsCString(), CloseCommandPipe(), lldb_private::Connection, lldb_private::PipePosix::CreateNew(), lldb_private::GetLog(), lldb_private::PipePosix::GetReadFileDescriptor(), lldb_private::PipePosix::GetWriteFileDescriptor(), LLDB_LOGF, m_pipe, and lldb_private::Status::Success().
Referenced by Connect(), and ConnectionFileDescriptor().
|
privatedelete |
|
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 242 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.
Referenced by lldb_private::Editline::CompleteCharacter(), and lldb_private::Editline::GetCharacter().
|
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 352 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_LOGF, m_io_sp, and m_shutting_down.
|
protected |
Definition at line 128 of file ConnectionFileDescriptorPosix.h.
Referenced by AcceptSocket(), AcceptTCP(), BytesAvailable(), ConnectFD(), ConnectFile(), ConnectionFileDescriptor(), ConnectSerialPort(), ConnectSocket(), ConnectUDP(), Disconnect(), GetReadObject(), InitializeSocket(), IsConnected(), Read(), and Write().
|
protected |
Definition at line 131 of file ConnectionFileDescriptorPosix.h.
Referenced by Connect(), Disconnect(), and Read().
|
protected |
Definition at line 130 of file ConnectionFileDescriptorPosix.h.
Referenced by BytesAvailable(), CloseCommandPipe(), Disconnect(), InterruptRead(), and OpenCommandPipe().
|
protected |
Definition at line 132 of file ConnectionFileDescriptorPosix.h.
Referenced by Disconnect(), Read(), and Write().
|
protected |
Definition at line 136 of file ConnectionFileDescriptorPosix.h.
Referenced by AcceptSocket(), AcceptTCP(), ConnectFD(), ConnectSocket(), ConnectUDP(), Disconnect(), GetURI(), and InitializeSocket().