================ @@ -666,7 +756,23 @@ ConnectionStatus ConnectionFileDescriptor::ConnectFD(llvm::StringRef s, socket_id_callback_type socket_id_callback, Status *error_ptr) { -#if LLDB_ENABLE_POSIX +#ifdef _WIN32 + int64_t fd = -1; + if (!s.getAsInteger(0, fd)) { + // Assume we own fd. + std::unique_ptr<TCPSocket> tcp_socket = + std::make_unique<TCPSocket>((NativeSocket)fd, true, false); + m_io_sp = std::move(tcp_socket); + m_uri = s.str(); + return eConnectionStatusSuccess; + } ---------------- labath wrote:
Reducing the number of ifdefs is great, but it also must be balanced with considerations like code readability and user confusion. I don't think this strikes the right balance as FD's are a thing on windows as well, and so this could be very surprising. Handles are windows-specific, but we are already using them in lldb as a generic concept of an object identifier. E.g. Socket::GetWaitableHandle returns the fd (`int`) on posix and the socket handle (`SOCKET`) on windows. Here's a specific suggestion: We can sidestep this problem by not roundtripping the socket through a string URL. ConnectionFileDescriptor has a constructor which takes a `Socket` argument, so I think we could use that. If we also make `SharedSocket::GetNativeSocket` (`GetSocket` ?) return a Socket object, then we can also reduce the usage of raw NativeSocket values. 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