[Lldb-commits] [lldb] [lldb] Inherit DuplicateFileAction(HANDLE, HANDLE) handles on windows (PR #137978)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 30 12:03:46 PDT 2025


================
@@ -274,10 +274,8 @@ static Status spawn_process(const char *progname, const FileSpec &prog,
   self_args.AppendArgument(llvm::StringRef("platform"));
   self_args.AppendArgument(llvm::StringRef("--child-platform-fd"));
   self_args.AppendArgument(llvm::to_string(shared_socket.GetSendableFD()));
-#ifndef _WIN32
   launch_info.AppendDuplicateFileAction((int)shared_socket.GetSendableFD(),
                                         (int)shared_socket.GetSendableFD());
----------------
labath wrote:

It's definitely not the most elegant piece of code I've written, but it does work. A HANDLE is not a real pointer anyway -- just an OS-assigned identifier that they chose to stick in a void*. I'm not sure how it gets chosen, but in my experiments all of the values were low integer values (<=1k). I've been planning to follow this up with a change to make ProcessLaunchInfo accept 64-bit integers, which should make it safer (and avoid the warnings about casts of pointers to ints of different size). We can definitely also do it beforehand, but I wanted to get this out to see what you think of the overall approach.

https://github.com/llvm/llvm-project/pull/137978


More information about the lldb-commits mailing list