[Lldb-commits] [lldb] [lldb] Updated lldb-server to spawn the child process and share socket on Windows (PR #101283)
Dmitry Vasilyev via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 5 06:54:05 PDT 2024
slydiman wrote:
@labath
>That's nice, but I think we should figure out how to reduce the number of ifdefs in this patch. Porting linux away from fork may not be your concern, but figuring out how to make the code less branchy is. If you can do that without removing forks, I can take it upon myself to handle the rest. I just think it would be easier to do it both together...
`#ifdef _WIN32` is used here for the following
- declare and initialize the parameter --accept (accept_fd)
- call spawn_process_child() and exit if accept_fd is defined
- call spawn_process_parent() instead of fork()
We can unify spawn_process_child() moving it to ConnectionFileDescriptor::ConnectFD() in ConnectionFileDescriptorPosix.cpp with `#ifdef _WIN32`.
Note I will remove `#ifndef _WIN32` around ::waitpid() in lldb-platform.cpp in the part 2 of this patch.
We still need spawn_process_reaped() here but I will remove it in part 2 too. Any static dummy will be enough.
For now we need spawn_process_reaped() here for `gdbserver_portmap.FreePortForProcess(pid);`.
We can try to move spawn_process_parent() to `lldb/source/Host/windows/` and probably a part to `lldb/source/Host/posix/`.
Where is the best place? HostProcess*.cpp, ProcessLauncher*.cpp?
It is necessary to implement some callback for spawn_process_reaped(), which will be removed in part 2.
It looks like a redundant work now.
Probably it is necessary to define a new type and an invalid value for accept_fd. It is int (socket fd) on Posix and pipe_t (HANDLE) on Windows.
What is the best type name and what is the best place to define it?
I would be happy to keep it as is till part 2 of this patch to minimize a redundant work.
https://github.com/llvm/llvm-project/pull/101283
More information about the lldb-commits
mailing list