LLDB  mainline
Public Member Functions | Private Member Functions | List of all members
lldb_private::Connection Class Referenceabstract

#include "lldb/Utility/Connection.h"

Inheritance diagram for lldb_private::Connection:
Inheritance graph
[legend]

Public Member Functions

 Connection ()=default
 Default constructor. More...
 
virtual ~Connection ()
 Virtual destructor since this class gets subclassed and handed to a Communication object. More...
 
virtual lldb::ConnectionStatus Connect (llvm::StringRef url, Status *error_ptr)=0
 Connect using the connect string url. More...
 
virtual lldb::ConnectionStatus Disconnect (Status *error_ptr)=0
 Disconnect the communications connection if one is currently connected. More...
 
virtual bool IsConnected () const =0
 Check if the connection is valid. More...
 
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. More...
 
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. More...
 
virtual std::string GetURI ()=0
 Returns a URI that describes this connection object. More...
 
virtual bool InterruptRead ()=0
 Interrupts an ongoing Read() operation. More...
 
virtual lldb::IOObjectSP GetReadObject ()
 Returns the underlying IOObject used by the Connection. More...
 

Private Member Functions

 Connection (const Connection &)=delete
 
const Connectionoperator= (const Connection &)=delete
 

Detailed Description

A communication connection class.

A class that implements that actual communication functions for connecting/disconnecting, reading/writing, and waiting for bytes to become available from a two way communication connection.

This class is designed to only do very simple communication functions. Instances can be instantiated and given to a Communication class to perform communications where clients can listen for broadcasts, and perform other higher level communications.

Definition at line 41 of file Connection.h.

Constructor & Destructor Documentation

◆ Connection() [1/2]

lldb_private::Connection::Connection ( )
default

Default constructor.

◆ ~Connection()

Connection::~Connection ( )
virtualdefault

Virtual destructor since this class gets subclassed and handed to a Communication object.

◆ Connection() [2/2]

lldb_private::Connection::Connection ( const Connection )
privatedelete

Member Function Documentation

◆ Connect()

virtual lldb::ConnectionStatus lldb_private::Connection::Connect ( llvm::StringRef  url,
Status error_ptr 
)
pure virtual

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

Implemented in lldb_private::ConnectionFileDescriptor, and lldb_private::ConnectionGenericFile.

◆ Disconnect()

virtual lldb::ConnectionStatus lldb_private::Connection::Disconnect ( Status error_ptr)
pure virtual

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

Implemented in lldb_private::ConnectionFileDescriptor, and lldb_private::ConnectionGenericFile.

◆ GetReadObject()

virtual lldb::IOObjectSP lldb_private::Connection::GetReadObject ( )
inlinevirtual

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 in lldb_private::ConnectionFileDescriptor.

Definition at line 174 of file Connection.h.

Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::StartSTDIOForwarding().

◆ GetURI()

virtual std::string lldb_private::Connection::GetURI ( )
pure virtual

Returns a URI that describes this connection object.

Subclasses may override this function.

Returns
Returns URI or an empty string if disconnecteds

Implemented in lldb_private::ConnectionFileDescriptor, and lldb_private::ConnectionGenericFile.

Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::LaunchGDBServer().

◆ InterruptRead()

virtual bool lldb_private::Connection::InterruptRead ( )
pure virtual

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.

Implemented in lldb_private::ConnectionFileDescriptor, and lldb_private::ConnectionGenericFile.

◆ IsConnected()

virtual bool lldb_private::Connection::IsConnected ( ) const
pure virtual

Check if the connection is valid.

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

Implemented in lldb_private::ConnectionFileDescriptor, and lldb_private::ConnectionGenericFile.

◆ operator=()

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

◆ Read()

virtual size_t lldb_private::Connection::Read ( void *  dst,
size_t  dst_len,
const Timeout< std::micro > &  timeout,
lldb::ConnectionStatus status,
Status error_ptr 
)
pure virtual

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);

Implemented in lldb_private::ConnectionFileDescriptor, and lldb_private::ConnectionGenericFile.

◆ Write()

virtual size_t lldb_private::Connection::Write ( const void *  dst,
size_t  dst_len,
lldb::ConnectionStatus status,
Status error_ptr 
)
pure virtual

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.

Implemented in lldb_private::ConnectionFileDescriptor, and lldb_private::ConnectionGenericFile.


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