]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / tools / lldb-mi / stack / main.cpp
1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include <exception>
11
12 struct inner
13 {
14     int var_d;
15 };
16
17 struct my_type
18 {
19     int var_a;
20     char var_b;
21     struct inner inner_;
22 };
23
24 int
25 local_int_test(void)
26 {
27     int a = 10, b = 20;
28     return 0; // BP_local_int_test
29 }
30
31 int
32 local_int_test_with_args(int c, int d)
33 {
34     int a = 10, b = 20;
35     return 0; // BP_local_int_test_with_args
36 }
37
38 int
39 local_struct_test(void)
40 {
41     struct my_type var_c;
42     var_c.var_a = 10;
43     var_c.var_b = 'a';
44     var_c.inner_.var_d = 30;
45     return 0; // BP_local_struct_test
46 }
47
48 int local_struct_test_with_args(struct my_type var_e)
49 {
50     struct my_type var_c;
51     var_c.var_a = 10;
52     var_c.var_b = 'a';
53     var_c.inner_.var_d = 30;
54     return 0; // BP_local_struct_test_with_args
55 }
56
57 int
58 local_array_test(void)
59 {
60     int array[3];
61     array[0] = 100;
62     array[1] = 200;
63     array[2] = 300;
64     return 0; // BP_local_array_test
65 }
66
67 int
68 local_array_test_with_args(int* other_array)
69 {
70     int array[3];
71     array[0] = 100;
72     array[1] = 200;
73     array[2] = 300;
74     return 0; // BP_local_array_test_with_args
75 }
76
77 int
78 local_pointer_test(void)
79 {
80     const char *test_str = "Rakaposhi";
81     int var_e = 24;
82     int *ptr = &var_e;
83     return 0; // BP_local_pointer_test
84 }
85
86 int
87 local_pointer_test_with_args(const char *arg_str, int *arg_ptr)
88 {
89     const char *test_str = "Rakaposhi";
90     int var_e = 24;
91     int *ptr = &var_e;
92     return 0; // BP_local_pointer_test_with_args
93 }
94
95 int do_tests_with_args()
96 {
97     local_int_test_with_args(30, 40);
98
99     struct my_type var_e;
100     var_e.var_a = 20;
101     var_e.var_b = 'b';
102     var_e.inner_.var_d = 40;
103     local_struct_test_with_args(var_e);
104
105     int array[3];
106     array[0] = 400;
107     array[1] = 500;
108     array[2] = 600;
109     local_array_test_with_args(array);
110
111     const char *test_str = "String";
112     int var_z = 25;
113     int *ptr = &var_z;
114     local_pointer_test_with_args(test_str, ptr);
115
116     return 0;
117 }
118
119 void catch_unnamed_test()
120 {
121     try
122     {
123         int i = 1, j = 2;
124         throw std::exception(); // BP_catch_unnamed
125     }
126     catch(std::exception&)
127     {
128     }
129 }
130
131 int
132 main(int argc, char const *argv[])
133 {
134     local_int_test();
135     local_struct_test();
136     local_array_test();
137     local_pointer_test();
138     catch_unnamed_test();
139
140     do_tests_with_args();
141     return 0;
142 }