1 /* Copyright 1999, 2004, 2005, 2007, 2008, 2009, 2010
2 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 struct _simple_struct
{
24 unsigned int unsigned_integer
;
26 signed char signed_character
;
31 typedef struct _simple_struct simpleton
;
33 simpleton global_simple
;
40 typedef enum foo efoo
;
48 typedef struct _struct_decl
{
56 void (*func_ptr
) (void);
57 struct _struct_decl (*func_ptr_struct
) (int, char *, long);
58 struct _struct_decl
*(*func_ptr_ptr
) (int, char *, long);
78 int (*func
) (int, char *);
88 struct _struct_n_pointer
{
91 struct _struct_n_pointer
*ptrs
[3];
92 struct _struct_n_pointer
*next
;
95 void do_locals_tests (void);
96 void do_block_tests (void);
97 void subroutine1 (int, long *);
99 void do_children_tests (void);
100 void do_special_tests (void);
122 struct _simple_struct lsimple
;
123 struct _simple_struct
*lpsimple
;
126 /* Simple assignments */
128 lpinteger
= &linteger
;
130 lpcharacter
= &lcharacter
;
135 ldouble
= 2.718281828459045;
137 lsimple
.integer
= 1234;
138 lsimple
.unsigned_integer
= 255;
139 lsimple
.character
= 'a';
140 lsimple
.signed_character
= 21;
141 lsimple
.char_ptr
= &lcharacter
;
150 ldouble
= 5.498548281828172;
151 lsimple
.integer
= 255;
152 lsimple
.unsigned_integer
= 4321;
153 lsimple
.character
= 'b';
154 lsimple
.signed_character
= 0;
156 subroutine1 (linteger
, &llong
);
165 subroutine1 (int i
, long *l
)
167 global_simple
.integer
= i
+ 3;
196 do_children_tests (void)
199 struct _struct_n_pointer
*psnp
;
200 struct _struct_n_pointer snp0
, snp1
, snp2
;
201 char a0
[2] = {}, *a1
, **a2
, ***a3
;
202 char b0
[2] = {}, *b1
, **b2
, ***b3
;
203 char c0
[2] = {}, *c1
, **c2
, ***c3
;
204 long z0
, *z1
, **z2
, ***z3
;
205 long y0
, *y1
, **y2
, ***y3
;
206 long x0
, *x1
, **x2
, ***x3
;
210 /* Avoid pointing into NULL, as that is editable on some
213 int *dummy_ptr
= &dummy
;
215 struct _struct_decl struct_declarations
= { 0, 0, NULL
, 0, &dummy_ptr
};
216 weird
= &struct_declarations
;
218 struct_declarations
.integer
= 123;
219 weird
->char_ptr
= "hello";
222 struct_declarations
.int_ptr_ptr
= &foo
;
223 weird
->long_array
[0] = 1234;
224 struct_declarations
.long_array
[1] = 2345;
225 weird
->long_array
[2] = 3456;
226 struct_declarations
.long_array
[3] = 4567;
227 weird
->long_array
[4] = 5678;
228 struct_declarations
.long_array
[5] = 6789;
229 weird
->long_array
[6] = 7890;
230 struct_declarations
.long_array
[7] = 8901;
231 weird
->long_array
[8] = 9012;
232 struct_declarations
.long_array
[9] = 1234;
234 weird
->func_ptr
= nothing
;
235 struct_declarations
.long_array
[10] = 3456;
236 struct_declarations
.long_array
[11] = 5678;
238 /* Struct/pointer/array tests */
265 snp0
.ptrs
[0] = &snp0
;
266 snp0
.ptrs
[1] = &snp1
;
267 snp0
.ptrs
[2] = &snp2
;
271 snp1
.ptrs
[0] = &snp0
;
272 snp1
.ptrs
[1] = &snp1
;
273 snp1
.ptrs
[2] = &snp2
;
277 snp2
.ptrs
[0] = &snp0
;
278 snp2
.ptrs
[1] = &snp1
;
279 snp2
.ptrs
[2] = &snp2
;
291 do_special_tests (void)
299 struct _simple_struct s
;
306 enum { A
, B
, C
} anone
;
314 struct very_simple_struct
321 do_child_deletion (void)
323 /*: BEGIN: child_deletion :*/
324 struct very_simple_struct s
= {1, 2};
326 mi_create_varobj S s "create varobj for s"
327 mi_list_varobj_children S {{S.a a 0 int} {S.b b 0 int}} \
329 mi_delete_varobj S.a "delete S.a"
330 mi_delete_varobj S.b "delete S.b"
331 mi_delete_varobj S "delete S"
334 /*: END: child_deletion :*/
338 main (int argc
, char *argv
[])
342 do_children_tests ();
344 do_child_deletion ();