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