================ @@ -393,125 +362,222 @@ 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; + if (fd != SharedSocket::kInvalidFD) { // Child process will handle the connection and exit. + if (gdbserver_port) + protocol = Socket::ProtocolTcp; + Log *log = GetLog(LLDBLog::Platform); - if (!listen_host_port.empty()) { - LLDB_LOGF(log, "lldb-platform child: " - "ambiguous parameters --listen and --child-platform-fd"); - return socket_error; - } - NativeSocket socket; - error = SharedSocket::GetNativeSocket(fd, socket); + NativeSocket sockfd; + error = SharedSocket::GetNativeSocket(fd, sockfd); if (error.Fail()) { LLDB_LOGF(log, "lldb-platform child: %s", error.AsCString()); return socket_error; } - GDBRemoteCommunicationServerPlatform platform(Socket::ProtocolTcp, "tcp"); - if (port_offset > 0) - platform.SetPortOffset(port_offset); - platform.SetPortMap(std::move(gdbserver_portmap)); + GDBRemoteCommunicationServerPlatform platform(protocol, gdbserver_port); + Socket *socket; + if (protocol == Socket::ProtocolTcp) + socket = new TCPSocket(sockfd, /*should_close=*/true, + /*child_processes_inherit=*/false); + else { +#if LLDB_ENABLE_POSIX + socket = new DomainSocket(sockfd, /*should_close=*/true, + /*child_processes_inherit=*/false); +#else + LLDB_LOGF(log, + "lldb-platform child: Unix domain sockets are not supported on " + "this platform."); ---------------- labath wrote:
print to stderr instead? https://github.com/llvm/llvm-project/pull/104238 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits