Commit | Line | Data |
---|---|---|
0b302171 | 1 | # Copyright 1999-2005, 2007-2012 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 | ||
22 | load_lib mi-support.exp | |
23 | set MIFLAGS "-i=mi2" | |
24 | ||
25 | gdb_exit | |
26 | if [mi_gdb_start] { | |
27 | continue | |
28 | } | |
29 | ||
30 | set testfile "var-cmd" | |
31 | set srcfile ${testfile}.c | |
3788363d | 32 | set binfile ${objdir}/${subdir}/mi2-var-display |
2fcf52f0 | 33 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { |
b60f0898 JB |
34 | untested mi2-var-display.exp |
35 | return -1 | |
2fcf52f0 AC |
36 | } |
37 | ||
38 | mi_delete_breakpoints | |
39 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
40 | mi_gdb_load ${binfile} | |
41 | ||
e1c2defa | 42 | set line_dct_end [gdb_get_line_number "{int a = 0;}"] |
469aff8e | 43 | |
d24317b4 VP |
44 | mi_create_breakpoint "$srcfile:$line_dct_end" 1 keep do_children_tests ".*var-cmd.c" $line_dct_end $hex \ |
45 | "break-insert operation" | |
2fcf52f0 AC |
46 | |
47 | mi_run_cmd | |
18ac113b AR |
48 | mi_expect_stop "breakpoint-hit" "do_children_tests" "" ".*var-cmd.c" \ |
49 | $line_dct_end { "" "disp=\"keep\"" } "run to main" | |
2fcf52f0 AC |
50 | |
51 | ##### ##### | |
52 | # # | |
53 | # Display tests # | |
54 | # # | |
55 | ##### ##### | |
56 | ||
57 | # Test: c_variable-6.1 | |
58 | # Desc: create variable bar | |
9e8e3afe | 59 | mi_create_varobj bar bar "create local variable bar" |
2fcf52f0 AC |
60 | |
61 | # Test: c_variable-6.2 | |
62 | # Desc: type of variable bar | |
63 | mi_gdb_test "-var-info-type bar" \ | |
64 | "\\^done,type=\"int\"" \ | |
65 | "info type variable bar" | |
66 | ||
67 | # Test: c_variable-6.3 | |
68 | # Desc: format of variable bar | |
69 | mi_gdb_test "-var-show-format bar" \ | |
70 | "\\^done,format=\"natural\"" \ | |
71 | "show format variable bar" | |
72 | ||
73 | # Test: c_variable-6.4 | |
74 | # Desc: value of variable bar | |
75 | mi_gdb_test "-var-evaluate-expression bar" \ | |
76 | "\\^done,value=\"2121\"" \ | |
77 | "eval variable bar" | |
78 | ||
79 | # Test: c_variable-6.5 | |
80 | # Desc: change format of bar to hex | |
81 | mi_gdb_test "-var-set-format bar hexadecimal" \ | |
8a578dd7 | 82 | "\\^done,format=\"hexadecimal\",value=\"0x849\"" \ |
2fcf52f0 AC |
83 | "set format variable bar" |
84 | ||
85 | # Test: c_variable-6.6 | |
86 | # Desc: value of bar with new format | |
87 | mi_gdb_test "-var-evaluate-expression bar" \ | |
88 | "\\^done,value=\"0x849\"" \ | |
89 | "eval variable bar with new format" | |
90 | ||
91 | # Test: c_variable-6.7 | |
92 | # Desc: change value of bar | |
93 | mi_gdb_test "-var-assign bar 3" \ | |
94 | "\\^done,value=\"0x3\"" \ | |
95 | "assing to variable bar" | |
96 | ||
97 | mi_gdb_test "-var-set-format bar decimal" \ | |
8a578dd7 | 98 | "\\^done,format=\"decimal\",value=\"3\"" \ |
2fcf52f0 AC |
99 | "set format variable bar" |
100 | ||
101 | mi_gdb_test "-var-evaluate-expression bar" \ | |
102 | "\\^done,value=\"3\"" \ | |
103 | "eval variable bar with new value" | |
104 | ||
105 | mi_gdb_test "-var-delete bar" \ | |
106 | "\\^done,ndeleted=\"1\"" \ | |
107 | "delete var bar" | |
108 | ||
109 | # Test: c_variable-6.11 | |
110 | # Desc: create variable foo | |
9e8e3afe | 111 | mi_create_varobj foo foo "create local variable foo" |
2fcf52f0 AC |
112 | |
113 | # Test: c_variable-6.12 | |
114 | # Desc: type of variable foo | |
115 | mi_gdb_test "-var-info-type foo" \ | |
116 | "\\^done,type=\"int \\*\"" \ | |
117 | "info type variable foo" | |
118 | ||
119 | # Test: c_variable-6.13 | |
120 | # Desc: format of variable foo | |
121 | mi_gdb_test "-var-show-format foo" \ | |
122 | "\\^done,format=\"natural\"" \ | |
123 | "show format variable foo" | |
124 | ||
125 | # Test: c_variable-6.14 | |
126 | # Desc: value of variable foo | |
127 | mi_gdb_test "-var-evaluate-expression foo" \ | |
128 | "\\^done,value=\"$hex\"" \ | |
129 | "eval variable foo" | |
130 | ||
131 | # Test: c_variable-6.15 | |
132 | # Desc: change format of var to octal | |
133 | mi_gdb_test "-var-set-format foo octal" \ | |
8a578dd7 | 134 | "\\^done,format=\"octal\",value=\"$octal\"" \ |
2fcf52f0 AC |
135 | "set format variable foo" |
136 | ||
137 | mi_gdb_test "-var-show-format foo" \ | |
138 | "\\^done,format=\"octal\"" \ | |
139 | "show format variable foo" | |
140 | ||
141 | # Test: c_variable-6.16 | |
142 | # Desc: value of foo with new format | |
143 | mi_gdb_test "-var-evaluate-expression foo" \ | |
144 | "\\^done,value=\"\[0-7\]+\"" \ | |
145 | "eval variable foo" | |
146 | ||
147 | # Test: c_variable-6.17 | |
148 | # Desc: change value of foo | |
149 | mi_gdb_test "-var-assign foo 3" \ | |
150 | "\\^done,value=\"03\"" \ | |
151 | "assing to variable foo" | |
152 | ||
153 | mi_gdb_test "-var-set-format foo decimal" \ | |
8a578dd7 | 154 | "\\^done,format=\"decimal\",value=\"3\"" \ |
2fcf52f0 AC |
155 | "set format variable foo" |
156 | ||
157 | # Test: c_variable-6.18 | |
158 | # Desc: check new value of foo | |
159 | mi_gdb_test "-var-evaluate-expression foo" \ | |
160 | "\\^done,value=\"3\"" \ | |
161 | "eval variable foo" | |
162 | ||
de051565 MK |
163 | # Test: c_variable-6.19 |
164 | # Desc: check optional format parameter of var-evaluate-expression | |
165 | # and check that current format is not changed | |
166 | mi_gdb_test "-var-evaluate-expression -f hex foo" \ | |
167 | "\\^done,value=\"0x3\"" \ | |
168 | "eval variable foo in hex" | |
169 | ||
170 | mi_gdb_test "-var-show-format foo" \ | |
171 | "\\^done,format=\"decimal\"" \ | |
172 | "show format variable foo after eval in hex" | |
173 | ||
174 | mi_gdb_test "-var-evaluate-expression -f octal foo" \ | |
175 | "\\^done,value=\"03\"" \ | |
176 | "eval variable foo in octal" | |
177 | ||
178 | mi_gdb_test "-var-show-format foo" \ | |
179 | "\\^done,format=\"decimal\"" \ | |
180 | "show format variable foo after eval in octal" | |
181 | ||
182 | mi_gdb_test "-var-evaluate-expression -f decimal foo" \ | |
183 | "\\^done,value=\"3\"" \ | |
184 | "eval variable foo in decimal" | |
185 | ||
186 | mi_gdb_test "-var-show-format foo" \ | |
187 | "\\^done,format=\"decimal\"" \ | |
188 | "show format variable foo after eval in decimal" | |
189 | ||
190 | mi_gdb_test "-var-evaluate-expression -f nat foo" \ | |
191 | "\\^done,value=\"0x3\"" \ | |
192 | "eval variable foo in natural" | |
193 | ||
194 | mi_gdb_test "-var-show-format foo" \ | |
195 | "\\^done,format=\"decimal\"" \ | |
196 | "show format variable foo after eval in natural" | |
197 | ||
198 | mi_gdb_test "-var-evaluate-expression -f bin foo" \ | |
199 | "\\^done,value=\"11\"" \ | |
200 | "eval variable foo in binary" | |
201 | ||
202 | mi_gdb_test "-var-show-format foo" \ | |
203 | "\\^done,format=\"decimal\"" \ | |
204 | "show format variable foo after eval in binary" | |
205 | ||
2fcf52f0 AC |
206 | mi_gdb_test "-var-delete foo" \ |
207 | "\\^done,ndeleted=\"1\"" \ | |
208 | "delete var foo" | |
209 | ||
210 | # Test: c_variable-6.21 | |
211 | # Desc: create variable weird and children | |
9e8e3afe VP |
212 | mi_create_varobj weird weird "create local variable weird" |
213 | ||
214 | mi_list_varobj_children weird { | |
215 | {weird.integer integer 0 int} | |
216 | {weird.character character 0 char} | |
217 | {weird.char_ptr char_ptr 1 "char \\*"} | |
218 | {weird.long_int long_int 0 "long int"} | |
219 | {weird.int_ptr_ptr int_ptr_ptr 1 "int \\*\\*"} | |
220 | {weird.long_array long_array 10 "long int \\[10\\]"} | |
221 | {weird.func_ptr func_ptr 0 "void \\(\\*\\)\\((void)?\\)"} | |
222 | {weird.func_ptr_struct func_ptr_struct 0 \ | |
223 | "struct _struct_decl \\(\\*\\)(\\(int, char \\*, long int\\))?"} | |
224 | {weird.func_ptr_ptr func_ptr_ptr 0 \ | |
225 | "struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long int)?\\)"} | |
226 | {weird.u1 u1 4 "union \\{\\.\\.\\.\\}"} | |
227 | {weird.s2 s2 4 "struct \\{\\.\\.\\.\\}"} | |
228 | } "get children local variable weird" | |
2fcf52f0 AC |
229 | |
230 | ||
231 | # Test: c_variable-6.23 | |
232 | # Desc: change format of weird.func_ptr and weird.func_ptr_ptr | |
233 | mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ | |
8a578dd7 | 234 | "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ |
2fcf52f0 AC |
235 | "set format variable weird.func_ptr" |
236 | ||
237 | mi_gdb_test "-var-show-format weird.func_ptr" \ | |
238 | "\\^done,format=\"hexadecimal\"" \ | |
239 | "show format variable weird.func_ptr" | |
240 | ||
241 | mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \ | |
8a578dd7 | 242 | "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ |
2fcf52f0 AC |
243 | "set format variable weird.func_ptr_ptr" |
244 | ||
245 | mi_gdb_test "-var-show-format weird.func_ptr_ptr" \ | |
246 | "\\^done,format=\"hexadecimal\"" \ | |
247 | "show format variable weird.func_ptr_ptr" | |
248 | ||
249 | # Test: c_variable-6.24 | |
250 | # Desc: format of weird and children | |
251 | mi_gdb_test "-var-set-format weird natural" \ | |
8a578dd7 | 252 | "\\^done,format=\"natural\",value=\"$hex\"" \ |
2fcf52f0 AC |
253 | "set format variable weird" |
254 | ||
255 | mi_gdb_test "-var-set-format weird.integer natural" \ | |
8a578dd7 | 256 | "\\^done,format=\"natural\",value=\"123\"" \ |
2fcf52f0 AC |
257 | "set format variable weird.integer" |
258 | ||
259 | mi_gdb_test "-var-set-format weird.character natural" \ | |
30b66ecc | 260 | "\\^done,format=\"natural\",value=\"0 '\\\\\\\\000'\"" \ |
2fcf52f0 AC |
261 | "set format variable weird.character" |
262 | ||
263 | mi_gdb_test "-var-set-format weird.char_ptr natural" \ | |
8a578dd7 | 264 | "\\^done,format=\"natural\",value=\"$hex \\\\\"hello\\\\\"\"" \ |
2fcf52f0 AC |
265 | "set format variable weird.char_ptr" |
266 | ||
267 | mi_gdb_test "-var-set-format weird.long_int natural" \ | |
8a578dd7 | 268 | "\\^done,format=\"natural\",value=\"0\"" \ |
2fcf52f0 AC |
269 | "set format variable weird.long_int" |
270 | ||
271 | mi_gdb_test "-var-set-format weird.int_ptr_ptr natural" \ | |
8a578dd7 | 272 | "\\^done,format=\"natural\",value=\"$hex\"" \ |
2fcf52f0 AC |
273 | "set format variable weird.int_ptr_ptr" |
274 | ||
275 | mi_gdb_test "-var-set-format weird.long_array natural" \ | |
8a578dd7 | 276 | "\\^done,format=\"natural\",value=\"\\\[10\\\]\"" \ |
2fcf52f0 AC |
277 | "set format variable weird.long_array" |
278 | ||
279 | mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ | |
8a578dd7 | 280 | "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ |
2fcf52f0 AC |
281 | "set format variable weird.func_ptr" |
282 | ||
283 | mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \ | |
8a578dd7 | 284 | "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ |
2fcf52f0 AC |
285 | "set format variable weird.func_ptr_struct" |
286 | ||
287 | mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \ | |
1d51a733 | 288 | "\\^done,format=\"natural\",value=\"0x0\"" \ |
2fcf52f0 AC |
289 | "set format variable weird.func_ptr_ptr" |
290 | ||
291 | mi_gdb_test "-var-set-format weird.u1 natural" \ | |
8a578dd7 | 292 | "\\^done,format=\"natural\",value=\"\{...\}\"" \ |
2fcf52f0 AC |
293 | "set format variable weird.u1" |
294 | ||
295 | mi_gdb_test "-var-set-format weird.s2 natural" \ | |
8a578dd7 | 296 | "\\^done,format=\"natural\",value=\"\{...\}\"" \ |
2fcf52f0 AC |
297 | "set format variable weird.s2" |
298 | ||
299 | # Test: c_variable-6.25 | |
300 | # Desc: value of weird and children | |
301 | #gdbtk_test c_variable-6.25 {value of weird and children} { | |
302 | # set values {} | |
303 | # foreach v [lsort [array names var]] f [list x "" "" x x x x d d d d d] { | |
304 | # lappend values [value $v $f] | |
305 | # } | |
306 | ||
307 | # set values | |
308 | #} {ok ok ok ok ok ok ok ok weird.long_array ok weird.s2 weird.u1} | |
309 | ||
310 | # Test: c_variable-6.26 | |
311 | # Desc: change format of weird and children to octal | |
312 | #gdbtk_test c_variable-6.26 {change format of weird and children to octal} { | |
313 | # set formats {} | |
314 | # foreach v [lsort [array names var]] { | |
315 | # $var($v) format octal | |
316 | # lappend formats [$var($v) format] | |
317 | # } | |
318 | ||
319 | # set formats | |
320 | #} {octal octal octal octal octal octal octal octal octal octal octal octal} | |
321 | ||
322 | # Test: c_variable-6.27 | |
323 | # Desc: value of weird and children with new format | |
324 | #gdbtk_test c_variable-6.27 {value of foo with new format} { | |
325 | # set values {} | |
326 | # foreach v [lsort [array names var]] { | |
327 | # lappend values [value $v o] | |
328 | # } | |
329 | ||
330 | # set values | |
331 | #} {ok ok ok ok ok ok ok ok weird.long_array ok weird.s2 weird.u1} | |
332 | ||
333 | # Test: c_variable-6.30 | |
334 | # Desc: create more children of weird | |
335 | #gdbtk_test c_variable-6.30 {create more children of weird} { | |
336 | # foreach v [array names var] { | |
337 | # get_children $v | |
338 | # } | |
339 | ||
340 | # # Do it twice to get more children | |
341 | # foreach v [array names var] { | |
342 | # get_children $v | |
343 | # } | |
344 | ||
345 | # lsort [array names var] | |
346 | #} {weird weird.char_ptr weird.character weird.func_ptr weird.func_ptr_ptr weird.func_ptr_struct weird.int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr weird.integer weird.long_array weird.long_array.0 weird.long_array.1 weird.long_array.2 weird.long_array.3 weird.long_array.4 weird.long_array.5 weird.long_array.6 weird.long_array.7 weird.long_array.8 weird.long_array.9 weird.long_int weird.s2 weird.s2.g weird.s2.h weird.s2.i weird.s2.i.0 weird.s2.i.1 weird.s2.i.2 weird.s2.i.3 weird.s2.i.4 weird.s2.i.5 weird.s2.i.6 weird.s2.i.7 weird.s2.i.8 weird.s2.i.9 weird.s2.u2 weird.s2.u2.f weird.s2.u2.u1s1 weird.s2.u2.u1s2 weird.u1 weird.u1.a weird.u1.b weird.u1.c weird.u1.d} | |
347 | ||
348 | # Test: c_variable-6.31 | |
349 | # Desc: check that all children of weird change | |
350 | # Ok, obviously things like weird.s2 and weird.u1 will not change! | |
351 | #gdbtk_test *c_variable-6.31 {check that all children of weird change (ops, we are now reporting array names as changed in this case - seems harmless though)} { | |
352 | # $var(weird) value 0x2121 | |
353 | # check_update | |
354 | #} {{weird.integer weird.character weird.char_ptr weird.long_int weird.int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr weird.long_array.0 weird.long_array.1 weird.long_array.2 weird.long_array.3 weird.long_array.4 weird.long_array.5 weird.long_array.6 weird.long_array.7 weird.long_array.8 weird.long_array.9 weird.func_ptr weird.func_ptr_struct weird.func_ptr_ptr weird.u1.a weird.u1.b weird.u1.c weird.u1.d weird.s2.u2.f weird.s2.g weird.s2.h weird.s2.i.0 weird.s2.i.1 weird.s2.i.2 weird.s2.i.3 weird.s2.i.4 weird.s2.i.5 weird.s2.i.6 weird.s2.i.7 weird.s2.i.8 weird.s2.i.9} {weird.s2.i weird.s2.u2 weird weird.s2.u2.u1s1 weird.s2.u2.u1s2 weird.s2 weird.long_array weird.u1} {}} | |
355 | ||
356 | mi_gdb_test "-var-delete weird" \ | |
357 | "\\^done,ndeleted=\"12\"" \ | |
358 | "delete var weird" | |
359 | ||
360 | ||
361 | ##### ##### | |
362 | # # | |
363 | # Special Display Tests # | |
364 | # # | |
365 | ##### ##### | |
366 | ||
367 | # Stop in "do_special_tests" | |
469aff8e | 368 | |
6c2d1a6b | 369 | set line_dst_incr_a_2 [gdb_get_line_number "incr_a(2);"] |
469aff8e | 370 | |
d24317b4 VP |
371 | mi_create_breakpoint "$line_dst_incr_a_2" 2 keep do_special_tests ".*var-cmd.c" $line_dst_incr_a_2 $hex \ |
372 | "break-insert operation 2" | |
2fcf52f0 | 373 | |
18ac113b AR |
374 | mi_execute_to "exec-continue" "breakpoint-hit" "do_special_tests" "" \ |
375 | ".*var-cmd.c" $line_dst_incr_a_2 { "" "disp=\"keep\"" } \ | |
bb378428 | 376 | "continue to do_special_tests" |
2fcf52f0 AC |
377 | |
378 | # Test: c_variable-7.10 | |
379 | # Desc: create union u | |
9e8e3afe | 380 | mi_create_varobj u u "create local variable u" |
2fcf52f0 AC |
381 | |
382 | # Test: c_variable-7.11 | |
383 | # Desc: value of u | |
384 | mi_gdb_test "-var-evaluate-expression u" \ | |
385 | "\\^done,value=\"\{\\.\\.\\.\}\"" \ | |
386 | "eval variable u" | |
387 | ||
388 | # Test: c_variable-7.12 | |
389 | # Desc: type of u | |
390 | mi_gdb_test "-var-info-type u" \ | |
391 | "\\^done,type=\"union named_union\"" \ | |
392 | "info type variable u" | |
393 | ||
394 | # Test: c_variable-7.13 | |
395 | # Desc: is u editable | |
396 | mi_gdb_test "-var-show-attributes u" \ | |
397 | "\\^done,attr=\"noneditable\"" \ | |
398 | "is u editable" | |
399 | ||
400 | # Test: c_variable-7.14 | |
401 | # Desc: number of children of u | |
402 | mi_gdb_test "-var-info-num-children u" \ | |
403 | "\\^done,numchild=\"2\"" \ | |
404 | "get number of children of u" | |
405 | ||
406 | # Test: c_variable-7.15 | |
407 | # Desc: children of u | |
9e8e3afe VP |
408 | mi_list_varobj_children u { |
409 | {u.integer integer 0 int} | |
410 | {u.char_ptr char_ptr 1 {char \*}} | |
411 | } "get children of u" | |
2fcf52f0 AC |
412 | |
413 | # Test: c_variable-7.20 | |
414 | # Desc: create anonu | |
9e8e3afe | 415 | mi_create_varobj anonu anonu "create local variable anonu" |
2fcf52f0 AC |
416 | |
417 | # Test: c_variable-7.21 | |
418 | # Desc: value of anonu | |
419 | mi_gdb_test "-var-evaluate-expression anonu" \ | |
420 | "\\^done,value=\"\{\\.\\.\\.\}\"" \ | |
421 | "eval variable anonu" | |
422 | ||
423 | # Test: c_variable-7.22 | |
424 | # Desc: type of anonu | |
425 | mi_gdb_test "-var-info-type anonu" \ | |
426 | "\\^done,type=\"union \{\\.\\.\\.\}\"" \ | |
427 | "info type variable anonu" | |
428 | ||
429 | # Test: c_variable-7.23 | |
430 | # Desc: is anonu editable | |
431 | mi_gdb_test "-var-show-attributes anonu" \ | |
432 | "\\^done,attr=\"noneditable\"" \ | |
433 | "is anonu editable" | |
434 | ||
435 | # Test: c_variable-7.24 | |
436 | # Desc: number of children of anonu | |
437 | mi_gdb_test "-var-info-num-children anonu" \ | |
438 | "\\^done,numchild=\"3\"" \ | |
439 | "get number of children of anonu" | |
440 | ||
441 | # Test: c_variable-7.25 | |
442 | # Desc: children of anonu | |
9e8e3afe VP |
443 | mi_list_varobj_children "anonu" { |
444 | {anonu.a a 0 int} | |
445 | {anonu.b b 0 char} | |
446 | {anonu.c c 0 "long int"} | |
447 | } "get children of anonu" | |
2fcf52f0 AC |
448 | |
449 | # Test: c_variable-7.30 | |
450 | # Desc: create struct s | |
9e8e3afe | 451 | mi_create_varobj s s "create local variable s" |
3fddb3ad | 452 | |
2fcf52f0 AC |
453 | |
454 | # Test: c_variable-7.31 | |
455 | # Desc: value of s | |
456 | mi_gdb_test "-var-evaluate-expression s" \ | |
457 | "\\^done,value=\"\{\\.\\.\\.\}\"" \ | |
458 | "eval variable s" | |
459 | ||
460 | # Test: c_variable-7.32 | |
461 | # Desc: type of s | |
462 | mi_gdb_test "-var-info-type s" \ | |
463 | "\\^done,type=\"struct _simple_struct\"" \ | |
464 | "info type variable s" | |
465 | ||
466 | # Test: c_variable-7.33 | |
467 | # Desc: is s editable | |
468 | mi_gdb_test "-var-show-attributes s" \ | |
469 | "\\^done,attr=\"noneditable\"" \ | |
470 | "is s editable" | |
471 | ||
472 | # Test: c_variable-7.34 | |
473 | # Desc: number of children of s | |
474 | mi_gdb_test "-var-info-num-children s" \ | |
475 | "\\^done,numchild=\"6\"" \ | |
476 | "get number of children of s" | |
477 | ||
478 | # Test: c_variable-7.35 | |
479 | # Desc: children of s | |
9e8e3afe VP |
480 | mi_list_varobj_children s { |
481 | {s.integer integer 0 int} | |
482 | {s.unsigned_integer unsigned_integer 0 "unsigned int"} | |
483 | {s.character character 0 char} | |
484 | {s.signed_character signed_character 0 "signed char"} | |
485 | {s.char_ptr char_ptr 1 {char \*}} | |
486 | {s.array_of_10 array_of_10 10 {int \[10\]}} | |
487 | } "get children of s" | |
2fcf52f0 AC |
488 | #} {integer unsigned_integer character signed_character char_ptr array_of_10} |
489 | ||
490 | # Test: c_variable-7.40 | |
491 | # Desc: create anons | |
9e8e3afe | 492 | mi_create_varobj anons anons "create local variable anons" |
2fcf52f0 AC |
493 | |
494 | # Test: c_variable-7.41 | |
495 | # Desc: value of anons | |
496 | mi_gdb_test "-var-evaluate-expression anons" \ | |
497 | "\\^done,value=\"\{\\.\\.\\.\}\"" \ | |
498 | "eval variable anons" | |
499 | ||
500 | # Test: c_variable-7.42 | |
501 | # Desc: type of anons | |
502 | mi_gdb_test "-var-info-type anons" \ | |
503 | "\\^done,type=\"struct \{\\.\\.\\.\}\"" \ | |
504 | "info type variable anons" | |
505 | ||
506 | # Test: c_variable-7.43 | |
507 | # Desc: is anons editable | |
508 | mi_gdb_test "-var-show-attributes anons" \ | |
509 | "\\^done,attr=\"noneditable\"" \ | |
510 | "is anons editable" | |
511 | ||
512 | # Test: c_variable-7.44 | |
513 | # Desc: number of children of anons | |
514 | mi_gdb_test "-var-info-num-children anons" \ | |
515 | "\\^done,numchild=\"3\"" \ | |
516 | "get number of children of anons" | |
517 | ||
518 | # Test: c_variable-7.45 | |
519 | # Desc: children of anons | |
9e8e3afe VP |
520 | mi_list_varobj_children anons { |
521 | {anons.a a 0 int} | |
522 | {anons.b b 0 char} | |
523 | {anons.c c 0 "long int"} | |
524 | } "get children of anons" | |
2fcf52f0 AC |
525 | |
526 | # Test: c_variable-7.50 | |
527 | # Desc: create enum e | |
9e8e3afe | 528 | mi_create_varobj e e "create local variable e" |
2fcf52f0 | 529 | |
2fcf52f0 AC |
530 | # Test: c_variable-7.51 |
531 | # Desc: value of e | |
532 | mi_gdb_test "-var-evaluate-expression e" \ | |
56767571 | 533 | "\\^done,value=\"bar\"" \ |
2fcf52f0 | 534 | "eval variable e" |
2fcf52f0 AC |
535 | |
536 | # Test: c_variable-7.52 | |
537 | # Desc: type of e | |
538 | mi_gdb_test "-var-info-type e" \ | |
539 | "\\^done,type=\"enum foo\"" \ | |
540 | "info type variable e" | |
541 | ||
542 | # Test: c_variable-7.53 | |
543 | # Desc: is e editable | |
544 | mi_gdb_test "-var-show-attributes e" \ | |
545 | "\\^done,attr=\"editable\"" \ | |
546 | "is e editable" | |
547 | ||
548 | # Test: c_variable-7.54 | |
549 | # Desc: number of children of e | |
550 | mi_gdb_test "-var-info-num-children e" \ | |
551 | "\\^done,numchild=\"0\"" \ | |
552 | "get number of children of e" | |
553 | ||
554 | # Test: c_variable-7.55 | |
555 | # Desc: children of e | |
556 | mi_gdb_test "-var-list-children e" \ | |
0cc7d26f | 557 | "\\^done,numchild=\"0\",has_more=\"0\"" \ |
2fcf52f0 AC |
558 | "get children of e" |
559 | ||
560 | # Test: c_variable-7.60 | |
561 | # Desc: create anone | |
9e8e3afe | 562 | mi_create_varobj anone anone "create local variable anone" |
2fcf52f0 | 563 | |
2fcf52f0 AC |
564 | # Test: c_variable-7.61 |
565 | # Desc: value of anone | |
566 | mi_gdb_test "-var-evaluate-expression anone" \ | |
567 | "\\^done,value=\"A\"" \ | |
568 | "eval variable anone" | |
2fcf52f0 AC |
569 | |
570 | # Test: c_variable-7.70 | |
571 | # Desc: create anone | |
572 | mi_gdb_test "-var-create anone * anone" \ | |
a13e061a | 573 | "\\^error,msg=\"Duplicate variable object name\"" \ |
2fcf52f0 AC |
574 | "create duplicate local variable anone" |
575 | ||
576 | ||
577 | # Test: c_variable-7.72 | |
578 | # Desc: type of anone | |
579 | mi_gdb_test "-var-info-type anone" \ | |
580 | "\\^done,type=\"enum \{\\.\\.\\.\}\"" \ | |
581 | "info type variable anone" | |
582 | ||
583 | ||
584 | # Test: c_variable-7.73 | |
585 | # Desc: is anone editable | |
586 | mi_gdb_test "-var-show-attributes anone" \ | |
587 | "\\^done,attr=\"editable\"" \ | |
588 | "is anone editable" | |
589 | ||
590 | # Test: c_variable-7.74 | |
591 | # Desc: number of children of anone | |
592 | mi_gdb_test "-var-info-num-children anone" \ | |
593 | "\\^done,numchild=\"0\"" \ | |
594 | "get number of children of anone" | |
595 | ||
596 | # Test: c_variable-7.75 | |
597 | # Desc: children of anone | |
598 | mi_gdb_test "-var-list-children anone" \ | |
0cc7d26f | 599 | "\\^done,numchild=\"0\",has_more=\"0\"" \ |
2fcf52f0 AC |
600 | "get children of anone" |
601 | ||
602 | ||
603 | # Record fp | |
9497469f MP |
604 | if ![mi_gdb_test "p/x \$fp" ".*($hex).*\\^done" "print FP register"] { |
605 | set fp $expect_out(3,string) | |
2fcf52f0 AC |
606 | } |
607 | ||
bb378428 | 608 | mi_continue_to "incr_a" |
2fcf52f0 AC |
609 | |
610 | # Test: c_variable-7.81 | |
611 | # Desc: Create variables in different scopes | |
3fddb3ad | 612 | mi_gdb_test "-var-create a1 * a" \ |
9e8e3afe | 613 | "\\^done,name=\"a1\",numchild=\"0\",value=\".*\",type=\"char\".*" \ |
3fddb3ad | 614 | "create local variable a1" |
2fcf52f0 AC |
615 | |
616 | mi_gdb_test "-var-create a2 $fp a" \ | |
9e8e3afe | 617 | "\\^done,name=\"a2\",numchild=\"0\",value=\".*\",type=\"int\".*" \ |
2fcf52f0 AC |
618 | "create variable a2 in different scope" |
619 | ||
620 | #gdbtk_test c_variable-7.81 {create variables in different scopes} { | |
621 | # set a1 [gdb_variable create -expr a] | |
622 | # set a2 [gdb_variable create -expr a -frame $fp] | |
623 | ||
624 | # set vals {} | |
625 | # lappend vals [$a1 value] | |
626 | # lappend vals [$a2 value] | |
627 | # set vals | |
628 | #} {2 1} | |
629 | ||
630 | ||
631 | mi_gdb_exit | |
632 | return 0 |