16#include "llvm/ADT/StringExtras.h"
17#include "llvm/Support/FormatVariadic.h"
57 if (!protocol || !protocol[0]) {
58 error.SetErrorString(
"no protocol specified");
63 if (!protocol_server) {
64 error.SetErrorStringWithFormat(
65 "unsupported protocol: %s. Supported protocols are: %s", protocol,
74SBProtocolServer::operator
bool()
const {
91 error.SetErrorString(
"invalid protocol server");
95 const char *connection_error =
96 "unsupported connection specifier, expected 'accept:///path' or "
97 "'listen://[host]:port'";
98 std::optional<URI> uri =
URI::Parse(connection_uri ? connection_uri :
"");
100 error.SetErrorString(connection_error);
104 std::optional<Socket::ProtocolModePair> protocol_and_mode =
107 error.SetErrorString(connection_error);
112 connection.
protocol = protocol_and_mode->first;
114 connection.
name = uri->path;
117 llvm::formatv(
"[{0}]:{1}",
118 uri->hostname.empty() ?
"0.0.0.0" : uri->hostname,
119 uri->port.value_or(0))
122 if (llvm::Error err =
m_opaque_up->server->Start(connection))
123 error.SetErrorString(llvm::toString(std::move(err)).c_str());
133 error.SetErrorString(
"invalid protocol server");
138 error.SetErrorString(llvm::toString(std::move(err)).c_str());
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT_VA(...)
const char * GetConnectionURI()
Returns the URI clients can connect to, valid after a successful Start, or nullptr if the server is n...
SBProtocolServer & operator=(const SBProtocolServer &rhs)
std::unique_ptr< lldb_private::SBProtocolServerImpl > m_opaque_up
static SBProtocolServer Create(const char *protocol, lldb::SBError &error)
Returns the protocol server for protocol, creating it if this process does not already have one.
lldb::SBError Start(const char *connection_uri)
Starts listening for clients on connection_uri, which must be an accepting URI such as "listen://[hos...
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
static std::vector< llvm::StringRef > GetSupportedProtocols()
static ProtocolServer * GetOrCreate(llvm::StringRef name)
PIMPL backing SBProtocolServer.
virtual std::vector< std::string > GetListeningConnectionURI() const
static std::optional< ProtocolModePair > GetProtocolAndMode(llvm::StringRef scheme)
A class that represents a running process on the host machine.
Socket::SocketProtocol protocol
static std::optional< URI > Parse(llvm::StringRef uri)