brintos

brintos / llvm-project-archived public Read only

0
0
Text · 892 B · 824f1b6 Raw
43 lines · cpp
1// This test is intended to create a situation in which two threads are stopped2// at a breakpoint and the debugger issues a step-out command.3 4#include "pseudo_barrier.h"5#include <thread>6 7pseudo_barrier_t g_barrier;8 9volatile int g_test = 0;10 11void step_out_of_here() {12  g_test += 5; // Set breakpoint here13}14 15void *16thread_func ()17{18    // Wait until both threads are running19    pseudo_barrier_wait(g_barrier);20 21    // Do something22    step_out_of_here(); // But we might still be here 23 24    // Return25    return NULL;  // Expect to stop here after step-out.26}27 28int main ()29{30    // Don't let either thread do anything until they're both ready.31    pseudo_barrier_init(g_barrier, 2);32 33    // Create two threads34    std::thread thread_1(thread_func);35    std::thread thread_2(thread_func);36 37    // Wait for the threads to finish38    thread_1.join();39    thread_2.join();40 41    return 0;42}43