[Lldb-commits] [lldb] r202424 - Remove an assertion that was being hit due to slow DNS name lookups on MacOSX for "localhost".
Greg Clayton
gclayton at apple.com
Thu Feb 27 11:38:18 PST 2014
Author: gclayton
Date: Thu Feb 27 13:38:18 2014
New Revision: 202424
URL: http://llvm.org/viewvc/llvm-project?rev=202424&view=rev
Log:
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>
Modified:
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Target/Platform.cpp
lldb/trunk/tools/debugserver/source/debugserver.cpp
Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=202424&r1=202423&r2=202424&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Thu Feb 27 13:38:18 2014
@@ -423,7 +423,7 @@ PlatformRemoteGDBServer::DebugProcess (l
// When remote debugging to iOS, we use a USB mux that always talks
// to localhost, so we will need the remote debugserver to accept connections
// only from localhost, no matter what our current hostname is
- port = m_gdb_client.LaunchGDBserverAndGetPort(debugserver_pid, "localhost");
+ port = m_gdb_client.LaunchGDBserverAndGetPort(debugserver_pid, "127.0.0.1");
}
else
{
@@ -511,7 +511,7 @@ PlatformRemoteGDBServer::Attach (lldb_pr
// When remote debugging to iOS, we use a USB mux that always talks
// to localhost, so we will need the remote debugserver to accept connections
// only from localhost, no matter what our current hostname is
- port = m_gdb_client.LaunchGDBserverAndGetPort(debugserver_pid, "localhost");
+ port = m_gdb_client.LaunchGDBserverAndGetPort(debugserver_pid, "127.0.0.1");
}
else
{
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=202424&r1=202423&r2=202424&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Thu Feb 27 13:38:18 2014
@@ -722,19 +722,27 @@ GDBRemoteCommunication::StartDebugserver
{
// 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;
+ }
}
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=202424&r1=202423&r2=202424&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Thu Feb 27 13:38:18 2014
@@ -271,7 +271,7 @@ protected:
lldb_private::Error
- StartListenThread (const char *hostname = "localhost",
+ StartListenThread (const char *hostname = "127.0.0.1",
uint16_t port = 0);
bool
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=202424&r1=202423&r2=202424&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Thu Feb 27 13:38:18 2014
@@ -452,7 +452,7 @@ GDBRemoteCommunicationServer::Handle_qHo
// 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 @@ GDBRemoteCommunicationServer::Handle_qLa
// 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);
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=202424&r1=202423&r2=202424&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Feb 27 13:38:18 2014
@@ -2604,7 +2604,7 @@ ProcessGDBRemote::LaunchAndConnectToDebu
#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
Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=202424&r1=202423&r2=202424&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Thu Feb 27 13:38:18 2014
@@ -744,7 +744,7 @@ const char *
Platform::GetHostname ()
{
if (IsHost())
- return "localhost";
+ return "127.0.0.1";
if (m_name.empty())
return NULL;
Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=202424&r1=202423&r2=202424&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/debugserver.cpp (original)
+++ lldb/trunk/tools/debugserver/source/debugserver.cpp Thu Feb 27 13:38:18 2014
@@ -745,7 +745,7 @@ ConnectRemote (RNBRemote *remote,
else
{
if (port != 0)
- RNBLogSTDOUT ("Listening to port %i for a connection from %s...\n", port, host ? host : "localhost");
+ RNBLogSTDOUT ("Listening to port %i for a connection from %s...\n", port, host ? host : "127.0.0.1");
if (unix_socket_name && unix_socket_name[0])
{
if (remote->Comm().Listen(host, port, PortWasBoundCallbackUnixSocket, unix_socket_name) != rnb_success)
@@ -1266,7 +1266,7 @@ main (int argc, char *argv[])
int items_scanned = ::sscanf (argv[0], "%i", &port);
if (items_scanned == 1)
{
- host = "localhost";
+ host = "127.0.0.1";
DNBLogDebug("host = '%s' port = %i", host.c_str(), port);
}
else if (argv[0][0] == '/')
More information about the lldb-commits
mailing list