Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-attach debugger to parent process after child exits #125717

Open
nyurik opened this issue Feb 4, 2025 · 4 comments
Open

Re-attach debugger to parent process after child exits #125717

nyurik opened this issue Feb 4, 2025 · 4 comments
Labels

Comments

@nyurik
Copy link

nyurik commented Feb 4, 2025

When debugging a complex multi-process code like Rust compiler unit tests, the current settings set target.process.follow-fork-mode child|parent is too limiting because a compiler test does a tree-like traversal - forking a subprocess which may spawn another subprocess, waiting for the child to finish, and forking another process and waiting for that, etc. If the follow mode is child, it will stop debugging when the first child exits. If it is the parent, it will never go into any child processes.

Thus, it is currently impossible to add a breakpoint to the code and wait for it to be hit - because it might be in the second child process that runs.

Would it be possible for the debugger to re-attach to the parent process once the child exits?

See also

@llvmbot
Copy link
Member

llvmbot commented Feb 4, 2025

@llvm/issue-subscribers-lldb

Author: Yuri Astrakhan (nyurik)

When debugging a complex multi-process code like Rust compiler unit tests, the current `settings set target.process.follow-fork-mode child|parent` is too limiting because a compiler test does a tree-like traversal - forking a subprocess which may spawn another subprocess, waiting for the child to finish, and forking another process and waiting for that, etc. If the follow mode is `child`, it will stop debugging when the first child exits. If it is the `parent`, it will never go into any child processes.

Thus, it is currently impossible to add a breakpoint to the code and wait for it to be hit - because it might be in the second child process that runs.

Would it be possible for the debugger to re-attach to the parent process once the child exits?

See also

@DavidSpickett
Copy link
Collaborator

I think @labath worked on these settings.

@jimingham
Copy link
Collaborator

jimingham commented Feb 6, 2025

I wouldn't do it this way. lldb supports multiple processes simultaneously so it seems like a much more natural flow for your use case would be to continue debugging the parent, and add the child as a separate target in that debug session.

IIRC, the only reason it was done this way was expediency. But if we're going to go another round with this feature, we should not force users to make the unnecessary choice between parent and child.

@jimingham
Copy link
Collaborator

That would also be much simpler to implement than trying to recover the parent you've forgotten about on child exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants