Commit | Line | Data |
---|---|---|
9b254dd1 | 1 | # Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 |
76ff342d | 2 | # Free Software Foundation, Inc. |
2fcf52f0 | 3 | # |
e22f8b7c | 4 | # This program is free software; you can redistribute it and/or modify |
2fcf52f0 | 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 |
2fcf52f0 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/>. |
2fcf52f0 | 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 | ||
23 | load_lib mi-support.exp | |
24 | set MIFLAGS "-i=mi2" | |
25 | ||
26 | gdb_exit | |
27 | if [mi_gdb_start] { | |
28 | continue | |
29 | } | |
30 | ||
31 | set testfile "var-cmd" | |
32 | set srcfile ${testfile}.c | |
33 | set binfile ${objdir}/${subdir}/${testfile} | |
34 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
b60f0898 JB |
35 | untested mi2-var-display.exp |
36 | return -1 | |
2fcf52f0 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 | |
e1c2defa NS |
45 | mi_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\"\}" \ | |
2fcf52f0 AC |
47 | "break-insert operation" |
48 | ||
49 | mi_run_cmd | |
50 | # The running part has been checked already by mi_run_cmd | |
51 | gdb_expect { | |
18e75969 | 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$" { |
2fcf52f0 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 | 67 | mi_create_varobj bar bar "create local variable bar" |
2fcf52f0 AC |
68 | |
69 | # Test: c_variable-6.2 | |
70 | # Desc: type of variable bar | |
71 | mi_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 | |
77 | mi_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 | |
83 | mi_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 | |
89 | mi_gdb_test "-var-set-format bar hexadecimal" \ | |
8a578dd7 | 90 | "\\^done,format=\"hexadecimal\",value=\"0x849\"" \ |
2fcf52f0 AC |
91 | "set format variable bar" |
92 | ||
93 | # Test: c_variable-6.6 | |
94 | # Desc: value of bar with new format | |
95 | mi_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 | |
101 | mi_gdb_test "-var-assign bar 3" \ | |
102 | "\\^done,value=\"0x3\"" \ | |
103 | "assing to variable bar" | |
104 | ||
105 | mi_gdb_test "-var-set-format bar decimal" \ | |
8a578dd7 | 106 | "\\^done,format=\"decimal\",value=\"3\"" \ |
2fcf52f0 AC |
107 | "set format variable bar" |
108 | ||
109 | mi_gdb_test "-var-evaluate-expression bar" \ | |
110 | "\\^done,value=\"3\"" \ | |
111 | "eval variable bar with new value" | |
112 | ||
113 | mi_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 | 119 | mi_create_varobj foo foo "create local variable foo" |
2fcf52f0 AC |
120 | |
121 | # Test: c_variable-6.12 | |
122 | # Desc: type of variable foo | |
123 | mi_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 | |
129 | mi_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 | |
135 | mi_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 | |
141 | mi_gdb_test "-var-set-format foo octal" \ | |
8a578dd7 | 142 | "\\^done,format=\"octal\",value=\"$octal\"" \ |
2fcf52f0 AC |
143 | "set format variable foo" |
144 | ||
145 | mi_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 | |
151 | mi_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 | |
157 | mi_gdb_test "-var-assign foo 3" \ | |
158 | "\\^done,value=\"03\"" \ | |
159 | "assing to variable foo" | |
160 | ||
161 | mi_gdb_test "-var-set-format foo decimal" \ | |
8a578dd7 | 162 | "\\^done,format=\"decimal\",value=\"3\"" \ |
2fcf52f0 AC |
163 | "set format variable foo" |
164 | ||
165 | # Test: c_variable-6.18 | |
166 | # Desc: check new value of foo | |
167 | mi_gdb_test "-var-evaluate-expression foo" \ | |
168 | "\\^done,value=\"3\"" \ | |
169 | "eval variable foo" | |
170 | ||
171 | mi_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 |
177 | mi_create_varobj weird weird "create local variable weird" |
178 | ||
179 | mi_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" | |
2fcf52f0 AC |
194 | |
195 | ||
196 | # Test: c_variable-6.23 | |
197 | # Desc: change format of weird.func_ptr and weird.func_ptr_ptr | |
198 | mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ | |
8a578dd7 | 199 | "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ |
2fcf52f0 AC |
200 | "set format variable weird.func_ptr" |
201 | ||
202 | mi_gdb_test "-var-show-format weird.func_ptr" \ | |
203 | "\\^done,format=\"hexadecimal\"" \ | |
204 | "show format variable weird.func_ptr" | |
205 | ||
206 | mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \ | |
8a578dd7 | 207 | "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ |
2fcf52f0 AC |
208 | "set format variable weird.func_ptr_ptr" |
209 | ||
210 | mi_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 | |
216 | mi_gdb_test "-var-set-format weird natural" \ | |
8a578dd7 | 217 | "\\^done,format=\"natural\",value=\"$hex\"" \ |
2fcf52f0 AC |
218 | "set format variable weird" |
219 | ||
220 | mi_gdb_test "-var-set-format weird.integer natural" \ | |
8a578dd7 | 221 | "\\^done,format=\"natural\",value=\"123\"" \ |
2fcf52f0 AC |
222 | "set format variable weird.integer" |
223 | ||
224 | mi_gdb_test "-var-set-format weird.character natural" \ | |
8a578dd7 | 225 | "\\^done,format=\"natural\",value=\"0 '\\\\\\\\0'\"" \ |
2fcf52f0 AC |
226 | "set format variable weird.character" |
227 | ||
228 | mi_gdb_test "-var-set-format weird.char_ptr natural" \ | |
8a578dd7 | 229 | "\\^done,format=\"natural\",value=\"$hex \\\\\"hello\\\\\"\"" \ |
2fcf52f0 AC |
230 | "set format variable weird.char_ptr" |
231 | ||
232 | mi_gdb_test "-var-set-format weird.long_int natural" \ | |
8a578dd7 | 233 | "\\^done,format=\"natural\",value=\"0\"" \ |
2fcf52f0 AC |
234 | "set format variable weird.long_int" |
235 | ||
236 | mi_gdb_test "-var-set-format weird.int_ptr_ptr natural" \ | |
8a578dd7 | 237 | "\\^done,format=\"natural\",value=\"$hex\"" \ |
2fcf52f0 AC |
238 | "set format variable weird.int_ptr_ptr" |
239 | ||
240 | mi_gdb_test "-var-set-format weird.long_array natural" \ | |
8a578dd7 | 241 | "\\^done,format=\"natural\",value=\"\\\[10\\\]\"" \ |
2fcf52f0 AC |
242 | "set format variable weird.long_array" |
243 | ||
244 | mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ | |
8a578dd7 | 245 | "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ |
2fcf52f0 AC |
246 | "set format variable weird.func_ptr" |
247 | ||
248 | mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \ | |
8a578dd7 | 249 | "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ |
2fcf52f0 AC |
250 | "set format variable weird.func_ptr_struct" |
251 | ||
252 | mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \ | |
8a578dd7 | 253 | "\\^done,format=\"natural\",value=\"0\"" \ |
2fcf52f0 AC |
254 | "set format variable weird.func_ptr_ptr" |
255 | ||
256 | mi_gdb_test "-var-set-format weird.u1 natural" \ | |
8a578dd7 | 257 | "\\^done,format=\"natural\",value=\"\{...\}\"" \ |
2fcf52f0 AC |
258 | "set format variable weird.u1" |
259 | ||
260 | mi_gdb_test "-var-set-format weird.s2 natural" \ | |
8a578dd7 | 261 | "\\^done,format=\"natural\",value=\"\{...\}\"" \ |
2fcf52f0 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 | ||
321 | mi_gdb_test "-var-delete weird" \ | |
322 | "\\^done,ndeleted=\"12\"" \ | |
323 | "delete var weird" | |
324 | ||
325 | ||
326 | ##### ##### | |
327 | # # | |
328 | # Special Display Tests # | |
329 | # # | |
330 | ##### ##### | |
331 | ||
332 | # Stop in "do_special_tests" | |
469aff8e | 333 | |
6c2d1a6b | 334 | set line_dst_incr_a_2 [gdb_get_line_number "incr_a(2);"] |
469aff8e | 335 | |
6c2d1a6b MK |
336 | mi_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\"\}" \ | |
2fcf52f0 AC |
338 | "break-insert operation" |
339 | ||
340 | send_gdb "-exec-continue\n" | |
341 | gdb_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$" { |
2fcf52f0 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 | 352 | mi_create_varobj u u "create local variable u" |
2fcf52f0 AC |
353 | |
354 | # Test: c_variable-7.11 | |
355 | # Desc: value of u | |
356 | mi_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 | |
362 | mi_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 | |
368 | mi_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 | |
374 | mi_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 |
380 | mi_list_varobj_children u { |
381 | {u.integer integer 0 int} | |
382 | {u.char_ptr char_ptr 1 {char \*}} | |
383 | } "get children of u" | |
2fcf52f0 AC |
384 | |
385 | # Test: c_variable-7.20 | |
386 | # Desc: create anonu | |
9e8e3afe | 387 | mi_create_varobj anonu anonu "create local variable anonu" |
2fcf52f0 AC |
388 | |
389 | # Test: c_variable-7.21 | |
390 | # Desc: value of anonu | |
391 | mi_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 | |
397 | mi_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 | |
403 | mi_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 | |
409 | mi_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 |
415 | mi_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" | |
2fcf52f0 AC |
420 | |
421 | # Test: c_variable-7.30 | |
422 | # Desc: create struct s | |
9e8e3afe | 423 | mi_create_varobj s s "create local variable s" |
3fddb3ad | 424 | |
2fcf52f0 AC |
425 | |
426 | # Test: c_variable-7.31 | |
427 | # Desc: value of s | |
428 | mi_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 | |
434 | mi_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 | |
440 | mi_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 | |
446 | mi_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 |
452 | mi_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" | |
2fcf52f0 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 | 464 | mi_create_varobj anons anons "create local variable anons" |
2fcf52f0 AC |
465 | |
466 | # Test: c_variable-7.41 | |
467 | # Desc: value of anons | |
468 | mi_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 | |
474 | mi_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 | |
480 | mi_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 | |
486 | mi_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 |
492 | mi_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" | |
2fcf52f0 AC |
497 | |
498 | # Test: c_variable-7.50 | |
499 | # Desc: create enum e | |
9e8e3afe | 500 | mi_create_varobj e e "create local variable e" |
2fcf52f0 AC |
501 | |
502 | setup_xfail "*-*-*" | |
503 | # Test: c_variable-7.51 | |
504 | # Desc: value of e | |
505 | mi_gdb_test "-var-evaluate-expression e" \ | |
506 | "\\^done,value=\"FIXME\"" \ | |
507 | "eval variable e" | |
508 | clear_xfail "*-*-*" | |
509 | ||
510 | # Test: c_variable-7.52 | |
511 | # Desc: type of e | |
512 | mi_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 | |
518 | mi_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 | |
524 | mi_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 | |
530 | mi_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 | 536 | mi_create_varobj anone anone "create local variable anone" |
2fcf52f0 | 537 | |
2fcf52f0 AC |
538 | # Test: c_variable-7.61 |
539 | # Desc: value of anone | |
540 | mi_gdb_test "-var-evaluate-expression anone" \ | |
541 | "\\^done,value=\"A\"" \ | |
542 | "eval variable anone" | |
2fcf52f0 AC |
543 | |
544 | # Test: c_variable-7.70 | |
545 | # Desc: create anone | |
546 | mi_gdb_test "-var-create anone * anone" \ | |
547 | "&\"Duplicate variable object name\\\\n\".*\\^error,msg=\"Duplicate variable object name\"" \ | |
548 | "create duplicate local variable anone" | |
549 | ||
550 | ||
551 | # Test: c_variable-7.72 | |
552 | # Desc: type of anone | |
553 | mi_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 | |
560 | mi_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 | |
566 | mi_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 | |
572 | mi_gdb_test "-var-list-children anone" \ | |
573 | "\\^done,numchild=\"0\"" \ | |
574 | "get children of anone" | |
575 | ||
576 | ||
577 | # Record fp | |
578 | ||
579 | send_gdb "p/x \$fp\n" | |
580 | gdb_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 |
589 | set line_incr_a_b_a [gdb_get_line_number "b = a;"] |
590 | ||
2fcf52f0 | 591 | mi_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\"\}" \ |
2fcf52f0 AC |
593 | "break-insert operation" |
594 | send_gdb "-exec-continue\n" | |
595 | gdb_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$" { |
2fcf52f0 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$" { |
2fcf52f0 AC |
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 | } | |
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 | 612 | mi_gdb_test "-var-create a1 * a" \ |
9e8e3afe | 613 | "\\^done,name=\"a1\",numchild=\"0\",value=\".*\",type=\"char\".*" \ |
3fddb3ad | 614 | "create local variable a1" |
2fcf52f0 AC |
615 | |
616 | mi_gdb_test "-var-create a2 $fp a" \ | |
9e8e3afe | 617 | "\\^done,name=\"a2\",numchild=\"0\",value=\".*\",type=\"int\".*" \ |
2fcf52f0 AC |
618 | "create variable a2 in different scope" |
619 | ||
620 | #gdbtk_test c_variable-7.81 {create variables in different scopes} { | |
621 | # set a1 [gdb_variable create -expr a] | |
622 | # set a2 [gdb_variable create -expr a -frame $fp] | |
623 | ||
624 | # set vals {} | |
625 | # lappend vals [$a1 value] | |
626 | # lappend vals [$a2 value] | |
627 | # set vals | |
628 | #} {2 1} | |
629 | ||
630 | ||
631 | mi_gdb_exit | |
632 | return 0 |