================
@@ -455,37 +455,33 @@ 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)
-      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
+    std::unique_ptr<Socket> socket;
+    if (gdbserver_port) {
+      socket = std::make_unique<TCPSocket>(sockfd, /*should_close=*/true);
+    } else {
+      llvm::Expected<std::unique_ptr<DomainSocket>> domain_socket =
+          DomainSocket::FromBoundNativeSocket(sockfd, /*should_close=*/true);
+      if (!domain_socket) {
+        LLDB_LOGF(log, "Failed to create socket: %s\n", error.AsCString());
----------------
labath wrote:

```suggestion
        LLDB_LOG_ERROR(log, domain_socket.takeError(), "Failed to create 
socket: {0}");
```

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