Remove an assertion that was being hit due to slow DNS name lookups on MacOSX for "localhost". 

Changed all "localhost" to "127.0.0.1" to prevent potentially long name lookups.

<rdar://problem/16154630>

llvm-svn: 202424
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 72600d8..e3bc9f1 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -722,19 +722,27 @@
         {
             // No host and port given, so lets listen on our end and make the debugserver
             // connect to us..
-            error = StartListenThread ("localhost", 0);
+            error = StartListenThread ("127.0.0.1", 0);
             if (error.Fail())
                 return error;
 
             ConnectionFileDescriptor *connection = (ConnectionFileDescriptor *)GetConnection ();
-            out_port = connection->GetBoundPort(3);
-            assert (out_port != 0);
-            char port_cstr[32];
-            snprintf(port_cstr, sizeof(port_cstr), "localhost:%i", out_port);
-            // Send the host and port down that debugserver and specify an option
-            // so that it connects back to the port we are listening to in this process
-            debugserver_args.AppendArgument("--reverse-connect");
-            debugserver_args.AppendArgument(port_cstr);
+            // Wait for 10 seconds to resolve the bound port
+            out_port = connection->GetBoundPort(10);
+            if (out_port > 0)
+            {
+                char port_cstr[32];
+                snprintf(port_cstr, sizeof(port_cstr), "127.0.0.1:%i", out_port);
+                // Send the host and port down that debugserver and specify an option
+                // so that it connects back to the port we are listening to in this process
+                debugserver_args.AppendArgument("--reverse-connect");
+                debugserver_args.AppendArgument(port_cstr);
+            }
+            else
+            {
+                error.SetErrorString ("failed to bind to port 0 on 127.0.0.1");
+                return error;
+            }
         }
 
         
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
index d836111..b11d385 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -271,7 +271,7 @@
     
 
     lldb_private::Error
-    StartListenThread (const char *hostname = "localhost",
+    StartListenThread (const char *hostname = "127.0.0.1",
                        uint16_t port = 0);
 
     bool
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index df95542..fbb72ba 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -452,7 +452,7 @@
     // to actually have a hostname as far as the remote lldb that is connecting
     // to this lldb-platform is concerned
     response.PutCString ("hostname:");
-    response.PutCStringAsRawHex8("localhost");
+    response.PutCStringAsRawHex8("127.0.0.1");
     response.PutChar(';');
 #else   // #if defined(__arm__)
     if (Host::GetHostname (s))
@@ -945,7 +945,7 @@
             // Spawn a debugserver and try to get the port it listens to.
             ProcessLaunchInfo debugserver_launch_info;
             if (hostname.empty())
-                hostname = "localhost";
+                hostname = "127.0.0.1";
             Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
             if (log)
                 log->Printf("Launching debugserver with: %s:%u...\n", hostname.c_str(), port);
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 1172222..800bd25 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2604,7 +2604,7 @@
 
 #if defined (__APPLE__) && defined (__arm__)
         // On iOS, still do a local connection using a random port
-        const char *hostname = "localhost";
+        const char *hostname = "127.0.0.1";
         uint16_t port = get_random_port ();
 #else
         // Set hostname being NULL to do the reverse connect where debugserver