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