[Lldb-commits] [lldb] [lldb] Allow forks to occur in expression evaluation (PR #184815)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 14 14:46:34 PDT 2026


clayborg wrote:

The use case for us is to fork() the current process in an expression and then exec into a python debugger with the forked child.

So the expression does a fork and optionally an exec. In this case we probably always want to stay with the parent process as we are running an expression. Not sure we should listen to the follow fork mode for fork/vfork in expressions.  

On linux, when you fork, the lldb-server will get a notification about the child process. If we following the parent, then the lldb-server needs a packet that tells it to detach from the forked child process and it will also clear any breakpoints in the child process so the forked child doesn't crash if it hits breakpoints that were set in the parent. If we are following the child, lldb-server needs to do the opposite: detach from the parent process and clear the breakpoints in that process and then switch over the becoming the GDB server for the child process. 

So the ProcessGDBRemote::DidFork()/DidVFork() will send the packets down the lldb-server to do this work.

So if we run an expression that contains a fork() or vfork() we need it to be able to keep the process running and send these packets. 

We both don't have much of an idea where this can and should be handled and we would like your input on where this should happen.

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


More information about the lldb-commits mailing list