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 stop_here() {
12 g_test += 5; // Set breakpoint here
13}
14
15void recurse_a_bit_1(int count) {
16 if (count == 50)
17 stop_here();
18 else
19 recurse_a_bit_1(count: ++count);
20}
21
22void recurse_a_bit_2(int count) {
23 if (count == 50)
24 stop_here();
25 else
26 recurse_a_bit_2(count: ++count);
27}
28
29void *thread_func_1() {
30 // Wait until both threads are running
31 pseudo_barrier_wait(g_barrier);
32
33 // Start the recursion:
34 recurse_a_bit_1(count: 0);
35
36 // Return
37 return NULL;
38}
39
40void *thread_func_2() {
41 // Wait until both threads are running
42 pseudo_barrier_wait(g_barrier);
43
44 // Start the recursion:
45 recurse_a_bit_2(count: 0);
46
47 // Return
48 return NULL;
49}
50
51int main() {
52 // Don't let either thread do anything until they're both ready.
53 pseudo_barrier_init(g_barrier, 2);
54
55 // Create two threads
56 std::thread thread_1(thread_func_1);
57 std::thread thread_2(thread_func_2);
58
59 // Wait for the threads to finish
60 thread_1.join();
61 thread_2.join();
62
63 return 0;
64}
65

source code of lldb/test/API/commands/thread/backtrace/main.cpp