[NativeProcessLinux] Add back synchronisation of thread create events
authorPavel Labath <labath@google.com>
Tue, 28 Apr 2015 07:51:52 +0000 (07:51 +0000)
committerPavel Labath <labath@google.com>
Tue, 28 Apr 2015 07:51:52 +0000 (07:51 +0000)
commit426bdf886153135e60e3ebef9e551435309dcf83
tree2b38615861871d23b7eccaa99fff3af29d6c4716
parent097f1bf4b22175dcd10786a2398998a7cce29ed3
[NativeProcessLinux] Add back synchronisation of thread create events

Summary:
Without the synchronisation between the two thread creation events the following case could
happen:
- threads A and B are running. A hits a breakpoint. We note that we want to stop B.
- before we could stop it, B creates a new thread C, we get the stop notification for B, but we
  don't record C's existence yet.
- we resume B
- before we get the C notification, B stops again (e.g. hits a breakpoint, gets our SIGSTOP,
  etc.)
- we see all known threads have stopped, and we notify LLDB
- C notification comes, we note it's existence and resume it
=> we have an inconsistent state (LLDB thinks we've stopped, but C is running)

I resolve this by doing a blocking wait for for the C notification when we get the creation
notification on the parent (B) thread. This way the two events are synchronised, but we don't
need to introduce the intermediate "launching" state which would complicate handling of thread
states as all code would need to be aware of the third possible state.

Test Plan:
This is an obscure corner case, which I had not observed in practise, so I have no
test for it. I have tested that this commit does not regress in existing tests though.

Reviewers: chaoren, vharron

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D9217

llvm-svn: 235969
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/Linux/NativeProcessLinux.h