Correct the ChangeLog entry for 2002-10-11 from:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi1-var-block.exp
CommitLineData
1f609b42
AC
1# Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
2#
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.
7#
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.
12#
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.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# Test essential Machine interface (MI) operations
21#
22# Verify that, using the MI, we can create, update, delete variables.
23#
24
25
26load_lib mi-support.exp
27set MIFLAGS "-i=mi1"
28
29gdb_exit
30if [mi_gdb_start] {
31 continue
32}
33
34set testfile "var-cmd"
35set srcfile ${testfile}.c
36set binfile ${objdir}/${subdir}/${testfile}
37if { [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."
39}
40
41mi_delete_breakpoints
42mi_gdb_reinitialize_dir $srcdir/$subdir
43mi_gdb_load ${binfile}
44
45mi_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"
48
49mi_run_cmd
50# The running part has been checked already by mi_run_cmd
51gdb_expect {
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"
54 }
55 -re ".*$mi_gdb_prompt$" {fail "run to do_block_tests (2)"}
56 timeout {fail "run to do_block_tests (timeout 2)"}
57}
58
59# Test: c_variable-3.2
60# Desc: create cb and foo
61mi_gdb_test "-var-create cb * cb" \
62 "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \
63 "create local variable cb"
64
65mi_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"
68
69# step to "foo = 123;"
70send_gdb "-exec-step\n"
71gdb_expect {
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"
74 }
75 timeout {
76 fail "step at do_block_tests (timeout)"
77 }
78}
79
80
81# Be paranoid and assume 3.2 created foo
82mi_gdb_test "-var-delete foo" \
83 "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \
84 "delete var foo"
85
86
87# Test: c_variable-3.3
88# Desc: create foo
89mi_gdb_test "-var-create foo * foo" \
90 "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \
91 "create local variable foo"
92
93# step to "foo2 = 123;"
94send_gdb "-exec-step\n"
95gdb_expect {
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"
98 }
99 timeout {
100 fail "step at do_block_tests (timeout)"
101 }
102}
103
104# Test: c_variable-3.4
105# Desc: check foo, cb changed
106mi_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"
109
110# step to "foo = 321;"
111send_gdb "-exec-step\n"
112gdb_expect {
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"
115 }
116 timeout {
117 fail "step at do_block_tests (timeout)"
118 }
119}
120
121# Test: c_variable-3.5
122# Desc: create inner block foo
123mi_gdb_test "-var-create inner_foo * foo" \
124 "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \
125 "create local variable inner_foo"
126
127# step to "foo2 = 0;"
128send_gdb "-exec-step\n"
129gdb_expect {
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"
132 }
133 timeout { fail "step at do_block_tests (timeout)" }
134}
135
136# Test: c_variable-3.6
137# Desc: create foo2
138mi_gdb_test "-var-create foo2 * foo2" \
139 "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \
140 "create local variable foo2"
141
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
145setup_xfail *-*-*
146mi_gdb_test "-var-update inner_foo" \
147 "\\^done,changelist=\{FIXME\}" \
148 "update inner_foo: should be out of scope: KNOWN PROBLEM"
149clear_xfail *-*-*
150
151setup_xfail *-*-*
152mi_gdb_test "-var-evaluate-expression inner_foo" \
153 "\\^done,value=\{FIXME\}" \
154 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
155clear_xfail *-*-*
156
157mi_gdb_test "-var-update foo" \
158 "\\^done,changelist=\{\}" \
159 "update foo: did not change"
160
161mi_gdb_test "-var-delete inner_foo" \
162 "\\^done,ndeleted=\"1\"" \
163 "delete var inner_foo"
164
165# step to "foo = 0;"
166send_gdb "-exec-step\n"
167gdb_expect {
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"
170 }
171 timeout { fail "step at do_block_tests (timeout)" }
172}
173
174# Test: c_variable-3.8
175# Desc: check that foo2 out of scope (known gdb problem)
176setup_xfail *-*-*
177mi_gdb_test "-var-update foo2" \
178 "\\^done,changelist=\{FIXME\}" \
179 "update foo2: should be out of scope: KNOWN PROBLEM"
180clear_xfail *-*-*
181
182# step to "cb = 21;"
183send_gdb "-exec-step\n"
184gdb_expect {
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"
187 }
188 timeout { fail "step at do_block_tests (timeout)" }
189}
190
191
192# Test: c_variable-3.9
193# Desc: check that only cb is in scope (known gdb problem)
194setup_xfail *-*-*
195mi_gdb_test "-var-update foo2" \
196 "\\^done,changelist=\{FIXME\}" \
197 "update foo2 should be out of scope: KNOWN PROBLEM"
198clear_xfail *-*-*
199setup_xfail *-*-*
200mi_gdb_test "-var-update foo" \
201 "\\^done,changelist=\{FIXME\}" \
202 "update foo should be out of scope: KNOWN PROBLEM"
203clear_xfail *-*-*
204mi_gdb_test "-var-update cb" \
205 "\\^done,changelist=\{\}" \
206 "update cb"
207
208# Test: c_variable-3.10
209# Desc: names of editable variables
210#gdbtk_test c_variable-3.10 {names of editable variables} {
211# editable_variables
212#} {{foo cb foo2} {}}
213
214# Done with block tests
215mi_gdb_test "-var-delete foo" \
216 "\\^done,ndeleted=\"1\"" \
217 "delete var foo"
218
219mi_gdb_test "-var-delete foo2" \
220 "\\^done,ndeleted=\"1\"" \
221 "delete var foo2"
222
223mi_gdb_test "-var-delete cb" \
224 "\\^done,ndeleted=\"1\"" \
225 "delete var cb"
226
227mi_gdb_exit
228return 0
This page took 0.076384 seconds and 4 git commands to generate.