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 (bool child_processes_inherit=false) | |
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. | |
bool | GetChildProcessesInherit () const |
void | SetChildProcessesInherit (bool child_processes_inherit) |
![]() | |
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 |
bool | m_child_processes_inherit |
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 | ( | bool | child_processes_inherit = false | ) |
Definition at line 54 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 63 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 77 of file ConnectionFileDescriptorPosix.cpp.
References InitializeSocket().
|
override |
Definition at line 83 of file ConnectionFileDescriptorPosix.cpp.
References CloseCommandPipe(), lldb_private::Connection, Disconnect(), lldb_private::GetLog(), LLDB_LOGF, and lldb_private::Object.
|
privatedelete |
|
protected |
Definition at line 604 of file ConnectionFileDescriptorPosix.cpp.
References AcceptSocket(), and lldb_private::Socket::ProtocolUnixAbstract.
Referenced by Connect().
|
protected |
Definition at line 587 of file ConnectionFileDescriptorPosix.cpp.
References AcceptSocket(), and lldb_private::Socket::ProtocolUnixDomain.
Referenced by Connect().
|
protected |
Definition at line 537 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Socket::Create(), lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, error(), m_child_processes_inherit, m_io_sp, and m_uri.
Referenced by AcceptAbstractSocket(), AcceptNamedSocket(), and AcceptTCP().
|
protected |
Definition at line 622 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 442 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::GetLog(), lldb_private::IOObject::kInvalidHandleValue, LLDB_LOG, LLDB_LOGF, m_io_sp, m_pipe, SelectHelper::Select(), lldb_private::Status::SetErrorString(), and SelectHelper::SetTimeout().
Referenced by Read().
|
protected |
Definition at line 111 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 130 of file ConnectionFileDescriptorPosix.cpp.
References AcceptAbstractSocket(), AcceptNamedSocket(), AcceptTCP(), ConnectAbstractSocket(), ConnectFD(), ConnectFile(), lldb_private::Connection, ConnectNamedSocket(), ConnectSerialPort(), ConnectTCP(), ConnectUDP(), lldb::eConnectionStatusError, lldb_private::GetLog(), LLDB_LOGF, m_mutex, OpenCommandPipe(), lldb_private::Status::SetErrorString(), and lldb_private::Status::SetErrorStringWithFormat().
|
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 123 of file ConnectionFileDescriptorPosix.cpp.
References Connect().
Referenced by Connect(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::ListenThread().
|
protected |
Definition at line 615 of file ConnectionFileDescriptorPosix.cpp.
References ConnectSocket(), and lldb_private::Socket::ProtocolUnixAbstract.
Referenced by Connect().
|
protected |
Definition at line 668 of file ConnectionFileDescriptorPosix.cpp.
References lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, lldb_private::File::eOpenOptionReadWrite, m_io_sp, m_uri, and lldb_private::Status::SetErrorStringWithFormat().
Referenced by Connect().
|
protected |
Definition at line 723 of file ConnectionFileDescriptorPosix.cpp.
References lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, lldb_private::File::eOpenOptionReadWrite, m_io_sp, and lldb_private::Status::SetErrorToErrno().
Referenced by Connect().
|
protected |
Definition at line 598 of file ConnectionFileDescriptorPosix.cpp.
References ConnectSocket(), and lldb_private::Socket::ProtocolUnixDomain.
Referenced by Connect().
|
protected |
Definition at line 761 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::SerialPort::Create(), lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, lldb_private::File::eOpenOptionReadWrite, m_io_sp, lldb_private::SerialPort::OptionsFromURL(), and lldb_private::Status::SetErrorToErrno().
Referenced by Connect().
|
protected |
Definition at line 566 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Socket::Create(), lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, error(), m_child_processes_inherit, m_io_sp, and m_uri.
Referenced by ConnectAbstractSocket(), ConnectNamedSocket(), and ConnectTCP().
|
protected |
Definition at line 640 of file ConnectionFileDescriptorPosix.cpp.
References ConnectSocket(), and lldb_private::Socket::ProtocolTcp.
Referenced by Connect().
|
protected |
Definition at line 647 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection, lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, lldb_private::GetLog(), LLDB_LOG_ERROR, m_child_processes_inherit, 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 190 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Status::AsCString(), lldb_private::Connection, lldb::eConnectionStatusError, lldb::eConnectionStatusSuccess, lldb_private::IOObject::eFDTypeSocket, error(), lldb_private::GetLog(), IsConnected(), LLDB_LOGF, m_io_sp, m_mutex, m_pipe, m_shutting_down, m_uri, and lldb_private::Socket::PreDisconnect().
Referenced by ~ConnectionFileDescriptor().
bool ConnectionFileDescriptor::GetChildProcessesInherit | ( | ) | const |
Definition at line 802 of file ConnectionFileDescriptorPosix.cpp.
References m_child_processes_inherit.
|
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 424 of file ConnectionFileDescriptorPosix.cpp.
References m_uri.
|
private |
Definition at line 811 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 184 of file ConnectionFileDescriptorPosix.cpp.
References m_pipe, and lldb_private::Status::Success().
|
overridevirtual |
Check if the connection is valid.
Implements lldb_private::Connection.
Definition at line 119 of file ConnectionFileDescriptorPosix.cpp.
References m_io_sp.
Referenced by Disconnect(), and Write().
|
protected |
Definition at line 91 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Status::AsCString(), CloseCommandPipe(), lldb_private::Connection, lldb_private::GetLog(), LLDB_LOGF, m_child_processes_inherit, 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 248 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::GetLog(), LLDB_LOG, LLDB_LOGF, m_io_sp, m_mutex, m_shutting_down, and lldb_private::Status::SetErrorString().
void ConnectionFileDescriptor::SetChildProcessesInherit | ( | bool | child_processes_inherit | ) |
Definition at line 806 of file ConnectionFileDescriptorPosix.cpp.
References m_child_processes_inherit.
|
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 357 of file ConnectionFileDescriptorPosix.cpp.
References lldb_private::Connection, lldb::eConnectionStatusError, lldb::eConnectionStatusLostConnection, lldb::eConnectionStatusNoConnection, lldb::eConnectionStatusSuccess, error(), lldb_private::GetLog(), IsConnected(), LLDB_LOGF, m_io_sp, m_shutting_down, and lldb_private::Status::SetErrorString().
|
protected |
Definition at line 138 of file ConnectionFileDescriptorPosix.h.
Referenced by AcceptSocket(), ConnectSocket(), ConnectUDP(), GetChildProcessesInherit(), OpenCommandPipe(), and SetChildProcessesInherit().
|
protected |
Definition at line 131 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 134 of file ConnectionFileDescriptorPosix.h.
Referenced by Connect(), Disconnect(), and Read().
|
protected |
Definition at line 133 of file ConnectionFileDescriptorPosix.h.
Referenced by BytesAvailable(), CloseCommandPipe(), Disconnect(), InterruptRead(), and OpenCommandPipe().
|
protected |
Definition at line 135 of file ConnectionFileDescriptorPosix.h.
Referenced by Disconnect(), Read(), and Write().
|
protected |
Definition at line 140 of file ConnectionFileDescriptorPosix.h.
Referenced by AcceptSocket(), AcceptTCP(), ConnectFD(), ConnectSocket(), ConnectUDP(), Disconnect(), GetURI(), and InitializeSocket().