LLDB mainline
lldb_private::ConnectionFileDescriptor Class Reference

#include <ConnectionFileDescriptorPosix.h>

Inheritance diagram for lldb_private::ConnectionFileDescriptor:
[legend]

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< boolm_shutting_down
std::string m_uri

Private Member Functions

 ConnectionFileDescriptor (const ConnectionFileDescriptor &)=delete
const ConnectionFileDescriptoroperator= (const ConnectionFileDescriptor &)=delete

Detailed Description

Definition at line 26 of file ConnectionFileDescriptorPosix.h.

Member Typedef Documentation

◆ socket_id_callback_type

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.

Constructor & Destructor Documentation

◆ ConnectionFileDescriptor() [1/4]

◆ ConnectionFileDescriptor() [2/4]

◆ ConnectionFileDescriptor() [3/4]

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.

◆ ~ConnectionFileDescriptor()

ConnectionFileDescriptor::~ConnectionFileDescriptor ( )
override

◆ ConnectionFileDescriptor() [4/4]

lldb_private::ConnectionFileDescriptor::ConnectionFileDescriptor ( const ConnectionFileDescriptor & )
privatedelete

Member Function Documentation

◆ AcceptAbstractSocket()

ConnectionStatus ConnectionFileDescriptor::AcceptAbstractSocket ( llvm::StringRef socket_name,
socket_id_callback_type socket_id_callback,
Status * error_ptr )
protected

◆ AcceptNamedSocket()

ConnectionStatus ConnectionFileDescriptor::AcceptNamedSocket ( llvm::StringRef socket_name,
socket_id_callback_type socket_id_callback,
Status * error_ptr )
protected

Definition at line 575 of file ConnectionFileDescriptorPosix.cpp.

References AcceptSocket(), and lldb_private::Socket::ProtocolUnixDomain.

Referenced by Connect().

◆ AcceptSocket()

lldb::ConnectionStatus ConnectionFileDescriptor::AcceptSocket ( Socket::SocketProtocol socket_protocol,
llvm::StringRef socket_name,
llvm::function_ref< void(Socket &)> post_listen_callback,
Status * error_ptr )
protected

◆ AcceptTCP()

ConnectionStatus ConnectionFileDescriptor::AcceptTCP ( llvm::StringRef host_and_port,
socket_id_callback_type socket_id_callback,
Status * error_ptr )
protected

◆ BytesAvailable()

◆ CloseCommandPipe()

void ConnectionFileDescriptor::CloseCommandPipe ( )
protected

◆ Connect() [1/2]

◆ Connect() [2/2]

ConnectionStatus ConnectionFileDescriptor::Connect ( llvm::StringRef url,
Status * error_ptr )
overridevirtual

Connect using the connect string url.

Parameters
[in]urlA string that contains all information needed by the subclass to connect to another client.
[out]error_ptrA 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.
Returns
True if the connect succeeded, false otherwise. The internal error object should be filled in with an appropriate value based on the result of this function.
See also
Status& Communication::GetError ();

Implements lldb_private::Connection.

Definition at line 122 of file ConnectionFileDescriptorPosix.cpp.

References Connect().

Referenced by Connect().

◆ ConnectAbstractSocket()

lldb::ConnectionStatus ConnectionFileDescriptor::ConnectAbstractSocket ( llvm::StringRef socket_name,
socket_id_callback_type socket_id_callback,
Status * error_ptr )
protected

◆ ConnectFD()

ConnectionStatus ConnectionFileDescriptor::ConnectFD ( llvm::StringRef args,
socket_id_callback_type socket_id_callback,
Status * error_ptr )
protected

◆ ConnectFile()

◆ ConnectNamedSocket()

ConnectionStatus ConnectionFileDescriptor::ConnectNamedSocket ( llvm::StringRef socket_name,
socket_id_callback_type socket_id_callback,
Status * error_ptr )
protected

◆ ConnectSerialPort()

◆ ConnectSocket()

lldb::ConnectionStatus ConnectionFileDescriptor::ConnectSocket ( Socket::SocketProtocol socket_protocol,
llvm::StringRef socket_name,
Status * error_ptr )
protected

◆ ConnectTCP()

ConnectionStatus ConnectionFileDescriptor::ConnectTCP ( llvm::StringRef host_and_port,
socket_id_callback_type socket_id_callback,
Status * error_ptr )
protected

Definition at line 628 of file ConnectionFileDescriptorPosix.cpp.

References ConnectSocket(), and lldb_private::Socket::ProtocolTcp.

Referenced by Connect().

◆ ConnectUDP()

◆ Disconnect()

ConnectionStatus ConnectionFileDescriptor::Disconnect ( Status * error_ptr)
overridevirtual

Disconnect the communications connection if one is currently connected.

Parameters
[out]error_ptrA 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.
Returns
True if the disconnect succeeded, false otherwise. The internal error object should be filled in with an appropriate value based on the result of this function.
See also
Status& Communication::GetError ();

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().

◆ GetReadObject()

lldb::IOObjectSP lldb_private::ConnectionFileDescriptor::GetReadObject ( )
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.

Returns
The underlying IOObject used for reading.

Reimplemented from lldb_private::Connection.

Definition at line 63 of file ConnectionFileDescriptorPosix.h.

References m_io_sp.

◆ GetURI()

std::string ConnectionFileDescriptor::GetURI ( )
overridevirtual

Returns a URI that describes this connection object.

Subclasses may override this function.

Returns
Returns URI or an empty string if disconnecteds

Implements lldb_private::Connection.

Definition at line 412 of file ConnectionFileDescriptorPosix.cpp.

References m_uri.

◆ InterruptRead()

bool ConnectionFileDescriptor::InterruptRead ( )
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).

Returns
Returns true is the interrupt request was successful.

Implements lldb_private::Connection.

Definition at line 182 of file ConnectionFileDescriptorPosix.cpp.

References m_pipe.

◆ IsConnected()

bool ConnectionFileDescriptor::IsConnected ( ) const
overridevirtual

Check if the connection is valid.

Returns
True if this object is currently connected, false otherwise.

Implements lldb_private::Connection.

Definition at line 118 of file ConnectionFileDescriptorPosix.cpp.

References m_io_sp.

Referenced by Disconnect(), and Write().

◆ OpenCommandPipe()

void ConnectionFileDescriptor::OpenCommandPipe ( )
protected

◆ operator=()

const ConnectionFileDescriptor & lldb_private::ConnectionFileDescriptor::operator= ( const ConnectionFileDescriptor & )
privatedelete

◆ Read()

size_t ConnectionFileDescriptor::Read ( void * dst,
size_t dst_len,
const Timeout< std::micro > & timeout,
lldb::ConnectionStatus & status,
Status * error_ptr )
overridevirtual

The read function that attempts to read from the connection.

Parameters
[in]dstA destination buffer that must be at least dst_len bytes long.
[in]dst_lenThe number of bytes to attempt to read, and also the max number of bytes that can be placed into dst.
[in]timeoutThe number of microseconds to wait for the data.
[out]statusOn return, indicates whether the call was successful or terminated due to some error condition.
[out]error_ptrA 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.
Returns
The number of bytes actually read.
See also
size_t Communication::Read (void *, size_t, uint32_t);

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.

◆ Write()

size_t ConnectionFileDescriptor::Write ( const void * dst,
size_t dst_len,
lldb::ConnectionStatus & status,
Status * error_ptr )
overridevirtual

The actual write function that attempts to write to the communications protocol.

Subclasses must override this function.

Parameters
[in]dstA destination buffer that must be at least dst_len bytes long.
[in]dst_lenThe number of bytes to attempt to write, and also the number of bytes are currently available in dst.
[out]error_ptrA 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.
Returns
The number of bytes actually Written.

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.

Member Data Documentation

◆ m_io_sp

◆ m_mutex

std::recursive_mutex lldb_private::ConnectionFileDescriptor::m_mutex
protected

◆ m_pipe

Pipe lldb_private::ConnectionFileDescriptor::m_pipe
protected

◆ m_shutting_down

std::atomic<bool> lldb_private::ConnectionFileDescriptor::m_shutting_down
protected

◆ m_uri

std::string lldb_private::ConnectionFileDescriptor::m_uri
protected

The documentation for this class was generated from the following files: