1// This test is intended to create a situation in which two threads are stopped
2// 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 here
13}
14
15void *
16thread_func ()
17{
18 // Wait until both threads are running
19 pseudo_barrier_wait(g_barrier);
20
21 // Do something
22 step_out_of_here(); // But we might still be here
23
24 // Return
25 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 threads
34 std::thread thread_1(thread_func);
35 std::thread thread_2(thread_func);
36
37 // Wait for the threads to finish
38 thread_1.join();
39 thread_2.join();
40
41 return 0;
42}
43

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