LLDB
mainline
|
#include "lldb/Core/Communication.h"
Public Types | |
typedef void(* | ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len) |
Public Member Functions | |
FLAGS_ANONYMOUS_ENUM () | |
Communication (const char *broadcaster_name) | |
Construct the Communication object with the specified name for the Broadcaster that this object inherits from. More... | |
~Communication () override | |
Destructor. More... | |
void | Clear () |
lldb::ConnectionStatus | Connect (const char *url, Status *error_ptr) |
Connect using the current connection by passing url to its connect function. More... | |
lldb::ConnectionStatus | Disconnect (Status *error_ptr=nullptr) |
Disconnect the communications connection if one is currently connected. More... | |
bool | IsConnected () const |
Check if the connection is valid. More... | |
bool | HasConnection () const |
lldb_private::Connection * | GetConnection () |
size_t | Read (void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr) |
Read bytes from the current connection. More... | |
size_t | Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr) |
The actual write function that attempts to write to the communications protocol. More... | |
size_t | WriteAll (const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr) |
Repeatedly attempt writing until either src_len bytes are written or a permanent failure occurs. More... | |
void | SetConnection (std::unique_ptr< Connection > connection) |
Sets the connection that it to be used by this class. More... | |
virtual bool | StartReadThread (Status *error_ptr=nullptr) |
Starts a read thread whose sole purpose it to read bytes from the current connection. More... | |
virtual bool | StopReadThread (Status *error_ptr=nullptr) |
Stops the read thread by cancelling it. More... | |
virtual bool | JoinReadThread (Status *error_ptr=nullptr) |
bool | ReadThreadIsRunning () |
Checks if there is a currently running read thread. More... | |
lldb::thread_result_t | ReadThread () |
The read thread function. More... | |
void | SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback, void *callback_baton) |
void | SynchronizeWithReadThread () |
Wait for the read thread to process all outstanding data. More... | |
bool | GetCloseOnEOF () const |
void | SetCloseOnEOF (bool b) |
ConstString & | GetBroadcasterClass () const override |
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager and do broadcaster class matching. More... | |
![]() | |
Broadcaster (lldb::BroadcasterManagerSP manager_sp, const char *name) | |
Construct with a broadcaster with a name. More... | |
virtual | ~Broadcaster () |
Destructor. More... | |
void | CheckInWithManager () |
void | BroadcastEvent (lldb::EventSP &event_sp) |
Broadcast an event which has no associated data. More... | |
void | BroadcastEventIfUnique (lldb::EventSP &event_sp) |
void | BroadcastEvent (uint32_t event_type, const lldb::EventDataSP &event_data_sp) |
void | BroadcastEvent (uint32_t event_type, EventData *event_data=nullptr) |
void | BroadcastEventIfUnique (uint32_t event_type, EventData *event_data=nullptr) |
void | Clear () |
virtual void | AddInitialEventsToListener (const lldb::ListenerSP &listener_sp, uint32_t requested_events) |
uint32_t | AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask) |
Listen for any events specified by event_mask. More... | |
ConstString | GetBroadcasterName () |
Get the NULL terminated C string name of this Broadcaster object. More... | |
bool | GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const |
Get the event name(s) for one or more event bits. More... | |
void | SetEventName (uint32_t event_mask, const char *name) |
Set the name for an event bit. More... | |
const char * | GetEventName (uint32_t event_mask) const |
bool | EventTypeHasListeners (uint32_t event_type) |
bool | RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX) |
Removes a Listener from this broadcasters list and frees the event bits specified by event_mask that were previously acquired by listener (assuming listener was listening to this object) for other listener objects to use. More... | |
bool | HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX) |
Provides a simple mechanism to temporarily redirect events from broadcaster. More... | |
bool | IsHijackedForEvent (uint32_t event_mask) |
void | RestoreBroadcaster () |
Restore the state of the Broadcaster from a previous hijack attempt. More... | |
lldb::BroadcasterManagerSP | GetManager () |
Static Public Member Functions | |
static std::string | ConnectionStatusAsString (lldb::ConnectionStatus status) |
static ConstString & | GetStaticBroadcasterClass () |
Protected Member Functions | |
size_t | ReadFromConnection (void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr) |
virtual void | AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast, lldb::ConnectionStatus status) |
Append new bytes that get read from the read thread into the internal object byte cache. More... | |
size_t | GetCachedBytes (void *dst, size_t dst_len) |
Get any available bytes from our data cache. More... | |
![]() | |
BroadcasterImplSP | GetBroadcasterImpl () |
const char * | GetHijackingListenerName () |
Protected Attributes | |
lldb::ConnectionSP | m_connection_sp |
The connection that is current in use by this communications class. More... | |
HostThread | m_read_thread |
The read thread handle in case we need to cancel the thread. More... | |
std::atomic< bool > | m_read_thread_enabled |
std::atomic< bool > | m_read_thread_did_exit |
std::string | m_bytes |
A buffer to cache bytes read in the ReadThread function. More... | |
std::recursive_mutex | m_bytes_mutex |
A mutex to protect multi-threaded access to the cached bytes. More... | |
std::mutex | m_write_mutex |
Don't let multiple threads write at the same time... More... | |
std::mutex | m_synchronize_mutex |
ReadThreadBytesReceived | m_callback |
void * | m_callback_baton |
bool | m_close_on_eof |
Private Member Functions | |
Communication (const Communication &)=delete | |
const Communication & | operator= (const Communication &)=delete |
Additional Inherited Members | |
![]() | |
typedef std::shared_ptr< BroadcasterImpl > | BroadcasterImplSP |
typedef std::weak_ptr< BroadcasterImpl > | BroadcasterImplWP |
An abstract communications class.
Communication is an class that handles data communication between two data sources. It uses a Connection class to do the real communication. This approach has a couple of advantages: it allows a single instance of this class to be used even though its connection can change. Connections could negotiate for different connections based on abilities like starting with Bluetooth and negotiating up to WiFi if available. It also allows this class to be subclassed by any interfaces that don't want to give bytes but want to validate and give out packets. This can be done by overriding:
AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast);
Communication inherits from Broadcaster which means it can be used in conjunction with Listener to wait for multiple broadcaster objects and multiple events from each of those objects. Communication defines a set of pre-defined event bits (see enumerations definitions that start with "eBroadcastBit" below).
There are two modes in which communications can occur:
In single-threaded mode, all reads and writes happen synchronously on the calling thread.
In multi-threaded mode, a read thread is spawned that continually reads data and caches any received bytes. To start the read thread clients call:
bool Communication::StartReadThread (Status *);
If true is returned a read thread has been spawned that will continually execute a call to the pure virtual DoRead function:
size_t Communication::ReadFromConnection (void *, size_t, uint32_t);
When bytes are received the data gets cached in m_bytes and this class will broadcast a eBroadcastBitReadThreadGotBytes event. Clients that want packet based communication should override AppendBytesToCache. The subclasses can choose to call the built in AppendBytesToCache with the broadcast parameter set to false. This will cause the eBroadcastBitReadThreadGotBytes event not get broadcast, and then the subclass can post a eBroadcastBitPacketAvailable event when a full packet of data has been received.
If the connection is disconnected a eBroadcastBitDisconnected event gets broadcast. If the read thread exits a eBroadcastBitReadThreadDidExit event will be broadcast. Clients can also post a eBroadcastBitReadThreadShouldExit event to this object which will cause the read thread to exit.
Definition at line 84 of file Communication.h.
typedef void(* lldb_private::Communication::ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len) |
Definition at line 106 of file Communication.h.
Communication::Communication | ( | const char * | broadcaster_name | ) |
Construct the Communication object with the specified name for the Broadcaster that this object inherits from.
[in] | broadcaster_name | The name of the broadcaster object. This name should be as complete as possible to uniquely identify this object. The broadcaster name can be updated after the connect function is called. |
Definition at line 42 of file Communication.cpp.
References lldb_private::Broadcaster::CheckInWithManager(), lldb_private::Communication, lldb_private::GetLog(), LLDB_LOG, lldb_private::Object, and lldb_private::Broadcaster::SetEventName().
|
override |
Destructor.
The destructor is virtual since this class gets subclassed.
Definition at line 63 of file Communication.cpp.
References Clear(), lldb_private::Communication, lldb_private::Broadcaster::GetBroadcasterName(), lldb_private::GetLog(), LLDB_LOG, and lldb_private::Object.
|
privatedelete |
|
protectedvirtual |
Append new bytes that get read from the read thread into the internal object byte cache.
This will cause a eBroadcastBitReadThreadGotBytes event to be broadcast if broadcast is true.
Subclasses can override this function in order to inspect the received data and check if a packet is available.
Subclasses can also still call this function from the overridden method to allow the caching to correctly happen and suppress the broadcasting of the eBroadcastBitReadThreadGotBytes event by setting broadcast to false.
[in] | src | A source buffer that must be at least src_len bytes long. |
[in] | src_len | The number of bytes to append to the cache. |
Definition at line 277 of file Communication.cpp.
References lldb_private::Broadcaster::BroadcastEventIfUnique(), lldb_private::Communication, lldb::eConnectionStatusEndOfFile, lldb_private::GetLog(), LLDB_LOG, m_bytes, m_bytes_mutex, m_callback, and m_callback_baton.
Referenced by ReadThread().
void Communication::Clear | ( | ) |
Definition at line 70 of file Communication.cpp.
References Disconnect(), SetReadThreadBytesReceivedCallback(), and StopReadThread().
Referenced by Connect(), ProcessKDP::DoDetach(), lldb_private::process_gdb_remote::ProcessGDBRemote::WillLaunchOrAttach(), and ~Communication().
ConnectionStatus Communication::Connect | ( | const char * | url, |
Status * | error_ptr | ||
) |
Connect using the current connection by passing url to its connect function.
string.
[in] | url | A string that contains all information needed by the subclass to connect to another client. |
Definition at line 76 of file Communication.cpp.
References Clear(), lldb_private::Communication, lldb::eConnectionStatusNoConnection, lldb_private::GetLog(), LLDB_LOG, m_connection_sp, and lldb_private::Status::SetErrorString().
Referenced by lldb::SBCommunication::Connect().
|
static |
Definition at line 424 of file Communication.cpp.
References lldb::eConnectionStatusEndOfFile, lldb::eConnectionStatusError, lldb::eConnectionStatusInterrupted, lldb::eConnectionStatusLostConnection, lldb::eConnectionStatusNoConnection, lldb::eConnectionStatusSuccess, and lldb::eConnectionStatusTimedOut.
Referenced by ReadThread(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::WaitForPacketNoLock().
ConnectionStatus Communication::Disconnect | ( | Status * | error_ptr = nullptr | ) |
Disconnect the communications connection if one is currently connected.
Definition at line 90 of file Communication.cpp.
References lldb_private::Communication, lldb::eConnectionStatusNoConnection, lldb_private::GetLog(), LLDB_LOG, m_connection_sp, m_read_thread_did_exit, and m_read_thread_enabled.
Referenced by lldb::SBCommunication::AdoptFileDesriptor(), Clear(), lldb_private::process_gdb_remote::ProcessGDBRemote::ConnectToDebugserver(), lldb_private::Process::DestroyImpl(), lldb_private::process_gdb_remote::ProcessGDBRemote::DidExit(), lldb::SBCommunication::Disconnect(), ProcessKDP::DoConnectRemote(), ProcessKDP::DoDetach(), Read(), ReadThread(), SetConnection(), lldb_private::Process::ShouldBroadcastEvent(), lldb_private::process_gdb_remote::GDBRemoteCommunication::WaitForPacketNoLock(), CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock(), CommunicationKDP::~CommunicationKDP(), lldb_private::process_gdb_remote::GDBRemoteCommunication::~GDBRemoteCommunication(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::~GDBRemoteCommunicationClient(), and lldb_private::ScriptInterpreterIORedirect::~ScriptInterpreterIORedirect().
|
inline |
< Sent when the communications connection is lost.
< Sent by the read thread when bytes become available.
< Sent by the read thread when it exits to inform clients.
< Sent by clients that need to cancel the read thread.
< Sent when data received makes a complete packet.
< Sent by the read thread to indicate all pending input has been processed.
< Subclasses can used bits 31:16 for any needed events.
Definition at line 86 of file Communication.h.
|
inlineoverridevirtual |
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager and do broadcaster class matching.
FIXME: Probably should make a ManagedBroadcaster subclass with all the bits needed to work with the BroadcasterManager, so that it is clearer how to add one.
Reimplemented from lldb_private::Broadcaster.
Definition at line 312 of file Communication.h.
References GetStaticBroadcasterClass().
|
protected |
Get any available bytes from our data cache.
If this call empties the data cache, the eBroadcastBitReadThreadGotBytes event will be reset to signify no more bytes are available.
[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 from the cache, and also the max number of bytes that can be placed into dst. |
Definition at line 259 of file Communication.cpp.
References m_bytes, and m_bytes_mutex.
Referenced by Read().
|
inline |
Definition at line 306 of file Communication.h.
References m_close_on_eof.
Referenced by lldb::SBCommunication::GetCloseOnEOF(), Read(), and ReadThread().
|
inline |
Definition at line 162 of file Communication.h.
References m_connection_sp.
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::LaunchGDBServer(), lldb_private::process_gdb_remote::GDBRemoteCommunication::ListenThread(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::MaybeCloseInferiorTerminalConnection(), and lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::StartSTDIOForwarding().
|
static |
Definition at line 37 of file Communication.cpp.
Referenced by GetBroadcasterClass().
bool Communication::HasConnection | ( | ) | const |
Definition at line 119 of file Communication.cpp.
References m_connection_sp.
Referenced by lldb::SBCommunication::AdoptFileDesriptor(), and lldb::SBCommunication::Connect().
bool Communication::IsConnected | ( | ) | const |
Check if the connection is valid.
Definition at line 114 of file Communication.cpp.
References m_connection_sp.
Referenced by lldb::SBCommunication::AdoptFileDesriptor(), lldb_private::process_gdb_remote::ProcessGDBRemote::ConnectToDebugserver(), ProcessKDP::DoDetach(), ProcessKDP::DoReadMemory(), ProcessKDP::DoWriteMemory(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetCurrentProcessAndThreadIDs(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::GetPacketAndSendResponse(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::HandshakeWithServer(), ProcessKDP::IsAlive(), lldb::SBCommunication::IsConnected(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::MaybeCloseInferiorTerminalConnection(), lldb_private::process_gdb_remote::GDBRemoteCommunication::SendRawPacketNoLock(), CommunicationKDP::SendRequestPacketNoLock(), lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SendSetCurrentThreadPacket(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor(), lldb_private::Process::SetSTDIOFileDescriptor(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::StartSTDIOForwarding(), lldb_private::process_gdb_remote::GDBRemoteCommunication::WaitForPacketNoLock(), CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock(), CommunicationKDP::~CommunicationKDP(), lldb_private::process_gdb_remote::GDBRemoteCommunication::~GDBRemoteCommunication(), and lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::~GDBRemoteCommunicationClient().
|
virtual |
Definition at line 251 of file Communication.cpp.
References error(), lldb_private::HostThread::IsJoinable(), lldb_private::HostThread::Join(), and m_read_thread.
Referenced by lldb_private::ScriptInterpreterIORedirect::~ScriptInterpreterIORedirect().
|
privatedelete |
size_t Communication::Read | ( | void * | dst, |
size_t | dst_len, | ||
const Timeout< std::micro > & | timeout, | ||
lldb::ConnectionStatus & | status, | ||
Status * | error_ptr | ||
) |
Read bytes from the current connection.
If no read thread is running, this function call the connection's Connection::Read(...) function to get any available.
If a read thread has been started, this function will check for any cached bytes that have already been read and return any currently available bytes. If no bytes are cached, it will wait for the bytes to become available by listening for the eBroadcastBitReadThreadGotBytes event. If this function consumes all of the bytes in the cache, it will reset the eBroadcastBitReadThreadGotBytes event bit.
[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 | A timeout value or llvm::None for no timeout. |
Definition at line 123 of file Communication.cpp.
References lldb_private::Communication, Disconnect(), lldb::eConnectionStatusNoConnection, lldb::eConnectionStatusSuccess, GetCachedBytes(), GetCloseOnEOF(), lldb_private::GetLog(), LLDB_LOG, m_connection_sp, m_read_thread_enabled, lldb_private::Listener::MakeListener(), ReadFromConnection(), and lldb_private::Status::SetErrorString().
Referenced by lldb::SBCommunication::Read(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::SendProcessOutput(), lldb_private::process_gdb_remote::GDBRemoteCommunication::WaitForPacketNoLock(), and CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock().
|
protected |
Definition at line 298 of file Communication.cpp.
References lldb::eConnectionStatusNoConnection, m_connection_sp, and lldb_private::Status::SetErrorString().
Referenced by Read(), and ReadThread().
lldb::thread_result_t Communication::ReadThread | ( | ) |
The read thread function.
This function will call the "DoRead" function continuously and wait for data to become available. When data is received it will append the available data to the internal cache and broadcast a eBroadcastBitReadThreadGotBytes event.
[in] | comm_ptr | A pointer to an instance of this class. |
Definition at line 314 of file Communication.cpp.
References AppendBytesToCache(), lldb_private::Broadcaster::BroadcastEvent(), lldb_private::Communication, ConnectionStatusAsString(), Disconnect(), lldb::eConnectionStatusEndOfFile, lldb::eConnectionStatusError, lldb::eConnectionStatusInterrupted, lldb::eConnectionStatusLostConnection, lldb::eConnectionStatusNoConnection, lldb::eConnectionStatusSuccess, lldb::eConnectionStatusTimedOut, lldb::eErrorTypePOSIX, error(), GetCloseOnEOF(), lldb_private::GetLog(), LLDB_LOG, m_read_thread_did_exit, m_read_thread_enabled, m_synchronize_mutex, and ReadFromConnection().
Referenced by StartReadThread().
bool Communication::ReadThreadIsRunning | ( | ) |
Checks if there is a currently running read thread.
Definition at line 312 of file Communication.cpp.
References m_read_thread_enabled.
Referenced by lldb::SBCommunication::ReadThreadIsRunning().
|
inline |
Definition at line 308 of file Communication.h.
References m_close_on_eof.
Referenced by lldb::SBCommunication::SetCloseOnEOF(), and lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor().
void Communication::SetConnection | ( | std::unique_ptr< Connection > | connection | ) |
Sets the connection that it to be used by this class.
By making a communication class that uses different connections it allows a single communication interface to negotiate and change its connection without any interruption to the client. It also allows the Communication class to be subclassed for packet based communication.
[in] | connection | A connection that this class will own and destroy. |
Definition at line 417 of file Communication.cpp.
References Disconnect(), m_connection_sp, and StopReadThread().
Referenced by lldb::SBCommunication::AdoptFileDesriptor(), lldb::SBCommunication::Connect(), lldb_private::process_gdb_remote::GDBRemoteCommunication::ConnectLocally(), lldb_private::process_gdb_remote::ProcessGDBRemote::ConnectToDebugserver(), ProcessKDP::DoConnectRemote(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::InitializeConnection(), lldb_private::process_gdb_remote::GDBRemoteCommunication::ListenThread(), lldb_private::ScriptInterpreterIORedirect::ScriptInterpreterIORedirect(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor(), lldb_private::Process::SetSTDIOFileDescriptor(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::StartListenThread().
void Communication::SetReadThreadBytesReceivedCallback | ( | ReadThreadBytesReceived | callback, |
void * | callback_baton | ||
) |
Definition at line 390 of file Communication.cpp.
References m_callback, and m_callback_baton.
Referenced by Clear(), lldb_private::ScriptInterpreterIORedirect::ScriptInterpreterIORedirect(), lldb::SBCommunication::SetReadThreadBytesReceivedCallback(), and lldb_private::Process::SetSTDIOFileDescriptor().
|
virtual |
Starts a read thread whose sole purpose it to read bytes from the current connection.
This function will call connection's read function:
size_t Connection::Read (void *, size_t);
When bytes are read and cached, this function will call:
Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast);
Subclasses should override this function if they wish to override the default action of caching the bytes and broadcasting a eBroadcastBitReadThreadGotBytes event.
Definition at line 200 of file Communication.cpp.
References lldb_private::Status::Clear(), lldb_private::Communication, lldb_private::Broadcaster::GetBroadcasterName(), lldb_private::GetLog(), lldb_private::Host, lldb_private::HostThread::IsJoinable(), lldb_private::ThreadLauncher::LaunchThread(), LLDB_LOG, m_read_thread, m_read_thread_did_exit, m_read_thread_enabled, ReadThread(), string(), and lldb_private::toString().
Referenced by lldb::SBCommunication::ReadThreadStart(), lldb_private::ScriptInterpreterIORedirect::ScriptInterpreterIORedirect(), and lldb_private::Process::SetSTDIOFileDescriptor().
|
virtual |
Stops the read thread by cancelling it.
Definition at line 234 of file Communication.cpp.
References lldb_private::Broadcaster::BroadcastEvent(), lldb_private::Communication, error(), lldb_private::GetLog(), lldb_private::HostThread::IsJoinable(), lldb_private::HostThread::Join(), LLDB_LOG, m_read_thread, and m_read_thread_enabled.
Referenced by Clear(), lldb_private::Process::DestroyImpl(), lldb::SBCommunication::ReadThreadStop(), SetConnection(), and lldb_private::Process::ShouldBroadcastEvent().
void Communication::SynchronizeWithReadThread | ( | ) |
Wait for the read thread to process all outstanding data.
After this function returns, the read thread has processed all data that has been waiting in the Connection queue.
Definition at line 396 of file Communication.cpp.
References m_connection_sp, m_read_thread_did_exit, m_read_thread_enabled, m_synchronize_mutex, and lldb_private::Listener::MakeListener().
Referenced by lldb_private::Process::ShouldBroadcastEvent().
size_t Communication::Write | ( | const void * | src, |
size_t | src_len, | ||
lldb::ConnectionStatus & | status, | ||
Status * | error_ptr | ||
) |
The actual write function that attempts to write to the communications protocol.
Subclasses must override this function.
[in] | src | A source buffer that must be at least src_len bytes long. |
[in] | src_len | The number of bytes to attempt to write, and also the number of bytes are currently available in src. |
Definition at line 171 of file Communication.cpp.
References lldb_private::Communication, lldb::eConnectionStatusNoConnection, lldb_private::GetLog(), LLDB_LOG, m_connection_sp, m_write_mutex, and lldb_private::Status::SetErrorString().
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::Handle_I(), CommunicationKDP::SendRequestPacketNoLock(), lldb::SBCommunication::Write(), and WriteAll().
size_t Communication::WriteAll | ( | const void * | src, |
size_t | src_len, | ||
lldb::ConnectionStatus & | status, | ||
Status * | error_ptr | ||
) |
Repeatedly attempt writing until either src_len bytes are written or a permanent failure occurs.
[in] | src | A source buffer that must be at least src_len bytes long. |
[in] | src_len | The number of bytes to attempt to write, and also the number of bytes are currently available in src. |
Definition at line 190 of file Communication.cpp.
References lldb::eConnectionStatusSuccess, and Write().
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::SendAck(), lldb_private::process_gdb_remote::GDBRemoteCommunication::SendNack(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::SendRawPacketNoLock().
|
protected |
A buffer to cache bytes read in the ReadThread function.
Definition at line 324 of file Communication.h.
Referenced by AppendBytesToCache(), CommunicationKDP::CheckForPacket(), lldb_private::process_gdb_remote::GDBRemoteCommunication::CheckForPacket(), lldb_private::process_gdb_remote::GDBRemoteCommunication::DecompressPacket(), and GetCachedBytes().
|
protected |
A mutex to protect multi-threaded access to the cached bytes.
Definition at line 325 of file Communication.h.
Referenced by AppendBytesToCache(), CommunicationKDP::CheckForPacket(), lldb_private::process_gdb_remote::GDBRemoteCommunication::CheckForPacket(), and GetCachedBytes().
|
protected |
Definition at line 330 of file Communication.h.
Referenced by AppendBytesToCache(), and SetReadThreadBytesReceivedCallback().
|
protected |
Definition at line 331 of file Communication.h.
Referenced by AppendBytesToCache(), and SetReadThreadBytesReceivedCallback().
|
protected |
Definition at line 332 of file Communication.h.
Referenced by GetCloseOnEOF(), and SetCloseOnEOF().
|
protected |
The connection that is current in use by this communications class.
Definition at line 317 of file Communication.h.
Referenced by Connect(), Disconnect(), GetConnection(), HasConnection(), IsConnected(), Read(), ReadFromConnection(), SetConnection(), SynchronizeWithReadThread(), and Write().
|
protected |
The read thread handle in case we need to cancel the thread.
Definition at line 319 of file Communication.h.
Referenced by JoinReadThread(), StartReadThread(), and StopReadThread().
|
protected |
Definition at line 322 of file Communication.h.
Referenced by Disconnect(), ReadThread(), StartReadThread(), and SynchronizeWithReadThread().
|
protected |
Definition at line 321 of file Communication.h.
Referenced by Disconnect(), Read(), ReadThread(), ReadThreadIsRunning(), StartReadThread(), StopReadThread(), and SynchronizeWithReadThread().
|
protected |
Definition at line 329 of file Communication.h.
Referenced by ReadThread(), and SynchronizeWithReadThread().
|
protected |
Don't let multiple threads write at the same time...
Definition at line 328 of file Communication.h.
Referenced by Write().