xref: /llvm-project/lldb/test/API/functionalities/thread/state/main.cpp (revision fdea9a4ec9b0d9585b8fe8a612686d9f44f40ddc)
1 // This test is intended to verify that thread states are properly maintained
2 // when transitional actions are performed in the debugger.  Most of the logic
3 // is in the test script.  This program merely provides places where the test
4 // can create the intended states.
5 
6 #include <chrono>
7 #include <thread>
8 
9 volatile int g_test = 0;
10 
addSomething(int a)11 int addSomething(int a)
12 {
13     return a + g_test;
14 }
15 
doNothing()16 int doNothing()
17 {
18     int temp = 0;   // Set first breakpoint here
19 
20     while (!g_test && temp < 5)
21     {
22         ++temp;
23         std::this_thread::sleep_for(std::chrono::seconds(2));
24     }
25 
26     return temp;    // Set second breakpoint here
27 }
28 
main()29 int main ()
30 {
31     int result = doNothing();
32 
33     int i = addSomething(result);
34 
35     return 0;
36 }
37