1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This test is intended to create a situation in which one thread will be
11 // created while the debugger is stepping in another thread.
18 pseudo_barrier_t g_barrier;
20 volatile int g_thread_created = 0;
21 volatile int g_test = 0;
26 g_test = 0; // Set breakpoint here
28 while (!g_thread_created)
31 // One more time to provide a continue point
32 g_test++; // Continue from here
39 create_thread_func (void *input)
41 std::thread *step_thread = (std::thread*)input;
43 // Wait until the main thread knows this thread is started.
44 pseudo_barrier_wait(g_barrier);
46 // Wait until the other thread is done.
55 // Use a simple count to simulate a barrier.
56 pseudo_barrier_init(g_barrier, 2);
58 // Create a thread to hit the breakpoint.
59 std::thread thread_1(step_thread_func);
61 // Wait until the step thread is stepping
65 // Create a thread to exit while we're stepping.
66 std::thread thread_2(create_thread_func, &thread_1);
68 // Wait until that thread is started
69 pseudo_barrier_wait(g_barrier);
71 // Let the stepping thread know the other thread is there
74 // Wait for the threads to finish.