Index: include/lldb/Core/Connection.h =================================================================== --- include/lldb/Core/Connection.h +++ include/lldb/Core/Connection.h @@ -133,13 +133,13 @@ /// /// Subclasses must override this function. /// - /// @param[in] src - /// A source buffer that must be at least \a src_len bytes + /// @param[in] dst + /// A desination buffer that must be at least \a dst_len bytes /// long. /// - /// @param[in] src_len + /// @param[in] dst_len /// The number of bytes to attempt to write, and also the - /// number of bytes are currently available in \a src. + /// number of bytes are currently available in \a dst. /// /// @param[out] error_ptr /// A pointer to an error object that should be given an @@ -150,8 +150,19 @@ /// The number of bytes actually Written. //------------------------------------------------------------------ virtual size_t - Write (const void *buffer, size_t length, lldb::ConnectionStatus &status, Error *error_ptr) = 0; + Write (const void *dst, size_t dst_len, lldb::ConnectionStatus &status, Error *error_ptr) = 0; + //------------------------------------------------------------------ + /// Returns a URI that describes this connection object + /// + /// Subclasses may override this function. + /// + /// @return + /// Returns URI or an empty string if disconnecteds + //------------------------------------------------------------------ + virtual std::string + GetURI() = 0; + private: //------------------------------------------------------------------ // For Connection only Index: include/lldb/Core/ConnectionMachPort.h =================================================================== --- include/lldb/Core/ConnectionMachPort.h +++ include/lldb/Core/ConnectionMachPort.h @@ -56,6 +56,9 @@ lldb::ConnectionStatus &status, lldb_private::Error *error_ptr); + virtual std::string + GetURI(); + lldb::ConnectionStatus BootstrapCheckIn (const char *port_name, lldb_private::Error *error_ptr); @@ -83,6 +86,7 @@ mach_port_t m_port; private: + std::string m_uri; DISALLOW_COPY_AND_ASSIGN (ConnectionMachPort); Index: include/lldb/Core/ConnectionSharedMemory.h =================================================================== --- include/lldb/Core/ConnectionSharedMemory.h +++ include/lldb/Core/ConnectionSharedMemory.h @@ -53,6 +53,9 @@ virtual size_t Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr); + virtual std::string + GetURI(); + lldb::ConnectionStatus Open (bool create, const char *name, size_t size, Error *error_ptr); Index: include/lldb/Host/posix/ConnectionFileDescriptorPosix.h =================================================================== --- include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -50,6 +50,8 @@ virtual size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr); + virtual std::string GetURI(); + lldb::ConnectionStatus BytesAvailable(uint32_t timeout_usec, Error *error_ptr); bool InterruptRead(); @@ -75,7 +77,7 @@ void CloseCommandPipe(); - lldb::ConnectionStatus SocketListen(const char *host_and_port, Error *error_ptr); + lldb::ConnectionStatus SocketListenAndAccept(const char *host_and_port, Error *error_ptr); lldb::ConnectionStatus ConnectTCP(const char *host_and_port, Error *error_ptr); @@ -99,6 +101,8 @@ bool m_waiting_for_accept; bool m_child_processes_inherit; + std::string m_uri; + private: DISALLOW_COPY_AND_ASSIGN(ConnectionFileDescriptor); }; Index: include/lldb/Host/windows/ConnectionGenericFileWindows.h =================================================================== --- include/lldb/Host/windows/ConnectionGenericFileWindows.h +++ include/lldb/Host/windows/ConnectionGenericFileWindows.h @@ -38,6 +38,8 @@ virtual size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr); + virtual std::string GetURI(); + bool InterruptRead(); protected: @@ -57,6 +59,8 @@ void InitializeEventHandles(); void IncrementFilePointer(DWORD amount); + std::string m_uri; + DISALLOW_COPY_AND_ASSIGN(ConnectionGenericFile); }; } Index: source/Core/ConnectionMachPort.cpp =================================================================== --- source/Core/ConnectionMachPort.cpp +++ source/Core/ConnectionMachPort.cpp @@ -107,6 +107,7 @@ { if (error_ptr) error_ptr->Clear(); + m_uri.assign(s); } else { @@ -209,6 +210,7 @@ error_ptr->SetError (kret, eErrorTypeMachKernel); m_port = MACH_PORT_TYPE_NONE; } + m_uri.clear(); return eConnectionStatusSuccess; } @@ -256,6 +258,12 @@ return 0; } +std::string +ConnectionMachPort::GetURI() +{ + return m_uri; +} + ConnectionStatus ConnectionMachPort::BytesAvailable (uint32_t timeout_usec, Error *error_ptr) { Index: source/Core/ConnectionSharedMemory.cpp =================================================================== --- source/Core/ConnectionSharedMemory.cpp +++ source/Core/ConnectionSharedMemory.cpp @@ -107,6 +107,13 @@ return 0; } +std::string +ConnectionSharedMemory::GetURI() +{ + // TODO: fix when Connect is fixed? + return ""; +} + ConnectionStatus ConnectionSharedMemory::BytesAvailable (uint32_t timeout_usec, Error *error_ptr) { Index: source/Host/common/Socket.cpp =================================================================== --- source/Host/common/Socket.cpp +++ source/Host/common/Socket.cpp @@ -190,7 +190,7 @@ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION)); if (log) - log->Printf ("ConnectionFileDescriptor::SocketListen (%s)", host_and_port.data()); + log->Printf ("Socket::TcpListen (%s)", host_and_port.data()); std::string host_str; std::string port_str; Index: source/Host/posix/ConnectionFileDescriptorPosix.cpp =================================================================== --- source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -143,7 +143,7 @@ if (strstr(s, "listen://") == s) { // listen://HOST:PORT - return SocketListen(s + strlen("listen://"), error_ptr); + return SocketListenAndAccept(s + strlen("listen://"), error_ptr); } else if (strstr(s, "accept://") == s) { @@ -220,6 +220,7 @@ m_read_sp.reset(new File(fd, false)); m_write_sp.reset(new File(fd, false)); } + m_uri.assign(s); return eConnectionStatusSuccess; } } @@ -352,6 +353,7 @@ if (error_ptr) *error_ptr = error.Fail() ? error : error2; + m_uri.clear(); m_shutting_down = false; return status; } @@ -511,6 +513,12 @@ return bytes_sent; } +std::string +ConnectionFileDescriptor::GetURI() +{ + return m_uri; +} + // This ConnectionFileDescriptor::BytesAvailable() uses select(). // // PROS: @@ -701,7 +709,12 @@ *error_ptr = error; m_write_sp.reset(socket); m_read_sp = m_write_sp; - return (error.Success()) ? eConnectionStatusSuccess : eConnectionStatusError; + if (error.Fail()) + { + return eConnectionStatusError; + } + m_uri.assign(socket_name); + return eConnectionStatusSuccess; } ConnectionStatus @@ -713,11 +726,16 @@ *error_ptr = error; m_write_sp.reset(socket); m_read_sp = m_write_sp; - return (error.Success()) ? eConnectionStatusSuccess : eConnectionStatusError; + if (error.Fail()) + { + return eConnectionStatusError; + } + m_uri.assign(socket_name); + return eConnectionStatusSuccess; } ConnectionStatus -ConnectionFileDescriptor::SocketListen(const char *s, Error *error_ptr) +ConnectionFileDescriptor::SocketListenAndAccept(const char *s, Error *error_ptr) { m_port_predicate.SetValue(0, eBroadcastNever); @@ -742,7 +760,14 @@ m_write_sp.reset(socket); m_read_sp = m_write_sp; - return (error.Success()) ? eConnectionStatusSuccess : eConnectionStatusError; + if (error.Fail()) + { + return eConnectionStatusError; + } + char uri[280]; // sizeof(uri) > strlen("connect://") + 255 + strlen(1) + strlen("65535") + 1 + snprintf(uri, sizeof(uri), "connect://%s:%u",socket->GetRemoteIPAddress().c_str(), socket->GetRemotePortNumber()); + m_uri.assign(uri); + return eConnectionStatusSuccess; } ConnectionStatus @@ -754,7 +779,12 @@ *error_ptr = error; m_write_sp.reset(socket); m_read_sp = m_write_sp; - return (error.Success()) ? eConnectionStatusSuccess : eConnectionStatusError; + if (error.Fail()) + { + return eConnectionStatusError; + } + m_uri.assign(s); + return eConnectionStatusSuccess; } ConnectionStatus @@ -767,7 +797,12 @@ *error_ptr = error; m_write_sp.reset(send_socket); m_read_sp.reset(recv_socket); - return (error.Success()) ? eConnectionStatusSuccess : eConnectionStatusError; + if (error.Fail()) + { + return eConnectionStatusError; + } + m_uri.assign(s); + return eConnectionStatusSuccess; } uint16_t Index: source/Host/windows/ConnectionGenericFileWindows.cpp =================================================================== --- source/Host/windows/ConnectionGenericFileWindows.cpp +++ source/Host/windows/ConnectionGenericFileWindows.cpp @@ -147,6 +147,7 @@ } m_owns_file = true; + m_uri.assign(s); return eConnectionStatusSuccess; } @@ -175,6 +176,7 @@ ::ZeroMemory(&m_file_position, sizeof(m_file_position)); m_owns_file = false; + m_uri.clear(); return eConnectionStatusSuccess; } @@ -328,6 +330,12 @@ return return_info.GetBytes(); } +std::string +ConnectionGenericFile::GetURI() +{ + return m_uri; +} + bool ConnectionGenericFile::InterruptRead() {