[Lldb-commits] [PATCH] D62980: [lldb] Replace "127.0.0.1" with "localhost" in GDBRemoteCommunication.cpp

Jorge Gorbe Moya via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 6 13:53:09 PDT 2019


jgorbe created this revision.
jgorbe added reviewers: clayborg, labath.

127.0.0.1 doesn't work in machines configured with IPv6-only networking.


https://reviews.llvm.org/D62980

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1078,7 +1078,7 @@
       } else {
         // No host and port given, so lets listen on our end and make the
         // debugserver connect to us..
-        error = StartListenThread("127.0.0.1", 0);
+        error = StartListenThread("localhost", 0);
         if (error.Fail()) {
           if (log)
             log->Printf("GDBRemoteCommunication::%s() unable to start listen "
@@ -1093,7 +1093,7 @@
         uint16_t port_ = connection->GetListeningPort(std::chrono::seconds(10));
         if (port_ > 0) {
           char port_cstr[32];
-          snprintf(port_cstr, sizeof(port_cstr), "127.0.0.1:%i", port_);
+          snprintf(port_cstr, sizeof(port_cstr), "localhost:%i", 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
@@ -1102,7 +1102,7 @@
           if (port)
             *port = port_;
         } else {
-          error.SetErrorString("failed to bind to port 0 on 127.0.0.1");
+          error.SetErrorString("failed to bind to port 0 on localhost");
           if (log)
             log->Printf("GDBRemoteCommunication::%s() failed: %s", __FUNCTION__,
                         error.AsCString());
@@ -1269,7 +1269,7 @@
   const int backlog = 5;
   TCPSocket listen_socket(true, child_processes_inherit);
   if (llvm::Error error =
-          listen_socket.Listen("127.0.0.1:0", backlog).ToError())
+          listen_socket.Listen("localhost:0", backlog).ToError())
     return error;
 
   Socket *accept_socket;
@@ -1278,7 +1278,7 @@
 
   llvm::SmallString<32> remote_addr;
   llvm::raw_svector_ostream(remote_addr)
-      << "connect://127.0.0.1:" << listen_socket.GetLocalPortNumber();
+      << "connect://localhost:" << listen_socket.GetLocalPortNumber();
 
   std::unique_ptr<ConnectionFileDescriptor> conn_up(
       new ConnectionFileDescriptor());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62980.203439.patch
Type: text/x-patch
Size: 2201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190606/3ee7a21d/attachment.bin>


More information about the lldb-commits mailing list