void * wait_thread_func () { // Wait until the entire first group of threads is running pseudo_barrier_wait(g_barrier1); // Wait until the breakpoint has been passed pseudo_barrier_wait(g_barrier2); // Return return NULL; }
int main () { // Use a simple count to simulate a barrier. pseudo_barrier_init(g_barrier, 2); // Create a thread to hit the breakpoint. std::thread thread_1(step_thread_func); // Wait until the step thread is stepping while (g_test < 1) do_nothing(); // Create a thread to exit while we're stepping. std::thread thread_2(create_thread_func, &thread_1); // Wait until that thread is started pseudo_barrier_wait(g_barrier); // Let the stepping thread know the other thread is there g_thread_created = 1; // Wait for the threads to finish. thread_2.join(); thread_1.join(); return 0; }
void * break_thread_func () { // Wait until all the threads are running pseudo_barrier_wait(g_barrier1); // Wait for the join thread to join std::this_thread::sleep_for(std::chrono::microseconds(50)); // Do something g_test++; // Set breakpoint here // Synchronize after the breakpoint pseudo_barrier_wait(g_barrier2); // Return return NULL; }
void * thread_func () { // Wait until both threads are running pseudo_barrier_wait(g_barrier); // Do something g_test++; // Set breakpoint here // Return return NULL; }
void * thread_func (void *input) { // Wait until both threads are running pseudo_barrier_wait(g_barrier); // Do something step_out_of_here(); // Expect to stop here after step-out (clang) // Return return NULL; // Expect to stop here after step-out (gcc) }
void * exit_thread_func (void *input) { // Wait until both threads are started. pseudo_barrier_wait(g_barrier); // Wait until the other thread is stepping. while (g_test == 0) do_nothing(); // Return return NULL; }
void * create_thread_func (void *input) { std::thread *step_thread = (std::thread*)input; // Wait until the main thread knows this thread is started. pseudo_barrier_wait(g_barrier); // Wait until the other thread is done. step_thread->join(); // Return return NULL; }
void * join_thread_func (void *input) { std::thread *thread_to_join = (std::thread *)input; // Sync up with the rest of the threads. pseudo_barrier_wait(g_barrier1); // Join the other thread thread_to_join->join(); // Return return NULL; }
void * step_thread_func (void *input) { // Wait until both threads are started. pseudo_barrier_wait(g_barrier); g_test = 0; // Set breakpoint here while (!g_thread_exited) g_test++; // One more time to provide a continue point g_test++; // Continue from here // Return return NULL; }