1 //===-- main.cpp ------------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // This test is intended to create a situation in which two threads are stopped 10 // at a breakpoint and the debugger issues a step-out command. 11 12 #include "pseudo_barrier.h" 13 #include <thread> 14 15 pseudo_barrier_t g_barrier; 16 17 volatile int g_test = 0; 18 19 void step_out_of_here() { 20 g_test += 5; // Set breakpoint here 21 } 22 23 void * 24 thread_func () 25 { 26 // Wait until both threads are running 27 pseudo_barrier_wait(g_barrier); 28 29 // Do something 30 step_out_of_here(); // Expect to stop here after step-out (clang) 31 32 // Return 33 return NULL; // Expect to stop here after step-out (icc and gcc; arm64) 34 } 35 36 int main () 37 { 38 // Don't let either thread do anything until they're both ready. 39 pseudo_barrier_init(g_barrier, 2); 40 41 // Create two threads 42 std::thread thread_1(thread_func); 43 std::thread thread_2(thread_func); 44 45 // Wait for the threads to finish 46 thread_1.join(); 47 thread_2.join(); 48 49 return 0; 50 } 51