================
@@ -455,35 +455,29 @@ int main_platform(int argc, char *argv[]) {
   lldb_private::Args inferior_arguments;
   inferior_arguments.SetArguments(argc, const_cast<const char **>(argv));
 
-  Socket::SocketProtocol protocol = Socket::ProtocolUnixDomain;
-
+  Log *log = GetLog(LLDBLog::Platform);
   if (fd != SharedSocket::kInvalidFD) {
     // Child process will handle the connection and exit.
-    if (gdbserver_port)
-      protocol = Socket::ProtocolTcp;
-
-    Log *log = GetLog(LLDBLog::Platform);
-
     NativeSocket sockfd;
     error = SharedSocket::GetNativeSocket(fd, sockfd);
     if (error.Fail()) {
       LLDB_LOGF(log, "lldb-platform child: %s", error.AsCString());
       return socket_error;
     }
 
-    GDBRemoteCommunicationServerPlatform platform(protocol, gdbserver_port);
     Socket *socket;
-    if (protocol == Socket::ProtocolTcp)
+    if (gdbserver_port) {
       socket = new TCPSocket(sockfd, /*should_close=*/true);
-    else {
-#if LLDB_ENABLE_POSIX
-      socket = new DomainSocket(sockfd, /*should_close=*/true);
-#else
-      WithColor::error() << "lldb-platform child: Unix domain sockets are not "
-                            "supported on this platform.";
-      return socket_error;
-#endif
+    } else {
+      socket = DomainSocket::Create(sockfd, /*should_close=*/true, error);
+      if (error.Fail()) {
+        LLDB_LOGF(log, "Failed to create socket: %s\n", error.AsCString());
+        return socket_error;
+      }
     }
+
+    Socket::SocketProtocol protocol = socket->GetSocketProtocol();
+    GDBRemoteCommunicationServerPlatform platform(protocol, gdbserver_port);
----------------
slydiman wrote:

```suggestion
    GDBRemoteCommunicationServerPlatform platform(socket->GetSocketProtocol(), 
gdbserver_port);
```

https://github.com/llvm/llvm-project/pull/136466
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to