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/>. */
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 nothing1 (int a
, char *b
, long c
)
166 struct _struct_decl foo
;
171 struct _struct_decl
*
172 nothing2 (int a
, char *b
, long c
)
174 return (struct _struct_decl
*) 0;
178 subroutine1 (int i
, long *l
)
180 global_simple
.integer
= i
+ 3;
209 do_children_tests (void)
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
;
223 /* Avoid pointing into NULL, as that is editable on some
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";
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 */
280 snp0
.ptrs
[0] = &snp0
;
281 snp0
.ptrs
[1] = &snp1
;
282 snp0
.ptrs
[2] = &snp2
;
286 snp1
.ptrs
[0] = &snp0
;
287 snp1
.ptrs
[1] = &snp1
;
288 snp1
.ptrs
[2] = &snp2
;
292 snp2
.ptrs
[0] = &snp0
;
293 snp2
.ptrs
[1] = &snp1
;
294 snp2
.ptrs
[2] = &snp2
;
306 do_special_tests (void)
314 struct _simple_struct s
;
321 enum { A
, B
, C
} anone
;
329 struct very_simple_struct
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}} \
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"
349 /*: END: child_deletion :*/
353 main (int argc
, char *argv
[])
357 do_children_tests ();
359 do_child_deletion ();