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