1 |
24 |
jeremybenn |
# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
|
2 |
|
|
# Free Software Foundation, Inc.
|
3 |
|
|
#
|
4 |
|
|
# This program is free software; you can redistribute it and/or modify
|
5 |
|
|
# it under the terms of the GNU General Public License as published by
|
6 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
7 |
|
|
# (at your option) any later version.
|
8 |
|
|
#
|
9 |
|
|
# This program is distributed in the hope that it will be useful,
|
10 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
# GNU General Public License for more details.
|
13 |
|
|
#
|
14 |
|
|
# You should have received a copy of the GNU General Public License
|
15 |
|
|
# along with this program. If not, see .
|
16 |
|
|
|
17 |
|
|
# Test essential Machine interface (MI) operations
|
18 |
|
|
#
|
19 |
|
|
# Verify that, using the MI, we can create, update, delete variables.
|
20 |
|
|
#
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
load_lib mi-support.exp
|
24 |
|
|
set MIFLAGS "-i=mi2"
|
25 |
|
|
|
26 |
|
|
gdb_exit
|
27 |
|
|
if [mi_gdb_start] {
|
28 |
|
|
continue
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
set testfile "var-cmd"
|
32 |
|
|
set srcfile ${testfile}.c
|
33 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
34 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
|
35 |
|
|
untested mi2-var-display.exp
|
36 |
|
|
return -1
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
mi_delete_breakpoints
|
40 |
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
41 |
|
|
mi_gdb_load ${binfile}
|
42 |
|
|
|
43 |
|
|
set line_dct_end [gdb_get_line_number "{int a = 0;}"]
|
44 |
|
|
|
45 |
|
|
mi_gdb_test "200-break-insert $srcfile:$line_dct_end" \
|
46 |
|
|
"200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_children_tests\",file=\".*var-cmd.c\",line=\"$line_dct_end\",times=\"0\"\}" \
|
47 |
|
|
"break-insert operation"
|
48 |
|
|
|
49 |
|
|
mi_run_cmd
|
50 |
|
|
# The running part has been checked already by mi_run_cmd
|
51 |
|
|
gdb_expect {
|
52 |
|
|
-re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\\\[\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dct_end\"\}\r\n$mi_gdb_prompt$" {
|
53 |
|
|
pass "run to do_children_tests"
|
54 |
|
|
}
|
55 |
|
|
-re ".*$mi_gdb_prompt$" {fail "run to do_children_tests (2)"}
|
56 |
|
|
timeout {fail "run to do_children_tests (timeout 2)"}
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
##### #####
|
60 |
|
|
# #
|
61 |
|
|
# Display tests #
|
62 |
|
|
# #
|
63 |
|
|
##### #####
|
64 |
|
|
|
65 |
|
|
# Test: c_variable-6.1
|
66 |
|
|
# Desc: create variable bar
|
67 |
|
|
mi_gdb_test "-var-create bar * bar" \
|
68 |
|
|
"\\^done,name=\"bar\",numchild=\"0\",value=\".*\",type=\"int\"" \
|
69 |
|
|
"create local variable bar"
|
70 |
|
|
|
71 |
|
|
# Test: c_variable-6.2
|
72 |
|
|
# Desc: type of variable bar
|
73 |
|
|
mi_gdb_test "-var-info-type bar" \
|
74 |
|
|
"\\^done,type=\"int\"" \
|
75 |
|
|
"info type variable bar"
|
76 |
|
|
|
77 |
|
|
# Test: c_variable-6.3
|
78 |
|
|
# Desc: format of variable bar
|
79 |
|
|
mi_gdb_test "-var-show-format bar" \
|
80 |
|
|
"\\^done,format=\"natural\"" \
|
81 |
|
|
"show format variable bar"
|
82 |
|
|
|
83 |
|
|
# Test: c_variable-6.4
|
84 |
|
|
# Desc: value of variable bar
|
85 |
|
|
mi_gdb_test "-var-evaluate-expression bar" \
|
86 |
|
|
"\\^done,value=\"2121\"" \
|
87 |
|
|
"eval variable bar"
|
88 |
|
|
|
89 |
|
|
# Test: c_variable-6.5
|
90 |
|
|
# Desc: change format of bar to hex
|
91 |
|
|
mi_gdb_test "-var-set-format bar hexadecimal" \
|
92 |
|
|
"\\^done,format=\"hexadecimal\",value=\"0x849\"" \
|
93 |
|
|
"set format variable bar"
|
94 |
|
|
|
95 |
|
|
# Test: c_variable-6.6
|
96 |
|
|
# Desc: value of bar with new format
|
97 |
|
|
mi_gdb_test "-var-evaluate-expression bar" \
|
98 |
|
|
"\\^done,value=\"0x849\"" \
|
99 |
|
|
"eval variable bar with new format"
|
100 |
|
|
|
101 |
|
|
# Test: c_variable-6.7
|
102 |
|
|
# Desc: change value of bar
|
103 |
|
|
mi_gdb_test "-var-assign bar 3" \
|
104 |
|
|
"\\^done,value=\"0x3\"" \
|
105 |
|
|
"assing to variable bar"
|
106 |
|
|
|
107 |
|
|
mi_gdb_test "-var-set-format bar decimal" \
|
108 |
|
|
"\\^done,format=\"decimal\",value=\"3\"" \
|
109 |
|
|
"set format variable bar"
|
110 |
|
|
|
111 |
|
|
mi_gdb_test "-var-evaluate-expression bar" \
|
112 |
|
|
"\\^done,value=\"3\"" \
|
113 |
|
|
"eval variable bar with new value"
|
114 |
|
|
|
115 |
|
|
mi_gdb_test "-var-delete bar" \
|
116 |
|
|
"\\^done,ndeleted=\"1\"" \
|
117 |
|
|
"delete var bar"
|
118 |
|
|
|
119 |
|
|
# Test: c_variable-6.11
|
120 |
|
|
# Desc: create variable foo
|
121 |
|
|
mi_gdb_test "-var-create foo * foo" \
|
122 |
|
|
"\\^done,name=\"foo\",numchild=\"1\",value=\".*\",type=\"int \\*\"" \
|
123 |
|
|
"create local variable foo"
|
124 |
|
|
|
125 |
|
|
# Test: c_variable-6.12
|
126 |
|
|
# Desc: type of variable foo
|
127 |
|
|
mi_gdb_test "-var-info-type foo" \
|
128 |
|
|
"\\^done,type=\"int \\*\"" \
|
129 |
|
|
"info type variable foo"
|
130 |
|
|
|
131 |
|
|
# Test: c_variable-6.13
|
132 |
|
|
# Desc: format of variable foo
|
133 |
|
|
mi_gdb_test "-var-show-format foo" \
|
134 |
|
|
"\\^done,format=\"natural\"" \
|
135 |
|
|
"show format variable foo"
|
136 |
|
|
|
137 |
|
|
# Test: c_variable-6.14
|
138 |
|
|
# Desc: value of variable foo
|
139 |
|
|
mi_gdb_test "-var-evaluate-expression foo" \
|
140 |
|
|
"\\^done,value=\"$hex\"" \
|
141 |
|
|
"eval variable foo"
|
142 |
|
|
|
143 |
|
|
# Test: c_variable-6.15
|
144 |
|
|
# Desc: change format of var to octal
|
145 |
|
|
mi_gdb_test "-var-set-format foo octal" \
|
146 |
|
|
"\\^done,format=\"octal\",value=\"$octal\"" \
|
147 |
|
|
"set format variable foo"
|
148 |
|
|
|
149 |
|
|
mi_gdb_test "-var-show-format foo" \
|
150 |
|
|
"\\^done,format=\"octal\"" \
|
151 |
|
|
"show format variable foo"
|
152 |
|
|
|
153 |
|
|
# Test: c_variable-6.16
|
154 |
|
|
# Desc: value of foo with new format
|
155 |
|
|
mi_gdb_test "-var-evaluate-expression foo" \
|
156 |
|
|
"\\^done,value=\"\[0-7\]+\"" \
|
157 |
|
|
"eval variable foo"
|
158 |
|
|
|
159 |
|
|
# Test: c_variable-6.17
|
160 |
|
|
# Desc: change value of foo
|
161 |
|
|
mi_gdb_test "-var-assign foo 3" \
|
162 |
|
|
"\\^done,value=\"03\"" \
|
163 |
|
|
"assing to variable foo"
|
164 |
|
|
|
165 |
|
|
mi_gdb_test "-var-set-format foo decimal" \
|
166 |
|
|
"\\^done,format=\"decimal\",value=\"3\"" \
|
167 |
|
|
"set format variable foo"
|
168 |
|
|
|
169 |
|
|
# Test: c_variable-6.18
|
170 |
|
|
# Desc: check new value of foo
|
171 |
|
|
mi_gdb_test "-var-evaluate-expression foo" \
|
172 |
|
|
"\\^done,value=\"3\"" \
|
173 |
|
|
"eval variable foo"
|
174 |
|
|
|
175 |
|
|
mi_gdb_test "-var-delete foo" \
|
176 |
|
|
"\\^done,ndeleted=\"1\"" \
|
177 |
|
|
"delete var foo"
|
178 |
|
|
|
179 |
|
|
# Test: c_variable-6.21
|
180 |
|
|
# Desc: create variable weird and children
|
181 |
|
|
mi_gdb_test "-var-create weird * weird" \
|
182 |
|
|
"\\^done,name=\"weird\",numchild=\"11\",value=\".*\",type=\"weird_struct \\*\"" \
|
183 |
|
|
"create local variable weird"
|
184 |
|
|
|
185 |
|
|
mi_gdb_test "-var-list-children weird" \
|
186 |
|
|
"\\^done,numchild=\"11\",children=\\\[child=\{name=\"weird.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"weird.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child={name=\"weird.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"weird.long_int\",exp=\"long_int\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.int_ptr_ptr\",exp=\"int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"\},child=\{name=\"weird.long_array\",exp=\"long_array\",numchild=\"10\",type=\"long int \\\[10\\\]\"\},child=\{name=\"weird.func_ptr\",exp=\"func_ptr\",numchild=\"0\",type=\"void \\(\\*\\)\\((void|)\\)\"\},child=\{name=\"weird.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\((int, char \\*, long int|)\\)\"\},child=\{name=\"weird.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long int|)\\)\"\},child=\{name=\"weird.u1\",exp=\"u1\",numchild=\"4\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"weird.s2\",exp=\"s2\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\}\\\]" \
|
187 |
|
|
"get children local variable weird"
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
# Test: c_variable-6.23
|
191 |
|
|
# Desc: change format of weird.func_ptr and weird.func_ptr_ptr
|
192 |
|
|
mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \
|
193 |
|
|
"\\^done,format=\"hexadecimal\",value=\"$hex\"" \
|
194 |
|
|
"set format variable weird.func_ptr"
|
195 |
|
|
|
196 |
|
|
mi_gdb_test "-var-show-format weird.func_ptr" \
|
197 |
|
|
"\\^done,format=\"hexadecimal\"" \
|
198 |
|
|
"show format variable weird.func_ptr"
|
199 |
|
|
|
200 |
|
|
mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \
|
201 |
|
|
"\\^done,format=\"hexadecimal\",value=\"$hex\"" \
|
202 |
|
|
"set format variable weird.func_ptr_ptr"
|
203 |
|
|
|
204 |
|
|
mi_gdb_test "-var-show-format weird.func_ptr_ptr" \
|
205 |
|
|
"\\^done,format=\"hexadecimal\"" \
|
206 |
|
|
"show format variable weird.func_ptr_ptr"
|
207 |
|
|
|
208 |
|
|
# Test: c_variable-6.24
|
209 |
|
|
# Desc: format of weird and children
|
210 |
|
|
mi_gdb_test "-var-set-format weird natural" \
|
211 |
|
|
"\\^done,format=\"natural\",value=\"$hex\"" \
|
212 |
|
|
"set format variable weird"
|
213 |
|
|
|
214 |
|
|
mi_gdb_test "-var-set-format weird.integer natural" \
|
215 |
|
|
"\\^done,format=\"natural\",value=\"123\"" \
|
216 |
|
|
"set format variable weird.integer"
|
217 |
|
|
|
218 |
|
|
mi_gdb_test "-var-set-format weird.character natural" \
|
219 |
|
|
"\\^done,format=\"natural\",value=\"0 '\\\\\\\\0'\"" \
|
220 |
|
|
"set format variable weird.character"
|
221 |
|
|
|
222 |
|
|
mi_gdb_test "-var-set-format weird.char_ptr natural" \
|
223 |
|
|
"\\^done,format=\"natural\",value=\"$hex \\\\\"hello\\\\\"\"" \
|
224 |
|
|
"set format variable weird.char_ptr"
|
225 |
|
|
|
226 |
|
|
mi_gdb_test "-var-set-format weird.long_int natural" \
|
227 |
|
|
"\\^done,format=\"natural\",value=\"0\"" \
|
228 |
|
|
"set format variable weird.long_int"
|
229 |
|
|
|
230 |
|
|
mi_gdb_test "-var-set-format weird.int_ptr_ptr natural" \
|
231 |
|
|
"\\^done,format=\"natural\",value=\"$hex\"" \
|
232 |
|
|
"set format variable weird.int_ptr_ptr"
|
233 |
|
|
|
234 |
|
|
mi_gdb_test "-var-set-format weird.long_array natural" \
|
235 |
|
|
"\\^done,format=\"natural\",value=\"\\\[10\\\]\"" \
|
236 |
|
|
"set format variable weird.long_array"
|
237 |
|
|
|
238 |
|
|
mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \
|
239 |
|
|
"\\^done,format=\"hexadecimal\",value=\"$hex\"" \
|
240 |
|
|
"set format variable weird.func_ptr"
|
241 |
|
|
|
242 |
|
|
mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \
|
243 |
|
|
"\\^done,format=\"hexadecimal\",value=\"$hex\"" \
|
244 |
|
|
"set format variable weird.func_ptr_struct"
|
245 |
|
|
|
246 |
|
|
mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \
|
247 |
|
|
"\\^done,format=\"natural\",value=\"0\"" \
|
248 |
|
|
"set format variable weird.func_ptr_ptr"
|
249 |
|
|
|
250 |
|
|
mi_gdb_test "-var-set-format weird.u1 natural" \
|
251 |
|
|
"\\^done,format=\"natural\",value=\"\{...\}\"" \
|
252 |
|
|
"set format variable weird.u1"
|
253 |
|
|
|
254 |
|
|
mi_gdb_test "-var-set-format weird.s2 natural" \
|
255 |
|
|
"\\^done,format=\"natural\",value=\"\{...\}\"" \
|
256 |
|
|
"set format variable weird.s2"
|
257 |
|
|
|
258 |
|
|
# Test: c_variable-6.25
|
259 |
|
|
# Desc: value of weird and children
|
260 |
|
|
#gdbtk_test c_variable-6.25 {value of weird and children} {
|
261 |
|
|
# set values {}
|
262 |
|
|
# foreach v [lsort [array names var]] f [list x "" "" x x x x d d d d d] {
|
263 |
|
|
# lappend values [value $v $f]
|
264 |
|
|
# }
|
265 |
|
|
|
266 |
|
|
# set values
|
267 |
|
|
#} {ok ok ok ok ok ok ok ok weird.long_array ok weird.s2 weird.u1}
|
268 |
|
|
|
269 |
|
|
# Test: c_variable-6.26
|
270 |
|
|
# Desc: change format of weird and children to octal
|
271 |
|
|
#gdbtk_test c_variable-6.26 {change format of weird and children to octal} {
|
272 |
|
|
# set formats {}
|
273 |
|
|
# foreach v [lsort [array names var]] {
|
274 |
|
|
# $var($v) format octal
|
275 |
|
|
# lappend formats [$var($v) format]
|
276 |
|
|
# }
|
277 |
|
|
|
278 |
|
|
# set formats
|
279 |
|
|
#} {octal octal octal octal octal octal octal octal octal octal octal octal}
|
280 |
|
|
|
281 |
|
|
# Test: c_variable-6.27
|
282 |
|
|
# Desc: value of weird and children with new format
|
283 |
|
|
#gdbtk_test c_variable-6.27 {value of foo with new format} {
|
284 |
|
|
# set values {}
|
285 |
|
|
# foreach v [lsort [array names var]] {
|
286 |
|
|
# lappend values [value $v o]
|
287 |
|
|
# }
|
288 |
|
|
|
289 |
|
|
# set values
|
290 |
|
|
#} {ok ok ok ok ok ok ok ok weird.long_array ok weird.s2 weird.u1}
|
291 |
|
|
|
292 |
|
|
# Test: c_variable-6.30
|
293 |
|
|
# Desc: create more children of weird
|
294 |
|
|
#gdbtk_test c_variable-6.30 {create more children of weird} {
|
295 |
|
|
# foreach v [array names var] {
|
296 |
|
|
# get_children $v
|
297 |
|
|
# }
|
298 |
|
|
|
299 |
|
|
# # Do it twice to get more children
|
300 |
|
|
# foreach v [array names var] {
|
301 |
|
|
# get_children $v
|
302 |
|
|
# }
|
303 |
|
|
|
304 |
|
|
# lsort [array names var]
|
305 |
|
|
#} {weird weird.char_ptr weird.character weird.func_ptr weird.func_ptr_ptr weird.func_ptr_struct weird.int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr weird.integer weird.long_array weird.long_array.0 weird.long_array.1 weird.long_array.2 weird.long_array.3 weird.long_array.4 weird.long_array.5 weird.long_array.6 weird.long_array.7 weird.long_array.8 weird.long_array.9 weird.long_int weird.s2 weird.s2.g weird.s2.h weird.s2.i weird.s2.i.0 weird.s2.i.1 weird.s2.i.2 weird.s2.i.3 weird.s2.i.4 weird.s2.i.5 weird.s2.i.6 weird.s2.i.7 weird.s2.i.8 weird.s2.i.9 weird.s2.u2 weird.s2.u2.f weird.s2.u2.u1s1 weird.s2.u2.u1s2 weird.u1 weird.u1.a weird.u1.b weird.u1.c weird.u1.d}
|
306 |
|
|
|
307 |
|
|
# Test: c_variable-6.31
|
308 |
|
|
# Desc: check that all children of weird change
|
309 |
|
|
# Ok, obviously things like weird.s2 and weird.u1 will not change!
|
310 |
|
|
#gdbtk_test *c_variable-6.31 {check that all children of weird change (ops, we are now reporting array names as changed in this case - seems harmless though)} {
|
311 |
|
|
# $var(weird) value 0x2121
|
312 |
|
|
# check_update
|
313 |
|
|
#} {{weird.integer weird.character weird.char_ptr weird.long_int weird.int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr weird.long_array.0 weird.long_array.1 weird.long_array.2 weird.long_array.3 weird.long_array.4 weird.long_array.5 weird.long_array.6 weird.long_array.7 weird.long_array.8 weird.long_array.9 weird.func_ptr weird.func_ptr_struct weird.func_ptr_ptr weird.u1.a weird.u1.b weird.u1.c weird.u1.d weird.s2.u2.f weird.s2.g weird.s2.h weird.s2.i.0 weird.s2.i.1 weird.s2.i.2 weird.s2.i.3 weird.s2.i.4 weird.s2.i.5 weird.s2.i.6 weird.s2.i.7 weird.s2.i.8 weird.s2.i.9} {weird.s2.i weird.s2.u2 weird weird.s2.u2.u1s1 weird.s2.u2.u1s2 weird.s2 weird.long_array weird.u1} {}}
|
314 |
|
|
|
315 |
|
|
mi_gdb_test "-var-delete weird" \
|
316 |
|
|
"\\^done,ndeleted=\"12\"" \
|
317 |
|
|
"delete var weird"
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
##### #####
|
321 |
|
|
# #
|
322 |
|
|
# Special Display Tests #
|
323 |
|
|
# #
|
324 |
|
|
##### #####
|
325 |
|
|
|
326 |
|
|
# Stop in "do_special_tests"
|
327 |
|
|
|
328 |
|
|
set line_dst_a_1 [gdb_get_line_number "a = 1;"]
|
329 |
|
|
|
330 |
|
|
mi_gdb_test "200-break-insert do_special_tests" \
|
331 |
|
|
"200\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_special_tests\",file=\".*var-cmd.c\",line=\"$line_dst_a_1\",times=\"0\"\}" \
|
332 |
|
|
"break-insert operation"
|
333 |
|
|
|
334 |
|
|
send_gdb "-exec-continue\n"
|
335 |
|
|
gdb_expect {
|
336 |
|
|
-re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_special_tests\",args=\\\[\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dst_a_1\"\}\r\n$mi_gdb_prompt$" {
|
337 |
|
|
pass "continue to do_special_tests"
|
338 |
|
|
}
|
339 |
|
|
timeout {
|
340 |
|
|
fail "continue to do_special_tests (timeout)"
|
341 |
|
|
}
|
342 |
|
|
}
|
343 |
|
|
|
344 |
|
|
# Test: c_variable-7.10
|
345 |
|
|
# Desc: create union u
|
346 |
|
|
mi_gdb_test "-var-create u * u" \
|
347 |
|
|
"\\^done,name=\"u\",numchild=\"2\",value=\".*\",type=\"union named_union\"" \
|
348 |
|
|
"create local variable u"
|
349 |
|
|
|
350 |
|
|
# Test: c_variable-7.11
|
351 |
|
|
# Desc: value of u
|
352 |
|
|
mi_gdb_test "-var-evaluate-expression u" \
|
353 |
|
|
"\\^done,value=\"\{\\.\\.\\.\}\"" \
|
354 |
|
|
"eval variable u"
|
355 |
|
|
|
356 |
|
|
# Test: c_variable-7.12
|
357 |
|
|
# Desc: type of u
|
358 |
|
|
mi_gdb_test "-var-info-type u" \
|
359 |
|
|
"\\^done,type=\"union named_union\"" \
|
360 |
|
|
"info type variable u"
|
361 |
|
|
|
362 |
|
|
# Test: c_variable-7.13
|
363 |
|
|
# Desc: is u editable
|
364 |
|
|
mi_gdb_test "-var-show-attributes u" \
|
365 |
|
|
"\\^done,attr=\"noneditable\"" \
|
366 |
|
|
"is u editable"
|
367 |
|
|
|
368 |
|
|
# Test: c_variable-7.14
|
369 |
|
|
# Desc: number of children of u
|
370 |
|
|
mi_gdb_test "-var-info-num-children u" \
|
371 |
|
|
"\\^done,numchild=\"2\"" \
|
372 |
|
|
"get number of children of u"
|
373 |
|
|
|
374 |
|
|
# Test: c_variable-7.15
|
375 |
|
|
# Desc: children of u
|
376 |
|
|
mi_gdb_test "-var-list-children u" \
|
377 |
|
|
"\\^done,numchild=\"2\",children=\\\[child=\{name=\"u.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"u.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\}\\\]" \
|
378 |
|
|
"get children of u"
|
379 |
|
|
|
380 |
|
|
# Test: c_variable-7.20
|
381 |
|
|
# Desc: create anonu
|
382 |
|
|
mi_gdb_test "-var-create anonu * anonu" \
|
383 |
|
|
"\\^done,name=\"anonu\",numchild=\"3\",value=\".*\",type=\"union \{\\.\\.\\.\}\"" \
|
384 |
|
|
"create local variable anonu"
|
385 |
|
|
|
386 |
|
|
# Test: c_variable-7.21
|
387 |
|
|
# Desc: value of anonu
|
388 |
|
|
mi_gdb_test "-var-evaluate-expression anonu" \
|
389 |
|
|
"\\^done,value=\"\{\\.\\.\\.\}\"" \
|
390 |
|
|
"eval variable anonu"
|
391 |
|
|
|
392 |
|
|
# Test: c_variable-7.22
|
393 |
|
|
# Desc: type of anonu
|
394 |
|
|
mi_gdb_test "-var-info-type anonu" \
|
395 |
|
|
"\\^done,type=\"union \{\\.\\.\\.\}\"" \
|
396 |
|
|
"info type variable anonu"
|
397 |
|
|
|
398 |
|
|
# Test: c_variable-7.23
|
399 |
|
|
# Desc: is anonu editable
|
400 |
|
|
mi_gdb_test "-var-show-attributes anonu" \
|
401 |
|
|
"\\^done,attr=\"noneditable\"" \
|
402 |
|
|
"is anonu editable"
|
403 |
|
|
|
404 |
|
|
# Test: c_variable-7.24
|
405 |
|
|
# Desc: number of children of anonu
|
406 |
|
|
mi_gdb_test "-var-info-num-children anonu" \
|
407 |
|
|
"\\^done,numchild=\"3\"" \
|
408 |
|
|
"get number of children of anonu"
|
409 |
|
|
|
410 |
|
|
# Test: c_variable-7.25
|
411 |
|
|
# Desc: children of anonu
|
412 |
|
|
mi_gdb_test "-var-list-children anonu" \
|
413 |
|
|
"\\^done,numchild=\"3\",children=\\\[child=\{name=\"anonu.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"anonu.b\",exp=\"b\",numchild=\"0\",type=\"char\"\},child=\{name=\"anonu.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\}\\\]" \
|
414 |
|
|
"get children of anonu"
|
415 |
|
|
|
416 |
|
|
# Test: c_variable-7.30
|
417 |
|
|
# Desc: create struct s
|
418 |
|
|
mi_gdb_test "-var-create s * s" \
|
419 |
|
|
"\\^done,name=\"s\",numchild=\"6\",value=\".*\",type=\"struct _simple_struct\"" \
|
420 |
|
|
"create local variable s"
|
421 |
|
|
|
422 |
|
|
|
423 |
|
|
# Test: c_variable-7.31
|
424 |
|
|
# Desc: value of s
|
425 |
|
|
mi_gdb_test "-var-evaluate-expression s" \
|
426 |
|
|
"\\^done,value=\"\{\\.\\.\\.\}\"" \
|
427 |
|
|
"eval variable s"
|
428 |
|
|
|
429 |
|
|
# Test: c_variable-7.32
|
430 |
|
|
# Desc: type of s
|
431 |
|
|
mi_gdb_test "-var-info-type s" \
|
432 |
|
|
"\\^done,type=\"struct _simple_struct\"" \
|
433 |
|
|
"info type variable s"
|
434 |
|
|
|
435 |
|
|
# Test: c_variable-7.33
|
436 |
|
|
# Desc: is s editable
|
437 |
|
|
mi_gdb_test "-var-show-attributes s" \
|
438 |
|
|
"\\^done,attr=\"noneditable\"" \
|
439 |
|
|
"is s editable"
|
440 |
|
|
|
441 |
|
|
# Test: c_variable-7.34
|
442 |
|
|
# Desc: number of children of s
|
443 |
|
|
mi_gdb_test "-var-info-num-children s" \
|
444 |
|
|
"\\^done,numchild=\"6\"" \
|
445 |
|
|
"get number of children of s"
|
446 |
|
|
|
447 |
|
|
# Test: c_variable-7.35
|
448 |
|
|
# Desc: children of s
|
449 |
|
|
mi_gdb_test "-var-list-children s" \
|
450 |
|
|
"\\^done,numchild=\"6\",children=\\\[child=\{name=\"s.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"s.unsigned_integer\",exp=\"unsigned_integer\",numchild=\"0\",type=\"unsigned int\"\},child=\{name=\"s.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child=\{name=\"s.signed_character\",exp=\"signed_character\",numchild=\"0\",type=\"signed char\"\},child=\{name=\"s.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"s.array_of_10\",exp=\"array_of_10\",numchild=\"10\",type=\"int \\\[10\\\]\"\}\\\]" \
|
451 |
|
|
"get children of s"
|
452 |
|
|
#} {integer unsigned_integer character signed_character char_ptr array_of_10}
|
453 |
|
|
|
454 |
|
|
# Test: c_variable-7.40
|
455 |
|
|
# Desc: create anons
|
456 |
|
|
mi_gdb_test "-var-create anons * anons" \
|
457 |
|
|
"\\^done,name=\"anons\",numchild=\"3\",value=\".*\",type=\"struct \{\\.\\.\\.\}\"" \
|
458 |
|
|
"create local variable anons"
|
459 |
|
|
|
460 |
|
|
# Test: c_variable-7.41
|
461 |
|
|
# Desc: value of anons
|
462 |
|
|
mi_gdb_test "-var-evaluate-expression anons" \
|
463 |
|
|
"\\^done,value=\"\{\\.\\.\\.\}\"" \
|
464 |
|
|
"eval variable anons"
|
465 |
|
|
|
466 |
|
|
# Test: c_variable-7.42
|
467 |
|
|
# Desc: type of anons
|
468 |
|
|
mi_gdb_test "-var-info-type anons" \
|
469 |
|
|
"\\^done,type=\"struct \{\\.\\.\\.\}\"" \
|
470 |
|
|
"info type variable anons"
|
471 |
|
|
|
472 |
|
|
# Test: c_variable-7.43
|
473 |
|
|
# Desc: is anons editable
|
474 |
|
|
mi_gdb_test "-var-show-attributes anons" \
|
475 |
|
|
"\\^done,attr=\"noneditable\"" \
|
476 |
|
|
"is anons editable"
|
477 |
|
|
|
478 |
|
|
# Test: c_variable-7.44
|
479 |
|
|
# Desc: number of children of anons
|
480 |
|
|
mi_gdb_test "-var-info-num-children anons" \
|
481 |
|
|
"\\^done,numchild=\"3\"" \
|
482 |
|
|
"get number of children of anons"
|
483 |
|
|
|
484 |
|
|
# Test: c_variable-7.45
|
485 |
|
|
# Desc: children of anons
|
486 |
|
|
mi_gdb_test "-var-list-children anons" \
|
487 |
|
|
"\\^done,numchild=\"3\",children=\\\[child=\{name=\"anons.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"anons.b\",exp=\"b\",numchild=\"0\",type=\"char\"\},child=\{name=\"anons.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\}\\\]" \
|
488 |
|
|
"get children of anons"
|
489 |
|
|
|
490 |
|
|
|
491 |
|
|
# Test: c_variable-7.50
|
492 |
|
|
# Desc: create enum e
|
493 |
|
|
mi_gdb_test "-var-create e * e" \
|
494 |
|
|
"\\^done,name=\"e\",numchild=\"0\",value=\".*\",type=\"enum foo\"" \
|
495 |
|
|
"create local variable e"
|
496 |
|
|
|
497 |
|
|
setup_xfail "*-*-*"
|
498 |
|
|
# Test: c_variable-7.51
|
499 |
|
|
# Desc: value of e
|
500 |
|
|
mi_gdb_test "-var-evaluate-expression e" \
|
501 |
|
|
"\\^done,value=\"FIXME\"" \
|
502 |
|
|
"eval variable e"
|
503 |
|
|
clear_xfail "*-*-*"
|
504 |
|
|
|
505 |
|
|
# Test: c_variable-7.52
|
506 |
|
|
# Desc: type of e
|
507 |
|
|
mi_gdb_test "-var-info-type e" \
|
508 |
|
|
"\\^done,type=\"enum foo\"" \
|
509 |
|
|
"info type variable e"
|
510 |
|
|
|
511 |
|
|
# Test: c_variable-7.53
|
512 |
|
|
# Desc: is e editable
|
513 |
|
|
mi_gdb_test "-var-show-attributes e" \
|
514 |
|
|
"\\^done,attr=\"editable\"" \
|
515 |
|
|
"is e editable"
|
516 |
|
|
|
517 |
|
|
# Test: c_variable-7.54
|
518 |
|
|
# Desc: number of children of e
|
519 |
|
|
mi_gdb_test "-var-info-num-children e" \
|
520 |
|
|
"\\^done,numchild=\"0\"" \
|
521 |
|
|
"get number of children of e"
|
522 |
|
|
|
523 |
|
|
# Test: c_variable-7.55
|
524 |
|
|
# Desc: children of e
|
525 |
|
|
mi_gdb_test "-var-list-children e" \
|
526 |
|
|
"\\^done,numchild=\"0\"" \
|
527 |
|
|
"get children of e"
|
528 |
|
|
|
529 |
|
|
# Test: c_variable-7.60
|
530 |
|
|
# Desc: create anone
|
531 |
|
|
mi_gdb_test "-var-create anone * anone" \
|
532 |
|
|
"\\^done,name=\"anone\",numchild=\"0\",value=\".*\",type=\"enum \{\\.\\.\\.\}\"" \
|
533 |
|
|
"create local variable anone"
|
534 |
|
|
|
535 |
|
|
setup_xfail "*-*-*"
|
536 |
|
|
# Test: c_variable-7.61
|
537 |
|
|
# Desc: value of anone
|
538 |
|
|
mi_gdb_test "-var-evaluate-expression anone" \
|
539 |
|
|
"\\^done,value=\"A\"" \
|
540 |
|
|
"eval variable anone"
|
541 |
|
|
clear_xfail "*-*-*"
|
542 |
|
|
|
543 |
|
|
|
544 |
|
|
# Test: c_variable-7.70
|
545 |
|
|
# Desc: create anone
|
546 |
|
|
mi_gdb_test "-var-create anone * anone" \
|
547 |
|
|
"&\"Duplicate variable object name\\\\n\".*\\^error,msg=\"Duplicate variable object name\"" \
|
548 |
|
|
"create duplicate local variable anone"
|
549 |
|
|
|
550 |
|
|
|
551 |
|
|
# Test: c_variable-7.72
|
552 |
|
|
# Desc: type of anone
|
553 |
|
|
mi_gdb_test "-var-info-type anone" \
|
554 |
|
|
"\\^done,type=\"enum \{\\.\\.\\.\}\"" \
|
555 |
|
|
"info type variable anone"
|
556 |
|
|
|
557 |
|
|
|
558 |
|
|
# Test: c_variable-7.73
|
559 |
|
|
# Desc: is anone editable
|
560 |
|
|
mi_gdb_test "-var-show-attributes anone" \
|
561 |
|
|
"\\^done,attr=\"editable\"" \
|
562 |
|
|
"is anone editable"
|
563 |
|
|
|
564 |
|
|
# Test: c_variable-7.74
|
565 |
|
|
# Desc: number of children of anone
|
566 |
|
|
mi_gdb_test "-var-info-num-children anone" \
|
567 |
|
|
"\\^done,numchild=\"0\"" \
|
568 |
|
|
"get number of children of anone"
|
569 |
|
|
|
570 |
|
|
# Test: c_variable-7.75
|
571 |
|
|
# Desc: children of anone
|
572 |
|
|
mi_gdb_test "-var-list-children anone" \
|
573 |
|
|
"\\^done,numchild=\"0\"" \
|
574 |
|
|
"get children of anone"
|
575 |
|
|
|
576 |
|
|
|
577 |
|
|
# Record fp
|
578 |
|
|
|
579 |
|
|
send_gdb "p/x \$fp\n"
|
580 |
|
|
gdb_expect {
|
581 |
|
|
-re ".*($hex).*\\^done\r\n$mi_gdb_prompt$" {
|
582 |
|
|
pass "print FP register"
|
583 |
|
|
set fp $expect_out(1,string)
|
584 |
|
|
}
|
585 |
|
|
# -re ".*" { fail "print FP register"}
|
586 |
|
|
timeout { fail "print FP register (timeout)"}
|
587 |
|
|
}
|
588 |
|
|
|
589 |
|
|
set line_incr_a_b_a [gdb_get_line_number "b = a;"]
|
590 |
|
|
|
591 |
|
|
mi_gdb_test "200-break-insert incr_a" \
|
592 |
|
|
"200\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"incr_a\",file=\".*var-cmd.c\",line=\"$line_incr_a_b_a\",times=\"0\"\}" \
|
593 |
|
|
"break-insert operation"
|
594 |
|
|
send_gdb "-exec-continue\n"
|
595 |
|
|
gdb_expect {
|
596 |
|
|
-re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"2\.*\"\}\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_incr_a_b_a\"\}\r\n$mi_gdb_prompt$" {
|
597 |
|
|
pass "continue to incr_a"
|
598 |
|
|
}
|
599 |
|
|
-re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"\.*\"\}\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"([expr $line_incr_a_b_a - 2]|[expr $line_incr_a_b_a - 1]|$line_incr_a_b_a)\"\}\r\n$mi_gdb_prompt$" {
|
600 |
|
|
fail "continue to incr_a (compiler debug info incorrect)"
|
601 |
|
|
}
|
602 |
|
|
-re "\\^running\r\n${mi_gdb_prompt}.*\r\n$mi_gdb_prompt$" {
|
603 |
|
|
fail "continue to incr_a (unknown output)"
|
604 |
|
|
}
|
605 |
|
|
timeout {
|
606 |
|
|
fail "continue to incr_a (timeout)"
|
607 |
|
|
}
|
608 |
|
|
}
|
609 |
|
|
|
610 |
|
|
# Test: c_variable-7.81
|
611 |
|
|
# Desc: Create variables in different scopes
|
612 |
|
|
mi_gdb_test "-var-create a1 * a" \
|
613 |
|
|
"\\^done,name=\"a1\",numchild=\"0\",value=\".*\",type=\"char\"" \
|
614 |
|
|
"create local variable a1"
|
615 |
|
|
|
616 |
|
|
mi_gdb_test "-var-create a2 $fp a" \
|
617 |
|
|
"\\^done,name=\"a2\",numchild=\"0\",value=\".*\",type=\"int\"" \
|
618 |
|
|
"create variable a2 in different scope"
|
619 |
|
|
|
620 |
|
|
#gdbtk_test c_variable-7.81 {create variables in different scopes} {
|
621 |
|
|
# set a1 [gdb_variable create -expr a]
|
622 |
|
|
# set a2 [gdb_variable create -expr a -frame $fp]
|
623 |
|
|
|
624 |
|
|
# set vals {}
|
625 |
|
|
# lappend vals [$a1 value]
|
626 |
|
|
# lappend vals [$a2 value]
|
627 |
|
|
# set vals
|
628 |
|
|
#} {2 1}
|
629 |
|
|
|
630 |
|
|
|
631 |
|
|
mi_gdb_exit
|
632 |
|
|
return 0
|