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