16#include "llvm/Support/Compiler.h"
30 : m_connection_sp(), m_write_mutex(), m_close_on_eof(true) {
45 "{0} Communication::Connect (url = {1})",
this, url);
49 return connection_sp->Connect(url, error_ptr);
79 return (connection_sp ? connection_sp->IsConnected() :
false);
92 "this = {0}, dst = {1}, dst_len = {2}, timeout = {3}, connection = {4}",
104 "{0} Communication::Write (src = {1}, src_len = {2}"
105 ") connection = {3}",
106 this, src, (uint64_t)src_len, connection_sp.get());
109 return connection_sp->Write(src, src_len, status, error_ptr);
119 size_t total_written = 0;
121 total_written +=
Write(
static_cast<const char *
>(src) + total_written,
122 src_len - total_written, status, error_ptr);
124 return total_written;
133 return connection_sp->Read(dst, dst_len, timeout, status, error_ptr);
156 return "no connection";
158 return "lost connection";
160 return "end of file";
162 return "interrupted";
165 return "@" + std::to_string(status);
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
size_t ReadFromConnection(void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr)
virtual 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.
lldb::ConnectionSP m_connection_sp
The connection that is current in use by this communications class.
lldb::ConnectionStatus Connect(const char *url, Status *error_ptr)
Connect using the current connection by passing url to its connect function.
bool IsConnected() const
Check if the connection is valid.
virtual void SetConnection(std::unique_ptr< Connection > connection)
Sets the connection that it to be used by this class.
virtual ~Communication()
Destructor.
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.
Communication()
Construct the Communication object.
virtual lldb::ConnectionStatus Disconnect(Status *error_ptr=nullptr)
Disconnect the communications connection if one is currently connected.
static std::string ConnectionStatusAsString(lldb::ConnectionStatus status)
bool HasConnection() const
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_write_mutex
Don't let multiple threads write at the same time...
static Status FromErrorString(const char *str)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::Connection > ConnectionSP
ConnectionStatus
Connection Status Types.
@ eConnectionStatusError
Check GetError() for details.
@ eConnectionStatusInterrupted
Interrupted read.
@ eConnectionStatusTimedOut
Request timed out.
@ eConnectionStatusEndOfFile
End-of-file encountered.
@ eConnectionStatusSuccess
Success.
@ eConnectionStatusLostConnection
Lost connection while connected to a valid connection.
@ eConnectionStatusNoConnection
No connection.