]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi2-var-child.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi2-var-child.exp
CommitLineData
8acc9f48 1# Copyright 1999-2013 Free Software Foundation, Inc.
2fcf52f0 2
e22f8b7c 3# This program is free software; you can redistribute it and/or modify
2fcf52f0 4# it under the terms of the GNU General Public License as published by
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
2fcf52f0
AC
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
2fcf52f0 15
2fcf52f0
AC
16# Test essential Machine interface (MI) operations
17#
18# Verify that, using the MI, we can create, update, delete variables.
19#
20
21
22load_lib mi-support.exp
23set MIFLAGS "-i=mi2"
24
25gdb_exit
26if [mi_gdb_start] {
27 continue
28}
29
298a9cf0
TT
30standard_testfile var-cmd.c
31
9357e021 32if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
33 untested mi2-var-child.exp
34 return -1
2fcf52f0
AC
35}
36
37mi_delete_breakpoints
38mi_gdb_reinitialize_dir $srcdir/$subdir
39mi_gdb_load ${binfile}
40
41mi_runto do_children_tests
42
a73bafbc
VP
43set line_dlt_first_real [gdb_get_line_number "weird = &struct_declarations;"]
44mi_continue_to_line $line_dlt_first_real "step to real start of do_children_test"
45
2fcf52f0
AC
46##### #####
47# #
48# children tests #
49# #
50##### #####
51
52
53# Test: c_variable-4.2
54# Desc: create variable "struct_declarations"
9e8e3afe 55mi_create_varobj "struct_declarations" "struct_declarations" \
3fddb3ad 56 "create local variable struct_declarations"
2fcf52f0
AC
57
58# Test: c_variable-4.3
59# Desc: children of struct_declarations
60# STABS doesn't give us argument types for the func ptr structs, but
61# Dwarf 2 does.
9e8e3afe
VP
62mi_list_varobj_children "struct_declarations" {
63 {struct_declarations.integer integer 0 int}
64 {struct_declarations.character character 0 char}
65 {struct_declarations.char_ptr char_ptr 1 "char \\*"}
bd69fc68 66 {struct_declarations.long_int long_int 0 "long"}
9e8e3afe 67 {struct_declarations.int_ptr_ptr int_ptr_ptr 1 "int \\*\\*"}
bd69fc68 68 {struct_declarations.long_array long_array 10 "long \\[10\\]"}
9e8e3afe
VP
69 {struct_declarations.func_ptr func_ptr 0 "void \\(\\*\\)\\((void)?\\)"}
70 {struct_declarations.func_ptr_struct func_ptr_struct 0 \
bd69fc68 71 "struct _struct_decl \\(\\*\\)(\\(int, char \\*, long\\))?"}
9e8e3afe 72 {struct_declarations.func_ptr_ptr func_ptr_ptr 0 \
bd69fc68 73 "struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long)?\\)"}
9e8e3afe
VP
74 {struct_declarations.u1 u1 4 "union \\{\\.\\.\\.\\}"}
75 {struct_declarations.s2 s2 4 "struct \\{\\.\\.\\.\\}"}
76} "get children of struct_declarations"
77
2fcf52f0
AC
78
79#gdbtk_test c_variable-4.3 {children of struct_declarations} {
80# get_children struct_declarations
81#} {integer character char_ptr long_int int_ptr_ptr long_array func_ptr func_ptr_struct func_ptr_ptr u1 s2}
82
83# Test: c_variable-4.4
84# Desc: number of children of struct_declarations
85mi_gdb_test "-var-info-num-children struct_declarations" \
86 "\\^done,numchild=\"11\"" \
87 "get number of children of struct_declarations"
88
89# Test: c_variable-4.5
90# Desc: children of struct_declarations.integer
9e8e3afe
VP
91mi_list_varobj_children "struct_declarations.integer" {} \
92 "get children of struct_declarations.integer"
2fcf52f0
AC
93
94# Test: c_variable-4.6
95# Desc: number of children of struct_declarations.integer
96mi_gdb_test "-var-info-num-children struct_declarations.integer" \
97 "\\^done,numchild=\"0\"" \
98 "get number of children of struct_declarations.integer"
99
100# Test: c_variable-4.7
101# Desc: children of struct_declarations.character
9e8e3afe 102mi_list_varobj_children "struct_declarations.character" {} \
2fcf52f0
AC
103 "get children of struct_declarations.character"
104
105# Test: c_variable-4.8
106# Desc: number of children of struct_declarations.character
107mi_gdb_test "-var-info-num-children struct_declarations.character" \
108 "\\^done,numchild=\"0\"" \
109 "get number of children of struct_declarations.character"
110
111# Test: c_variable-4.9
112# Desc: children of struct_declarations.char_ptr
9e8e3afe
VP
113mi_list_varobj_children "struct_declarations.char_ptr" {
114 {{struct_declarations.char_ptr.\*char_ptr} {\*char_ptr} 0 char}
115} "get children of struct_declarations.char_ptr"
2fcf52f0
AC
116
117# Test: c_variable-4.10
118# Desc: number of children of struct_declarations.char_ptr
119mi_gdb_test "-var-info-num-children struct_declarations.char_ptr" \
120 "\\^done,numchild=\"1\"" \
121 "get number of children of struct_declarations.char_ptr"
122
123# Test: c_variable-4.11
124# Desc: children of struct_declarations.long_int
9e8e3afe 125mi_list_varobj_children "struct_declarations.long_int" {} \
2fcf52f0
AC
126 "get children of struct_declarations.long_int"
127
128# Test: c_variable-4.12
129# Desc: number of children of struct_declarations.long_int
130mi_gdb_test "-var-info-num-children struct_declarations.long_int" \
131 "\\^done,numchild=\"0\"" \
132 "get number of children of struct_declarations.long_int"
133
134# Test: c_variable-4.13
135# Desc: children of int_ptr_ptr
9e8e3afe
VP
136mi_list_varobj_children "struct_declarations.int_ptr_ptr" {
137 {{struct_declarations.int_ptr_ptr.\*int_ptr_ptr} {\*int_ptr_ptr} 1 {int \*}}
138} "get children of struct_declarations.int_ptr_ptr"
2fcf52f0
AC
139
140#gdbtk_test c_variable-4.13 {children of int_ptr_ptr} {
141# get_children struct_declarations.int_ptr_ptr
142#} {*int_ptr_ptr}
143
144# Test: c_variable-4.14
145# Desc: number of children of int_ptr_ptr
146mi_gdb_test "-var-info-num-children struct_declarations.int_ptr_ptr" \
147 "\\^done,numchild=\"1\"" \
148 "get number of children of struct_declarations.int_ptr_ptr"
149
150
151# Test: c_variable-4.15
152# Desc: children of struct_declarations.long_array
bd69fc68 153mi_list_array_varobj_children "struct_declarations.long_array" 10 "long" \
9e8e3afe 154 "get children of struct_declarations.long_array"
2fcf52f0
AC
155
156# Test: c_variable-4.16
157# Desc: number of children of struct_declarations.long_array
158mi_gdb_test "-var-info-num-children struct_declarations.long_array" \
159 "\\^done,numchild=\"10\"" \
160 "get number of children of struct_declarations.long_array"
161
162# Test: c_variable-4.17
163# Desc: children of struct_declarations.func_ptr
9e8e3afe 164mi_list_varobj_children "struct_declarations.func_ptr" {} \
2fcf52f0
AC
165 "get children of struct_declarations.func_ptr"
166
2fcf52f0
AC
167# Test: c_variable-4.18
168# Desc: number of children of struct_declarations.func_ptr
169mi_gdb_test "-var-info-num-children struct_declarations.func_ptr" \
170 "\\^done,numchild=\"0\"" \
171 "get number of children of struct_declarations.func_ptr"
172
173
174# Test: c_variable-4.19
175# Desc: children of struct_declarations.func_ptr_struct
9e8e3afe 176mi_list_varobj_children "struct_declarations.func_ptr_struct" {} \
2fcf52f0
AC
177 "get children of struct_declarations.func_ptr_struct"
178
179# Test: c_variable-4.20
180# Desc: number of children of struct_declarations.func_ptr_struct
181mi_gdb_test "-var-info-num-children struct_declarations.func_ptr_struct" \
182 "\\^done,numchild=\"0\"" \
183 "get number of children of struct_declarations.func_ptr_struct"
184
185
186# Test: c_variable-4.21
187# Desc: children of struct_declarations.func_ptr_ptr
9e8e3afe 188mi_list_varobj_children "struct_declarations.func_ptr_ptr" {} \
2fcf52f0
AC
189 "get children of struct_declarations.func_ptr_ptr"
190
191# Test: c_variable-4.22
192# Desc: number of children of struct_declarations.func_ptr_ptr
193mi_gdb_test "-var-info-num-children struct_declarations.func_ptr_ptr" \
9e8e3afe
VP
194 "\\^done,numchild=\"0\"" \
195 "get number of children of struct_declarations.func_ptr_ptr"
2fcf52f0
AC
196
197# Test: c_variable-4.23
198# Desc: children of struct_declarations.u1
9e8e3afe
VP
199mi_list_varobj_children "struct_declarations.u1" {
200 {struct_declarations.u1.a a 0 int}
201 {struct_declarations.u1.b b 1 {char \*}}
bd69fc68 202 {struct_declarations.u1.c c 0 {long}}
9e8e3afe
VP
203 {struct_declarations.u1.d d 0 {enum foo}}
204} "get children of struct_declarations.u1"
2fcf52f0
AC
205
206# Test: c_variable-4.24
207# Desc: number of children of struct_declarations.u1
208mi_gdb_test "-var-info-num-children struct_declarations.u1" \
209 "\\^done,numchild=\"4\"" \
210 "get number of children of struct_declarations.u1"
211
212# Test: c_variable-4.25
213# Desc: children of struct_declarations.s2
9e8e3afe
VP
214mi_list_varobj_children "struct_declarations.s2" {
215 {struct_declarations.s2.u2 u2 3 {union \{\.\.\.\}}}
216 {struct_declarations.s2.g g 0 int}
217 {struct_declarations.s2.h h 0 char}
bd69fc68 218 {struct_declarations.s2.i i 10 {long \[10\]}}
9e8e3afe
VP
219} "get children of struct_declarations.s2"
220
2fcf52f0
AC
221#gdbtk_test c_variable-4.25 {children of struct_declarations.s2} {
222# get_children struct_declarations.s2
223#} {u2 g h i}
224
225# Test: c_variable-4.26
226# Desc: number of children of struct_declarations.s2
227mi_gdb_test "-var-info-num-children struct_declarations.s2" \
228 "\\^done,numchild=\"4\"" \
229 "get number of children of struct_declarations.s2"
230
231
9e8e3afe
VP
232for {set i 1} {$i <= 9} {incr i} {
233 mi_list_varobj_children "struct_declarations.long_array.$i" {} \
234 "get children of struct_declarations.long_array.$i"
2fcf52f0 235
9e8e3afe 236 mi_gdb_test "-var-info-num-children struct_declarations.long_array.$i" \
2fcf52f0 237 "\\^done,numchild=\"0\"" \
9e8e3afe
VP
238 "get number of children of struct_declarations.long_array.$i"
239}
2fcf52f0
AC
240
241# Test: c_variable-4.45
242# Desc: children of struct_declarations.u1.a
9e8e3afe 243mi_list_varobj_children "struct_declarations.u1.a" {} \
2fcf52f0
AC
244 "get children of struct_declarations.u1.a"
245
246# Test: c_variable-4.46
247# Desc: number of children of struct_declarations.u1.a
248mi_gdb_test "-var-info-num-children struct_declarations.u1.a" \
249 "\\^done,numchild=\"0\"" \
250 "get number of children of struct_declarations.u1.a"
251
252# Test: c_variable-4.47
253# Desc: children of struct_declarations.u1.b
9e8e3afe
VP
254mi_list_varobj_children "struct_declarations.u1.b" {
255 {{struct_declarations.u1.b.\*b} {\*b} 0 char}
256} "get children of struct_declarations.u1.b"
2fcf52f0
AC
257
258# Test: c_variable-4.48
259# Desc: number of children of struct_declarations.u1.b
260mi_gdb_test "-var-info-num-children struct_declarations.u1.b" \
261 "\\^done,numchild=\"1\"" \
262 "get number of children of struct_declarations.u1.b"
263
264# Test: c_variable-4.49
265# Desc: children of struct_declarations.u1.c
9e8e3afe 266mi_list_varobj_children "struct_declarations.u1.c" {} \
2fcf52f0
AC
267 "get children of struct_declarations.u1.c"
268
269# Test: c_variable-4.50
270# Desc: number of children of struct_declarations.u1.c
271mi_gdb_test "-var-info-num-children struct_declarations.u1.c" \
272 "\\^done,numchild=\"0\"" \
273 "get number of children of struct_declarations.u1.c"
274
275# Test: c_variable-4.51
276# Desc: children of struct_declarations.u1.d
9e8e3afe 277mi_list_varobj_children "struct_declarations.u1.d" {} \
2fcf52f0
AC
278 "get children of struct_declarations.u1.d"
279
280
281# Test: c_variable-4.52
282# Desc: number of children of struct_declarations.u1.d
283mi_gdb_test "-var-info-num-children struct_declarations.u1.d" \
284 "\\^done,numchild=\"0\"" \
285 "get number of children of struct_declarations.u1.d"
286
287
288# Test: c_variable-4.53
289# Desc: children of struct_declarations.s2.u2
9e8e3afe
VP
290mi_list_varobj_children "struct_declarations.s2.u2" {
291 {"struct_declarations.s2.u2.u1s1" "u1s1" 4 {struct \{\.\.\.\}}}
bd69fc68 292 {struct_declarations.s2.u2.f f 0 "long"}
9e8e3afe
VP
293 {struct_declarations.s2.u2.u1s2 u1s2 2 {struct \{\.\.\.\}}}
294} "get children of struct_declarations.s2.u2"
2fcf52f0
AC
295
296# Test: c_variable-4.54
297# Desc: number of children of struct_declarations.s2.u2
298mi_gdb_test "-var-info-num-children struct_declarations.s2.u2" \
299 "\\^done,numchild=\"3\"" \
300 "get number of children of struct_declarations.s2.u2"
301
302# Test: c_variable-4.55
303# Desc: children of struct_declarations.s2.g
9e8e3afe 304mi_list_varobj_children struct_declarations.s2.g {} \
2fcf52f0
AC
305 "get children of struct_declarations.s2.g"
306
307# Test: c_variable-4.56
308# Desc: number of children of struct_declarations.s2.g
309mi_gdb_test "-var-info-num-children struct_declarations.s2.g" \
310 "\\^done,numchild=\"0\"" \
311 "get number of children of struct_declarations.s2.g"
312
313
314# Test: c_variable-4.57
315# Desc: children of struct_declarations.s2.h
9e8e3afe 316mi_list_varobj_children struct_declarations.s2.h {} \
2fcf52f0
AC
317 "get children of struct_declarations.s2.h"
318
319# Test: c_variable-4.58
320# Desc: number of children of struct_declarations.s2.h
321mi_gdb_test "-var-info-num-children struct_declarations.s2.h" \
322 "\\^done,numchild=\"0\"" \
323 "get number of children of struct_declarations.s2.h"
324
325
326# Test: c_variable-4.59
327# Desc: children of struct_declarations.s2.i
9e8e3afe
VP
328set t {}
329for {set i 0} {$i < 10} {incr i} {
bd69fc68 330 lappend t [list struct_declarations.s2.i.$i $i 0 "long"]
9e8e3afe
VP
331}
332mi_list_varobj_children struct_declarations.s2.i $t \
2fcf52f0
AC
333 "get children of struct_declarations.s2.i"
334
335# Test: c_variable-4.60
336# Desc: number of children of struct_declarations.s2.i
337mi_gdb_test "-var-info-num-children struct_declarations.s2.i" \
338 "\\^done,numchild=\"10\"" \
339 "get number of children of struct_declarations.s2.i"
340
341# Test: c_variable-4.61
342# Desc: children of struct_declarations.s2.u2.u1s1
9e8e3afe
VP
343mi_list_varobj_children struct_declarations.s2.u2.u1s1 {
344 {struct_declarations.s2.u2.u1s1.d d 0 int}
345 {struct_declarations.s2.u2.u1s1.e e 10 {char \[10\]}}
346 {struct_declarations.s2.u2.u1s1.func func 0 {int \*\(\*\)\((void)?\)}}
347 {struct_declarations.s2.u2.u1s1.foo foo 0 efoo}
348} "get children of struct_declarations.s2.u2.u1s1"
2fcf52f0
AC
349
350# Test: c_variable-4.62
351# Desc: number of children of struct_declarations.s2.u2.u1s1
352mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1" \
353 "\\^done,numchild=\"4\"" \
354 "get number of children of struct_declarations.s2.u2.u1s1"
355
356# Test: c_variable-4.63
357# Desc: children of struct_declarations.s2.u2.f
9e8e3afe 358mi_list_varobj_children struct_declarations.s2.u2.f {} \
2fcf52f0
AC
359 "get children of struct_declarations.s2.u2.f"
360
361# Test: c_variable-4.64
362# Desc: number of children of struct_declarations.s2.u2.f
363mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.f" \
364 "\\^done,numchild=\"0\"" \
365 "get number of children of struct_declarations.s2.u2.f"
366
367# Test: c_variable-4.65
368# Desc: children of struct_declarations.s2.u2.u1s2
9e8e3afe
VP
369mi_list_varobj_children struct_declarations.s2.u2.u1s2 {
370 {struct_declarations.s2.u2.u1s2.array_ptr array_ptr 2 {char \[2\]}}
371 {struct_declarations.s2.u2.u1s2.func func 0 {int \(\*\)\((int, char \*)?\)}}
372} "get children of struct_declarations.s2.u2.u1s2"
2fcf52f0
AC
373
374# Test: c_variable-4.66
375# Desc: number of children of struct_declarations.s2.u2.u1s2
376mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s2" \
377 "\\^done,numchild=\"2\"" \
378 "get number of children of struct_declarations.s2.u2.u1s2"
379
380# Test: c_variable-4.67
381# Desc: children of struct_declarations.s2.u2.u1s1.d
9e8e3afe 382mi_list_varobj_children struct_declarations.s2.u2.u1s1.d {} \
2fcf52f0
AC
383 "get children of struct_declarations.s2.u2.u1s1.d"
384
385# Test: c_variable-4.68
386# Desc: number of children of struct_declarations.s2.u2.u1s1.d
387mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.d" \
388 "\\^done,numchild=\"0\"" \
389 "get number of children of struct_declarations.s2.u2.u1s1.d"
390
391# Test: c_variable-4.69
392# Desc: children of struct_declarations.s2.u2.u1s1.e
9e8e3afe
VP
393set t {}
394for {set i 0} {$i < 10} {incr i} {
395 lappend t [list struct_declarations.s2.u2.u1s1.e.$i $i 0 char]
396}
397mi_list_varobj_children struct_declarations.s2.u2.u1s1.e $t \
2fcf52f0
AC
398 "get children of struct_declarations.s2.u2.u1s1.e"
399
400# Test: c_variable-4.70
401# Desc: number of children of struct_declarations.s2.u2.u1s1.e
402mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.e" \
403 "\\^done,numchild=\"10\"" \
404 "get number of children of struct_declarations.s2.u2.u1s1.e"
405
406
407# Test: c_variable-4.71
408# Desc: children of struct_declarations.s2.u2.u1s1.func
9e8e3afe 409mi_list_varobj_children struct_declarations.s2.u2.u1s1.func {} \
2fcf52f0
AC
410 "get children of struct_declarations.s2.u2.u1s1.func"
411
412# Test: c_variable-4.72
413# Desc: number of children of struct_declarations.s2.u2.u1s1.func
414mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.func" \
415 "\\^done,numchild=\"0\"" \
416 "get number of children of struct_declarations.s2.u2.u1s1.func"
417
418
419# Test: c_variable-4.73
420# Desc: children of struct_declarations.s2.u2.u1s1.foo
9e8e3afe 421mi_list_varobj_children struct_declarations.s2.u2.u1s1.foo {} \
2fcf52f0
AC
422 "get children of struct_declarations.s2.u2.u1s1.foo"
423
424# Test: c_variable-4.74
425# Desc: number of children of struct_declarations.s2.u2.u1s1.foo
426mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.foo" \
427 "\\^done,numchild=\"0\"" \
428 "get number of children of struct_declarations.s2.u2.u1s1.foo"
429
430
431# Test: c_variable-4.75
432# Desc: children of struct_declarations.s2.u2.u1s2.array_ptr
9e8e3afe
VP
433mi_list_varobj_children struct_declarations.s2.u2.u1s2.array_ptr {
434 {struct_declarations.s2.u2.u1s2.array_ptr.0 0 0 char}
435 {struct_declarations.s2.u2.u1s2.array_ptr.1 1 0 char}
436} "get children of struct_declarations.s2.u2.u1s2.array_ptr"
2fcf52f0
AC
437
438# Test: c_variable-4.76
439# Desc: number of children of struct_declarations.s2.u2.u1s2.array_ptr
440mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s2.array_ptr" \
441 "\\^done,numchild=\"2\"" \
442 "get number of children of struct_declarations.s2.u2.u1s2.array_ptr"
443
444# Test: c_variable-4.77
445# Desc: children of struct_declarations.s2.u2.u1s2.func
9e8e3afe 446mi_list_varobj_children struct_declarations.s2.u2.u1s2.func {} \
2fcf52f0
AC
447 "get children of struct_declarations.s2.u2.u1s2.func"
448
449# Test: c_variable-4.78
450# Desc: number of children of struct_declarations.s2.u2.u1s2.func
451mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s2.func" \
452 "\\^done,numchild=\"0\"" \
453 "get number of children of struct_declarations.s2.u2.u1s2.func"
454
455# Test: c_variable-4.79
456# Desc: children of struct_declarations.int_ptr_ptr.*int_ptr_ptr
9e8e3afe
VP
457mi_list_varobj_children "struct_declarations.int_ptr_ptr.*int_ptr_ptr" {
458 {{struct_declarations.int_ptr_ptr.\*int_ptr_ptr.\*\*int_ptr_ptr} \
459 {\*\*int_ptr_ptr} 0 int}
460} "get children of struct_declarations.int_ptr_ptr.*int_ptr_ptr"
2fcf52f0
AC
461
462# Test: c_variable-4.80
463# Desc: Number of children of struct_declarations.int_ptr_ptr.*int_ptr_ptr
464mi_gdb_test "-var-info-num-children struct_declarations.int_ptr_ptr.*int_ptr_ptr" \
465 "\\^done,numchild=\"1\"" \
466 "get number of children of struct_declarations.int_ptr_ptr.*int_ptr_ptr"
467
468
469# Step to "struct_declarations.integer = 123;"
469aff8e
MC
470set line_dct_123 [gdb_get_line_number "struct_declarations.integer = 123;"]
471mi_step_to do_children_tests {} {.*var-cmd.c} \
472 $line_dct_123 "step to line \$line_dct_123"
2fcf52f0
AC
473
474# Test: c_variable-4.81
475# Desc: create local variable "weird"
9e8e3afe 476mi_create_varobj weird weird "create local variable weird"
2fcf52f0
AC
477
478# Test: c_variable-4.82
479# Desc: children of weird
9e8e3afe
VP
480mi_list_varobj_children "weird" {
481 {weird.integer integer 0 int}
482 {weird.character character 0 char}
483 {weird.char_ptr char_ptr 1 "char \\*"}
bd69fc68 484 {weird.long_int long_int 0 "long"}
9e8e3afe 485 {weird.int_ptr_ptr int_ptr_ptr 1 "int \\*\\*"}
bd69fc68 486 {weird.long_array long_array 10 "long \\[10\\]"}
9e8e3afe
VP
487 {weird.func_ptr func_ptr 0 "void \\(\\*\\)\\((void)?\\)"}
488 {weird.func_ptr_struct func_ptr_struct 0 \
bd69fc68 489 "struct _struct_decl \\(\\*\\)(\\(int, char \\*, long\\))?"}
9e8e3afe 490 {weird.func_ptr_ptr func_ptr_ptr 0 \
bd69fc68 491 "struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long)?\\)"}
9e8e3afe
VP
492 {weird.u1 u1 4 "union \\{\\.\\.\\.\\}"}
493 {weird.s2 s2 4 "struct \\{\\.\\.\\.\\}"}
494} "get children of weird"
2fcf52f0
AC
495
496# Test: c_variable-4.83
497# Desc: number of children of weird
498mi_gdb_test "-var-info-num-children weird" \
499 "\\^done,numchild=\"11\"" \
500 "get number of children of weird"
501
502
503# Test: c_variable-4.84
504# Desc: children of weird->long_array
bd69fc68 505mi_list_array_varobj_children weird.long_array 10 "long" \
2fcf52f0
AC
506 "get children of weird.long_array"
507#gdbtk_test c_variable-4.84 {children of weird->long_array} {
508# get_children weird.long_array
509#} {0 1 2 3 4 5 6 7 8 9}
510
511# Test: c_variable-4.85
512# Desc: number of children of weird.long_array
513mi_gdb_test "-var-info-num-children weird.long_array" \
514 "\\^done,numchild=\"10\"" \
515 "get number of children of weird.long_array"
516
517# Test: c_variable-4.86
518# Desc: children of weird.int_ptr_ptr
9e8e3afe
VP
519mi_list_varobj_children weird.int_ptr_ptr {
520 {{weird.int_ptr_ptr.\*int_ptr_ptr} {\*int_ptr_ptr} 1 {int \*}}
521} "get children of weird.int_ptr_ptr"
2fcf52f0
AC
522#gdbtk_test c_variable-4.86 {children of weird->int_ptr_ptr} {
523# get_children weird.int_ptr_ptr
524#} {*int_ptr_ptr}
525
526# Test: c_variable-4.87
527# Desc: number of children of weird.int_ptr_ptr
528mi_gdb_test "-var-info-num-children weird.int_ptr_ptr" \
529 "\\^done,numchild=\"1\"" \
530 "get number of children of weird.int_ptr_ptr"
531
532# Test: c_variable-4.88
533# Desc: children of *weird->int_ptr_ptr
9e8e3afe
VP
534mi_list_varobj_children "weird.int_ptr_ptr.*int_ptr_ptr" {
535 {{weird.int_ptr_ptr.\*int_ptr_ptr.\*\*int_ptr_ptr} {\*\*int_ptr_ptr} 0 "int"}
536} "get children of weird.int_ptr_ptr.*int_ptr_ptr"
2fcf52f0
AC
537#gdbtk_test c_variable-4.88 {children of *weird->int_ptr_ptr} {
538# get_children weird.int_ptr_ptr.*int_ptr_ptr
539#} {**int_ptr_ptr}
540
541# Test: c_variable-4.89
542# Desc: number of children *weird->int_ptr_ptr
543mi_gdb_test "-var-info-num-children weird.int_ptr_ptr.*int_ptr_ptr" \
544 "\\^done,numchild=\"1\"" \
545 "get number of children of weird.int_ptr_ptr.*int_ptr_ptr"
546
547# Test: c_variable-4.90
548# Desc: create weird->int_ptr_ptr
9e8e3afe 549mi_create_varobj "weird->int_ptr_ptr" "weird->int_ptr_ptr" \
3fddb3ad 550 "create local variable weird->int_ptr_ptr"
2fcf52f0
AC
551
552# Test: c_variable-4.91
553# Desc: children of weird->int_ptr_ptr
9e8e3afe
VP
554mi_list_varobj_children "weird->int_ptr_ptr" {
555 {{weird->int_ptr_ptr.\*weird->int_ptr_ptr} {\*weird->int_ptr_ptr} 1 {int \*}}
556} "get children of weird->int_ptr_ptr"
2fcf52f0
AC
557
558# Test: c_variable-4.92
559# Desc: number of children of (weird->int_ptr_ptr)
560mi_gdb_test "-var-info-num-children weird->int_ptr_ptr" \
561 "\\^done,numchild=\"1\"" \
562 "get number of children of weird->int_ptr_ptr"
563
564# Test: c_variable-4.93
565# Desc: children of *(weird->int_ptr_ptr)
9e8e3afe
VP
566mi_list_varobj_children "weird->int_ptr_ptr.*weird->int_ptr_ptr" {
567 {{weird->int_ptr_ptr.\*weird->int_ptr_ptr.\*\*weird->int_ptr_ptr} \
568 {\*\*weird->int_ptr_ptr} 0 int}
569} "get children of weird->int_ptr_ptr.*weird->int_ptr_ptr"
2fcf52f0
AC
570
571# Test: c_variable-4.94
572# Desc: number of children of *(weird->int_ptr_ptr)
573mi_gdb_test "-var-info-num-children weird->int_ptr_ptr.*weird->int_ptr_ptr" \
574 "\\^done,numchild=\"1\"" \
575 "get number of children of weird->int_ptr_ptr.*weird->int_ptr_ptr"
576
577# Test: c_variable-4.95
578# Desc: children of *(*(weird->int_ptr_ptr))
9e8e3afe 579mi_list_varobj_children "weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" {} \
2fcf52f0
AC
580 "get children of weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr"
581
582# Test: c_variable-4.96
583# Desc: number of children of *(*(weird->int_ptr_ptr))
9e8e3afe 584mi_list_varobj_children "weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" {} \
2fcf52f0
AC
585 "get number of children of weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr"
586
587# Test: c_variable-4.97
588# Desc: is weird editable
589mi_gdb_test "-var-show-attributes weird" \
590 "\\^done,attr=\"editable\"" \
591 "is weird editable"
592
593# Test: c_variable-4.98
594# Desc: is weird->int_ptr_ptr editable
595mi_gdb_test "-var-show-attributes weird->int_ptr_ptr" \
596 "\\^done,attr=\"editable\"" \
597 "is weird->int_ptr_ptr editable"
598
599# Test: c_variable-4.99
600# Desc: is *(weird->int_ptr_ptr) editable
601mi_gdb_test "-var-show-attributes weird.int_ptr_ptr.*int_ptr_ptr" \
c7dd36a1 602 "\\^done,attr=\"editable\"" \
2fcf52f0
AC
603 "is weird.int_ptr_ptr.*int_ptr_ptr editable"
604
605# Test: c_variable-4.100
606# Desc: is *(*(weird->int_ptr_ptr)) editable
607mi_gdb_test "-var-show-attributes weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr" \
c7dd36a1 608 "\\^done,attr=\"editable\"" \
2fcf52f0
AC
609 "is weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr editable"
610
611# Test: c_variable-4.101
612# Desc: is weird->u1 editable
613mi_gdb_test "-var-show-attributes weird.u1" \
614 "\\^done,attr=\"noneditable\"" \
615 "is weird.u1 editable"
616
617# Test: c_variable-4.102
618# Desc: is weird->s2 editable
619mi_gdb_test "-var-show-attributes weird.s2" \
620 "\\^done,attr=\"noneditable\"" \
621 "is weird.s2 editable"
622
623# Test: c_variable-4.103
624# Desc: is struct_declarations.u1.a editable
625mi_gdb_test "-var-show-attributes struct_declarations.u1.a" \
626 "\\^done,attr=\"editable\"" \
627 "is struct_declarations.u1.a editable"
628
629# Test: c_variable-4.104
630# Desc: is struct_declarations.u1.b editable
631mi_gdb_test "-var-show-attributes struct_declarations.u1.b" \
632 "\\^done,attr=\"editable\"" \
633 "is struct_declarations.u1.b editable"
634
635# Test: c_variable-4.105
636# Desc: is struct_declarations.u1.c editable
637mi_gdb_test "-var-show-attributes struct_declarations.u1.c" \
638 "\\^done,attr=\"editable\"" \
639 "is struct_declarations.u1.c editable"
640
641# Test: c_variable-4.106
642# Desc: is struct_declarations.long_array editable
643mi_gdb_test "-var-show-attributes struct_declarations.long_array" \
644 "\\^done,attr=\"noneditable\"" \
645 "is struct_declarations.long_array editable"
646
647# Test: c_variable-4.107
648# Desc: is struct_declarations.long_array[0] editable
649mi_gdb_test "-var-show-attributes struct_declarations.long_array.0" \
650 "\\^done,attr=\"editable\"" \
651 "is struct_declarations.long_array.0 editable"
652
653# Test: c_variable-4.108
654# Desc: is struct_declarations editable
655mi_gdb_test "-var-show-attributes struct_declarations" \
656 "\\^done,attr=\"noneditable\"" \
657 "is struct_declarations editable"
658
659mi_gdb_test "-var-delete weird" \
660 "\\^done,ndeleted=\"24\"" \
661 "delete var weird"
662
663##### #####
664# #
665# children and update tests #
666# #
667##### #####
668
669# Test: c_variable-5.1
670# Desc: check that nothing changed
671mi_gdb_test "-var-update *" \
672 "\\^done,changelist=\\\[\\\]" \
673 "update all vars. None changed"
674
675# Step over "struct_declarations.integer = 123;"
469aff8e
MC
676mi_step_to do_children_tests {} {.*var-cmd.c} \
677 [expr $line_dct_123 + 1] "step \$line_dct_123 + 1"
2fcf52f0
AC
678
679# Test: c_variable-5.2
680# Desc: check that integer changed
681mi_gdb_test "-var-update *" \
0cc7d26f 682 "\\^done,changelist=\\\[\{name=\"struct_declarations.integer\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
683 "update all vars struct_declarations.integer"
684
685# Step over:
686# weird->char_ptr = "hello";
687# bar = 2121;
688# foo = &bar;
469aff8e
MC
689mi_execute_to "exec-step 3" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \
690 [expr $line_dct_123 + 4] {} "step \$line_dct_123 + 4"
2fcf52f0
AC
691
692# Test: c_variable-5.3
693# Desc: check that char_ptr changed
694mi_gdb_test "-var-update *" \
0cc7d26f 695 "\\^done,changelist=\\\[\{name=\"struct_declarations.char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.char_ptr.\\*char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
696 "update all vars struct_declarations.char_ptr"
697
698# Step over "struct_declarations.int_ptr_ptr = &foo;"
469aff8e
MC
699mi_step_to do_children_tests {} {.*var-cmd.c} \
700 [expr $line_dct_123 + 5] "step \$line_dct_123 + 5"
2fcf52f0
AC
701
702# Test: c_variable-5.4
703# Desc: check that int_ptr_ptr and children changed
704mi_gdb_test "-var-update *" \
0cc7d26f 705 "\\^done,changelist=\\\[\{name=\"weird->int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr.\\*\\*weird->int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr.\\*\\*int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
706 "update all vars int_ptr_ptr and children changed"
707
708# Step over "weird->long_array[0] = 1234;"
469aff8e
MC
709mi_step_to do_children_tests {} {.*var-cmd.c} \
710 [expr $line_dct_123 + 6] "step \$line_dct_123 + 6"
2fcf52f0
AC
711
712# Test: c_variable-5.5
713# Desc: check that long_array[0] changed
714mi_gdb_test "-var-update *" \
0cc7d26f 715 "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.0\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
716 "update all vars struct_declarations.long_array.0 changed"
717
718# Step over "struct_declarations.long_array[1] = 2345;"
469aff8e
MC
719mi_step_to do_children_tests {} {.*var-cmd.c} \
720 [expr $line_dct_123 + 7] "step \$line_dct_123 + 7"
2fcf52f0
AC
721
722# Test: c_variable-5.6
723# Desc: check that long_array[1] changed
724mi_gdb_test "-var-update *" \
0cc7d26f 725 "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.1\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
726 "update all vars struct_declarations.long_array.1 changed"
727
728# Step over "weird->long_array[2] = 3456;"
469aff8e
MC
729mi_step_to do_children_tests {} {.*var-cmd.c} \
730 [expr $line_dct_123 + 8] "step \$line_dct_123 + 8"
2fcf52f0
AC
731
732# Test: c_variable-5.7
733# Desc: check that long_array[2] changed
734mi_gdb_test "-var-update *" \
0cc7d26f 735 "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.2\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
736 "update all vars struct_declarations.long_array.2 changed"
737
738# Step over:
739# struct_declarations.long_array[3] = 4567;
740# weird->long_array[4] = 5678;
741# struct_declarations.long_array[5] = 6789;
742# weird->long_array[6] = 7890;
743# struct_declarations.long_array[7] = 8901;
744# weird->long_array[8] = 9012;
745# struct_declarations.long_array[9] = 1234;
469aff8e
MC
746
747set line_dct_nothing [gdb_get_line_number "weird->func_ptr = nothing;"]
748mi_execute_to "exec-step 7" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \
749 $line_dct_nothing {} "step \$line_dct_nothing"
2fcf52f0
AC
750
751# Test: c_variable-5.8
752# Desc: check that long_array[3-9] changed
753mi_gdb_test "-var-update *" \
0cc7d26f 754 "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.3\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.long_array.4\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.long_array.5\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.long_array.6\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.long_array.7\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.long_array.8\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"struct_declarations.long_array.9\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
755 "update all vars struct_declarations.long_array.3-9 changed"
756
757
758# Step over "weird->func_ptr = nothing;"
a73bafbc 759set line_dct_a0_0 [gdb_get_line_number "a0\[0\] = '0';"]
469aff8e
MC
760mi_step_to do_children_tests {} {.*var-cmd.c} \
761 $line_dct_a0_0 "step \$line_dct_a0_0"
2fcf52f0
AC
762
763# Test: c_variable-5.9
764# Desc: check that func_ptr changed
765mi_gdb_test "-var-update *" \
0cc7d26f 766 "\\^done,changelist=\\\[\{name=\"struct_declarations.func_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
767 "update all vars struct_declarations.func_ptr changed"
768
769# Delete all variables
770mi_gdb_test "-var-delete struct_declarations" \
771 "\\^done,ndeleted=\"65\"" \
772 "delete var struct_declarations"
773
774mi_gdb_test "-var-delete weird->int_ptr_ptr" \
775 "\\^done,ndeleted=\"3\"" \
776 "delete var weird->int_ptr_ptr"
777
778# Step over all lines:
779# ...
780# psnp = &snp0;
469aff8e
MC
781
782set line_dct_snp0 [gdb_get_line_number "psnp = &snp0;"]
783mi_execute_to "exec-step 43" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \
784 [expr $line_dct_snp0 + 1] {} "step \$line_dct_snp0 + 1"
2fcf52f0
AC
785
786# Test: c_variable-5.10
787# Desc: create psnp->char_ptr
9e8e3afe 788mi_create_varobj "psnp->char_ptr" "psnp->char_ptr" \
3fddb3ad 789 "create local variable psnp->char_ptr"
2fcf52f0
AC
790
791# Test: c_variable-5.11
792# Desc: children of psnp->char_ptr
9e8e3afe
VP
793mi_list_varobj_children "psnp->char_ptr" {
794 {{psnp->char_ptr.\*psnp->char_ptr} {\*psnp->char_ptr} 1 {char \*\*\*}}
795} "get children of psnp->char_ptr"
2fcf52f0
AC
796
797# Test: c_variable-5.12
798# Desc: number of children of psnp->char_ptr
799mi_gdb_test "-var-info-num-children psnp->char_ptr" \
800 "\\^done,numchild=\"1\"" \
801 "get number of children of psnp->char_ptr"
802
803# Test: c_variable-5.13
804# Desc: children of *(psnp->char_ptr)
9e8e3afe
VP
805mi_list_varobj_children "psnp->char_ptr.*psnp->char_ptr" {
806 {{psnp->char_ptr.\*psnp->char_ptr.\*\*psnp->char_ptr} \
807 {\*\*psnp->char_ptr} 1 {char \*\*}}
808} "get children of psnp->char_ptr.*psnp->char_ptr"
2fcf52f0
AC
809
810# Test: c_variable-5.14
811# Desc: number of children of *(psnp->char_ptr)
812mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr" \
813 "\\^done,numchild=\"1\"" \
814 "get number of children of psnp->char_ptr.*psnp->char_ptr"
815
816# Test: c_variable-5.15
817# Desc: children of *(*(psnp->char_ptr))
9e8e3afe
VP
818mi_list_varobj_children "psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" {
819 {{psnp->char_ptr.\*psnp->char_ptr.\*\*psnp->char_ptr.\*\*\*psnp->char_ptr} \
820 {\*\*\*psnp->char_ptr} 1 {char \*}}
821} "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr"
2fcf52f0
AC
822
823# Test: c_variable-5.15B
824# Desc: children of *(*(*(psnp->char_ptr)))
9e8e3afe
VP
825mi_list_varobj_children "psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" {
826 {{psnp->char_ptr.\*psnp->char_ptr.\*\*psnp->char_ptr.\*\*\*psnp->char_ptr.\*\*\*\*psnp->char_ptr} \
827 {\*\*\*\*psnp->char_ptr} 0 char}
828} "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr"
2fcf52f0
AC
829
830# Test: c_variable-5.16
831# Desc: number of children of *(*(psnp->char_ptr))
832mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" \
833 "\\^done,numchild=\"1\"" \
834 "get number of children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr"
835
836# Test: c_variable-5.17
837# Desc: children of *(*(*(psnp->char_ptr)))
9e8e3afe
VP
838mi_list_varobj_children "psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" {
839 {{psnp->char_ptr.\*psnp->char_ptr.\*\*psnp->char_ptr.\*\*\*psnp->char_ptr.\*\*\*\*psnp->char_ptr} \
840 {\*\*\*\*psnp->char_ptr} 0 char}
841} "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr"
2fcf52f0
AC
842
843# Test: c_variable-5.18
844# Desc: number of children of *(*(*(psnp->char_ptr)))
845mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" \
846 "\\^done,numchild=\"1\"" \
847 "get number of children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr"
848
849# Test: c_variable-5.17B
850# Desc: children of *(*(*(*(psnp->char_ptr))))
9e8e3afe 851mi_list_varobj_children "psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" {} \
2fcf52f0
AC
852 "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr"
853
854# Test: c_variable-5.18B
855# Desc: number of children of *(*(*(*(psnp->char_ptr))))
856mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" \
857 "\\^done,numchild=\"0\"" \
858 "get number of children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr"
859
2fcf52f0
AC
860# Test: c_variable-5.19
861# Desc: create psnp->long_ptr
9e8e3afe 862mi_create_varobj "psnp->long_ptr" "psnp->long_ptr" \
3fddb3ad 863 "create local variable psnp->long_ptr"
2fcf52f0
AC
864
865# Test: c_variable-5.20
866# Desc: children of psnp->long_ptr
9e8e3afe 867mi_list_varobj_children "psnp->long_ptr" {
bd69fc68 868 {{psnp->long_ptr.\*psnp->long_ptr} {\*psnp->long_ptr} 1 {long \*\*\*}}
9e8e3afe 869} "get children of psnp->long_ptr"
2fcf52f0
AC
870
871# Test: c_variable-5.21
872# Desc: number of children of psnp->long_ptr
873mi_gdb_test "-var-info-num-children psnp->long_ptr" \
874 "\\^done,numchild=\"1\"" \
875 "get number of children of psnp->long_ptr"
876
877# Test: c_variable-5.22
878# Desc: children of *(psnp->long_ptr)
9e8e3afe 879mi_list_varobj_children "psnp->long_ptr.*psnp->long_ptr" {
bd69fc68 880 {{psnp->long_ptr.\*psnp->long_ptr.\*\*psnp->long_ptr} {\*\*psnp->long_ptr} 1 {long \*\*}}
9e8e3afe 881} "get children of psnp->long_ptr.*psnp->long_ptr"
2fcf52f0
AC
882
883
884# Test: c_variable-5.23
885# Desc: number of children of *(psnp->long_ptr)
886mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr" \
887 "\\^done,numchild=\"1\"" \
888 "get number of children of psnp->long_ptr.*psnp->long_ptr"
889
890# Test: c_variable-5.24
891# Desc: children of *(*(psnp->long_ptr))
9e8e3afe
VP
892mi_list_varobj_children "psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" {
893 {{psnp->long_ptr.\*psnp->long_ptr.\*\*psnp->long_ptr.\*\*\*psnp->long_ptr} \
bd69fc68 894 {\*\*\*psnp->long_ptr} 1 {long \*}}
9e8e3afe 895} "get children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr"
2fcf52f0
AC
896
897# Test: c_variable-5.25
898# Desc: number of children of *(*(psnp->long_ptr))
899mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" \
900 "\\^done,numchild=\"1\"" \
901 "get number of children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr"
902
903# Test: c_variable-5.26
904# Desc: children of *(*(*(psnp->long_ptr)))
9e8e3afe
VP
905mi_list_varobj_children "psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" {
906 {{psnp->long_ptr.\*psnp->long_ptr.\*\*psnp->long_ptr.\*\*\*psnp->long_ptr.\*\*\*\*psnp->long_ptr}
bd69fc68 907 {\*\*\*\*psnp->long_ptr} 0 {long}}
9e8e3afe 908} "get children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr"
2fcf52f0
AC
909
910# Test: c_variable-5.27
911# Desc: number of children of *(*(*(psnp->long_ptr)))
912mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" \
913 "\\^done,numchild=\"1\"" \
914 "get number of children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr"
915
916# Test: c_variable-5.28
917# Desc: children of *(*(*(*(psnp->long_ptr))))
9e8e3afe 918mi_list_varobj_children "psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" {} \
2fcf52f0
AC
919 "get children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr"
920
921# Test: c_variable-5.29
922# Desc: number of children of *(*(*(*(psnp->long_ptr))))
923mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" \
924 "\\^done,numchild=\"0\"" \
925 "get number of children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr"
926
9e8e3afe 927
2fcf52f0
AC
928# Test: c_variable-5.30
929# Desc: create psnp->ptrs
9e8e3afe 930mi_create_varobj "psnp->ptrs" "psnp->ptrs" \
3fddb3ad 931 "create local variable psnp->ptrs"
2fcf52f0
AC
932
933# Test: c_variable-5.31
934# Desc: children of psnp->ptrs
9e8e3afe
VP
935mi_list_varobj_children "psnp->ptrs" {
936 {psnp->ptrs.0 0 4 {struct _struct_n_pointer \*}}
937 {psnp->ptrs.1 1 4 {struct _struct_n_pointer \*}}
938 {psnp->ptrs.2 2 4 {struct _struct_n_pointer \*}}
939} "get children of psnp->ptrs"
2fcf52f0
AC
940
941# Test: c_variable-5.32
942# Desc: number of children of psnp->ptrs
943mi_gdb_test "-var-info-num-children psnp->ptrs" \
944 "\\^done,numchild=\"3\"" \
945 "get number of children of psnp->ptrs"
946
947# Test: c_variable-5.33
948# Desc: children of psnp->ptrs[0]
9e8e3afe
VP
949mi_list_varobj_children "psnp->ptrs.0" {
950 {psnp->ptrs.0.char_ptr char_ptr 1 {char \*\*\*\*}}
bd69fc68 951 {psnp->ptrs.0.long_ptr long_ptr 1 {long \*\*\*\*}}
9e8e3afe
VP
952 {psnp->ptrs.0.ptrs ptrs 3 {struct _struct_n_pointer \*\[3\]}}
953 {psnp->ptrs.0.next next 4 {struct _struct_n_pointer \*}}
954} "get children of psnp->ptrs.0"
2fcf52f0
AC
955
956# Test: c_variable-5.34
957# Desc: number of children of psnp->ptrs[0]
958mi_gdb_test "-var-info-num-children psnp->ptrs.0" \
959 "\\^done,numchild=\"4\"" \
960 "get number of children of psnp->ptrs.0"
961
962# Test: c_variable-5.35
963# Desc: children of psnp->ptrs[0]->next
9e8e3afe
VP
964mi_list_varobj_children "psnp->ptrs.0.next" {
965 {psnp->ptrs.0.next.char_ptr char_ptr 1 {char \*\*\*\*}}
bd69fc68 966 {psnp->ptrs.0.next.long_ptr long_ptr 1 {long \*\*\*\*}}
9e8e3afe
VP
967 {psnp->ptrs.0.next.ptrs ptrs 3 {struct _struct_n_pointer \*\[3\]}}
968 {psnp->ptrs.0.next.next next 4 {struct _struct_n_pointer \*}}
969} "get children of psnp->ptrs.0.next"
2fcf52f0
AC
970
971#} {char_ptr long_ptr ptrs next}
972
973# Test: c_variable-5.36
974# Desc: number of children of psnp->ptrs[0]->next
975mi_gdb_test "-var-info-num-children psnp->ptrs.0.next" \
976 "\\^done,numchild=\"4\"" \
977 "get number of children of psnp->ptrs.0.next"
978
979
980# Test: c_variable-5.37
981# Desc: children of psnp->ptrs[0]->next->char_ptr
9e8e3afe
VP
982mi_list_varobj_children "psnp->ptrs.0.next.char_ptr" {
983 {{psnp->ptrs.0.next.char_ptr.\*char_ptr} {\*char_ptr} 1 {char \*\*\*}}
984} "get children of psnp->ptrs.0.next.char_ptr"
2fcf52f0
AC
985
986#gdbtk_test c_variable-5.37 {children of psnp->ptrs[0]->next->char_ptr} {
987# get_children psnp->ptrs.0.next.char_ptr
988#} {*char_ptr}
989
990# Test: c_variable-5.38
991# Desc: number of children of psnp->ptrs[0]->next->char_ptr
992mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr" \
993 "\\^done,numchild=\"1\"" \
994 "get number of children of psnp->ptrs.0.next.char_ptr"
995
996# Test: c_variable-5.39
997# Desc: children of *psnp->ptrs[0]->next->char_ptr
9e8e3afe
VP
998mi_list_varobj_children "psnp->ptrs.0.next.char_ptr.*char_ptr" {
999 {{psnp->ptrs.0.next.char_ptr.\*char_ptr.\*\*char_ptr} {\*\*char_ptr} 1 {char \*\*}}
1000} "get children of psnp->ptrs.0.next.char_ptr.*char_ptr"
2fcf52f0
AC
1001
1002# Test: c_variable-5.40
1003# Desc: number of children of *psnp->ptrs[0]->next->char_ptr
1004mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr" \
1005 "\\^done,numchild=\"1\"" \
1006 "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr"
1007
1008# Test: c_variable-5.41
1009# Desc: children of **psnp->ptrs[0]->next->char_ptr
9e8e3afe
VP
1010mi_list_varobj_children "psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" {
1011 {{psnp->ptrs.0.next.char_ptr.\*char_ptr.\*\*char_ptr.\*\*\*char_ptr} \
1012 {\*\*\*char_ptr} 1 {char \*}}
1013} "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr"
2fcf52f0
AC
1014
1015# Test: c_variable-5.41B
1016# Desc: children of ***psnp->ptrs[0]->next->char_ptr
9e8e3afe
VP
1017mi_list_varobj_children "psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" {
1018 {{psnp->ptrs.0.next.char_ptr.\*char_ptr.\*\*char_ptr.\*\*\*char_ptr.\*\*\*\*char_ptr} \
1019 {\*\*\*\*char_ptr} 0 char}
1020} "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr"
2fcf52f0
AC
1021
1022# Test: c_variable-5.42
1023# Desc: number of children of **psnp->ptrs[0]->next->char_ptr
1024mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" \
1025 "\\^done,numchild=\"1\"" \
1026 "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr"
1027
1028# Test: c_variable-5.43
1029# Desc: children of ***psnp->ptrs[0]->next->char_ptr
9e8e3afe
VP
1030mi_list_varobj_children "psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" {
1031 {{psnp->ptrs.0.next.char_ptr.\*char_ptr.\*\*char_ptr.\*\*\*char_ptr.\*\*\*\*char_ptr} \
1032 {\*\*\*\*char_ptr} 0 char}
1033} "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr"
2fcf52f0
AC
1034
1035# Test: c_variable-5.44
1036# Desc: number of children of ***psnp->ptrs[0]->next->char_ptr
1037mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" \
1038 "\\^done,numchild=\"1\"" \
1039 "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr"
1040
1041# Test: c_variable-5.43B
1042# Desc: children of ****psnp->ptrs[0]->next->char_ptr
9e8e3afe 1043mi_list_varobj_children "psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr.****char_ptr" {} \
2fcf52f0
AC
1044 "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr"
1045
1046# Test: c_variable-5.44B
1047# Desc: number of children of ****psnp->ptrs[0]->next->char_ptr
1048mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr.****char_ptr" \
1049 "\\^done,numchild=\"0\"" \
1050 "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr"
1051
1052# Test: c_variable-5.45
1053# Desc: children of psnp->ptrs[0]->next->next
9e8e3afe
VP
1054mi_list_varobj_children "psnp->ptrs.0.next.next" {
1055 {psnp->ptrs.0.next.next.char_ptr char_ptr 1 {char \*\*\*\*}}
bd69fc68 1056 {psnp->ptrs.0.next.next.long_ptr long_ptr 1 {long \*\*\*\*}}
9e8e3afe
VP
1057 {psnp->ptrs.0.next.next.ptrs ptrs 3 {struct _struct_n_pointer \*\[3\]}}
1058 {psnp->ptrs.0.next.next.next next 4 {struct _struct_n_pointer \*}}
1059} "get children of psnp->ptrs.0.next.next"
1060
2fcf52f0
AC
1061
1062# Test: c_variable-5.46
1063# Desc: children of psnp->ptrs[0]->next->next->ptrs
9e8e3afe
VP
1064mi_list_varobj_children "psnp->ptrs.0.next.next.ptrs" {
1065 {psnp->ptrs.0.next.next.ptrs.0 0 4 {struct _struct_n_pointer \*}}
1066 {psnp->ptrs.0.next.next.ptrs.1 1 4 {struct _struct_n_pointer \*}}
1067 {psnp->ptrs.0.next.next.ptrs.2 2 4 {struct _struct_n_pointer \*}}
1068} "get children of psnp->ptrs.0.next.next.ptrs"
2fcf52f0
AC
1069
1070# Step over "snp0.char_ptr = &b3;"
469aff8e
MC
1071mi_step_to do_children_tests {} {.*var-cmd.c} \
1072 [expr $line_dct_snp0 + 2] "step \$line_dct_snp0 + 2"
2fcf52f0
AC
1073
1074# Test: c_variable-5.47
1075# Desc: check that psnp->char_ptr (and [0].char_ptr) changed
1076mi_gdb_test "-var-update *" \
0cc7d26f 1077 "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->char_ptr.\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr.\\*\\*\\*\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
1078 "update all vars psnp->char_ptr (and 0.char_ptr) changed"
1079
1080# Step over "snp1.char_ptr = &c3;"
469aff8e
MC
1081mi_step_to do_children_tests {} {.*var-cmd.c} \
1082 [expr $line_dct_snp0 + 3] "step \$line_dct_snp0 + 3"
2fcf52f0
AC
1083
1084# Test: c_variable-5.48
1085# Desc: check that psnp->next->char_ptr (and [1].char_ptr) changed
1086mi_gdb_test "-var-update *" \
0cc7d26f 1087 "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr.\\*\\*\\*\\*char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
1088 "update all vars psnp->next->char_ptr (and 1.char_ptr) changed"
1089
1090
1091# Step over "snp2.char_ptr = &a3;"
469aff8e
MC
1092mi_step_to do_children_tests {} {.*var-cmd.c} \
1093 [expr $line_dct_snp0 + 4] "step \$line_dct_snp0 + 4"
2fcf52f0
AC
1094
1095# Test: c_variable-5.49
1096# Desc: check that psnp->next->next->char_ptr (and [2].char_ptr) changed
1097mi_gdb_test "-var-update *" \
0cc7d26f 1098 "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.next.char_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
1099 "update all vars psnp->next->next->char_ptr (and 2.char_ptr) changed"
1100
1101
1102# Step over "snp0.long_ptr = &y3;"
469aff8e
MC
1103mi_step_to do_children_tests {} {.*var-cmd.c} \
1104 [expr $line_dct_snp0 + 5] "step \$line_dct_snp0 + 5"
2fcf52f0
AC
1105
1106# Test: c_variable-5.50
1107# Desc: check that psnp->long_ptr (and [0].long_ptr) changed
1108mi_gdb_test "-var-update *" \
0cc7d26f 1109 "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.long_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->long_ptr.\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr.\\*\\*\\*\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
1110 "update all vars psnp->long_ptr (and 0.long_ptr) changed"
1111
1112
1113# Step over "snp1.long_ptr = &x3;"
469aff8e
MC
1114mi_step_to do_children_tests {} {.*var-cmd.c} \
1115 [expr $line_dct_snp0 + 6] "step \$line_dct_snp0 + 6"
2fcf52f0
AC
1116
1117# Test: c_variable-5.51
1118# Desc: check that psnp->next->long_ptr (and [1].long_ptr) changed
1119# Why does this have a FIXME?
1120setup_xfail *-*-*
1121mi_gdb_test "-var-update *" \
0cc7d26f 1122 "FIXME\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.long_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
1123 "update all vars psnp->next->long_ptr (and 1.long_ptr) changed"
1124clear_xfail *-*-*
1125
1126# This command produces this error message:
1127# &"warning: varobj_list: assertion failed - mycount <> 0\n"
1128#
1129
1130# Step over "snp2.long_ptr = &z3;"
469aff8e
MC
1131mi_step_to do_children_tests {} {.*var-cmd.c} \
1132 [expr $line_dct_snp0 + 7] "step \$line_dct_snp0 + 7"
2fcf52f0
AC
1133
1134# Test: c_variable-5.52
1135# Desc: check that psnp->next->next->long_ptr (and [2].long_ptr) changed
1136mi_gdb_test "-var-update *" \
0cc7d26f 1137 "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.next.long_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
2fcf52f0
AC
1138 "update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed"
1139
1140
3848a17f
KS
1141# Anonymous type tests
1142proc verify_everything {variable_name} {
1143 # Test -var-list-children
1144 mi_varobj_tree_test_children_callback $variable_name
1145
1146 # Bring the variable named by VARIABLE_NAME into the current scope
1147 # in VAROBJ.
1148 upvar #0 $variable_name varobj
1149
1150 # Test -var-info-path-expression
1151 mi_gdb_test "-var-info-path-expression $varobj(obj_name)" \
1152 "\\^done,path_expr=\"[string_to_regexp $varobj(path_expr)]\"" \
1153 "path expression for $varobj(obj_name)"
1154
1155 # Test -var-info-expression
1156 mi_gdb_test "-var-info-expression $varobj(obj_name)" \
1157 "\\^done,lang=\"C\",exp=\"[string_to_regexp $varobj(display_name)]\"" \
1158 "expression for $varobj(obj_name)"
1159}
1160
1161set lineno [gdb_get_line_number "anonymous type tests breakpoint"]
1162mi_create_breakpoint \
1163 "$srcfile:$lineno" {[0-9]+} keep {do_anonymous_type_tests} \
1164 ".*var-cmd.c" $lineno $hex "break in do_anonymous_type_tests"
1165mi_execute_to "exec-continue" "breakpoint-hit" "do_anonymous_type_tests" ""\
1166 ".*" ".*" {"" "disp=\"keep\""} \
1167 "continue to do_anonymous_type_tests breakpoint"
1168
1169# Run the varobj tree on variable "ptr".
1170set tree {
1171 {struct anonymous **} ptr {
1172 {struct anonymous *} {*ptr} {
1173 int a {}
1174 anonymous struct {
1175 int b {}
1176 {char *} c {
1177 char {*c} {}
1178 }
1179 anonymous union {
1180 int d {}
1181 {void *} e {}
1182 char f {}
1183 anonymous struct {
1184 char g {}
1185 {const char **} h {
1186 {const char *} {*h} {
1187 {const char} {**h} {}
1188 }
1189 }
1190 {simpleton ***} simple {
1191 {simpleton **} {*simple} {
1192 {simpleton *} {**simple} {
1193 int integer {}
1194 {unsigned int} unsigned_integer {}
1195 char character {}
1196 {signed char} signed_character {}
1197 {char *} char_ptr {
1198 char {*char_ptr} {}
1199 }
1200 {int [10]} array_of_10 {
1201 int 0 {}
1202 int 1 {}
1203 int 2 {}
1204 int 3 {}
1205 int 4 {}
1206 int 5 {}
1207 int 6 {}
1208 int 7 {}
1209 int 8 {}
1210 int 9 {}
1211 }
1212 }
1213 }
1214 }
1215 }
1216 }
1217 }
1218 }
1219 }
1220}
1221
1222mi_walk_varobj_tree c $tree verify_everything
1223
1224set tree {
1225 {struct {...}} v {
1226 int x {}
1227 anonymous struct {
1228 int a {}
1229 }
1230 anonymous struct {
1231 int b {}
1232 }
1233 }
1234}
2fcf52f0 1235
3848a17f 1236mi_walk_varobj_tree c $tree verify_everything
2fcf52f0
AC
1237
1238mi_gdb_exit
1239return 0