Go to the documentation of this file.
9 #ifndef LLDB_CORE_COMMUNICATION_H
10 #define LLDB_CORE_COMMUNICATION_H
87 eBroadcastBitDisconnected =
89 eBroadcastBitReadThreadGotBytes =
91 eBroadcastBitReadThreadDidExit =
94 eBroadcastBitReadThreadShouldExit =
96 eBroadcastBitPacketAvailable =
98 eBroadcastBitNoMorePendingInput = (1u << 5),
101 kLoUserBroadcastBit =
103 kHiUserBroadcastBit = (1u << 31),
104 eAllEventBits = 0xffffffff};
225 size_t WriteAll(
const void *src,
size_t src_len,
295 void *callback_baton);
384 #endif // LLDB_CORE_COMMUNICATION_H
void SynchronizeWithReadThread()
Wait for the read thread to process all outstanding data.
bool ReadThreadIsRunning()
Checks if there is a currently running read thread.
void SetCloseOnEOF(bool b)
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.
ReadThreadBytesReceived m_callback
static std::string ConnectionStatusAsString(lldb::ConnectionStatus status)
size_t GetCachedBytes(void *dst, size_t dst_len)
Get any available bytes from our data cache.
std::mutex m_write_mutex
Don't let multiple threads write at the same time...
Communication(const char *broadcaster_name)
Construct the Communication object with the specified name for the Broadcaster that this object inher...
lldb::ConnectionSP m_connection_sp
The connection that is current in use by this communications class.
~Communication() override
Destructor.
void SetConnection(std::unique_ptr< Connection > connection)
Sets the connection that it to be used by this class.
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.
HostThread m_read_thread
The read thread handle in case we need to cancel the thread.
size_t ReadFromConnection(void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr)
std::atomic< bool > m_read_thread_did_exit
static ConstString & GetStaticBroadcasterClass()
lldb::thread_result_t ReadThread()
The read thread function.
ConstString & GetBroadcasterClass() const override
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager ...
virtual bool StartReadThread(Status *error_ptr=nullptr)
Starts a read thread whose sole purpose it to read bytes from the current connection.
ConnectionStatus
Connection Status Types.
void SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback, void *callback_baton)
virtual bool StopReadThread(Status *error_ptr=nullptr)
Stops the read thread by cancelling it.
string(SUBSTRING ${p} 10 -1 pStripped) if($
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.
std::mutex m_synchronize_mutex
const Communication & operator=(const Communication &)=delete
lldb::ConnectionStatus Disconnect(Status *error_ptr=nullptr)
Disconnect the communications connection if one is currently connected.
bool HasConnection() const
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.
bool IsConnected() const
Check if the connection is valid.
bool GetCloseOnEOF() const
A class that represents a running process on the host machine.
lldb_private::Connection * GetConnection()
void(* ReadThreadBytesReceived)(void *baton, const void *src, size_t src_len)
std::atomic< bool > m_read_thread_enabled
virtual bool JoinReadThread(Status *error_ptr=nullptr)
std::string m_bytes
A buffer to cache bytes read in the ReadThread function.
std::recursive_mutex m_bytes_mutex
A mutex to protect multi-threaded access to the cached bytes.
lldb::ConnectionStatus Connect(const char *url, Status *error_ptr)
Connect using the current connection by passing url to its connect function.