xref: /llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp (revision f4461cf4f30417be118487142bca6635e07ed1e6)
1 #include <stdint.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string>
5 
6 struct i_am_cool
7 {
8 	int integer;
9 	float floating;
10 	char character;
i_am_cooli_am_cool11 	i_am_cool(int I, float F, char C) :
12     integer(I), floating(F), character(C) {}
i_am_cooli_am_cool13 	i_am_cool() : integer(1), floating(2), character('3') {}
14 
15 };
16 
17 struct i_am_cooler
18 {
19 	i_am_cool first_cool;
20 	i_am_cool second_cool;
21 	float floating;
22 
i_am_cooleri_am_cooler23 	i_am_cooler(int I1, int I2, float F1, float F2, char C1, char C2) :
24     first_cool(I1,F1,C1),
25     second_cool(I2,F2,C2),
26     floating((F1 + F2)/2) {}
27 };
28 
29 struct IWrapPointers
30 {
31     int* int_pointer;
32     float* float_pointer;
IWrapPointersIWrapPointers33 	IWrapPointers() : int_pointer(new int(4)), float_pointer(new float(1.111)) {}
34 };
35 
36 struct Simple
37 {
38 	int x;
39 	float y;
40 	char z;
SimpleSimple41 	Simple(int X, float Y, char Z) :
42 	x(X),
43 	y(Y),
44 	z(Z)
45 	{}
46 };
47 
48 struct SimpleWithPointers
49 {
50 	int *x;
51 	float *y;
52 	char *z;
SimpleWithPointersSimpleWithPointers53 	SimpleWithPointers(int X, float Y, char Z) :
54 	x(new int (X)),
55 	y(new float (Y)),
56 	z(new char[2])
57 	{
58           z[0] = Z;
59           z[1] = '\0';
60         }
61 };
62 
63 struct Couple
64 {
65 	SimpleWithPointers sp;
66 	Simple* s;
CoupleCouple67 	Couple(int X, float Y, char Z) : sp(X,Y,Z),
68 	s(new Simple(X,Y,Z)) {}
69 };
70 
71 struct VeryLong
72 {
73     int a_1;
74     int b_1;
75     int c_1;
76     int d_1;
77     int e_1;
78     int f_1;
79     int g_1;
80     int h_1;
81     int i_1;
82     int j_1;
83     int k_1;
84     int l_1;
85     int m_1;
86     int n_1;
87     int o_1;
88     int p_1;
89     int q_1;
90     int r_1;
91     int s_1;
92     int t_1;
93     int u_1;
94     int v_1;
95     int w_1;
96     int x_1;
97     int y_1;
98     int z_1;
99 
100     int a_2;
101     int b_2;
102     int c_2;
103     int d_2;
104     int e_2;
105     int f_2;
106     int g_2;
107     int h_2;
108     int i_2;
109     int j_2;
110     int k_2;
111     int l_2;
112     int m_2;
113     int n_2;
114     int o_2;
115     int p_2;
116     int q_2;
117     int r_2;
118     int s_2;
119     int t_2;
120     int u_2;
121     int v_2;
122     int w_2;
123     int x_2;
124     int y_2;
125     int z_2;
126 };
127 
main(int argc,const char * argv[])128 int main (int argc, const char * argv[])
129 {
130 
131     int iAmInt = 9;
132     const int constInt = 42;
133     volatile int volatileInt = 43;
134     const volatile int constVolatileInt = 44;
135 
136     i_am_cool cool_boy(1,0.5,3);
137     i_am_cooler cooler_boy(1,2,0.1,0.2,'A','B');
138 
139 	i_am_cool *cool_pointer = new i_am_cool(3,-3.141592,'E');
140 
141     i_am_cool cool_array[5];
142 
143     cool_array[3].floating = 5.25;
144     cool_array[4].integer = 6;
145     cool_array[2].character = 'Q';
146 
147     int int_array[] = {1,2,3,4,5};
148     const int const_int_array[] = {11, 12, 13, 14, 15};
149 
150     IWrapPointers wrapper;
151 
152     *int_array = -1;
153 
154     int* pointer = &cool_array[4].integer;
155 
156     IWrapPointers *wrap_pointer = &wrapper;
157 
158     Couple couple(9,9.99,'X');
159 
160 	SimpleWithPointers sparray[] =
161         {SimpleWithPointers(-1,-2,'3'),
162         SimpleWithPointers(-4,-5,'6'),
163         SimpleWithPointers(-7,-8,'9')};
164 
165     Simple a_simple_object(3,0.14,'E');
166 
167     VeryLong a_long_guy;
168 
169     std::string some_string = "012345678901234567890123456789"
170                               "012345678901234567890123456789"
171                               "012345678901234567890123456789"
172                               "012345678901234567890123456789";
173     char const *some_cstring = some_string.c_str();
174 
175     char const some_carr[] = "012345678901234567890123456789"
176                              "012345678901234567890123456789"
177                              "012345678901234567890123456789"
178                              "012345678901234567890123456789";
179 
180     return 0; // Set break point at this line.
181 }
182