[Lldb-commits] [lldb] Ptrace seize dead process (PR #137041)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 24 05:08:05 PDT 2025
labath wrote:
We already have one piece of "status" parsing code in `source/Host/linux/Host.cpp`. I think it'd be better to reuse that one. I'm slightly torn as to whether reuse Host::GetProcessInfo for this (and add a new field to ProcessInstanceInfo -- or possibly expand on IsZombie), or whether to create a new linux-specific entry point which will return this data.
> Some caveats that I need to address before we publish this PR is how to prevent LLDB from running any expressions or really anything that trys to SIGCONT, because that will immediately terminate the process, I would like this behavior to mimic how we inform the user post mortem processes can't run expressions.
I don't know the answer to that, but I can say that I don't think this feature needs to be (or should be) specific to this use case. One of the things that I would like to be able to do is to stop a process right before it exits (regardless of whether that's through the exit syscall, or a fatal signal, etc.). `PTRACE_O_TRACEEXIT` lets you do that, but it means the process will end up in the same "almost a zombie" state, where any attempt to resume it will cause it to disappear. If we had a mechanism to prevent this, we could use it in this case as well. (and this case, unlike this "dead" state, is actually testable).
I think the tricky part is that (in both cases) the user might legitimately want to let the process exit, and "continue" is the normal way to do that, so I don't think we'd want to just error out of the continue command (or from the `vCont` packet). I think what we'd want is to make sure that the process doesn't accidentally exit while running an expression (possibly from within a data formatter), and for that I guess we'd need to let lldb know that running expressions is "dangerous". We already have `Thread::SafeToCallFunctions`, even though it's used for a slightly different purpose, but *maybe* it could be extended to handle this as well?
https://github.com/llvm/llvm-project/pull/137041
More information about the lldb-commits
mailing list