1// This test is intended to create a situation in which a breakpoint will be
2// hit in two threads at nearly the same moment. The expected result is that
3// the breakpoint in the second thread will be hit while the breakpoint handler
4// in the first thread is trying to stop all threads.
5
6#include "pseudo_barrier.h"
7#include <thread>
8
9pseudo_barrier_t g_barrier;
10
11volatile int g_test = 0;
12
13void *
14thread_func ()
15{
16 // Wait until both threads are running
17 pseudo_barrier_wait(g_barrier);
18
19 // Do something
20 g_test++; // Set breakpoint here
21
22 // Return
23 return NULL;
24}
25
26int main ()
27{
28 // Don't let either thread do anything until they're both ready.
29 pseudo_barrier_init(g_barrier, 2);
30
31 // Create two threads
32 std::thread thread_1(thread_func);
33 std::thread thread_2(thread_func);
34
35 // Wait for the threads to finish
36 thread_1.join();
37 thread_2.join();
38
39 return 0;
40}
41

source code of lldb/test/API/functionalities/thread/multi_break/main.cpp