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