1 # Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007
2 # Free Software Foundation, Inc.
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 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Test essential Machine interface (MI) operations
19 # Verify that, using the MI, we can create, update, delete variables.
23 load_lib mi-support.exp
31 set testfile "var-cmd"
32 set srcfile ${testfile}.c
33 set binfile ${objdir}/${subdir}/${testfile}
34 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
35 untested mi-var-cmd.exp
40 mi_gdb_reinitialize_dir $srcdir/$subdir
41 mi_gdb_load ${binfile}
46 # Variable Creation tests #
50 # Test: c_variable-1.1
51 # Desc: Create global variable
53 mi_gdb_test "111-var-create global_simple * global_simple" \
54 "111\\^done,name=\"global_simple\",numchild=\"6\",value=\"{...}\",type=\"simpleton\"" \
55 "create global variable"
57 # Test: c_variable-1.2
58 # Desc: Create non-existent variable
60 mi_gdb_test "112-var-create bogus_unknown_variable * bogus_unknown_variable" \
61 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*112\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
62 "create non-existent variable"
64 # Test: c_variable-1.3
65 # Desc: Create out of scope variable
67 mi_gdb_test "113-var-create argc * argc" \
68 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*113\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
69 "create out of scope variable"
71 mi_runto do_locals_tests
73 set line_dlt_first_real [gdb_get_line_number "linteger = 1234;"]
75 mi_continue_to_line $line_dlt_first_real "step to real start of do_locals_test"
78 # Test: c_variable-1.4
79 # Desc: create local variables
81 mi_gdb_test "-var-create linteger * linteger" \
82 "\\^done,name=\"linteger\",numchild=\"0\",value=\".*\",type=\"int\"" \
83 "create local variable linteger"
85 mi_gdb_test "-var-create lpinteger * lpinteger" \
86 "\\^done,name=\"lpinteger\",numchild=\"1\",value=\"$hex\",type=\"int \\*\"" \
87 "create local variable lpinteger"
89 mi_gdb_test "-var-create lcharacter * lcharacter\[0\]" \
90 "\\^done,name=\"lcharacter\",numchild=\"0\",value=\".*\",type=\"char\"" \
91 "create local variable lcharacter "
93 mi_gdb_test "-var-create lpcharacter * lpcharacter" \
94 "\\^done,name=\"lpcharacter\",numchild=\"1\",value=\"$hex.*\",type=\"char \\*\"" \
95 "create local variable lpcharacter"
97 mi_gdb_test "-var-create llong * llong" \
98 "\\^done,name=\"llong\",numchild=\"0\",value=\".*\",type=\"long int\"" \
99 "create local variable llong"
101 mi_gdb_test "-var-create lplong * lplong" \
102 "\\^done,name=\"lplong\",numchild=\"1\",value=\"$hex\",type=\"long int \\*\"" \
103 "create local variable lplong"
105 mi_gdb_test "-var-create lfloat * lfloat" \
106 "\\^done,name=\"lfloat\",numchild=\"0\",value=\".*\",type=\"float\"" \
107 "create local variable lfloat"
109 mi_gdb_test "-var-create lpfloat * lpfloat" \
110 "\\^done,name=\"lpfloat\",numchild=\"1\",value=\"$hex\",type=\"float \\*\"" \
111 "create local variable lpfloat"
113 mi_gdb_test "-var-create ldouble * ldouble" \
114 "\\^done,name=\"ldouble\",numchild=\"0\",value=\".*\",type=\"double\"" \
115 "create local variable ldouble"
117 mi_gdb_test "-var-create lpdouble * lpdouble" \
118 "\\^done,name=\"lpdouble\",numchild=\"1\",value=\"$hex\",type=\"double \\*\"" \
119 "create local variable lpdouble"
121 mi_gdb_test "-var-create lsimple * lsimple" \
122 "\\^done,name=\"lsimple\",numchild=\"6\",value=\"{...}\",type=\"struct _simple_struct\"" \
123 "create local variable lsimple"
125 mi_gdb_test "-var-create lpsimple * lpsimple" \
126 "\\^done,name=\"lpsimple\",numchild=\"6\",value=\"$hex\",type=\"struct _simple_struct \\*\"" \
127 "create local variable lpsimple"
129 mi_gdb_test "-var-create func * func" \
130 "\\^done,name=\"func\",numchild=\"0\",value=\".*\",type=\"void \\(\\*\\)\\((void|)\\)\"" \
131 "create local variable func"
133 # Test: c_variable-1.5
134 # Desc: create lsimple.character
135 mi_gdb_test "-var-create lsimple.character * lsimple.character" \
136 "\\^done,name=\"lsimple.character\",numchild=\"0\",value=\".*\",type=\"char\"" \
137 "create lsimple.character"
139 # Test: c_variable-1.6
140 # Desc: create lpsimple->integer
141 mi_gdb_test "-var-create lsimple->integer * lsimple->integer" \
142 "\\^done,name=\"lsimple->integer\",numchild=\"0\",value=\".*\",type=\"int\"" \
143 "create lsimple->integer"
145 # Test: c_variable-1.7
146 # Desc: ceate lsimple.integer
147 mi_gdb_test "-var-create lsimple.integer * lsimple.integer" \
148 "\\^done,name=\"lsimple.integer\",numchild=\"0\",value=\".*\",type=\"int\"" \
149 "create lsimple->integer"
152 # Test: c_variable-1.9
153 # Desc: create type name
154 # Type names (like int, long, etc..) are all proper expressions to gdb.
155 # make sure variable code does not allow users to create variables, though.
156 mi_gdb_test "-var-create int * int" \
157 "&\"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\"" \
163 # Value changed tests #
167 # Test: c_variable-2.1
168 # Desc: check whether values changed at do_block_tests
169 mi_gdb_test "-var-update *" \
170 "\\^done,changelist=\\\[\\\]" \
173 # Step over "linteger = 1234;"
174 set line_dlt_linteger [gdb_get_line_number "lpinteger = &linteger;"]
175 mi_step_to "do_locals_tests" "" "var-cmd.c" $line_dlt_linteger "step at do_locals_test"
177 # Test: c_variable-2.2
178 # Desc: check whether only linteger changed values
179 mi_gdb_test "-var-update *" \
180 "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
181 "update all vars: linteger changed"
183 # Step over "lpinteger = &linteger;"
184 mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 1] "step at do_locals_tests (2)"
186 # Test: c_variable-2.3
187 # Desc: check whether only lpinteger changed
188 mi_gdb_test "-var-update *" \
189 "\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
190 "update all vars: lpinteger changed"
192 # Step over "lcharacter = 'a';"
193 mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 2] "step at do_locals_tests (3)"
195 # Test: c_variable-2.4
196 # Desc: check whether only lcharacter changed
197 mi_gdb_test "-var-update *" \
198 "\\^done,changelist=\\\[\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
199 "update all vars: lcharacter changed"
201 # Step over "lpcharacter = &lcharacter;"
202 mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 3] "step at do_locals_tests (4)"
204 # Test: c_variable-2.5
205 # Desc: check whether only lpcharacter changed
206 mi_gdb_test "-var-update *" \
207 "\\^done,changelist=\\\[\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
208 "update all vars: lpcharacter changed"
216 # ldouble = 2.718281828459045;
217 # lpdouble = &ldouble;
218 # lsimple.integer = 1234;
219 # lsimple.unsigned_integer = 255;
220 # lsimple.character = 'a';
222 mi_execute_to "exec-step 9" "end-stepping-range" "do_locals_tests" "" \
223 "var-cmd.c" [expr $line_dlt_linteger + 12] "" "step at do_locals_tests (5)"
225 # Test: c_variable-2.6
226 # Desc: check whether llong, lplong, lfloat, lpfloat, ldouble, lpdouble, lsimple.integer,
227 # lsimple.unsigned_character lsimple.integer lsimple.character changed
228 mi_gdb_test "-var-update *" \
229 "\\^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\"\}\\\]" \
230 "update all vars: many changed"
233 # lsimple.signed_character = 21;
234 # lsimple.char_ptr = &lcharacter;
235 # lpsimple = &lsimple;
238 set line_dlt_4321 [gdb_get_line_number "linteger = 4321;"]
240 mi_execute_to "exec-step 4" "end-stepping-range" "do_locals_tests" "" \
241 "var-cmd.c" $line_dlt_4321 "" "step at do_locals_tests (6)"
243 # Test: c_variable-2.7
244 # Desc: check whether (lsimple.signed_character, lsimple.char_ptr) lpsimple, func changed
245 mi_gdb_test "-var-update *" \
246 "\\^done,changelist=\\\[\{name=\"func\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"lpsimple\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
247 "update all vars: func and lpsimple changed"
254 # ldouble = 5.498548281828172;
255 # lsimple.integer = 255;
256 # lsimple.unsigned_integer = 4321;
257 # lsimple.character = 'b';
259 mi_execute_to "exec-step 8" "end-stepping-range" "do_locals_tests" "" \
260 "var-cmd.c" [expr $line_dlt_4321 + 8] "" "step at do_locals_tests (7)"
262 # Test: c_variable-2.8
263 # Desc: check whether linteger, lcharacter, llong, lfoat, ldouble, lsimple.integer,
264 # lpsimple.integer lsimple.character changed
265 # Note: this test also checks that lpsimple->integer and lsimple.integer have
266 # changed (they are the same)
267 mi_gdb_test "-var-update *" \
268 "\\^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\"\}\\\]" \
269 "update all vars: lsimple and others changed"
274 # Test assignment to variables. More tests on assignment are in other files.
277 mi_gdb_test "-var-assign global_simple 0" \
278 "&\"mi_cmd_var_assign: Variable object is not editable\\\\n\".*\\^error,msg=\"mi_cmd_var_assign: Variable object is not editable\"" \
279 "assign to global_simple"
281 mi_gdb_test "-var-assign linteger 3333" \
282 "\\^done,value=\"3333\"" \
285 # Allow lpcharacter to update, optionally. Because it points to a
286 # char variable instead of a zero-terminated string, if linteger is
287 # directly after it in memory the printed characters may appear to
289 set lpchar_update "\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\},"
290 mi_gdb_test "-var-update *" \
291 "\\^done,changelist=\\\[($lpchar_update)?\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
292 "update all vars: linteger changed after assign"
294 mi_gdb_test "-var-assign linteger 3333" \
295 "\\^done,value=\"3333\"" \
296 "assign to linteger again, same value"
298 mi_gdb_test "-var-update *" \
299 "\\^done,changelist=\\\[\\\]" \
300 "update all vars: linteger not changed after same assign"
302 mi_gdb_test "-var-evaluate-expression linteger" \
303 "\\^done,value=\"3333\"" \
306 mi_gdb_test "-var-assign lpinteger \"&linteger + 3\"" \
307 "\\^done,value=\"$hex\"" \
308 "assign to lpinteger"
310 mi_gdb_test "-var-update *" \
311 "\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
312 "update all vars: lpinteger changed after assign"
314 mi_gdb_test "-var-update *" \
315 "\\^done,changelist=\\\[\\\]" \
316 "update all vars: no changes on second update"
318 mi_gdb_test "-var-evaluate-expression lpinteger" \
319 "\\^done,value=\"$hex\"" \
322 # reset the values to the original ones so that the rest of the file doesn't suffer.
324 mi_gdb_test "-var-assign linteger 4321" \
325 "\\^done,value=\"4321\"" \
328 mi_gdb_test "-var-assign lpinteger &linteger" \
329 "\\^done,value=\"$hex\"" \
330 "assign to lpinteger"
332 mi_gdb_test "-var-assign lcharacter 'z'" \
333 "\\^done,value=\"122 'z'\"" \
334 "assign to lcharacter"
336 mi_gdb_test "-var-evaluate-expression lcharacter" \
337 "\\^done,value=\"122 'z'\"" \
340 mi_gdb_test "-var-assign llong 1313L" \
341 "\\^done,value=\"1313\"" \
343 mi_gdb_test "-var-evaluate-expression llong" \
344 "\\^done,value=\"1313\"" \
346 mi_gdb_test "-var-assign llong 1212L" \
347 "\\^done,value=\"1212\"" \
350 mi_gdb_test "-var-assign lplong &llong+4" \
351 "\\^done,value=\"$hex\"" \
353 mi_gdb_test "-var-evaluate-expression lplong" \
354 "\\^done,value=\"$hex\"" \
356 mi_gdb_test "-var-assign lplong &llong" \
357 "\\^done,value=\"$hex\"" \
360 mi_gdb_test "-var-assign lfloat 3.4567" \
361 "\\^done,value=\"3.45.*\"" \
363 mi_gdb_test "-var-evaluate-expression lfloat" \
364 "\\^done,value=\"3.45.*\"" \
366 mi_gdb_test "-var-assign lfloat 1.2345" \
367 "\\^done,value=\"1.23.*\"" \
370 mi_gdb_test "-var-assign lpfloat &lfloat+4" \
371 "\\^done,value=\"$hex\"" \
374 mi_gdb_test "-var-assign ldouble 5.333318284590435" \
375 "\\^done,value=\"5.333318284590435\"" \
378 mi_gdb_test "-var-assign func do_block_tests" \
379 "\\^done,value=\"$hex <do_block_tests>\"" \
382 mi_gdb_test "-var-assign lsimple.character 'd'" \
383 "\\^done,value=\"100 'd'\"" \
384 "assign to lsimple.character"
386 mi_gdb_test "-var-assign lsimple->integer 222" \
387 "\\^done,value=\"222\"" \
388 "assign to lsimple->integer"
390 mi_gdb_test "-var-assign lsimple.integer 333" \
391 "\\^done,value=\"333\"" \
392 "assign to lsimple.integer"
394 mi_gdb_test "-var-update *" \
395 "\\^done,changelist=.*" \
398 # Check that assignment of function and array values
399 # promotes the assigned value to function pointer/data
400 # pointer before comparing with the existing value,
401 # and does not incorrectly make the value as changed.
402 mi_gdb_test "-var-assign func do_block_tests" \
403 "\\^done,value=\"$hex <do_block_tests>\"" \
404 "assign same value to func"
406 mi_gdb_test "-var-update *" \
407 "\\^done,changelist=\\\[\\\]" \
408 "assign same value to func (update)"
410 mi_gdb_test "-var-create array_ptr * array_ptr" \
411 "\\^done,name=\"array_ptr\",numchild=\"1\",value=\"$hex\",type=\"int \\*\"" \
412 "create global variable array_ptr"
414 mi_gdb_test "-var-assign array_ptr array2" \
415 "\\^done,value=\"$hex\"" \
416 "assign array to pointer"
418 mi_gdb_test "-var-update *" \
419 "\\^done,changelist=\\\[\{name=\"array_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
420 "assign array to pointer (update)"
422 mi_gdb_test "-var-assign array_ptr array2" \
423 "\\^done,value=\"$hex\"" \
424 "assign same array to pointer"
426 mi_gdb_test "-var-update *" \
427 "\\^done,changelist=\\\[\\\]" \
428 "assign same array to pointer (update)"
432 # End of assign tests
435 set line_subroutine1_body [gdb_get_line_number "global_simple.integer = i + 3;"]
437 mi_continue_to subroutine1
439 # Test: c_variable-2.10
440 # Desc: create variable for locals i,l in subroutine1
441 mi_gdb_test "-var-create i * i" \
442 "\\^done,name=\"i\",numchild=\"0\",value=\"4321\",type=\"int\"" \
445 mi_gdb_test "-var-create l * l" \
446 "\\^done,name=\"l\",numchild=\"1\",value=\"$hex\",type=\"long int \\*\"" \
449 # Test: c_variable-2.11
450 # Desc: create do_locals_tests local in subroutine1
451 mi_gdb_test "-var-create linteger * linteger" \
452 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
455 mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
456 "var-cmd.c" [expr $line_subroutine1_body + 1] "step at subroutine1"
458 # Test: c_variable-2.12
459 # Desc: change global_simple.integer
460 # Note: This also tests whether we are reporting changes in structs properly.
461 # gdb normally would say that global_simple has changed, but we
462 # special case that, since it is not what a human expects to
466 mi_gdb_test "-var-update *" \
467 "\\^done,changelist=\{FIXME: WHAT IS CORRECT HERE\}" \
468 "update all vars: changed FIXME"
471 mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
472 "var-cmd.c" [expr $line_subroutine1_body + 2] "step at subroutine1 (2)"
474 # Test: c_variable-2.13
475 # Desc: change subroutine1 local i
476 mi_gdb_test "-var-update *" \
477 "\\^done,changelist=\\\[\{name=\"i\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
478 "update all vars: i changed"
480 mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
481 "var-cmd.c" [expr $line_subroutine1_body + 3] "step at subroutine1 (3)"
483 # Test: c_variable-2.14
484 # Desc: change do_locals_tests local llong
485 mi_gdb_test "-var-update *" \
486 "\\^done,changelist=\\\[\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
487 "update all vars: llong changed"
489 set line_dlt_call_subroutine1 [gdb_get_line_number "subroutine1 (linteger, &llong);"]
490 mi_next_to "do_locals_tests" "" "var-cmd.c" \
491 [expr $line_dlt_call_subroutine1 + 1] "next out of subroutine1"
493 # Test: c_variable-2.15
494 # Desc: check for out of scope subroutine1 locals
495 mi_gdb_test "-var-update *" \
496 "\\^done,changelist=\\\[\{name=\"l\",in_scope=\"false\"\},\{name=\"i\",in_scope=\"false\"\}\\\]" \
497 "update all vars: all now out of scope"
499 # Done with locals/globals tests. Erase all variables
500 #delete_all_variables
501 mi_gdb_test "-var-delete global_simple" \
502 "\\^done,ndeleted=\"1\"" \
505 mi_gdb_test "-var-delete linteger" \
506 "\\^done,ndeleted=\"1\"" \
507 "delete var linteger"
509 mi_gdb_test "-var-delete lpinteger" \
510 "\\^done,ndeleted=\"1\"" \
511 "delete var lpinteger"
513 mi_gdb_test "-var-delete lcharacter" \
514 "\\^done,ndeleted=\"1\"" \
515 "delete var lcharacter"
517 mi_gdb_test "-var-delete lpcharacter" \
518 "\\^done,ndeleted=\"1\"" \
519 "delete var lpcharacter"
521 mi_gdb_test "-var-delete llong" \
522 "\\^done,ndeleted=\"1\"" \
525 mi_gdb_test "-var-delete lplong" \
526 "\\^done,ndeleted=\"1\"" \
529 mi_gdb_test "-var-delete lfloat" \
530 "\\^done,ndeleted=\"1\"" \
533 mi_gdb_test "-var-delete lpfloat" \
534 "\\^done,ndeleted=\"1\"" \
537 mi_gdb_test "-var-delete ldouble" \
538 "\\^done,ndeleted=\"1\"" \
541 mi_gdb_test "-var-delete lpdouble" \
542 "\\^done,ndeleted=\"1\"" \
543 "delete var lpdouble"
545 mi_gdb_test "-var-delete lsimple" \
546 "\\^done,ndeleted=\"1\"" \
549 mi_gdb_test "-var-delete lpsimple" \
550 "\\^done,ndeleted=\"1\"" \
551 "delete var lpsimple"
553 mi_gdb_test "-var-delete func" \
554 "\\^done,ndeleted=\"1\"" \
557 mi_gdb_test "-var-delete lsimple.character" \
558 "\\^done,ndeleted=\"1\"" \
559 "delete var lsimple.character"
561 mi_gdb_test "-var-delete lsimple->integer" \
562 "\\^done,ndeleted=\"1\"" \
563 "delete var lsimple->integer"
565 mi_gdb_test "-var-delete lsimple.integer" \
566 "\\^done,ndeleted=\"1\"" \
567 "delete var lsimple.integer"
569 mi_gdb_test "-var-delete i" \
570 "\\^done,ndeleted=\"1\"" \
573 mi_gdb_test "-var-delete l" \
574 "\\^done,ndeleted=\"1\"" \
577 # Test whether we can follow the name of a variable through multiple
579 mi_continue_to do_special_tests
581 mi_gdb_test "-var-create selected_a @ a" \
582 {\^done,name="selected_a",numchild="0",value=\".*\",type="int"} \
585 mi_continue_to incr_a
587 mi_gdb_test "-var-update selected_a" \
588 "\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"char\",new_num_children=\"0\"\}\\\]" \
589 "update selected_a in incr_a"
591 mi_next "step a line in incr_a"
592 mi_next "return from incr_a to do_special_tests"
594 mi_gdb_test "-var-update selected_a" \
595 "\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"int\",new_num_children=\"0\"\}\\\]" \
596 "update selected_a in do_special_tests"
598 mi_delete_varobj selected_a "delete selected_a"
599 mi_delete_varobj array_ptr "delete array_ptr"
601 proc set_frozen {varobjs flag} {
603 mi_gdb_test "-var-set-frozen $v $flag" \
605 "-var-set-frozen $v $flag"
609 mi_prepare_inline_tests $srcfile
610 mi_run_inline_test frozen
612 # Test whether bad varobjs crash GDB.
614 # A varobj we fail to read during -var-update should be considered
616 mi_gdb_test "-var-create null_ptr * **0" \
617 {\^done,name="null_ptr",numchild="0",value=".*",type="int"} \
620 # Allow this to succeed, if address zero is readable, although it
621 # will not test what it was meant to. Most important is that GDB
623 mi_gdb_test "-var-update null_ptr" \
624 {\^done,changelist=\[.*\]} \
627 mi_gdb_test "-var-delete null_ptr" \
628 "\\^done,ndeleted=\"1\"" \
631 # When we fail to read a varobj created from a named variable,
632 # we evaluate its type instead. Make sure that doesn't blow
633 # up by trying to read it again. We can use _end when not running
634 # the program to simulate an unreadable variable, if this platform
635 # provides _end, but cope if it's missing.
638 {&"kill\\n".*\^done} \
639 "kill program before endvar"
641 mi_gdb_test "-var-create endvar * _end" \
642 {(\^done,name="endvar",numchild="0",value=".*",type=".*"|&".*unable to.*".*\^error,msg=".*")} \
645 # Allow this to succeed whether the value is readable, unreadable, or
646 # missing. Most important is that GDB does not crash.
647 mi_gdb_test "-var-update endvar" \
648 {(\^done,changelist=\[.*\]|^".*".*\^error,msg=".*not found")} \
651 mi_gdb_test "-var-delete endvar" \
652 "\\^done,ndeleted=\"1\"" \