[PATCH 12/57][Arm][GAS] Add support for MVE instructions: vaddlv and vaddv
[binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-var-child.c
blob190699426e4355643f6b71b027efb473c57101cb
1 /* Copyright 1999-2019 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #include <stdlib.h>
19 #include <string.h>
21 struct _simple_struct {
22 int integer;
23 unsigned int unsigned_integer;
24 char character;
25 signed char signed_character;
26 char *char_ptr;
27 int array_of_10[10];
30 typedef struct _simple_struct simpleton;
32 simpleton global_simple;
34 enum foo {
35 bar = 1,
36 baz
39 typedef enum foo efoo;
41 union named_union
43 int integer;
44 char *char_ptr;
47 typedef struct _struct_decl {
48 int integer;
49 char character;
50 char *char_ptr;
51 long long_int;
52 int **int_ptr_ptr;
53 long long_array[12];
55 void (*func_ptr) (void);
56 struct _struct_decl (*func_ptr_struct) (int, char *, long);
57 struct _struct_decl *(*func_ptr_ptr) (int, char *, long);
58 union {
59 int a;
60 char *b;
61 long c;
62 enum foo d;
63 } u1;
65 struct {
66 union {
67 struct {
68 int d;
69 char e[10];
70 int *(*func) (void);
71 efoo foo;
72 } u1s1;
74 long f;
75 struct {
76 char array_ptr[2];
77 int (*func) (int, char *);
78 } u1s2;
79 } u2;
81 int g;
82 char h;
83 long i[10];
84 } s2;
85 } weird_struct;
87 struct _struct_n_pointer {
88 char ****char_ptr;
89 long ****long_ptr;
90 struct _struct_n_pointer *ptrs[3];
91 struct _struct_n_pointer *next;
94 void do_locals_tests (void);
95 void do_block_tests (void);
96 void subroutine1 (int, long *);
97 void nothing (void);
98 void do_children_tests (void);
99 void do_special_tests (void);
100 void incr_a (char);
102 void incr_a (char a)
104 int b;
105 b = a;
108 void
109 do_locals_tests ()
111 int linteger;
112 int *lpinteger;
113 char lcharacter;
114 char *lpcharacter;
115 long llong;
116 long *lplong;
117 float lfloat;
118 float *lpfloat;
119 double ldouble;
120 double *lpdouble;
121 struct _simple_struct lsimple;
122 struct _simple_struct *lpsimple;
123 void (*func) (void);
125 /* Simple assignments */
126 linteger = 1234;
127 lpinteger = &linteger;
128 lcharacter = 'a';
129 lpcharacter = &lcharacter;
130 llong = 2121L;
131 lplong = &llong;
132 lfloat = 2.1;
133 lpfloat = &lfloat;
134 ldouble = 2.718281828459045;
135 lpdouble = &ldouble;
136 lsimple.integer = 1234;
137 lsimple.unsigned_integer = 255;
138 lsimple.character = 'a';
139 lsimple.signed_character = 21;
140 lsimple.char_ptr = &lcharacter;
141 lpsimple = &lsimple;
142 func = nothing;
144 /* Check pointers */
145 linteger = 4321;
146 lcharacter = 'b';
147 llong = 1212L;
148 lfloat = 1.2;
149 ldouble = 5.498548281828172;
150 lsimple.integer = 255;
151 lsimple.unsigned_integer = 4321;
152 lsimple.character = 'b';
153 lsimple.signed_character = 0;
155 subroutine1 (linteger, &llong);
158 void
159 nothing ()
163 struct _struct_decl
164 nothing1 (int a, char *b, long c)
166 struct _struct_decl foo;
168 return foo;
171 struct _struct_decl *
172 nothing2 (int a, char *b, long c)
174 return (struct _struct_decl *) 0;
177 void
178 subroutine1 (int i, long *l)
180 global_simple.integer = i + 3;
181 i = 212;
182 *l = 12;
185 void
186 do_block_tests ()
188 int cb = 12;
191 int foo;
192 foo = 123;
194 int foo2;
195 foo2 = 123;
197 int foo;
198 foo = 321;
200 foo2 = 0;
202 foo = 0;
205 cb = 21;
208 void
209 do_children_tests (void)
211 weird_struct *weird;
212 struct _struct_n_pointer *psnp;
213 struct _struct_n_pointer snp0, snp1, snp2;
214 char a0[2] = {}, *a1, **a2, ***a3;
215 char b0[2] = {}, *b1, **b2, ***b3;
216 char c0[2] = {}, *c1, **c2, ***c3;
217 long z0, *z1, **z2, ***z3;
218 long y0, *y1, **y2, ***y3;
219 long x0, *x1, **x2, ***x3;
220 int *foo;
221 int bar;
223 /* Avoid pointing into NULL, as that is editable on some
224 systems. */
225 int dummy;
226 int *dummy_ptr = &dummy;
228 struct _struct_decl struct_declarations = { 0, 0, NULL, 0, &dummy_ptr };
229 weird = &struct_declarations;
231 struct_declarations.integer = 123;
232 weird->char_ptr = "hello";
233 bar = 2121;
234 foo = &bar;
235 struct_declarations.int_ptr_ptr = &foo;
236 weird->long_array[0] = 1234;
237 struct_declarations.long_array[1] = 2345;
238 weird->long_array[2] = 3456;
239 struct_declarations.long_array[3] = 4567;
240 weird->long_array[4] = 5678;
241 struct_declarations.long_array[5] = 6789;
242 weird->long_array[6] = 7890;
243 struct_declarations.long_array[7] = 8901;
244 weird->long_array[8] = 9012;
245 struct_declarations.long_array[9] = 1234;
247 weird->func_ptr = nothing;
248 weird->func_ptr_struct = nothing1;
249 weird->func_ptr_ptr = nothing2;
250 struct_declarations.long_array[10] = 3456;
251 struct_declarations.long_array[11] = 5678;
253 /* Struct/pointer/array tests */
254 a0[0] = '0';
255 a1 = a0;
256 a2 = &a1;
257 a3 = &a2;
258 b0[0] = '1';
259 b1 = b0;
260 b2 = &b1;
261 b3 = &b2;
262 c0[1] = '2';
263 c1 = c0;
264 c2 = &c1;
265 c3 = &c2;
266 z0 = 0xdead + 0;
267 z1 = &z0;
268 z2 = &z1;
269 z3 = &z2;
270 y0 = 0xdead + 1;
271 y1 = &y0;
272 y2 = &y1;
273 y3 = &y2;
274 x0 = 0xdead + 2;
275 x1 = &x0;
276 x2 = &x1;
277 x3 = &x2;
278 snp0.char_ptr = &a3;
279 snp0.long_ptr = &z3;
280 snp0.ptrs[0] = &snp0;
281 snp0.ptrs[1] = &snp1;
282 snp0.ptrs[2] = &snp2;
283 snp0.next = &snp1;
284 snp1.char_ptr = &b3;
285 snp1.long_ptr = &y3;
286 snp1.ptrs[0] = &snp0;
287 snp1.ptrs[1] = &snp1;
288 snp1.ptrs[2] = &snp2;
289 snp1.next = &snp2;
290 snp2.char_ptr = &c3;
291 snp2.long_ptr = &x3;
292 snp2.ptrs[0] = &snp0;
293 snp2.ptrs[1] = &snp1;
294 snp2.ptrs[2] = &snp2;
295 snp2.next = 0x0;
296 psnp = &snp0;
297 snp0.char_ptr = &b3;
298 snp1.char_ptr = &c3;
299 snp2.char_ptr = &a3;
300 snp0.long_ptr = &y3;
301 snp1.long_ptr = &x3;
302 snp2.long_ptr = &z3;
305 void
306 do_special_tests (void)
308 union named_union u;
309 union {
310 int a;
311 char b;
312 long c;
313 } anonu;
314 struct _simple_struct s;
315 struct {
316 int a;
317 char b;
318 long c;
319 } anons;
320 enum foo e;
321 enum { A, B, C } anone;
322 int array[21];
323 int a;
325 a = 1;
326 incr_a(2);
329 struct very_simple_struct
331 int a;
332 int b;
336 do_child_deletion (void)
338 /*: BEGIN: child_deletion :*/
339 struct very_simple_struct s = {1, 2};
341 mi_create_varobj S s "create varobj for s"
342 mi_list_varobj_children S {{S.a a 0 int} {S.b b 0 int}} \
343 "list children of S"
344 mi_delete_varobj S.a "delete S.a"
345 mi_delete_varobj S.b "delete S.b"
346 mi_delete_varobj S "delete S"
348 return 99;
349 /*: END: child_deletion :*/
353 main (int argc, char *argv [])
355 do_locals_tests ();
356 do_block_tests ();
357 do_children_tests ();
358 do_special_tests ();
359 do_child_deletion ();
360 exit (0);