LLDB mainline
|
#include <Socket.h>
Classes | |
struct | HostAndPort |
Public Types | |
enum | SocketProtocol { ProtocolTcp , ProtocolUdp , ProtocolUnixDomain , ProtocolUnixAbstract } |
enum | SocketMode { ModeAccept , ModeConnect } |
using | ProtocolModePair = std::pair<SocketProtocol, SocketMode> |
using | Pair = std::pair<std::unique_ptr<Socket>, std::unique_ptr<Socket>> |
Public Types inherited from lldb_private::IOObject | |
enum | FDType { eFDTypeFile , eFDTypeSocket } |
using | WaitableHandle = lldb::file_t |
Public Member Functions | |
~Socket () override | |
virtual Status | Connect (llvm::StringRef name)=0 |
virtual Status | Listen (llvm::StringRef name, int backlog)=0 |
virtual llvm::Expected< std::vector< MainLoopBase::ReadHandleUP > > | Accept (MainLoopBase &loop, std::function< void(std::unique_ptr< Socket > socket)> sock_cb)=0 |
virtual Status | Accept (const Timeout< std::micro > &timeout, Socket *&socket) |
int | GetOption (int level, int option_name, int &option_value) |
int | SetOption (int level, int option_name, int option_value) |
NativeSocket | GetNativeSocket () const |
SocketProtocol | GetSocketProtocol () const |
Status | Read (void *buf, size_t &num_bytes) override |
Status | Write (const void *buf, size_t &num_bytes) override |
Status | Close () override |
bool | IsValid () const override |
WaitableHandle | GetWaitableHandle () override |
virtual std::string | GetRemoteConnectionURI () const |
virtual std::vector< std::string > | GetListeningConnectionURI () const |
Public Member Functions inherited from lldb_private::IOObject | |
IOObject (FDType type) | |
virtual | ~IOObject () |
FDType | GetFdType () const |
Static Public Member Functions | |
static std::optional< ProtocolModePair > | GetProtocolAndMode (llvm::StringRef scheme) |
static const char * | FindSchemeByProtocol (const SocketProtocol protocol) |
static bool | FindProtocolByScheme (const char *scheme, SocketProtocol &protocol) |
static llvm::Error | Initialize () |
static void | Terminate () |
static std::unique_ptr< Socket > | Create (const SocketProtocol protocol, Status &error) |
static llvm::Expected< Pair > | CreatePair (std::optional< SocketProtocol > protocol=std::nullopt) |
static llvm::Expected< std::unique_ptr< TCPSocket > > | TcpListen (llvm::StringRef host_and_port, int backlog=5) |
static llvm::Expected< std::unique_ptr< Socket > > | TcpConnect (llvm::StringRef host_and_port) |
static llvm::Expected< std::unique_ptr< UDPSocket > > | UdpConnect (llvm::StringRef host_and_port) |
static int | GetOption (NativeSocket sockfd, int level, int option_name, int &option_value) |
static int | SetOption (NativeSocket sockfd, int level, int option_name, int option_value) |
static llvm::Expected< HostAndPort > | DecodeHostAndPort (llvm::StringRef host_and_port) |
Static Public Attributes | |
static const NativeSocket | kInvalidSocketValue = -1 |
Static Public Attributes inherited from lldb_private::IOObject | |
static const WaitableHandle | kInvalidHandleValue = -1 |
Protected Member Functions | |
Socket (SocketProtocol protocol, bool should_close) | |
virtual size_t | Send (const void *buf, const size_t num_bytes) |
Static Protected Member Functions | |
static int | CloseSocket (NativeSocket sockfd) |
static Status | GetLastError () |
static void | SetLastError (Status &error) |
static NativeSocket | CreateSocket (const int domain, const int type, const int protocol, Status &error) |
static NativeSocket | AcceptSocket (NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, Status &error) |
Protected Attributes | |
SocketProtocol | m_protocol |
NativeSocket | m_socket |
bool | m_should_close_fd |
Protected Attributes inherited from lldb_private::IOObject | |
FDType | m_fd_type |
using lldb_private::Socket::Pair = std::pair<std::unique_ptr<Socket>, std::unique_ptr<Socket>> |
using lldb_private::Socket::ProtocolModePair = std::pair<SocketProtocol, SocketMode> |
|
override |
Definition at line 174 of file Socket.cpp.
References Close().
|
protected |
Definition at line 170 of file Socket.cpp.
References lldb_private::IOObject::eFDTypeSocket, lldb_private::IOObject::IOObject(), kInvalidSocketValue, m_protocol, m_should_close_fd, and m_socket.
Referenced by Accept(), Accept(), lldb_private::TCPSocket::CreatePair(), lldb_private::DomainSocket::DomainSocket(), lldb_private::DomainSocket::DomainSocket(), lldb_private::DomainSocket::DomainSocket(), lldb_private::DomainSocket::DomainSocket(), lldb_private::TCPSocket::TCPSocket(), lldb_private::TCPSocket::TCPSocket(), lldb_private::TCPSocket::TCPSocket(), lldb_private::UDPSocket::UDPSocket(), and lldb_private::UDPSocket::UDPSocket().
Reimplemented in lldb_private::DomainSocket, and lldb_private::TCPSocket.
Definition at line 454 of file Socket.cpp.
References Accept(), lldb_private::MainLoopBase::AddCallback(), lldb_private::Status::Fail(), lldb_private::Status::FromError(), lldb_private::MainLoopBase::RequestTermination(), lldb_private::MainLoopPosix::Run(), Socket(), and lldb_private::Status.
|
pure virtual |
Implemented in lldb_private::DomainSocket, lldb_private::TCPSocket, and lldb_private::UDPSocket.
References Socket().
Referenced by Accept().
|
staticprotected |
Definition at line 476 of file Socket.cpp.
References error(), kInvalidSocketValue, and SetLastError().
Referenced by lldb_private::DomainSocket::Accept(), and lldb_private::TCPSocket::Accept().
|
overridevirtual |
Implements lldb_private::IOObject.
Definition at line 374 of file Socket.cpp.
References CloseSocket(), lldb_private::Connection, error(), lldb_private::GetLog(), IsValid(), kInvalidSocketValue, LLDB_LOGF, m_should_close_fd, m_socket, and SetLastError().
Referenced by lldb_private::TCPSocket::Connect(), lldb_private::TCPSocket::CreateSocket(), and ~Socket().
|
staticprotected |
Definition at line 432 of file Socket.cpp.
Referenced by lldb_private::TCPSocket::Accept(), Close(), lldb_private::TCPSocket::CloseListenSockets(), and lldb_private::TCPSocket::Listen().
|
pure virtual |
Implemented in lldb_private::DomainSocket, lldb_private::TCPSocket, and lldb_private::UDPSocket.
|
static |
Definition at line 200 of file Socket.cpp.
References error(), lldb_private::Status::FromErrorString(), ProtocolTcp, ProtocolUdp, ProtocolUnixAbstract, and ProtocolUnixDomain.
Referenced by lldb_private::ConnectionFileDescriptor::AcceptSocket(), lldb_private::ConnectionFileDescriptor::ConnectSocket(), lldb_private::mcp::ProtocolServerMCP::Start(), and TcpConnect().
|
static |
Definition at line 238 of file Socket.cpp.
References lldb_private::DomainSocket::CreatePair(), lldb_private::TCPSocket::CreatePair(), ProtocolTcp, ProtocolUnixAbstract, and ProtocolUnixDomain.
Referenced by lldb_private::process_gdb_remote::ProcessGDBRemote::LaunchAndConnectToDebugserver().
|
staticprotected |
Definition at line 440 of file Socket.cpp.
References error(), kInvalidSocketValue, and SetLastError().
Referenced by lldb_private::DomainSocket::Connect(), lldb_private::UDPSocket::CreateConnected(), lldb_private::TCPSocket::CreateSocket(), lldb_private::DomainSocket::Listen(), and lldb_private::TCPSocket::Listen().
|
static |
Definition at line 292 of file Socket.cpp.
References lldb_private::Socket::HostAndPort::hostname, and lldb_private::Socket::HostAndPort::port.
Referenced by lldb_private::TCPSocket::Connect(), lldb_private::UDPSocket::CreateConnected(), lldb_private::TCPSocket::Listen(), and lldb_private::process_gdb_remote::LLGSArgToURL().
|
static |
Definition at line 159 of file Socket.cpp.
References socket_schemes.
|
static |
Definition at line 151 of file Socket.cpp.
References socket_schemes.
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::LaunchGDBServer().
|
staticprotected |
Definition at line 422 of file Socket.cpp.
Referenced by lldb_private::TCPSocket::Listen().
|
inlinevirtual |
Reimplemented in lldb_private::DomainSocket, and lldb_private::TCPSocket.
|
inline |
Definition at line 151 of file Socket.h.
References m_socket.
Referenced by lldb_private::DomainSocket::Accept(), lldb_private::DomainSocket::Connect(), lldb_private::TCPSocket::Connect(), lldb_private::DomainSocket::Listen(), and lldb_private::SharedSocket::SharedSocket().
|
inline |
Definition at line 141 of file Socket.h.
References GetOption(), and m_socket.
|
static |
Definition at line 393 of file Socket.cpp.
Referenced by GetOption().
|
static |
Definition at line 498 of file Socket.cpp.
References ModeAccept, ModeConnect, ProtocolTcp, ProtocolUnixAbstract, and ProtocolUnixDomain.
Referenced by CommandObjectProtocolServerStart::DoExecute().
|
inlinevirtual |
Reimplemented in lldb_private::DomainSocket, lldb_private::TCPSocket, and lldb_private::UDPSocket.
|
inline |
Definition at line 152 of file Socket.h.
References m_protocol.
|
overridevirtual |
|
static |
Definition at line 176 of file Socket.cpp.
Referenced by lldb_private::SystemInitializerCommon::Initialize().
|
inlineoverridevirtual |
Implements lldb_private::IOObject.
Reimplemented in lldb_private::TCPSocket.
Definition at line 159 of file Socket.h.
References kInvalidSocketValue, and m_socket.
Referenced by Close().
|
pure virtual |
Implemented in lldb_private::DomainSocket, lldb_private::TCPSocket, and lldb_private::UDPSocket.
|
overridevirtual |
Implements lldb_private::IOObject.
Definition at line 319 of file Socket.cpp.
References lldb_private::Communication, error(), lldb_private::GetLog(), IsInterrupted(), LLDB_LOGF, m_socket, and SetLastError().
|
protectedvirtual |
Reimplemented in lldb_private::UDPSocket.
Definition at line 410 of file Socket.cpp.
References m_socket.
Referenced by Write().
|
staticprotected |
Definition at line 414 of file Socket.cpp.
References lldb::eErrorTypeWin32, error(), lldb_private::Status::FromErrno(), and lldb_private::Status.
Referenced by AcceptSocket(), Close(), lldb_private::DomainSocket::Connect(), CreateSocket(), lldb_private::DomainSocket::Listen(), Read(), and Write().
|
inline |
Definition at line 147 of file Socket.h.
References m_socket, and SetOption().
|
static |
Definition at line 402 of file Socket.cpp.
Referenced by lldb_private::TCPSocket::Listen(), SetOption(), lldb_private::TCPSocket::SetOptionNoDelay(), and lldb_private::TCPSocket::SetOptionReuseAddress().
|
static |
Definition at line 255 of file Socket.cpp.
References lldb_private::Connection, Create(), error(), lldb_private::GetLog(), LLDB_LOG, and ProtocolTcp.
|
static |
Definition at line 272 of file Socket.cpp.
References lldb_private::Connection, error(), lldb_private::GetLog(), and LLDB_LOG.
|
static |
Definition at line 194 of file Socket.cpp.
Referenced by lldb_private::SystemInitializerCommon::Terminate().
|
static |
Definition at line 287 of file Socket.cpp.
References lldb_private::UDPSocket::CreateConnected().
Referenced by lldb_private::ConnectionFileDescriptor::ConnectUDP().
|
overridevirtual |
Implements lldb_private::IOObject.
Definition at line 346 of file Socket.cpp.
References lldb_private::Communication, error(), lldb_private::GetLog(), IsInterrupted(), LLDB_LOGF, m_socket, Send(), and SetLastError().
|
static |
Definition at line 95 of file Socket.h.
Referenced by AcceptSocket(), Close(), CreateSocket(), lldb_private::DomainSocket::DomainSocket(), lldb_private::DomainSocket::GetListeningConnectionURI(), lldb_private::TCPSocket::GetLocalIPAddress(), lldb_private::TCPSocket::GetLocalPortNumber(), lldb_private::SharedSocket::GetNativeSocket(), lldb_private::TCPSocket::GetRemoteConnectionURI(), lldb_private::UDPSocket::GetRemoteConnectionURI(), lldb_private::TCPSocket::GetRemoteIPAddress(), lldb_private::TCPSocket::GetRemotePortNumber(), lldb_private::DomainSocket::GetSocketName(), IsValid(), lldb_private::TCPSocket::IsValid(), and Socket().
|
protected |
Definition at line 186 of file Socket.h.
Referenced by GetSocketProtocol(), and Socket().
|
protected |
Definition at line 188 of file Socket.h.
Referenced by Close(), lldb_private::DomainSocket::DomainSocket(), Socket(), and lldb_private::TCPSocket::TCPSocket().
|
protected |
Definition at line 187 of file Socket.h.
Referenced by Close(), lldb_private::DomainSocket::Connect(), lldb_private::TCPSocket::CreateSocket(), lldb_private::DomainSocket::DomainSocket(), lldb_private::DomainSocket::DomainSocket(), lldb_private::DomainSocket::DomainSocket(), lldb_private::DomainSocket::GetListeningConnectionURI(), lldb_private::TCPSocket::GetLocalIPAddress(), lldb_private::TCPSocket::GetLocalPortNumber(), GetNativeSocket(), GetOption(), lldb_private::TCPSocket::GetRemoteConnectionURI(), lldb_private::UDPSocket::GetRemoteConnectionURI(), lldb_private::TCPSocket::GetRemoteIPAddress(), lldb_private::TCPSocket::GetRemotePortNumber(), lldb_private::DomainSocket::GetSocketName(), GetWaitableHandle(), IsValid(), lldb_private::TCPSocket::IsValid(), lldb_private::DomainSocket::Listen(), Read(), Send(), lldb_private::UDPSocket::Send(), SetOption(), Socket(), lldb_private::TCPSocket::TCPSocket(), lldb_private::TCPSocket::TCPSocket(), lldb_private::UDPSocket::UDPSocket(), and Write().