diff options
author | Pavel Labath <pavel@labath.sk> | 2022-03-30 11:40:34 +0200 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2022-04-05 11:22:37 +0200 |
commit | 4384c96fe7eb5ceb5f2c1ece4a73c22a18bac19f (patch) | |
tree | 06936b8fd5e387885b3eb20c734821ba069a36c3 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 331150a47dd5b26758293d73c5df3aa1b61ecad9 (diff) | |
download | llvm-4384c96fe7eb5ceb5f2c1ece4a73c22a18bac19f.zip llvm-4384c96fe7eb5ceb5f2c1ece4a73c22a18bac19f.tar.gz llvm-4384c96fe7eb5ceb5f2c1ece4a73c22a18bac19f.tar.bz2 |
[lldb/linux] Handle main thread exits
This patch handles the situation where the main thread exits (through
the SYS_exit syscall). In this case, the process as a whole continues
running until all of the other threads exit, or one of them issues an
exit_group syscall.
The patch consists of two changes:
- a moderate redesign of the handling of thread exit (WIFEXITED) events.
Previously, we were removing (forgetting) a thread once we received
the WIFEXITED (or WIFSIGNALED) event. This was problematic for the
main thread, since the main thread WIFEXITED event (which is better thought
of as a process-wide event) gets reported only after the entire process
exits. This resulted in deadlocks, where we were waiting for the
process to stop (because we still considered the main thread "live").
This patch changes the logic such that the main thread is removed as
soon as its PTRACE_EVENT_EXIT (the pre-exit) event is received. At
this point we can consider the thread gone (for most purposes). As a
corrolary, I needed to add special logic to catch process-wide exit
events in the cases where we don't have the main thread around.
- The second part of the patch is the removal of the assumptions that
the main thread is always available. This generally meant replacing
the uses of GetThreadByID(process_id) with GetCurrentThread() in
various process-wide operations (such as memory reads).
Differential Revision: https://reviews.llvm.org/D122716
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions