1 /* Copyright 1999, 2004, 2007 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/>. */
20 struct _simple_struct
{
22 unsigned int unsigned_integer
;
24 signed char signed_character
;
29 typedef struct _simple_struct simpleton
;
31 simpleton global_simple
;
38 typedef enum foo efoo
;
46 typedef struct _struct_decl
{
54 void (*func_ptr
) (void);
55 struct _struct_decl (*func_ptr_struct
) (int, char *, long);
56 struct _struct_decl
*(*func_ptr_ptr
) (int, char *, long);
76 int (*func
) (int, char *);
86 struct _struct_n_pointer
{
89 struct _struct_n_pointer
*ptrs
[3];
90 struct _struct_n_pointer
*next
;
93 void do_locals_tests (void);
94 void do_block_tests (void);
95 void subroutine1 (int, long *);
97 void do_children_tests (void);
98 void do_special_tests (void);
107 int array
[] = {1,2,3};
108 int array2
[] = {4,5,6};
109 int *array_ptr
= array
;
117 char *lpcharacter
= 0;
123 double *lpdouble
= 0;
124 struct _simple_struct lsimple
;
125 struct _simple_struct
*lpsimple
;
128 /* Simple assignments */
130 lpinteger
= &linteger
;
132 lpcharacter
= &lcharacter
;
137 ldouble
= 2.718281828459045;
139 lsimple
.integer
= 1234;
140 lsimple
.unsigned_integer
= 255;
141 lsimple
.character
= 'a';
142 lsimple
.signed_character
= 21;
143 lsimple
.char_ptr
= &lcharacter
;
152 ldouble
= 5.498548281828172;
153 lsimple
.integer
= 255;
154 lsimple
.unsigned_integer
= 4321;
155 lsimple
.character
= 'b';
156 lsimple
.signed_character
= 0;
158 subroutine1 (linteger
, &llong
);
167 subroutine1 (int i
, long *l
)
169 global_simple
.integer
= i
+ 3;
198 do_children_tests (void)
201 struct _struct_n_pointer
*psnp
;
202 struct _struct_n_pointer snp0
, snp1
, snp2
;
203 char a0
[2] = {}, *a1
, **a2
, ***a3
;
204 char b0
[2] = {}, *b1
, **b2
, ***b3
;
205 char c0
[2] = {}, *c1
, **c2
, ***c3
;
206 long z0
, *z1
, **z2
, ***z3
;
207 long y0
, *y1
, **y2
, ***y3
;
208 long x0
, *x1
, **x2
, ***x3
;
212 struct _struct_decl struct_declarations
;
213 weird
= &struct_declarations
;
215 struct_declarations
.integer
= 123;
216 weird
->char_ptr
= "hello";
219 struct_declarations
.int_ptr_ptr
= &foo
;
220 weird
->long_array
[0] = 1234;
221 struct_declarations
.long_array
[1] = 2345;
222 weird
->long_array
[2] = 3456;
223 struct_declarations
.long_array
[3] = 4567;
224 weird
->long_array
[4] = 5678;
225 struct_declarations
.long_array
[5] = 6789;
226 weird
->long_array
[6] = 7890;
227 struct_declarations
.long_array
[7] = 8901;
228 weird
->long_array
[8] = 9012;
229 struct_declarations
.long_array
[9] = 1234;
231 weird
->func_ptr
= nothing
;
233 /* Struct/pointer/array tests */
260 snp0
.ptrs
[0] = &snp0
;
261 snp0
.ptrs
[1] = &snp1
;
262 snp0
.ptrs
[2] = &snp2
;
266 snp1
.ptrs
[0] = &snp0
;
267 snp1
.ptrs
[1] = &snp1
;
268 snp1
.ptrs
[2] = &snp2
;
272 snp2
.ptrs
[0] = &snp0
;
273 snp2
.ptrs
[1] = &snp1
;
274 snp2
.ptrs
[2] = &snp2
;
287 do_special_tests (void)
295 struct _simple_struct s
;
302 enum { A
, B
, C
} anone
;
316 void do_frozen_tests ()
318 /*: BEGIN: frozen :*/
329 mi_create_varobj V1 v1 "create varobj for v1"
330 mi_create_varobj V2 v2 "create varobj for v2"
332 mi_list_varobj_children "V1" {
333 {"V1.i" "i" "0" "int"}
334 {"V1.nested" "nested" "2" "struct {...}"}
335 } "list children of v1"
337 mi_list_varobj_children "V1.nested" {
338 {"V1.nested.j" "j" "0" "int"}
339 {"V1.nested.k" "k" "0" "int"}
340 } "list children of v1.nested"
342 mi_check_varobj_value V1.i 1 "check V1.i: 1"
343 mi_check_varobj_value V1.nested.j 2 "check V1.nested.j: 2"
344 mi_check_varobj_value V1.nested.k 3 "check V1.nested.k: 3"
345 mi_check_varobj_value V2 4 "check V2: 4"
349 mi_varobj_update * {V2} "update varobjs: V2 changed"
354 mi_varobj_update * {} "update varobjs: nothing changed"
355 mi_check_varobj_value V2 5 "check V2: 5"
356 mi_varobj_update V2 {V2} "update V2 explicitly"
357 mi_check_varobj_value V2 6 "check V2: 6"
364 mi_varobj_update * {} "update varobjs: nothing changed"
365 mi_check_varobj_value V1.i 1 "check V1.i: 1"
366 mi_check_varobj_value V1.nested.j 2 "check V1.nested.j: 2"
367 mi_check_varobj_value V1.nested.k 3 "check V1.nested.k: 3"
368 # Check that explicit update for elements of structures
371 mi_varobj_update V1.nested.j {V1.nested.j} "update V1.nested.j"
372 mi_check_varobj_value V1.i 1 "check V1.i: 1"
373 mi_check_varobj_value V1.nested.j 8 "check V1.nested.j: 8"
374 mi_check_varobj_value V1.nested.k 3 "check V1.nested.k: 3"
375 # Update v1.nested, check that children is updated.
376 mi_varobj_update V1.nested {V1.nested.k} "update V1.nested"
377 mi_check_varobj_value V1.i 1 "check V1.i: 1"
378 mi_check_varobj_value V1.nested.j 8 "check V1.nested.j: 8"
379 mi_check_varobj_value V1.nested.k 9 "check V1.nested.k: 9"
381 mi_varobj_update V1.i {V1.i} "update V1.i"
382 mi_check_varobj_value V1.i 7 "check V1.i: 7"
388 # Check that unfreeze itself does not updates the values.
390 mi_check_varobj_value V1.i 7 "check V1.i: 7"
391 mi_check_varobj_value V1.nested.j 8 "check V1.nested.j: 8"
392 mi_check_varobj_value V1.nested.k 9 "check V1.nested.k: 9"
393 mi_varobj_update V1 {V1.i V1.nested.j V1.nested.k} "update V1"
394 mi_check_varobj_value V1.i 10 "check V1.i: 10"
395 mi_check_varobj_value V1.nested.j 11 "check V1.nested.j: 11"
396 mi_check_varobj_value V1.nested.k 12 "check V1.nested.k: 12"
403 main (int argc
, char *argv
[])
407 do_children_tests ();