1 # Copyright 1999-2004, 2007-2012 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Test essential Machine interface (MI) operations
18 # Verify that, using the MI, we can create, update, delete variables.
22 load_lib mi-support.exp
30 set testfile "var-cmd"
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/mi2-var-block
33 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
34 untested mi2-var-block.exp
39 mi_gdb_reinitialize_dir $srcdir/$subdir
40 mi_gdb_load ${binfile}
42 mi_runto do_block_tests
44 # Test: c_variable-3.2
45 # Desc: create cb and foo
46 mi_create_varobj "cb" "cb" "create local variable cb"
48 mi_gdb_test "-var-create foo * foo" \
49 "\\^error,msg=\"-var-create: unable to create variable object\"" \
50 "create local variable foo"
52 # step to "foo = 123;"
53 mi_step_to "do_block_tests" "" "var-cmd.c" \
54 [gdb_get_line_number "foo = 123;"] \
55 "step at do_block_test"
58 # Be paranoid and assume 3.2 created foo
59 mi_gdb_test "-var-delete foo" \
60 "\\^error,msg=\"Variable object not found\"" \
64 # Test: c_variable-3.3
66 mi_create_varobj "foo" "foo" "create local variable foo"
68 # step to "foo2 = 123;"
69 mi_step_to "do_block_tests" "" "var-cmd.c" \
70 [gdb_get_line_number "foo2 = 123;"] \
71 "step at do_block_test"
73 # Test: c_variable-3.4
74 # Desc: check foo, cb changed
75 mi_gdb_test "-var-update *" \
76 "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
77 "update all vars: cb foo changed"
79 # step to "foo = 321;"
80 mi_step_to "do_block_tests" "" "var-cmd.c" \
81 [gdb_get_line_number "foo = 321;"] \
82 "step at do_block_test"
84 # Test: c_variable-3.5
85 # Desc: create inner block foo
86 mi_create_varobj "inner_foo" "foo" "create local variable inner_foo"
89 mi_step_to "do_block_tests" "" "var-cmd.c" \
90 [gdb_get_line_number "foo2 = 0;"] \
91 "step at do_block_test"
93 # Test: c_variable-3.6
95 mi_create_varobj "foo2" "foo2" "create local variable foo2"
97 # Test: c_variable-3.7
98 # Desc: check that outer foo in scope and inner foo out of scope
99 # Note: also a known gdb problem
101 mi_gdb_test "-var-update inner_foo" \
102 "\\^done,changelist=\{FIXME\}" \
103 "update inner_foo: should be out of scope: KNOWN PROBLEM"
107 mi_gdb_test "-var-evaluate-expression inner_foo" \
108 "\\^done,value=\{FIXME\}" \
109 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
112 mi_gdb_test "-var-update foo" \
113 "\\^done,changelist=\\\[\\\]" \
114 "update foo: did not change"
116 mi_gdb_test "-var-delete inner_foo" \
117 "\\^done,ndeleted=\"1\"" \
118 "delete var inner_foo"
121 mi_step_to "do_block_tests" "" "var-cmd.c" \
122 [gdb_get_line_number "foo = 0;"] \
123 "step at do_block_test"
125 # Test: c_variable-3.8
126 # Desc: check that foo2 out of scope (known gdb problem)
128 mi_gdb_test "-var-update foo2" \
129 "\\^done,changelist=\{FIXME\}" \
130 "update foo2: should be out of scope: KNOWN PROBLEM"
134 mi_step_to "do_block_tests" "" "var-cmd.c" \
135 [gdb_get_line_number "cb = 21;"] \
136 "step at do_block_test"
138 # Test: c_variable-3.9
139 # Desc: check that only cb is in scope (known gdb problem)
141 mi_gdb_test "-var-update foo2" \
142 "\\^done,changelist=\\\[FIXME\\\]" \
143 "update foo2 should be out of scope: KNOWN PROBLEM"
146 mi_gdb_test "-var-update foo" \
147 "\\^done,changelist=\{FIXME\}" \
148 "update foo should be out of scope: KNOWN PROBLEM"
150 mi_gdb_test "-var-update cb" \
151 "\\^done,changelist=\\\[\\\]" \
154 # Test: c_variable-3.10
155 # Desc: names of editable variables
156 #gdbtk_test c_variable-3.10 {names of editable variables} {
158 #} {{foo cb foo2} {}}
160 # Done with block tests
161 mi_gdb_test "-var-delete foo" \
162 "\\^done,ndeleted=\"1\"" \
165 mi_gdb_test "-var-delete foo2" \
166 "\\^done,ndeleted=\"1\"" \
169 mi_gdb_test "-var-delete cb" \
170 "\\^done,ndeleted=\"1\"" \