[Lldb-commits] [lldb] r251547 - Make lldb-gdbserver to take explicit socket scheme as command line argument.

Oleksiy Vyalov via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 28 12:49:50 PDT 2015


Author: ovyalov
Date: Wed Oct 28 14:49:50 2015
New Revision: 251547

URL: http://llvm.org/viewvc/llvm-project?rev=251547&view=rev
Log:
Make lldb-gdbserver to take explicit socket scheme as command line argument.

http://reviews.llvm.org/D14126


Modified:
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
    lldb/trunk/tools/lldb-server/Acceptor.cpp
    lldb/trunk/tools/lldb-server/Acceptor.h
    lldb/trunk/tools/lldb-server/lldb-platform.cpp

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp?rev=251547&r1=251546&r2=251547&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp Wed Oct 28 14:49:50 2015
@@ -46,9 +46,11 @@ using namespace lldb_private::process_gd
 //----------------------------------------------------------------------
 // GDBRemoteCommunicationServerPlatform constructor
 //----------------------------------------------------------------------
-GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(const Socket::SocketProtocol socket_protocol) :
+GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(const Socket::SocketProtocol socket_protocol,
+                                                                           const char* socket_scheme) :
     GDBRemoteCommunicationServerCommon ("gdb-remote.server", "gdb-remote.server.rx_packet"),
     m_socket_protocol(socket_protocol),
+    m_socket_scheme(socket_scheme),
     m_spawned_pids_mutex (Mutex::eMutexTypeRecursive),
     m_platform_sp (Platform::GetHostPlatform ()),
     m_port_map (),
@@ -150,6 +152,7 @@ GDBRemoteCommunicationServerPlatform::Ha
     std::ostringstream url;
 
     uint16_t* port_ptr = &port;
+    url << m_socket_scheme << "://";
     if (m_socket_protocol == Socket::ProtocolTcp)
         url << platform_ip << ":" << port;
     else

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h?rev=251547&r1=251546&r2=251547&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h Wed Oct 28 14:49:50 2015
@@ -29,7 +29,8 @@ class GDBRemoteCommunicationServerPlatfo
 public:
     typedef std::map<uint16_t, lldb::pid_t> PortMap;
 
-    GDBRemoteCommunicationServerPlatform(const Socket::SocketProtocol socket_protocol);
+    GDBRemoteCommunicationServerPlatform(const Socket::SocketProtocol socket_protocol,
+                                         const char* socket_scheme);
 
     ~GDBRemoteCommunicationServerPlatform() override;
 
@@ -67,6 +68,7 @@ public:
 
 protected:
     const Socket::SocketProtocol m_socket_protocol;
+    const std::string m_socket_scheme;
     Mutex m_spawned_pids_mutex;
     std::set<lldb::pid_t> m_spawned_pids;
     lldb::PlatformSP m_platform_sp;

Modified: lldb/trunk/tools/lldb-server/Acceptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/Acceptor.cpp?rev=251547&r1=251546&r2=251547&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/Acceptor.cpp (original)
+++ lldb/trunk/tools/lldb-server/Acceptor.cpp Wed Oct 28 14:49:50 2015
@@ -37,7 +37,8 @@ SocketScheme socket_schemes[] = {
     {"unix-abstract", Socket::ProtocolUnixAbstract},
 };
 
-bool FindProtocolByScheme(const char* scheme, Socket::SocketProtocol& protocol)
+bool
+FindProtocolByScheme(const char* scheme, Socket::SocketProtocol& protocol)
 {
     for (auto s: socket_schemes)
     {
@@ -50,6 +51,17 @@ bool FindProtocolByScheme(const char* sc
     return false;
 }
 
+const char*
+FindSchemeByProtocol(const Socket::SocketProtocol protocol)
+{
+    for (auto s: socket_schemes)
+    {
+        if (s.m_protocol == protocol)
+            return s.m_scheme;
+    }
+    return nullptr;
+}
+
 }
 
 Error
@@ -78,6 +90,12 @@ Acceptor::GetSocketProtocol() const
     return m_listener_socket_up->GetSocketProtocol();
 }
 
+const char*
+Acceptor::GetSocketScheme() const
+{
+    return FindSchemeByProtocol(GetSocketProtocol());
+}
+
 std::string
 Acceptor::GetLocalSocketId() const
 {

Modified: lldb/trunk/tools/lldb-server/Acceptor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/Acceptor.h?rev=251547&r1=251546&r2=251547&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/Acceptor.h (original)
+++ lldb/trunk/tools/lldb-server/Acceptor.h Wed Oct 28 14:49:50 2015
@@ -42,6 +42,9 @@ public:
     Socket::SocketProtocol
     GetSocketProtocol() const;
 
+    const char*
+    GetSocketScheme() const;
+
     // Returns either TCP port number as string or domain socket path.
     // Empty string is returned in case of error.
     std::string

Modified: lldb/trunk/tools/lldb-server/lldb-platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/lldb-platform.cpp?rev=251547&r1=251546&r2=251547&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/lldb-platform.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-platform.cpp Wed Oct 28 14:49:50 2015
@@ -315,7 +315,8 @@ main_platform (int argc, char *argv[])
     }
 
     do {
-        GDBRemoteCommunicationServerPlatform platform(acceptor_up->GetSocketProtocol());
+        GDBRemoteCommunicationServerPlatform platform(acceptor_up->GetSocketProtocol(),
+                                                      acceptor_up->GetSocketScheme());
         
         if (port_offset > 0)
             platform.SetPortOffset(port_offset);




More information about the lldb-commits mailing list