]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.mi/mi-var-cmd.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-var-cmd.exp
1 # Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007
2 # Free Software Foundation, Inc.
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
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
25 set MIFLAGS "-i=mi"
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}] != "" } {
36 untested mi-var-cmd.exp
37 return -1
38 }
39
40 mi_delete_breakpoints
41 mi_gdb_reinitialize_dir $srcdir/$subdir
42 mi_gdb_load ${binfile}
43
44
45 ##### #####
46 # #
47 # Variable Creation tests #
48 # #
49 ##### #####
50
51 # Test: c_variable-1.1
52 # Desc: Create global variable
53
54 mi_gdb_test "111-var-create global_simple * global_simple" \
55 "111\\^done,name=\"global_simple\",numchild=\"6\",type=\"simpleton\"" \
56 "create global variable"
57
58 # Test: c_variable-1.2
59 # Desc: Create non-existent variable
60
61 mi_gdb_test "112-var-create bogus_unknown_variable * bogus_unknown_variable" \
62 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*112\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
63 "create non-existent variable"
64
65 # Test: c_variable-1.3
66 # Desc: Create out of scope variable
67
68 mi_gdb_test "113-var-create argc * argc" \
69 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*113\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
70 "create out of scope variable"
71
72 mi_runto do_locals_tests
73
74 # Test: c_variable-1.4
75 # Desc: create local variables
76
77 mi_gdb_test "-var-create linteger * linteger" \
78 "\\^done,name=\"linteger\",numchild=\"0\",type=\"int\"" \
79 "create local variable linteger"
80
81 mi_gdb_test "-var-create lpinteger * lpinteger" \
82 "\\^done,name=\"lpinteger\",numchild=\"1\",type=\"int \\*\"" \
83 "create local variable lpinteger"
84
85 mi_gdb_test "-var-create lcharacter * lcharacter" \
86 "\\^done,name=\"lcharacter\",numchild=\"0\",type=\"char\"" \
87 "create local variablelcharacter "
88
89 mi_gdb_test "-var-create lpcharacter * lpcharacter" \
90 "\\^done,name=\"lpcharacter\",numchild=\"1\",type=\"char \\*\"" \
91 "create local variable lpcharacter"
92
93 mi_gdb_test "-var-create llong * llong" \
94 "\\^done,name=\"llong\",numchild=\"0\",type=\"long int\"" \
95 "create local variable llong"
96
97 mi_gdb_test "-var-create lplong * lplong" \
98 "\\^done,name=\"lplong\",numchild=\"1\",type=\"long int \\*\"" \
99 "create local variable lplong"
100
101 mi_gdb_test "-var-create lfloat * lfloat" \
102 "\\^done,name=\"lfloat\",numchild=\"0\",type=\"float\"" \
103 "create local variable lfloat"
104
105 mi_gdb_test "-var-create lpfloat * lpfloat" \
106 "\\^done,name=\"lpfloat\",numchild=\"1\",type=\"float \\*\"" \
107 "create local variable lpfloat"
108
109 mi_gdb_test "-var-create ldouble * ldouble" \
110 "\\^done,name=\"ldouble\",numchild=\"0\",type=\"double\"" \
111 "create local variable ldouble"
112
113 mi_gdb_test "-var-create lpdouble * lpdouble" \
114 "\\^done,name=\"lpdouble\",numchild=\"1\",type=\"double \\*\"" \
115 "create local variable lpdouble"
116
117 mi_gdb_test "-var-create lsimple * lsimple" \
118 "\\^done,name=\"lsimple\",numchild=\"6\",type=\"struct _simple_struct\"" \
119 "create local variable lsimple"
120
121 mi_gdb_test "-var-create lpsimple * lpsimple" \
122 "\\^done,name=\"lpsimple\",numchild=\"6\",type=\"struct _simple_struct \\*\"" \
123 "create local variable lpsimple"
124
125 mi_gdb_test "-var-create func * func" \
126 "\\^done,name=\"func\",numchild=\"0\",type=\"void \\(\\*\\)\\((void|)\\)\"" \
127 "create local variable func"
128
129 # Test: c_variable-1.5
130 # Desc: create lsimple.character
131 mi_gdb_test "-var-create lsimple.character * lsimple.character" \
132 "\\^done,name=\"lsimple.character\",numchild=\"0\",type=\"char\"" \
133 "create lsimple.character"
134
135 # Test: c_variable-1.6
136 # Desc: create lpsimple->integer
137 mi_gdb_test "-var-create lsimple->integer * lsimple->integer" \
138 "\\^done,name=\"lsimple->integer\",numchild=\"0\",type=\"int\"" \
139 "create lsimple->integer"
140
141 # Test: c_variable-1.7
142 # Desc: ceate lsimple.integer
143 mi_gdb_test "-var-create lsimple.integer * lsimple.integer" \
144 "\\^done,name=\"lsimple.integer\",numchild=\"0\",type=\"int\"" \
145 "create lsimple->integer"
146
147
148 # Test: c_variable-1.9
149 # Desc: create type name
150 # Type names (like int, long, etc..) are all proper expressions to gdb.
151 # make sure variable code does not allow users to create variables, though.
152 mi_gdb_test "-var-create int * int" \
153 "&\"Attempt to use a type name as an expression.\\\\n\".*&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
154 "create int"
155
156
157 ##### #####
158 # #
159 # Value changed tests #
160 # #
161 ##### #####
162
163 # Test: c_variable-2.1
164 # Desc: check whether values changed at do_block_tests
165 mi_gdb_test "-var-update *" \
166 "\\^done,changelist=\\\[\\\]" \
167 "update all vars"
168
169 # Step over "linteger = 1234;"
170 set line_dlt_linteger [gdb_get_line_number "lpinteger = &linteger;"]
171 mi_step_to "do_locals_tests" "" "var-cmd.c" $line_dlt_linteger "step at do_locals_test"
172
173 # Test: c_variable-2.2
174 # Desc: check whether only linteger changed values
175 mi_gdb_test "-var-update *" \
176 "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
177 "update all vars: linteger changed"
178
179 # Step over "lpinteger = &linteger;"
180 mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 1] "step at do_locals_tests (2)"
181
182 # Test: c_variable-2.3
183 # Desc: check whether only lpinteger changed
184 mi_gdb_test "-var-update *" \
185 "\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
186 "update all vars: lpinteger changed"
187
188 # Step over "lcharacter = 'a';"
189 mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 2] "step at do_locals_tests (3)"
190
191 # Test: c_variable-2.4
192 # Desc: check whether only lcharacter changed
193 mi_gdb_test "-var-update *" \
194 "\\^done,changelist=\\\[\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
195 "update all vars: lcharacter changed"
196
197 # Step over "lpcharacter = &lcharacter;"
198 mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 3] "step at do_locals_tests (4)"
199
200 # Test: c_variable-2.5
201 # Desc: check whether only lpcharacter changed
202 mi_gdb_test "-var-update *" \
203 "\\^done,changelist=\\\[\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
204 "update all vars: lpcharacter changed"
205
206
207 # Step over:
208 # llong = 2121L;
209 # lplong = &llong;
210 # lfloat = 2.1;
211 # lpfloat = &lfloat;
212 # ldouble = 2.718281828459045;
213 # lpdouble = &ldouble;
214 # lsimple.integer = 1234;
215 # lsimple.unsigned_integer = 255;
216 # lsimple.character = 'a';
217
218 mi_execute_to "exec-step 9" "end-stepping-range" "do_locals_tests" "" \
219 "var-cmd.c" [expr $line_dlt_linteger + 12] "" "step at do_locals_tests (5)"
220
221 # Test: c_variable-2.6
222 # Desc: check whether llong, lplong, lfloat, lpfloat, ldouble, lpdouble, lsimple.integer,
223 # lsimple.unsigned_character lsimple.integer lsimple.character changed
224 mi_gdb_test "-var-update *" \
225 "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpdouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lplong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
226 "update all vars: many changed"
227
228 # Step over:
229 # lsimple.signed_character = 21;
230 # lsimple.char_ptr = &lcharacter;
231 # lpsimple = &lsimple;
232 # func = nothing;
233
234 set line_dlt_4321 [gdb_get_line_number "linteger = 4321;"]
235
236 mi_execute_to "exec-step 4" "end-stepping-range" "do_locals_tests" "" \
237 "var-cmd.c" $line_dlt_4321 "" "step at do_locals_tests (6)"
238
239 # Test: c_variable-2.7
240 # Desc: check whether (lsimple.signed_character, lsimple.char_ptr) lpsimple, func changed
241 mi_gdb_test "-var-update *" \
242 "\\^done,changelist=\\\[\{name=\"func\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpsimple\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
243 "update all vars: func and lpsimple changed"
244
245 # Step over
246 # linteger = 4321;
247 # lcharacter = 'b';
248 # llong = 1212L;
249 # lfloat = 1.2;
250 # ldouble = 5.498548281828172;
251 # lsimple.integer = 255;
252 # lsimple.unsigned_integer = 4321;
253 # lsimple.character = 'b';
254
255 mi_execute_to "exec-step 8" "end-stepping-range" "do_locals_tests" "" \
256 "var-cmd.c" [expr $line_dlt_4321 + 8] "" "step at do_locals_tests (7)"
257
258 # Test: c_variable-2.8
259 # Desc: check whether linteger, lcharacter, llong, lfoat, ldouble, lsimple.integer,
260 # lpsimple.integer lsimple.character changed
261 # Note: this test also checks that lpsimple->integer and lsimple.integer have
262 # changed (they are the same)
263 mi_gdb_test "-var-update *" \
264 "\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
265 "update all vars: lsimple and others changed"
266
267
268 ###
269 #
270 # Test assignment to variables. More tests on assignment are in other files.
271 #
272 ###
273 mi_gdb_test "-var-assign global_simple 0" \
274 "&\"mi_cmd_var_assign: Variable object is not editable\\\\n\".*\\^error,msg=\"mi_cmd_var_assign: Variable object is not editable\"" \
275 "assign to global_simple"
276
277 mi_gdb_test "-var-assign linteger 3333" \
278 "\\^done,value=\"3333\"" \
279 "assign to linteger"
280
281 # Allow lpcharacter to update, optionally. Because it points to a
282 # char variable instead of a zero-terminated string, if linteger is
283 # directly after it in memory the printed characters may appear to
284 # change.
285 set lpchar_update "\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\},"
286 mi_gdb_test "-var-update *" \
287 "\\^done,changelist=\\\[($lpchar_update)?\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
288 "update all vars: linteger changed after assign"
289
290 mi_gdb_test "-var-assign linteger 3333" \
291 "\\^done,value=\"3333\"" \
292 "assign to linteger again, same value"
293
294 mi_gdb_test "-var-update *" \
295 "\\^done,changelist=\\\[\\\]" \
296 "update all vars: linteger not changed after same assign"
297
298 mi_gdb_test "-var-evaluate-expression linteger" \
299 "\\^done,value=\"3333\"" \
300 "eval linteger"
301
302 mi_gdb_test "-var-assign lpinteger \"&linteger + 3\"" \
303 "\\^done,value=\"$hex\"" \
304 "assign to lpinteger"
305
306 mi_gdb_test "-var-update *" \
307 "\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
308 "update all vars: lpinteger changed after assign"
309
310 mi_gdb_test "-var-update *" \
311 "\\^done,changelist=\\\[\\\]" \
312 "update all vars: no changes on second update"
313
314 mi_gdb_test "-var-evaluate-expression lpinteger" \
315 "\\^done,value=\"$hex\"" \
316 "eval lpinteger"
317
318 # reset the values to the original ones so that the rest of the file doesn't suffer.
319
320 mi_gdb_test "-var-assign linteger 4321" \
321 "\\^done,value=\"4321\"" \
322 "assign to linteger"
323
324 mi_gdb_test "-var-assign lpinteger &linteger" \
325 "\\^done,value=\"$hex\"" \
326 "assign to lpinteger"
327
328 mi_gdb_test "-var-assign lcharacter 'z'" \
329 "\\^done,value=\"122 'z'\"" \
330 "assign to lcharacter"
331
332 mi_gdb_test "-var-evaluate-expression lcharacter" \
333 "\\^done,value=\"122 'z'\"" \
334 "eval lcharacter"
335
336 mi_gdb_test "-var-assign llong 1313L" \
337 "\\^done,value=\"1313\"" \
338 "assign to llong"
339 mi_gdb_test "-var-evaluate-expression llong" \
340 "\\^done,value=\"1313\"" \
341 "eval llong"
342 mi_gdb_test "-var-assign llong 1212L" \
343 "\\^done,value=\"1212\"" \
344 "assign to llong"
345
346 mi_gdb_test "-var-assign lplong &llong+4" \
347 "\\^done,value=\"$hex\"" \
348 "assign to lplong"
349 mi_gdb_test "-var-evaluate-expression lplong" \
350 "\\^done,value=\"$hex\"" \
351 "eval lplong"
352 mi_gdb_test "-var-assign lplong &llong" \
353 "\\^done,value=\"$hex\"" \
354 "assign to lplong"
355
356 mi_gdb_test "-var-assign lfloat 3.4567" \
357 "\\^done,value=\"3.45.*\"" \
358 "assign to lfloat"
359 mi_gdb_test "-var-evaluate-expression lfloat" \
360 "\\^done,value=\"3.45.*\"" \
361 "eval lfloat"
362 mi_gdb_test "-var-assign lfloat 1.2345" \
363 "\\^done,value=\"1.23.*\"" \
364 "assign to lfloat"
365
366 mi_gdb_test "-var-assign lpfloat &lfloat+4" \
367 "\\^done,value=\"$hex\"" \
368 "assign to lpfloat"
369
370 mi_gdb_test "-var-assign ldouble 5.333318284590435" \
371 "\\^done,value=\"5.333318284590435\"" \
372 "assign to ldouble"
373
374 mi_gdb_test "-var-assign func do_block_tests" \
375 "\\^done,value=\"$hex <do_block_tests>\"" \
376 "assign to func"
377
378 mi_gdb_test "-var-assign lsimple.character 'd'" \
379 "\\^done,value=\"100 'd'\"" \
380 "assign to lsimple.character"
381
382 mi_gdb_test "-var-assign lsimple->integer 222" \
383 "\\^done,value=\"222\"" \
384 "assign to lsimple->integer"
385
386 mi_gdb_test "-var-assign lsimple.integer 333" \
387 "\\^done,value=\"333\"" \
388 "assign to lsimple.integer"
389
390 mi_gdb_test "-var-update *" \
391 "\\^done,changelist=.*" \
392 "var update"
393
394 # Check that assignment of function and array values
395 # promotes the assigned value to function pointer/data
396 # pointer before comparing with the existing value,
397 # and does not incorrectly make the value as changed.
398 mi_gdb_test "-var-assign func do_block_tests" \
399 "\\^done,value=\"$hex <do_block_tests>\"" \
400 "assign same value to func"
401
402 mi_gdb_test "-var-update *" \
403 "\\^done,changelist=\\\[\\\]" \
404 "assign same value to func (update)"
405
406 mi_gdb_test "-var-create array_ptr * array_ptr" \
407 "\\^done,name=\"array_ptr\",numchild=\"1\",type=\"int \\*\"" \
408 "create global variable array_ptr"
409
410 mi_gdb_test "-var-assign array_ptr array2" \
411 "\\^done,value=\"$hex\"" \
412 "assign array to pointer"
413
414 mi_gdb_test "-var-update *" \
415 "\\^done,changelist=\\\[\{name=\"array_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
416 "assign array to pointer (update)"
417
418 mi_gdb_test "-var-assign array_ptr array2" \
419 "\\^done,value=\"$hex\"" \
420 "assign same array to pointer"
421
422 mi_gdb_test "-var-update *" \
423 "\\^done,changelist=\\\[\\\]" \
424 "assign same array to pointer (update)"
425
426
427 ######
428 # End of assign tests
429 #####
430
431 set line_subroutine1_body [gdb_get_line_number "global_simple.integer = i + 3;"]
432
433 mi_continue_to subroutine1
434
435 # Test: c_variable-2.10
436 # Desc: create variable for locals i,l in subroutine1
437 mi_gdb_test "-var-create i * i" \
438 "\\^done,name=\"i\",numchild=\"0\",type=\"int\"" \
439 "create i"
440
441 mi_gdb_test "-var-create l * l" \
442 "\\^done,name=\"l\",numchild=\"1\",type=\"long int \\*\"" \
443 "create l"
444
445 # Test: c_variable-2.11
446 # Desc: create do_locals_tests local in subroutine1
447 mi_gdb_test "-var-create linteger * linteger" \
448 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
449 "create linteger"
450
451 mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
452 "var-cmd.c" [expr $line_subroutine1_body + 1] "step at subroutine1"
453
454 # Test: c_variable-2.12
455 # Desc: change global_simple.integer
456 # Note: This also tests whether we are reporting changes in structs properly.
457 # gdb normally would say that global_simple has changed, but we
458 # special case that, since it is not what a human expects to
459 # see.
460
461 setup_xfail *-*-*
462 mi_gdb_test "-var-update *" \
463 "\\^done,changelist=\{FIXME: WHAT IS CORRECT HERE\}" \
464 "update all vars: changed FIXME"
465 clear_xfail *-*-*
466
467 mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
468 "var-cmd.c" [expr $line_subroutine1_body + 2] "step at subroutine1 (2)"
469
470 # Test: c_variable-2.13
471 # Desc: change subroutine1 local i
472 mi_gdb_test "-var-update *" \
473 "\\^done,changelist=\\\[\{name=\"i\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
474 "update all vars: i changed"
475
476 mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
477 "var-cmd.c" [expr $line_subroutine1_body + 3] "step at subroutine1 (3)"
478
479 # Test: c_variable-2.14
480 # Desc: change do_locals_tests local llong
481 mi_gdb_test "-var-update *" \
482 "\\^done,changelist=\\\[\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
483 "update all vars: llong changed"
484
485 set line_dlt_call_subroutine1 [gdb_get_line_number "subroutine1 (linteger, &llong);"]
486 mi_next_to "do_locals_tests" "" "var-cmd.c" \
487 [expr $line_dlt_call_subroutine1 + 1] "next out of subroutine1"
488
489 # Test: c_variable-2.15
490 # Desc: check for out of scope subroutine1 locals
491 mi_gdb_test "-var-update *" \
492 "\\^done,changelist=\\\[\{name=\"l\",in_scope=\"false\"\},\{name=\"i\",in_scope=\"false\"\}\\\]" \
493 "update all vars: all now out of scope"
494
495 # Done with locals/globals tests. Erase all variables
496 #delete_all_variables
497 mi_gdb_test "-var-delete global_simple" \
498 "\\^done,ndeleted=\"1\"" \
499 "delete var"
500
501 mi_gdb_test "-var-delete linteger" \
502 "\\^done,ndeleted=\"1\"" \
503 "delete var linteger"
504
505 mi_gdb_test "-var-delete lpinteger" \
506 "\\^done,ndeleted=\"1\"" \
507 "delete var lpinteger"
508
509 mi_gdb_test "-var-delete lcharacter" \
510 "\\^done,ndeleted=\"1\"" \
511 "delete var lcharacter"
512
513 mi_gdb_test "-var-delete lpcharacter" \
514 "\\^done,ndeleted=\"1\"" \
515 "delete var lpcharacter"
516
517 mi_gdb_test "-var-delete llong" \
518 "\\^done,ndeleted=\"1\"" \
519 "delete var llong"
520
521 mi_gdb_test "-var-delete lplong" \
522 "\\^done,ndeleted=\"1\"" \
523 "delete var lplong"
524
525 mi_gdb_test "-var-delete lfloat" \
526 "\\^done,ndeleted=\"1\"" \
527 "delete var lfloat"
528
529 mi_gdb_test "-var-delete lpfloat" \
530 "\\^done,ndeleted=\"1\"" \
531 "delete var lpfloat"
532
533 mi_gdb_test "-var-delete ldouble" \
534 "\\^done,ndeleted=\"1\"" \
535 "delete var ldouble"
536
537 mi_gdb_test "-var-delete lpdouble" \
538 "\\^done,ndeleted=\"1\"" \
539 "delete var lpdouble"
540
541 mi_gdb_test "-var-delete lsimple" \
542 "\\^done,ndeleted=\"1\"" \
543 "delete var lsimple"
544
545 mi_gdb_test "-var-delete lpsimple" \
546 "\\^done,ndeleted=\"1\"" \
547 "delete var lpsimple"
548
549 mi_gdb_test "-var-delete func" \
550 "\\^done,ndeleted=\"1\"" \
551 "delete var func"
552
553 mi_gdb_test "-var-delete lsimple.character" \
554 "\\^done,ndeleted=\"1\"" \
555 "delete var lsimple.character"
556
557 mi_gdb_test "-var-delete lsimple->integer" \
558 "\\^done,ndeleted=\"1\"" \
559 "delete var lsimple->integer"
560
561 mi_gdb_test "-var-delete lsimple.integer" \
562 "\\^done,ndeleted=\"1\"" \
563 "delete var lsimple.integer"
564
565 mi_gdb_test "-var-delete i" \
566 "\\^done,ndeleted=\"1\"" \
567 "delete var i"
568
569 mi_gdb_test "-var-delete l" \
570 "\\^done,ndeleted=\"1\"" \
571 "delete var l"
572
573 # Test whether we can follow the name of a variable through multiple
574 # stack frames.
575 mi_continue_to do_special_tests
576
577 mi_gdb_test "-var-create selected_a @ a" \
578 {\^done,name="selected_a",numchild="0",type="int"} \
579 "create selected_a"
580
581 mi_continue_to incr_a
582
583 mi_gdb_test "-var-update selected_a" \
584 "\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"char\",new_num_children=\"0\"\}\\\]" \
585 "update selected_a in incr_a"
586
587 mi_next "step a line in incr_a"
588 mi_next "return from incr_a to do_special_tests"
589
590 mi_gdb_test "-var-update selected_a" \
591 "\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"int\",new_num_children=\"0\"\}\\\]" \
592 "update selected_a in do_special_tests"
593
594 # Test whether bad varobjs crash GDB.
595
596 # A varobj we fail to read during -var-update should be considered
597 # out of scope.
598 mi_gdb_test "-var-create null_ptr * **0" \
599 {\^done,name="null_ptr",numchild="0",type="int"} \
600 "create null_ptr"
601
602 # Allow this to succeed, if address zero is readable, although it
603 # will not test what it was meant to. Most important is that GDB
604 # does not crash.
605 mi_gdb_test "-var-update null_ptr" \
606 {\^done,changelist=\[{.*}\]} \
607 "update null_ptr"
608
609 mi_gdb_test "-var-delete null_ptr" \
610 "\\^done,ndeleted=\"1\"" \
611 "delete null_ptr"
612
613 # When we fail to read a varobj created from a named variable,
614 # we evaluate its type instead. Make sure that doesn't blow
615 # up by trying to read it again. We can use _end when not running
616 # the program to simulate an unreadable variable, if this platform
617 # provides _end, but cope if it's missing.
618
619 mi_gdb_test "kill" \
620 {&"kill\\n".*\^done} \
621 "kill program before endvar"
622
623 mi_gdb_test "-var-create endvar * _end" \
624 {(\^done,name="endvar",numchild="0",type=".*"|&".*unable to.*".*\^error,msg=".*")} \
625 "create endvar"
626
627 # Allow this to succeed whether the value is readable, unreadable, or
628 # missing. Most important is that GDB does not crash.
629 mi_gdb_test "-var-update endvar" \
630 {(\^done,changelist=\[.*\]|^".*".*\^error,msg=".*not found")} \
631 "update endvar"
632
633 mi_gdb_test "-var-delete endvar" \
634 "\\^done,ndeleted=\"1\"" \
635 "delete endvar"
636
637 mi_gdb_exit
638 return 0