1 |
106 |
markom |
# Copyright (C) 1999 2000 s Solutions
|
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 |
|
|
|
26 |
|
|
load_lib mi-support.exp
|
27 |
|
|
|
28 |
|
|
gdb_exit
|
29 |
|
|
if [mi_gdb_start] {
|
30 |
|
|
continue
|
31 |
|
|
}
|
32 |
|
|
|
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."
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
mi_delete_breakpoints
|
41 |
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
42 |
|
|
mi_gdb_load ${binfile}
|
43 |
|
|
|
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"
|
47 |
|
|
|
48 |
|
|
mi_run_cmd
|
49 |
|
|
# The running part has been checked already by mi_run_cmd
|
50 |
|
|
gdb_expect {
|
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"
|
53 |
|
|
}
|
54 |
|
|
-re ".*$mi_gdb_prompt$" {fail "run to do_block_tests (2)"}
|
55 |
|
|
timeout {fail "run to do_block_tests (timeout 2)"}
|
56 |
|
|
}
|
57 |
|
|
|
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"
|
63 |
|
|
|
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"
|
67 |
|
|
|
68 |
|
|
# step to "foo = 123;"
|
69 |
|
|
send_gdb "-exec-step\n"
|
70 |
|
|
gdb_expect {
|
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"
|
73 |
|
|
}
|
74 |
|
|
timeout {
|
75 |
|
|
fail "step at do_block_tests (timeout)"
|
76 |
|
|
}
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
|
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\"" \
|
83 |
|
|
"delete var foo"
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
# Test: c_variable-3.3
|
87 |
|
|
# Desc: create foo
|
88 |
|
|
mi_gdb_test "-var-create foo * foo" \
|
89 |
|
|
"\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \
|
90 |
|
|
"create local variable foo"
|
91 |
|
|
|
92 |
|
|
# step to "foo2 = 123;"
|
93 |
|
|
send_gdb "-exec-step\n"
|
94 |
|
|
gdb_expect {
|
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"
|
97 |
|
|
}
|
98 |
|
|
timeout {
|
99 |
|
|
fail "step at do_block_tests (timeout)"
|
100 |
|
|
}
|
101 |
|
|
}
|
102 |
|
|
|
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"
|
108 |
|
|
|
109 |
|
|
# step to "foo = 321;"
|
110 |
|
|
send_gdb "-exec-step\n"
|
111 |
|
|
gdb_expect {
|
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"
|
114 |
|
|
}
|
115 |
|
|
timeout {
|
116 |
|
|
fail "step at do_block_tests (timeout)"
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
|
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"
|
125 |
|
|
|
126 |
|
|
# step to "foo2 = 0;"
|
127 |
|
|
send_gdb "-exec-step\n"
|
128 |
|
|
gdb_expect {
|
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"
|
131 |
|
|
}
|
132 |
|
|
timeout { fail "step at do_block_tests (timeout)" }
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
# Test: c_variable-3.6
|
136 |
|
|
# Desc: create foo2
|
137 |
|
|
mi_gdb_test "-var-create foo2 * foo2" \
|
138 |
|
|
"\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \
|
139 |
|
|
"create local variable foo2"
|
140 |
|
|
|
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
|
144 |
|
|
setup_xfail *-*-*
|
145 |
|
|
mi_gdb_test "-var-update inner_foo" \
|
146 |
|
|
"\\^done,changelist=\{FIXME\}" \
|
147 |
|
|
"update inner_foo: should be out of scope: KNOWN PROBLEM"
|
148 |
|
|
clear_xfail *-*-*
|
149 |
|
|
|
150 |
|
|
setup_xfail *-*-*
|
151 |
|
|
mi_gdb_test "-var-evaluate-expression inner_foo" \
|
152 |
|
|
"\\^done,value=\{FIXME\}" \
|
153 |
|
|
"evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
|
154 |
|
|
clear_xfail *-*-*
|
155 |
|
|
|
156 |
|
|
mi_gdb_test "-var-update foo" \
|
157 |
|
|
"\\^done,changelist=\{\}" \
|
158 |
|
|
"update foo: did not change"
|
159 |
|
|
|
160 |
|
|
mi_gdb_test "-var-delete inner_foo" \
|
161 |
|
|
"\\^done,ndeleted=\"1\"" \
|
162 |
|
|
"delete var inner_foo"
|
163 |
|
|
|
164 |
|
|
# step to "foo = 0;"
|
165 |
|
|
send_gdb "-exec-step\n"
|
166 |
|
|
gdb_expect {
|
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"
|
169 |
|
|
}
|
170 |
|
|
timeout { fail "step at do_block_tests (timeout)" }
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
# Test: c_variable-3.8
|
174 |
|
|
# Desc: check that foo2 out of scope (known gdb problem)
|
175 |
|
|
setup_xfail *-*-*
|
176 |
|
|
mi_gdb_test "-var-update foo2" \
|
177 |
|
|
"\\^done,changelist=\{FIXME\}" \
|
178 |
|
|
"update foo2: should be out of scope: KNOWN PROBLEM"
|
179 |
|
|
clear_xfail *-*-*
|
180 |
|
|
|
181 |
|
|
# step to "cb = 21;"
|
182 |
|
|
send_gdb "-exec-step\n"
|
183 |
|
|
gdb_expect {
|
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"
|
186 |
|
|
}
|
187 |
|
|
timeout { fail "step at do_block_tests (timeout)" }
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
# Test: c_variable-3.9
|
192 |
|
|
# Desc: check that only cb is in scope (known gdb problem)
|
193 |
|
|
setup_xfail *-*-*
|
194 |
|
|
mi_gdb_test "-var-update foo2" \
|
195 |
|
|
"\\^done,changelist=\{FIXME\}" \
|
196 |
|
|
"update foo2 should be out of scope: KNOWN PROBLEM"
|
197 |
|
|
clear_xfail *-*-*
|
198 |
|
|
setup_xfail *-*-*
|
199 |
|
|
mi_gdb_test "-var-update foo" \
|
200 |
|
|
"\\^done,changelist=\{FIXME\}" \
|
201 |
|
|
"update foo should be out of scope: KNOWN PROBLEM"
|
202 |
|
|
clear_xfail *-*-*
|
203 |
|
|
mi_gdb_test "-var-update cb" \
|
204 |
|
|
"\\^done,changelist=\{\}" \
|
205 |
|
|
"update cb"
|
206 |
|
|
|
207 |
|
|
# Test: c_variable-3.10
|
208 |
|
|
# Desc: names of editable variables
|
209 |
|
|
#gdbtk_test c_variable-3.10 {names of editable variables} {
|
210 |
|
|
# editable_variables
|
211 |
|
|
#} {{foo cb foo2} {}}
|
212 |
|
|
|
213 |
|
|
# Done with block tests
|
214 |
|
|
mi_gdb_test "-var-delete foo" \
|
215 |
|
|
"\\^done,ndeleted=\"1\"" \
|
216 |
|
|
"delete var foo"
|
217 |
|
|
|
218 |
|
|
mi_gdb_test "-var-delete foo2" \
|
219 |
|
|
"\\^done,ndeleted=\"1\"" \
|
220 |
|
|
"delete var foo2"
|
221 |
|
|
|
222 |
|
|
mi_gdb_test "-var-delete cb" \
|
223 |
|
|
"\\^done,ndeleted=\"1\"" \
|
224 |
|
|
"delete var cb"
|
225 |
|
|
|
226 |
|
|
mi_gdb_exit
|
227 |
|
|
return 0
|
228 |
|
|
|
229 |
|
|
# Local variables:
|
230 |
|
|
# change-log-default-name: "ChangeLog-mi"
|
231 |
|
|
# End:
|
232 |
|
|
|
233 |
|
|
|