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