Modified local spawning in debugserver processes to use a new --reverse-connect option so that debugserver actually connects back to LLDB instead of LLDB connecting to debugserver.

This gets rid of our hacky "get_random_port()" which would grab a random port and tell debugserver to open that port. Now LLDB creates, binds, listens and accepts a connection by binding to port zero and sending the correctly bound port down as the host:port to connect back to.

Fixed the "ConnectionFileDescriptor" to be able to correctly listen for connections from a specified host, localhost, or any host. Prior to this fix "listen://" only accepted the following format:

listen://<port>

But now it can accept:

listen://<port>         // Listen for connection from localhost on port <port>
listen://<host>:<port>  // Listen for connection from <host> and <port>    
listen://*:<port>       // Listen for connection from any host on port <port>

llvm-svn: 196547
diff --git a/lldb/tools/lldb-platform/lldb-platform.cpp b/lldb/tools/lldb-platform/lldb-platform.cpp
index bc9d629..d58e804 100644
--- a/lldb/tools/lldb-platform/lldb-platform.cpp
+++ b/lldb/tools/lldb-platform/lldb-platform.cpp
@@ -262,24 +262,18 @@
             std::unique_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor());
             if (conn_ap.get())
             {
-                for (int j = 0; j < listen_host_port.size(); j++)
-                {
-                    char c = listen_host_port[j];
-                    if (c > '9' || c < '0')
-                        printf("WARNING: passing anything but a number as argument to --listen will most probably make connecting impossible.\n");
-                }
-                std::auto_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor());
-                if (conn_ap.get())
-                {
-                    std::string connect_url ("listen://");
-                    connect_url.append(listen_host_port.c_str());
+                std::string connect_url ("listen://");
+                connect_url.append(listen_host_port.c_str());
 
-                    printf ("Listening for a connection on %s...\n", listen_host_port.c_str());
-                    if (conn_ap->Connect(connect_url.c_str(), &error) == eConnectionStatusSuccess)
-                    {
-                        printf ("Connection established.\n");
-                        gdb_server.SetConnection (conn_ap.release());
-                    }
+                printf ("Listening for a connection from %s...\n", listen_host_port.c_str());
+                if (conn_ap->Connect(connect_url.c_str(), &error) == eConnectionStatusSuccess)
+                {
+                    printf ("Connection established.\n");
+                    gdb_server.SetConnection (conn_ap.release());
+                }
+                else
+                {
+                    printf ("error: %s\n", error.AsCString());
                 }
             }