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