1 # Copyright (C) 1999 2000 s Solutions
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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # Test essential Machine interface (MI) operations
22 # Verify that, using the MI, we can create, update, delete variables.
26 load_lib mi-support.exp
34 set testfile "var-cmd"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
38 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
42 mi_gdb_reinitialize_dir $srcdir/$subdir
43 mi_gdb_load ${binfile}
45 mi_gdb_test "200-break-insert do_block_tests" \
46 "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_block_tests\",file=\".*var-cmd.c\",line=\"154\",times=\"0\"\}" \
47 "break-insert operation"
50 # The running part has been checked already by mi_run_cmd
52 -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"154\"\}\r\n$mi_gdb_prompt$" {
53 pass "run to do_block_tests"
55 -re ".*$mi_gdb_prompt$" {fail "run to do_block_tests (2)"}
56 timeout {fail "run to do_block_tests (timeout 2)"}
59 # Test: c_variable-3.2
60 # Desc: create cb and foo
61 mi_gdb_test "-var-create cb * cb" \
62 "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \
63 "create local variable cb"
65 mi_gdb_test "-var-create foo * foo" \
66 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
67 "create local variable foo"
69 # step to "foo = 123;"
70 send_gdb "-exec-step\n"
72 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"158\"\}\r\n$mi_gdb_prompt$" {
73 pass "step at do_block_tests"
76 fail "step at do_block_tests (timeout)"
81 # Be paranoid and assume 3.2 created foo
82 mi_gdb_test "-var-delete foo" \
83 "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \
87 # Test: c_variable-3.3
89 mi_gdb_test "-var-create foo * foo" \
90 "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \
91 "create local variable foo"
93 # step to "foo2 = 123;"
94 send_gdb "-exec-step\n"
96 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"161\"\}\r\n$mi_gdb_prompt$" {
97 pass "step at do_block_tests"
100 fail "step at do_block_tests (timeout)"
104 # Test: c_variable-3.4
105 # Desc: check foo, cb changed
106 mi_gdb_test "-var-update *" \
107 "\\^done,changelist=\{name=\"foo\",in_scope=\"true\",type_changed=\"false\",name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}" \
108 "update all vars: cb foo changed"
110 # step to "foo = 321;"
111 send_gdb "-exec-step\n"
113 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"164\"\}\r\n$mi_gdb_prompt$" {
114 pass "step at do_block_tests"
117 fail "step at do_block_tests (timeout)"
121 # Test: c_variable-3.5
122 # Desc: create inner block foo
123 mi_gdb_test "-var-create inner_foo * foo" \
124 "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \
125 "create local variable inner_foo"
127 # step to "foo2 = 0;"
128 send_gdb "-exec-step\n"
130 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"166\"\}\r\n$mi_gdb_prompt$" {
131 pass "step at do_block_tests"
133 timeout { fail "step at do_block_tests (timeout)" }
136 # Test: c_variable-3.6
138 mi_gdb_test "-var-create foo2 * foo2" \
139 "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \
140 "create local variable foo2"
142 # Test: c_variable-3.7
143 # Desc: check that outer foo in scope and inner foo out of scope
144 # Note: also a known gdb problem
146 mi_gdb_test "-var-update inner_foo" \
147 "\\^done,changelist=\{FIXME\}" \
148 "update inner_foo: should be out of scope: KNOWN PROBLEM"
152 mi_gdb_test "-var-evaluate-expression inner_foo" \
153 "\\^done,value=\{FIXME\}" \
154 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
157 mi_gdb_test "-var-update foo" \
158 "\\^done,changelist=\{\}" \
159 "update foo: did not change"
161 mi_gdb_test "-var-delete inner_foo" \
162 "\\^done,ndeleted=\"1\"" \
163 "delete var inner_foo"
166 send_gdb "-exec-step\n"
168 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"168\"\}\r\n$mi_gdb_prompt$" {
169 pass "step at do_block_tests"
171 timeout { fail "step at do_block_tests (timeout)" }
174 # Test: c_variable-3.8
175 # Desc: check that foo2 out of scope (known gdb problem)
177 mi_gdb_test "-var-update foo2" \
178 "\\^done,changelist=\{FIXME\}" \
179 "update foo2: should be out of scope: KNOWN PROBLEM"
183 send_gdb "-exec-step\n"
185 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"171\"\}\r\n$mi_gdb_prompt$" {
186 pass "step at do_block_tests"
188 timeout { fail "step at do_block_tests (timeout)" }
192 # Test: c_variable-3.9
193 # Desc: check that only cb is in scope (known gdb problem)
195 mi_gdb_test "-var-update foo2" \
196 "\\^done,changelist=\{FIXME\}" \
197 "update foo2 should be out of scope: KNOWN PROBLEM"
200 mi_gdb_test "-var-update foo" \
201 "\\^done,changelist=\{FIXME\}" \
202 "update foo should be out of scope: KNOWN PROBLEM"
204 mi_gdb_test "-var-update cb" \
205 "\\^done,changelist=\{\}" \
208 # Test: c_variable-3.10
209 # Desc: names of editable variables
210 #gdbtk_test c_variable-3.10 {names of editable variables} {
212 #} {{foo cb foo2} {}}
214 # Done with block tests
215 mi_gdb_test "-var-delete foo" \
216 "\\^done,ndeleted=\"1\"" \
219 mi_gdb_test "-var-delete foo2" \
220 "\\^done,ndeleted=\"1\"" \
223 mi_gdb_test "-var-delete cb" \
224 "\\^done,ndeleted=\"1\"" \