1 # Copyright 1999, 2000, 2001, 2002, 2004, 2007, 2008, 2009
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}/mi-var-block
34 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
35 untested mi-var-block.exp
40 mi_gdb_reinitialize_dir $srcdir/$subdir
41 mi_gdb_load ${binfile}
43 mi_runto do_block_tests
45 # Test: c_variable-3.2
46 # Desc: create cb and foo
47 mi_create_varobj "cb" "cb" "create local variable cb"
49 mi_gdb_test "-var-create foo * foo" \
50 "\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
51 "try to create local variable foo"
53 # step to "foo = 123;"
54 mi_step_to "do_block_tests" "" "var-cmd.c" \
55 [gdb_get_line_number "foo = 123;"] \
56 "step at do_block_test"
59 # Be paranoid and assume 3.2 created foo
60 mi_gdb_test "-var-delete foo" \
61 "\\^error,msg=\"Variable object not found\"" \
65 # Test: c_variable-3.3
67 mi_create_varobj "foo" "foo" "create local variable foo"
69 # step to "foo2 = 123;"
70 mi_step_to "do_block_tests" "" "var-cmd.c" \
71 [gdb_get_line_number "foo2 = 123;"] \
72 "step at do_block_test"
74 # Test: c_variable-3.4
75 # Desc: check foo, cb changed
76 mi_gdb_test "-var-update *" \
77 "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
78 "update all vars: cb foo changed"
80 # step to "foo = 321;"
81 mi_step_to "do_block_tests" "" "var-cmd.c" \
82 [gdb_get_line_number "foo = 321;"] \
83 "step at do_block_test"
85 # Test: c_variable-3.5
86 # Desc: create inner block foo
87 mi_create_varobj "inner_foo" "foo" "create local variable inner_foo"
90 mi_step_to "do_block_tests" "" "var-cmd.c" \
91 [gdb_get_line_number "foo2 = 0;"] \
92 "step at do_block_test"
94 # Test: c_variable-3.6
96 mi_create_varobj "foo2" "foo2" "create local variable foo2"
98 # Test: c_variable-3.7
99 # Desc: check that outer foo in scope and inner foo out of scope
100 # Note: also a known gdb problem
102 mi_gdb_test "-var-update inner_foo" \
103 "\\^done,changelist=\{FIXME\}" \
104 "update inner_foo: should be out of scope: KNOWN PROBLEM"
108 mi_gdb_test "-var-evaluate-expression inner_foo" \
109 "\\^done,value=\{FIXME\}" \
110 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
113 mi_gdb_test "-var-update foo" \
114 "\\^done,changelist=\\\[\\\]" \
115 "update foo: did not change"
117 mi_gdb_test "-var-delete inner_foo" \
118 "\\^done,ndeleted=\"1\"" \
119 "delete var inner_foo"
122 mi_step_to "do_block_tests" "" "var-cmd.c" \
123 [gdb_get_line_number "foo = 0;"] \
124 "step at do_block_test"
126 # Test: c_variable-3.8
127 # Desc: check that foo2 out of scope (known gdb problem)
129 mi_gdb_test "-var-update foo2" \
130 "\\^done,changelist=\{FIXME\}" \
131 "update foo2: should be out of scope: KNOWN PROBLEM"
135 mi_step_to "do_block_tests" "" "var-cmd.c" \
136 [gdb_get_line_number "cb = 21;"] \
137 "step at do_block_test"
139 # Test: c_variable-3.9
140 # Desc: check that only cb is in scope (known gdb problem)
142 mi_gdb_test "-var-update foo2" \
143 "\\^done,changelist=\\\[FIXME\\\]" \
144 "update foo2 should be out of scope: KNOWN PROBLEM"
147 mi_gdb_test "-var-update foo" \
148 "\\^done,changelist=\{FIXME\}" \
149 "update foo should be out of scope: KNOWN PROBLEM"
151 mi_gdb_test "-var-update cb" \
152 "\\^done,changelist=\\\[\\\]" \
155 # Test: c_variable-3.10
156 # Desc: names of editable variables
157 #gdbtk_test c_variable-3.10 {names of editable variables} {
159 #} {{foo cb foo2} {}}
161 # Done with block tests
162 mi_gdb_test "-var-delete foo" \
163 "\\^done,ndeleted=\"1\"" \
166 mi_gdb_test "-var-delete foo2" \
167 "\\^done,ndeleted=\"1\"" \
170 mi_gdb_test "-var-delete cb" \
171 "\\^done,ndeleted=\"1\"" \