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
33 set testfile "var-cmd"
34 set srcfile ${testfile}.c
35 set binfile ${objdir}/${subdir}/${testfile}
36 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
37 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
41 mi_gdb_reinitialize_dir $srcdir/$subdir
42 mi_gdb_load ${binfile}
44 mi_gdb_test "200-break-insert do_block_tests" \
45 "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\"\}" \
46 "break-insert operation"
49 # The running part has been checked already by mi_run_cmd
51 -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"154\"\}\r\n$mi_gdb_prompt$" {
52 pass "run to do_block_tests"
54 -re ".*$mi_gdb_prompt$" {fail "run to do_block_tests (2)"}
55 timeout {fail "run to do_block_tests (timeout 2)"}
58 # Test: c_variable-3.2
59 # Desc: create cb and foo
60 mi_gdb_test "-var-create cb * cb" \
61 "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \
62 "create local variable cb"
64 mi_gdb_test "-var-create foo * foo" \
65 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
66 "create local variable foo"
68 # step to "foo = 123;"
69 send_gdb "-exec-step\n"
71 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"158\"\}\r\n$mi_gdb_prompt$" {
72 pass "step at do_block_tests"
75 fail "step at do_block_tests (timeout)"
80 # Be paranoid and assume 3.2 created foo
81 mi_gdb_test "-var-delete foo" \
82 "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \
86 # Test: c_variable-3.3
88 mi_gdb_test "-var-create foo * foo" \
89 "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \
90 "create local variable foo"
92 # step to "foo2 = 123;"
93 send_gdb "-exec-step\n"
95 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"161\"\}\r\n$mi_gdb_prompt$" {
96 pass "step at do_block_tests"
99 fail "step at do_block_tests (timeout)"
103 # Test: c_variable-3.4
104 # Desc: check foo, cb changed
105 mi_gdb_test "-var-update *" \
106 "\\^done,changelist=\{name=\"foo\",in_scope=\"true\",type_changed=\"false\",name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}" \
107 "update all vars: cb foo changed"
109 # step to "foo = 321;"
110 send_gdb "-exec-step\n"
112 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"164\"\}\r\n$mi_gdb_prompt$" {
113 pass "step at do_block_tests"
116 fail "step at do_block_tests (timeout)"
120 # Test: c_variable-3.5
121 # Desc: create inner block foo
122 mi_gdb_test "-var-create inner_foo * foo" \
123 "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \
124 "create local variable inner_foo"
126 # step to "foo2 = 0;"
127 send_gdb "-exec-step\n"
129 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"166\"\}\r\n$mi_gdb_prompt$" {
130 pass "step at do_block_tests"
132 timeout { fail "step at do_block_tests (timeout)" }
135 # Test: c_variable-3.6
137 mi_gdb_test "-var-create foo2 * foo2" \
138 "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \
139 "create local variable foo2"
141 # Test: c_variable-3.7
142 # Desc: check that outer foo in scope and inner foo out of scope
143 # Note: also a known gdb problem
145 mi_gdb_test "-var-update inner_foo" \
146 "\\^done,changelist=\{FIXME\}" \
147 "update inner_foo: should be out of scope: KNOWN PROBLEM"
151 mi_gdb_test "-var-evaluate-expression inner_foo" \
152 "\\^done,value=\{FIXME\}" \
153 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
156 mi_gdb_test "-var-update foo" \
157 "\\^done,changelist=\{\}" \
158 "update foo: did not change"
160 mi_gdb_test "-var-delete inner_foo" \
161 "\\^done,ndeleted=\"1\"" \
162 "delete var inner_foo"
165 send_gdb "-exec-step\n"
167 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"168\"\}\r\n$mi_gdb_prompt$" {
168 pass "step at do_block_tests"
170 timeout { fail "step at do_block_tests (timeout)" }
173 # Test: c_variable-3.8
174 # Desc: check that foo2 out of scope (known gdb problem)
176 mi_gdb_test "-var-update foo2" \
177 "\\^done,changelist=\{FIXME\}" \
178 "update foo2: should be out of scope: KNOWN PROBLEM"
182 send_gdb "-exec-step\n"
184 -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"171\"\}\r\n$mi_gdb_prompt$" {
185 pass "step at do_block_tests"
187 timeout { fail "step at do_block_tests (timeout)" }
191 # Test: c_variable-3.9
192 # Desc: check that only cb is in scope (known gdb problem)
194 mi_gdb_test "-var-update foo2" \
195 "\\^done,changelist=\{FIXME\}" \
196 "update foo2 should be out of scope: KNOWN PROBLEM"
199 mi_gdb_test "-var-update foo" \
200 "\\^done,changelist=\{FIXME\}" \
201 "update foo should be out of scope: KNOWN PROBLEM"
203 mi_gdb_test "-var-update cb" \
204 "\\^done,changelist=\{\}" \
207 # Test: c_variable-3.10
208 # Desc: names of editable variables
209 #gdbtk_test c_variable-3.10 {names of editable variables} {
211 #} {{foo cb foo2} {}}
213 # Done with block tests
214 mi_gdb_test "-var-delete foo" \
215 "\\^done,ndeleted=\"1\"" \
218 mi_gdb_test "-var-delete foo2" \
219 "\\^done,ndeleted=\"1\"" \
222 mi_gdb_test "-var-delete cb" \
223 "\\^done,ndeleted=\"1\"" \
230 # change-log-default-name: "ChangeLog-mi"