[Lldb-commits] [lldb] [lldb] Allow forks to occur in expression evaluation (PR #184815)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 8 15:09:28 PDT 2026
jimingham wrote:
> @jimingham I don't think we can we can handle this in Process::RunThreadPlan() because the thread plan will already be marked as failed. I've changed the approach to overloading ShouldStopSynchronous(), which seems right to me, but if you still think RunThreadPlan() is the way to go, I can try to work make something work in there.
We are in control of whether we think stopping for a fork makes the ThreadPlanCallFunction fail or not. I don't think that's a real objection.
I'm not sure how you expect this to work. Normally when you use `fork` you are writing code like:
pid_t pid = fork()
if (pid == 0) {
// Do child stuff
exec("path", arg0, ...);
} else {
// Do parent stuff
}
So you really need to keep the expression running on BOTH sides of the fork to make this work generally. That's hard to do because the original implementation of `follow fork` was done incorrectly. Instead of making a new target for the forked child, and allowing lldb to control both, you have to discard one or the other process.
Still, by switching silently to the child before RunThreadPlan even sees the fork stop event, you give lldb no chance to clean up the expression in the parent and are just hoping that that will all work out okay. But if you stop in RunThreadPlan with a fork stop event, you are in a position to handle this correctly. lldb could suspend the child and postpone switching to it; make sure the function call succeeds on the parent side (so the //Do parent stuff works). Then switch to the child and let the expression finish on the child side so both processes are in a good state after the expression.
https://github.com/llvm/llvm-project/pull/184815
More information about the lldb-commits
mailing list