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 verify that thread states are properly maintained
10 // when transitional actions are performed in the debugger.  Most of the logic
11 // is in the test script.  This program merely provides places where the test
12 // can create the intended states.
13 
14 #include <chrono>
15 #include <thread>
16 
17 volatile int g_test = 0;
18 
19 int addSomething(int a)
20 {
21     return a + g_test;
22 }
23 
24 int doNothing()
25 {
26     int temp = 0;   // Set first breakpoint here
27 
28     while (!g_test && temp < 5)
29     {
30         ++temp;
31         std::this_thread::sleep_for(std::chrono::seconds(2));
32     }
33 
34     return temp;    // Set second breakpoint here
35 }
36 
37 int main ()
38 {
39     int result = doNothing();
40 
41     int i = addSomething(result);
42 
43     return 0;
44 }
45