1 /* Copyright 1999, 2004-2005, 2007-2012 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/>. */
21 struct _simple_struct {
23 unsigned int unsigned_integer;
25 signed char signed_character;
30 typedef struct _simple_struct simpleton;
32 simpleton global_simple;
39 typedef enum foo efoo;
47 typedef struct _struct_decl {
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);
77 int (*func) (int, char *);
87 struct _struct_n_pointer {
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 *);
98 void do_children_tests (void);
99 void do_special_tests (void);
121 struct _simple_struct lsimple;
122 struct _simple_struct *lpsimple;
125 /* Simple assignments */
127 lpinteger = &linteger;
129 lpcharacter = &lcharacter;
134 ldouble = 2.718281828459045;
136 lsimple.integer = 1234;
137 lsimple.unsigned_integer = 255;
138 lsimple.character = 'a';
139 lsimple.signed_character = 21;
140 lsimple.char_ptr = &lcharacter;
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);
164 subroutine1 (int i, long *l)
166 global_simple.integer = i + 3;
195 do_children_tests (void)
198 struct _struct_n_pointer *psnp;
199 struct _struct_n_pointer snp0, snp1, snp2;
200 char a0[2] = {}, *a1, **a2, ***a3;
201 char b0[2] = {}, *b1, **b2, ***b3;
202 char c0[2] = {}, *c1, **c2, ***c3;
203 long z0, *z1, **z2, ***z3;
204 long y0, *y1, **y2, ***y3;
205 long x0, *x1, **x2, ***x3;
209 /* Avoid pointing into NULL, as that is editable on some
212 int *dummy_ptr = &dummy;
214 struct _struct_decl struct_declarations = { 0, 0, NULL, 0, &dummy_ptr };
215 weird = &struct_declarations;
217 struct_declarations.integer = 123;
218 weird->char_ptr = "hello";
221 struct_declarations.int_ptr_ptr = &foo;
222 weird->long_array[0] = 1234;
223 struct_declarations.long_array[1] = 2345;
224 weird->long_array[2] = 3456;
225 struct_declarations.long_array[3] = 4567;
226 weird->long_array[4] = 5678;
227 struct_declarations.long_array[5] = 6789;
228 weird->long_array[6] = 7890;
229 struct_declarations.long_array[7] = 8901;
230 weird->long_array[8] = 9012;
231 struct_declarations.long_array[9] = 1234;
233 weird->func_ptr = nothing;
234 struct_declarations.long_array[10] = 3456;
235 struct_declarations.long_array[11] = 5678;
237 /* Struct/pointer/array tests */
264 snp0.ptrs[0] = &snp0;
265 snp0.ptrs[1] = &snp1;
266 snp0.ptrs[2] = &snp2;
270 snp1.ptrs[0] = &snp0;
271 snp1.ptrs[1] = &snp1;
272 snp1.ptrs[2] = &snp2;
276 snp2.ptrs[0] = &snp0;
277 snp2.ptrs[1] = &snp1;
278 snp2.ptrs[2] = &snp2;
290 do_special_tests (void)
298 struct _simple_struct s;
305 enum { A, B, C } anone;
313 struct very_simple_struct
320 do_child_deletion (void)
322 /*: BEGIN: child_deletion :*/
323 struct very_simple_struct s = {1, 2};
325 mi_create_varobj S s "create varobj for s"
326 mi_list_varobj_children S {{S.a a 0 int} {S.b b 0 int}} \
328 mi_delete_varobj S.a "delete S.a"
329 mi_delete_varobj S.b "delete S.b"
330 mi_delete_varobj S "delete S"
333 /*: END: child_deletion :*/
337 main (int argc, char *argv [])
341 do_children_tests ();
343 do_child_deletion ();