1 |
227 |
jeremybenn |
# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009, 2010
|
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=mi"
|
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}/mi-var-cmd
|
34 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
|
35 |
|
|
untested mi-var-cmd.exp
|
36 |
|
|
return -1
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
mi_delete_breakpoints
|
40 |
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
41 |
|
|
mi_gdb_load ${binfile}
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
##### #####
|
45 |
|
|
# #
|
46 |
|
|
# Variable Creation tests #
|
47 |
|
|
# #
|
48 |
|
|
##### #####
|
49 |
|
|
|
50 |
|
|
# Test: c_variable-1.1
|
51 |
|
|
# Desc: Create global variable
|
52 |
|
|
|
53 |
|
|
mi_create_varobj "global_simple" "global_simple" "create global variable"
|
54 |
|
|
|
55 |
|
|
# Test: c_variable-1.2
|
56 |
|
|
# Desc: Create non-existent variable
|
57 |
|
|
|
58 |
|
|
mi_gdb_test "112-var-create bogus_unknown_variable * bogus_unknown_variable" \
|
59 |
|
|
"112\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
|
60 |
|
|
"create non-existent variable"
|
61 |
|
|
|
62 |
|
|
# Test: c_variable-1.3
|
63 |
|
|
# Desc: Create out of scope variable
|
64 |
|
|
|
65 |
|
|
mi_gdb_test "113-var-create argc * argc" \
|
66 |
|
|
"113\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
|
67 |
|
|
"create out of scope variable"
|
68 |
|
|
|
69 |
|
|
mi_runto do_locals_tests
|
70 |
|
|
|
71 |
|
|
set line_dlt_first_real [gdb_get_line_number "linteger = 1234;"]
|
72 |
|
|
|
73 |
|
|
mi_continue_to_line $line_dlt_first_real "step to real start of do_locals_test"
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
# Test: c_variable-1.4
|
77 |
|
|
# Desc: create local variables
|
78 |
|
|
|
79 |
|
|
mi_create_varobj_checked linteger linteger int "create local variable linteger"
|
80 |
|
|
|
81 |
|
|
mi_create_varobj_checked lpinteger lpinteger {int \*} "create local variable lpinteger"
|
82 |
|
|
|
83 |
|
|
mi_create_varobj_checked lcharacter lcharacter\[0\] char "create local variable lcharacter"
|
84 |
|
|
|
85 |
|
|
mi_create_varobj_checked lpcharacter lpcharacter {char \*} "create local variable lpcharacter"
|
86 |
|
|
|
87 |
|
|
mi_create_varobj_checked llong llong "long int" "create local variable llong"
|
88 |
|
|
|
89 |
|
|
mi_create_varobj_checked lplong lplong {long int \*} "create local variable lplong"
|
90 |
|
|
|
91 |
|
|
mi_create_varobj_checked lfloat lfloat float "create local variable lfloat"
|
92 |
|
|
|
93 |
|
|
mi_create_varobj_checked lpfloat lpfloat {float \*} "create local variable lpfloat"
|
94 |
|
|
|
95 |
|
|
mi_create_varobj_checked ldouble ldouble double "create local variable ldouble"
|
96 |
|
|
|
97 |
|
|
mi_create_varobj_checked lpdouble lpdouble {double \*} "create local variable lpdouble"
|
98 |
|
|
|
99 |
|
|
mi_create_varobj_checked lsimple lsimple "struct _simple_struct" "create local variable lsimple"
|
100 |
|
|
|
101 |
|
|
mi_create_varobj_checked lpsimple lpsimple {struct _simple_struct \*} "create local variable lpsimple"
|
102 |
|
|
|
103 |
|
|
mi_create_varobj_checked func func {void \(\*\)\((void|)\)} "create local variable func"
|
104 |
|
|
|
105 |
|
|
# Test: c_variable-1.5
|
106 |
|
|
# Desc: create lsimple.character
|
107 |
|
|
mi_create_varobj_checked lsimple.character lsimple.character "char" \
|
108 |
|
|
"create lsimple.character"
|
109 |
|
|
|
110 |
|
|
# Test: c_variable-1.6
|
111 |
|
|
# Desc: create lpsimple->integer
|
112 |
|
|
mi_create_varobj_checked lsimple->integer lsimple->integer "int" \
|
113 |
|
|
"create lsimple->integer"
|
114 |
|
|
|
115 |
|
|
# Test: c_variable-1.7
|
116 |
|
|
# Desc: create lsimple.integer
|
117 |
|
|
mi_create_varobj_checked lsimple.integer lsimple.integer "int" \
|
118 |
|
|
"create lsimple.integer"
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
# Test: c_variable-1.9
|
122 |
|
|
# Desc: create type name
|
123 |
|
|
# Type names (like int, long, etc..) are all proper expressions to gdb.
|
124 |
|
|
# make sure variable code does not allow users to create variables, though.
|
125 |
|
|
mi_gdb_test "-var-create int * int" \
|
126 |
|
|
"&\"Attempt to use a type name as an expression.\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
|
127 |
|
|
"create int"
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
##### #####
|
131 |
|
|
# #
|
132 |
|
|
# Value changed tests #
|
133 |
|
|
# #
|
134 |
|
|
##### #####
|
135 |
|
|
|
136 |
|
|
# Test: c_variable-2.1
|
137 |
|
|
# Desc: check whether values changed at do_block_tests
|
138 |
|
|
mi_gdb_test "-var-update *" \
|
139 |
|
|
"\\^done,changelist=\\\[\\\]" \
|
140 |
|
|
"update all vars"
|
141 |
|
|
|
142 |
|
|
# Step over "linteger = 1234;"
|
143 |
|
|
set line_dlt_linteger [gdb_get_line_number "lpinteger = &linteger;"]
|
144 |
|
|
mi_step_to "do_locals_tests" "" "var-cmd.c" $line_dlt_linteger "step at do_locals_test"
|
145 |
|
|
|
146 |
|
|
# Test: c_variable-2.2
|
147 |
|
|
# Desc: check whether only linteger changed values
|
148 |
|
|
mi_gdb_test "-var-update *" \
|
149 |
|
|
"\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
150 |
|
|
"update all vars: linteger changed"
|
151 |
|
|
|
152 |
|
|
# Step over "lpinteger = &linteger;"
|
153 |
|
|
mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 1] "step at do_locals_tests (2)"
|
154 |
|
|
|
155 |
|
|
# Test: c_variable-2.3
|
156 |
|
|
# Desc: check whether only lpinteger changed
|
157 |
|
|
mi_gdb_test "-var-update *" \
|
158 |
|
|
"\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
159 |
|
|
"update all vars: lpinteger changed"
|
160 |
|
|
|
161 |
|
|
# Step over "lcharacter = 'a';"
|
162 |
|
|
mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 2] "step at do_locals_tests (3)"
|
163 |
|
|
|
164 |
|
|
# Test: c_variable-2.4
|
165 |
|
|
# Desc: check whether only lcharacter changed
|
166 |
|
|
mi_gdb_test "-var-update *" \
|
167 |
|
|
"\\^done,changelist=\\\[\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
168 |
|
|
"update all vars: lcharacter changed"
|
169 |
|
|
|
170 |
|
|
# Step over "lpcharacter = &lcharacter;"
|
171 |
|
|
mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 3] "step at do_locals_tests (4)"
|
172 |
|
|
|
173 |
|
|
# Test: c_variable-2.5
|
174 |
|
|
# Desc: check whether only lpcharacter changed
|
175 |
|
|
mi_gdb_test "-var-update *" \
|
176 |
|
|
"\\^done,changelist=\\\[\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
177 |
|
|
"update all vars: lpcharacter changed"
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
# Step over:
|
181 |
|
|
# llong = 2121L;
|
182 |
|
|
# lplong = &llong;
|
183 |
|
|
# lfloat = 2.1;
|
184 |
|
|
# lpfloat = &lfloat;
|
185 |
|
|
# ldouble = 2.718281828459045;
|
186 |
|
|
# lpdouble = &ldouble;
|
187 |
|
|
# lsimple.integer = 1234;
|
188 |
|
|
# lsimple.unsigned_integer = 255;
|
189 |
|
|
# lsimple.character = 'a';
|
190 |
|
|
|
191 |
|
|
mi_execute_to "exec-step 9" "end-stepping-range" "do_locals_tests" "" \
|
192 |
|
|
"var-cmd.c" [expr $line_dlt_linteger + 12] "" "step at do_locals_tests (5)"
|
193 |
|
|
|
194 |
|
|
# Test: c_variable-2.6
|
195 |
|
|
# Desc: check whether llong, lplong, lfloat, lpfloat, ldouble, lpdouble, lsimple.integer,
|
196 |
|
|
# lsimple.unsigned_character lsimple.integer lsimple.character changed
|
197 |
|
|
mi_gdb_test "-var-update *" \
|
198 |
|
|
"\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lpdouble\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lpfloat\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lplong\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
199 |
|
|
"update all vars: many changed"
|
200 |
|
|
|
201 |
|
|
# Step over:
|
202 |
|
|
# lsimple.signed_character = 21;
|
203 |
|
|
# lsimple.char_ptr = &lcharacter;
|
204 |
|
|
# lpsimple = &lsimple;
|
205 |
|
|
# func = nothing;
|
206 |
|
|
|
207 |
|
|
set line_dlt_4321 [gdb_get_line_number "linteger = 4321;"]
|
208 |
|
|
|
209 |
|
|
mi_execute_to "exec-step 4" "end-stepping-range" "do_locals_tests" "" \
|
210 |
|
|
"var-cmd.c" $line_dlt_4321 "" "step at do_locals_tests (6)"
|
211 |
|
|
|
212 |
|
|
# Test: c_variable-2.7
|
213 |
|
|
# Desc: check whether (lsimple.signed_character, lsimple.char_ptr) lpsimple, func changed
|
214 |
|
|
mi_gdb_test "-var-update *" \
|
215 |
|
|
"\\^done,changelist=\\\[\{name=\"func\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lpsimple\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
216 |
|
|
"update all vars: func and lpsimple changed"
|
217 |
|
|
|
218 |
|
|
# Step over
|
219 |
|
|
# linteger = 4321;
|
220 |
|
|
# lcharacter = 'b';
|
221 |
|
|
# llong = 1212L;
|
222 |
|
|
# lfloat = 1.2;
|
223 |
|
|
# ldouble = 5.498548281828172;
|
224 |
|
|
# lsimple.integer = 255;
|
225 |
|
|
# lsimple.unsigned_integer = 4321;
|
226 |
|
|
# lsimple.character = 'b';
|
227 |
|
|
|
228 |
|
|
mi_execute_to "exec-step 8" "end-stepping-range" "do_locals_tests" "" \
|
229 |
|
|
"var-cmd.c" [expr $line_dlt_4321 + 8] "" "step at do_locals_tests (7)"
|
230 |
|
|
|
231 |
|
|
# Test: c_variable-2.8
|
232 |
|
|
# Desc: check whether linteger, lcharacter, llong, lfoat, ldouble, lsimple.integer,
|
233 |
|
|
# lpsimple.integer lsimple.character changed
|
234 |
|
|
# Note: this test also checks that lpsimple->integer and lsimple.integer have
|
235 |
|
|
# changed (they are the same)
|
236 |
|
|
mi_gdb_test "-var-update *" \
|
237 |
|
|
"\\^done,changelist=\\\[\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"ldouble\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lfloat\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"llong\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
238 |
|
|
"update all vars: lsimple and others changed"
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
###
|
242 |
|
|
#
|
243 |
|
|
# Test assignment to variables. More tests on assignment are in other files.
|
244 |
|
|
#
|
245 |
|
|
###
|
246 |
|
|
mi_gdb_test "-var-assign global_simple 0" \
|
247 |
|
|
"\\^error,msg=\"mi_cmd_var_assign: Variable object is not editable\"" \
|
248 |
|
|
"assign to global_simple"
|
249 |
|
|
|
250 |
|
|
mi_gdb_test "-var-assign linteger 3333" \
|
251 |
|
|
"\\^done,value=\"3333\"" \
|
252 |
|
|
"assign to linteger"
|
253 |
|
|
|
254 |
|
|
# Allow lpcharacter to update, optionally. Because it points to a
|
255 |
|
|
# char variable instead of a zero-terminated string, if linteger is
|
256 |
|
|
# directly after it in memory the printed characters may appear to
|
257 |
|
|
# change.
|
258 |
|
|
set lpchar_update "\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\},"
|
259 |
|
|
mi_gdb_test "-var-update *" \
|
260 |
|
|
"\\^done,changelist=\\\[($lpchar_update)?\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
261 |
|
|
"update all vars: linteger changed after assign"
|
262 |
|
|
|
263 |
|
|
mi_gdb_test "-var-assign linteger 3333" \
|
264 |
|
|
"\\^done,value=\"3333\"" \
|
265 |
|
|
"assign to linteger again, same value"
|
266 |
|
|
|
267 |
|
|
mi_gdb_test "-var-update *" \
|
268 |
|
|
"\\^done,changelist=\\\[\\\]" \
|
269 |
|
|
"update all vars: linteger not changed after same assign"
|
270 |
|
|
|
271 |
|
|
mi_gdb_test "-var-evaluate-expression linteger" \
|
272 |
|
|
"\\^done,value=\"3333\"" \
|
273 |
|
|
"eval linteger"
|
274 |
|
|
|
275 |
|
|
mi_gdb_test "-var-assign lpinteger \"&linteger + 3\"" \
|
276 |
|
|
"\\^done,value=\"$hex\"" \
|
277 |
|
|
"assign to lpinteger"
|
278 |
|
|
|
279 |
|
|
mi_gdb_test "-var-update *" \
|
280 |
|
|
"\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
281 |
|
|
"update all vars: lpinteger changed after assign"
|
282 |
|
|
|
283 |
|
|
mi_gdb_test "-var-update *" \
|
284 |
|
|
"\\^done,changelist=\\\[\\\]" \
|
285 |
|
|
"update all vars: no changes on second update"
|
286 |
|
|
|
287 |
|
|
mi_gdb_test "-var-evaluate-expression lpinteger" \
|
288 |
|
|
"\\^done,value=\"$hex\"" \
|
289 |
|
|
"eval lpinteger"
|
290 |
|
|
|
291 |
|
|
# reset the values to the original ones so that the rest of the file doesn't suffer.
|
292 |
|
|
|
293 |
|
|
mi_gdb_test "-var-assign linteger 4321" \
|
294 |
|
|
"\\^done,value=\"4321\"" \
|
295 |
|
|
"assign to linteger"
|
296 |
|
|
|
297 |
|
|
mi_gdb_test "-var-assign lpinteger &linteger" \
|
298 |
|
|
"\\^done,value=\"$hex\"" \
|
299 |
|
|
"assign to lpinteger"
|
300 |
|
|
|
301 |
|
|
mi_gdb_test "-var-assign lcharacter 'z'" \
|
302 |
|
|
"\\^done,value=\"122 'z'\"" \
|
303 |
|
|
"assign to lcharacter"
|
304 |
|
|
|
305 |
|
|
mi_gdb_test "-var-evaluate-expression lcharacter" \
|
306 |
|
|
"\\^done,value=\"122 'z'\"" \
|
307 |
|
|
"eval lcharacter"
|
308 |
|
|
|
309 |
|
|
mi_gdb_test "-var-assign llong 1313L" \
|
310 |
|
|
"\\^done,value=\"1313\"" \
|
311 |
|
|
"assign to llong"
|
312 |
|
|
mi_gdb_test "-var-evaluate-expression llong" \
|
313 |
|
|
"\\^done,value=\"1313\"" \
|
314 |
|
|
"eval llong"
|
315 |
|
|
mi_gdb_test "-var-assign llong 1212L" \
|
316 |
|
|
"\\^done,value=\"1212\"" \
|
317 |
|
|
"assign to llong"
|
318 |
|
|
|
319 |
|
|
mi_gdb_test "-var-assign lplong &llong+4" \
|
320 |
|
|
"\\^done,value=\"$hex\"" \
|
321 |
|
|
"assign to lplong"
|
322 |
|
|
mi_gdb_test "-var-evaluate-expression lplong" \
|
323 |
|
|
"\\^done,value=\"$hex\"" \
|
324 |
|
|
"eval lplong"
|
325 |
|
|
mi_gdb_test "-var-assign lplong &llong" \
|
326 |
|
|
"\\^done,value=\"$hex\"" \
|
327 |
|
|
"assign to lplong"
|
328 |
|
|
|
329 |
|
|
mi_gdb_test "-var-assign lfloat 3.4567" \
|
330 |
|
|
"\\^done,value=\"3.45.*\"" \
|
331 |
|
|
"assign to lfloat"
|
332 |
|
|
mi_gdb_test "-var-evaluate-expression lfloat" \
|
333 |
|
|
"\\^done,value=\"3.45.*\"" \
|
334 |
|
|
"eval lfloat"
|
335 |
|
|
mi_gdb_test "-var-assign lfloat 1.2345" \
|
336 |
|
|
"\\^done,value=\"1.23.*\"" \
|
337 |
|
|
"assign to lfloat"
|
338 |
|
|
|
339 |
|
|
mi_gdb_test "-var-assign lpfloat &lfloat+4" \
|
340 |
|
|
"\\^done,value=\"$hex\"" \
|
341 |
|
|
"assign to lpfloat"
|
342 |
|
|
|
343 |
|
|
mi_gdb_test "-var-assign ldouble 5.333318284590435" \
|
344 |
|
|
"\\^done,value=\"5.333318284590435\"" \
|
345 |
|
|
"assign to ldouble"
|
346 |
|
|
|
347 |
|
|
mi_gdb_test "-var-assign func do_block_tests" \
|
348 |
|
|
"\\^done,value=\"$hex \"" \
|
349 |
|
|
"assign to func"
|
350 |
|
|
|
351 |
|
|
mi_gdb_test "-var-assign lsimple.character 'd'" \
|
352 |
|
|
"\\^done,value=\"100 'd'\"" \
|
353 |
|
|
"assign to lsimple.character"
|
354 |
|
|
|
355 |
|
|
mi_gdb_test "-var-assign lsimple->integer 222" \
|
356 |
|
|
"\\^done,value=\"222\"" \
|
357 |
|
|
"assign to lsimple->integer"
|
358 |
|
|
|
359 |
|
|
mi_gdb_test "-var-assign lsimple.integer 333" \
|
360 |
|
|
"\\^done,value=\"333\"" \
|
361 |
|
|
"assign to lsimple.integer"
|
362 |
|
|
|
363 |
|
|
mi_gdb_test "-var-update *" \
|
364 |
|
|
"\\^done,changelist=.*" \
|
365 |
|
|
"var update"
|
366 |
|
|
|
367 |
|
|
# Check that assignment of function and array values
|
368 |
|
|
# promotes the assigned value to function pointer/data
|
369 |
|
|
# pointer before comparing with the existing value,
|
370 |
|
|
# and does not incorrectly make the value as changed.
|
371 |
|
|
mi_gdb_test "-var-assign func do_block_tests" \
|
372 |
|
|
"\\^done,value=\"$hex \"" \
|
373 |
|
|
"assign same value to func"
|
374 |
|
|
|
375 |
|
|
mi_gdb_test "-var-update *" \
|
376 |
|
|
"\\^done,changelist=\\\[\\\]" \
|
377 |
|
|
"assign same value to func (update)"
|
378 |
|
|
|
379 |
|
|
mi_gdb_test "-var-create array_ptr * array_ptr" \
|
380 |
|
|
"\\^done,name=\"array_ptr\",numchild=\"1\",value=\"$hex\",type=\"int \\*\",has_more=\"0\"" \
|
381 |
|
|
"create global variable array_ptr"
|
382 |
|
|
|
383 |
|
|
mi_gdb_test "-var-assign array_ptr array2" \
|
384 |
|
|
"\\^done,value=\"$hex\"" \
|
385 |
|
|
"assign array to pointer"
|
386 |
|
|
|
387 |
|
|
mi_gdb_test "-var-update *" \
|
388 |
|
|
"\\^done,changelist=\\\[\{name=\"array_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
389 |
|
|
"assign array to pointer (update)"
|
390 |
|
|
|
391 |
|
|
mi_gdb_test "-var-assign array_ptr array2" \
|
392 |
|
|
"\\^done,value=\"$hex\"" \
|
393 |
|
|
"assign same array to pointer"
|
394 |
|
|
|
395 |
|
|
mi_gdb_test "-var-update *" \
|
396 |
|
|
"\\^done,changelist=\\\[\\\]" \
|
397 |
|
|
"assign same array to pointer (update)"
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
######
|
401 |
|
|
# End of assign tests
|
402 |
|
|
#####
|
403 |
|
|
|
404 |
|
|
set line_subroutine1_body [gdb_get_line_number "global_simple.integer = i + 3;"]
|
405 |
|
|
|
406 |
|
|
mi_continue_to subroutine1
|
407 |
|
|
|
408 |
|
|
# Test: c_variable-2.10
|
409 |
|
|
# Desc: create variable for locals i,l in subroutine1
|
410 |
|
|
mi_create_varobj_checked i i int "create i"
|
411 |
|
|
|
412 |
|
|
mi_create_varobj_checked l l {long int \*} "create l"
|
413 |
|
|
|
414 |
|
|
# Test: c_variable-2.11
|
415 |
|
|
# Desc: create do_locals_tests local in subroutine1
|
416 |
|
|
mi_gdb_test "-var-create linteger * linteger" \
|
417 |
|
|
"\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
|
418 |
|
|
"create linteger"
|
419 |
|
|
|
420 |
|
|
mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
|
421 |
|
|
"var-cmd.c" [expr $line_subroutine1_body + 1] "step at subroutine1"
|
422 |
|
|
|
423 |
|
|
# Test: c_variable-2.12
|
424 |
|
|
# Desc: change global_simple.integer
|
425 |
|
|
# Note: This also tests whether we are reporting changes in structs properly.
|
426 |
|
|
# gdb normally would say that global_simple has changed, but we
|
427 |
|
|
# special case that, since it is not what a human expects to
|
428 |
|
|
# see.
|
429 |
|
|
|
430 |
|
|
setup_xfail *-*-*
|
431 |
|
|
mi_gdb_test "-var-update *" \
|
432 |
|
|
"\\^done,changelist=\{FIXME: WHAT IS CORRECT HERE\}" \
|
433 |
|
|
"update all vars: changed FIXME"
|
434 |
|
|
clear_xfail *-*-*
|
435 |
|
|
|
436 |
|
|
mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
|
437 |
|
|
"var-cmd.c" [expr $line_subroutine1_body + 2] "step at subroutine1 (2)"
|
438 |
|
|
|
439 |
|
|
# Test: c_variable-2.13
|
440 |
|
|
# Desc: change subroutine1 local i
|
441 |
|
|
mi_gdb_test "-var-update *" \
|
442 |
|
|
"\\^done,changelist=\\\[\{name=\"i\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
443 |
|
|
"update all vars: i changed"
|
444 |
|
|
|
445 |
|
|
mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
|
446 |
|
|
"var-cmd.c" [expr $line_subroutine1_body + 3] "step at subroutine1 (3)"
|
447 |
|
|
|
448 |
|
|
# Test: c_variable-2.14
|
449 |
|
|
# Desc: change do_locals_tests local llong
|
450 |
|
|
mi_gdb_test "-var-update *" \
|
451 |
|
|
"\\^done,changelist=\\\[\{name=\"llong\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
452 |
|
|
"update all vars: llong changed"
|
453 |
|
|
|
454 |
|
|
set line_dlt_call_subroutine1 [gdb_get_line_number "subroutine1 (linteger, &llong);"]
|
455 |
|
|
mi_next_to "do_locals_tests" "" "var-cmd.c" \
|
456 |
|
|
[expr $line_dlt_call_subroutine1 + 1] "next out of subroutine1"
|
457 |
|
|
|
458 |
|
|
# Test: c_variable-2.15
|
459 |
|
|
# Desc: check for out of scope subroutine1 locals
|
460 |
|
|
mi_gdb_test "-var-update *" \
|
461 |
|
|
"\\^done,changelist=\\\[\{name=\"l\",in_scope=\"false\"\,type_changed=\"false\",has_more=\"0\"},\{name=\"i\",in_scope=\"false\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
|
462 |
|
|
"update all vars: all now out of scope"
|
463 |
|
|
|
464 |
|
|
# Done with locals/globals tests. Erase all variables
|
465 |
|
|
#delete_all_variables
|
466 |
|
|
mi_gdb_test "-var-delete global_simple" \
|
467 |
|
|
"\\^done,ndeleted=\"1\"" \
|
468 |
|
|
"delete var"
|
469 |
|
|
|
470 |
|
|
mi_gdb_test "-var-delete linteger" \
|
471 |
|
|
"\\^done,ndeleted=\"1\"" \
|
472 |
|
|
"delete var linteger"
|
473 |
|
|
|
474 |
|
|
mi_gdb_test "-var-delete lpinteger" \
|
475 |
|
|
"\\^done,ndeleted=\"1\"" \
|
476 |
|
|
"delete var lpinteger"
|
477 |
|
|
|
478 |
|
|
mi_gdb_test "-var-delete lcharacter" \
|
479 |
|
|
"\\^done,ndeleted=\"1\"" \
|
480 |
|
|
"delete var lcharacter"
|
481 |
|
|
|
482 |
|
|
mi_gdb_test "-var-delete lpcharacter" \
|
483 |
|
|
"\\^done,ndeleted=\"1\"" \
|
484 |
|
|
"delete var lpcharacter"
|
485 |
|
|
|
486 |
|
|
mi_gdb_test "-var-delete llong" \
|
487 |
|
|
"\\^done,ndeleted=\"1\"" \
|
488 |
|
|
"delete var llong"
|
489 |
|
|
|
490 |
|
|
mi_gdb_test "-var-delete lplong" \
|
491 |
|
|
"\\^done,ndeleted=\"1\"" \
|
492 |
|
|
"delete var lplong"
|
493 |
|
|
|
494 |
|
|
mi_gdb_test "-var-delete lfloat" \
|
495 |
|
|
"\\^done,ndeleted=\"1\"" \
|
496 |
|
|
"delete var lfloat"
|
497 |
|
|
|
498 |
|
|
mi_gdb_test "-var-delete lpfloat" \
|
499 |
|
|
"\\^done,ndeleted=\"1\"" \
|
500 |
|
|
"delete var lpfloat"
|
501 |
|
|
|
502 |
|
|
mi_gdb_test "-var-delete ldouble" \
|
503 |
|
|
"\\^done,ndeleted=\"1\"" \
|
504 |
|
|
"delete var ldouble"
|
505 |
|
|
|
506 |
|
|
mi_gdb_test "-var-delete lpdouble" \
|
507 |
|
|
"\\^done,ndeleted=\"1\"" \
|
508 |
|
|
"delete var lpdouble"
|
509 |
|
|
|
510 |
|
|
mi_gdb_test "-var-delete lsimple" \
|
511 |
|
|
"\\^done,ndeleted=\"1\"" \
|
512 |
|
|
"delete var lsimple"
|
513 |
|
|
|
514 |
|
|
mi_gdb_test "-var-delete lpsimple" \
|
515 |
|
|
"\\^done,ndeleted=\"1\"" \
|
516 |
|
|
"delete var lpsimple"
|
517 |
|
|
|
518 |
|
|
mi_gdb_test "-var-delete func" \
|
519 |
|
|
"\\^done,ndeleted=\"1\"" \
|
520 |
|
|
"delete var func"
|
521 |
|
|
|
522 |
|
|
mi_gdb_test "-var-delete lsimple.character" \
|
523 |
|
|
"\\^done,ndeleted=\"1\"" \
|
524 |
|
|
"delete var lsimple.character"
|
525 |
|
|
|
526 |
|
|
mi_gdb_test "-var-delete lsimple->integer" \
|
527 |
|
|
"\\^done,ndeleted=\"1\"" \
|
528 |
|
|
"delete var lsimple->integer"
|
529 |
|
|
|
530 |
|
|
mi_gdb_test "-var-delete lsimple.integer" \
|
531 |
|
|
"\\^done,ndeleted=\"1\"" \
|
532 |
|
|
"delete var lsimple.integer"
|
533 |
|
|
|
534 |
|
|
mi_gdb_test "-var-delete i" \
|
535 |
|
|
"\\^done,ndeleted=\"1\"" \
|
536 |
|
|
"delete var i"
|
537 |
|
|
|
538 |
|
|
mi_gdb_test "-var-delete l" \
|
539 |
|
|
"\\^done,ndeleted=\"1\"" \
|
540 |
|
|
"delete var l"
|
541 |
|
|
|
542 |
|
|
# Test whether we can follow the name of a variable through multiple
|
543 |
|
|
# stack frames.
|
544 |
|
|
mi_continue_to do_special_tests
|
545 |
|
|
|
546 |
|
|
mi_gdb_test "-var-create selected_a @ a" \
|
547 |
|
|
{\^done,name="selected_a",numchild="0",value=\".*\",type="int".*} \
|
548 |
|
|
"create selected_a"
|
549 |
|
|
|
550 |
|
|
mi_continue_to incr_a
|
551 |
|
|
|
552 |
|
|
mi_gdb_test "-var-update selected_a" \
|
553 |
|
|
"\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",type_changed=\"true\",new_type=\"char\",new_num_children=\"0\",has_more=\"0\"\}\\\]" \
|
554 |
|
|
"update selected_a in incr_a"
|
555 |
|
|
|
556 |
|
|
mi_next "step a line in incr_a"
|
557 |
|
|
mi_next "return from incr_a to do_special_tests"
|
558 |
|
|
|
559 |
|
|
mi_gdb_test "-var-update selected_a" \
|
560 |
|
|
"\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",type_changed=\"true\",new_type=\"int\",new_num_children=\"0\",has_more=\"0\"\}\\\]" \
|
561 |
|
|
"update selected_a in do_special_tests"
|
562 |
|
|
|
563 |
|
|
mi_gdb_test "-file-exec-and-symbols ${binfile}" "\\^done" \
|
564 |
|
|
"floating varobj invalidation"
|
565 |
|
|
|
566 |
|
|
mi_delete_varobj selected_a "delete selected_a"
|
567 |
|
|
mi_delete_varobj array_ptr "delete array_ptr"
|
568 |
|
|
|
569 |
|
|
proc set_frozen {varobjs flag} {
|
570 |
|
|
foreach v $varobjs {
|
571 |
|
|
mi_gdb_test "-var-set-frozen $v $flag" \
|
572 |
|
|
"\\^done" \
|
573 |
|
|
"-var-set-frozen $v $flag"
|
574 |
|
|
}
|
575 |
|
|
}
|
576 |
|
|
|
577 |
|
|
mi_prepare_inline_tests $srcfile
|
578 |
|
|
mi_run_inline_test frozen
|
579 |
|
|
|
580 |
|
|
mi_run_inline_test bitfield
|
581 |
|
|
|
582 |
|
|
# Since the inline test framework does not really work with
|
583 |
|
|
# function calls, first to inline tests and then do the reminder
|
584 |
|
|
# manually.
|
585 |
|
|
mi_run_inline_test floating
|
586 |
|
|
set do_at_tests_callee_breakpoint [gdb_get_line_number "breakpoint inside callee"]
|
587 |
|
|
mi_gdb_test "-break-insert var-cmd.c:$do_at_tests_callee_breakpoint" ".*" \
|
588 |
|
|
"inside breakpoint inside callee"
|
589 |
|
|
mi_execute_to "exec-continue" "breakpoint-hit" do_at_tests_callee "" ".*" ".*" \
|
590 |
|
|
{ "" "disp=\"keep\"" } \
|
591 |
|
|
"continue to where i is initialized"
|
592 |
|
|
|
593 |
|
|
mi_varobj_update F {F} "update F inside callee"
|
594 |
|
|
mi_check_varobj_value F 7 "check F inside callee"
|
595 |
|
|
|
596 |
|
|
# Test whether bad varobjs crash GDB.
|
597 |
|
|
|
598 |
|
|
# A varobj we fail to read during -var-update should be considered
|
599 |
|
|
# out of scope.
|
600 |
|
|
mi_gdb_test "-var-create null_ptr * **0" \
|
601 |
|
|
{\^done,name="null_ptr",numchild="0",value=".*",type="int",has_more="0"} \
|
602 |
|
|
"create null_ptr"
|
603 |
|
|
|
604 |
|
|
# Allow this to succeed, if address zero is readable, although it
|
605 |
|
|
# will not test what it was meant to. Most important is that GDB
|
606 |
|
|
# does not crash.
|
607 |
|
|
mi_gdb_test "-var-update null_ptr" \
|
608 |
|
|
{\^done,changelist=\[.*\]} \
|
609 |
|
|
"update null_ptr"
|
610 |
|
|
|
611 |
|
|
mi_gdb_test "-var-delete null_ptr" \
|
612 |
|
|
"\\^done,ndeleted=\"1\"" \
|
613 |
|
|
"delete null_ptr"
|
614 |
|
|
|
615 |
|
|
# When we fail to read a varobj created from a named variable,
|
616 |
|
|
# we evaluate its type instead. Make sure that doesn't blow
|
617 |
|
|
# up by trying to read it again. We can use _end when not running
|
618 |
|
|
# the program to simulate an unreadable variable, if this platform
|
619 |
|
|
# provides _end, but cope if it's missing.
|
620 |
|
|
|
621 |
|
|
mi_gdb_test "kill" \
|
622 |
|
|
{&"kill\\n".*\^done} \
|
623 |
|
|
"kill program before endvar"
|
624 |
|
|
|
625 |
|
|
mi_gdb_test "-var-create endvar * _end" \
|
626 |
|
|
{(\^done,name="endvar",numchild="0",value=".*",type=".*"|&".*unable to.*".*\^error,msg=".*")} \
|
627 |
|
|
"create endvar"
|
628 |
|
|
|
629 |
|
|
# Allow this to succeed whether the value is readable, unreadable, or
|
630 |
|
|
# missing. Most important is that GDB does not crash.
|
631 |
|
|
mi_gdb_test "-var-update endvar" \
|
632 |
|
|
{(\^done,changelist=\[.*\]|^".*".*\^error,msg=".*not found")} \
|
633 |
|
|
"update endvar"
|
634 |
|
|
|
635 |
|
|
mi_gdb_test "-var-delete endvar" \
|
636 |
|
|
"\\^done,ndeleted=\"1\"" \
|
637 |
|
|
"delete endvar"
|
638 |
|
|
|
639 |
|
|
mi_delete_breakpoints
|
640 |
|
|
|
641 |
|
|
mi_runto do_locals_tests
|
642 |
|
|
|
643 |
|
|
mi_create_varobj "L" "lsimple" "in-and-out-of-scope: create varobj"
|
644 |
|
|
mi_check_varobj_value "L" "{...}" "in-and-out-of-scope: check initial value"
|
645 |
|
|
|
646 |
|
|
mi_runto main
|
647 |
|
|
|
648 |
|
|
mi_gdb_test "-var-update L" \
|
649 |
|
|
{\^done,changelist=\[{name="L",in_scope="false",type_changed="false",has_more="0"}\]} \
|
650 |
|
|
"in-and-out-of-scope: out of scope now"
|
651 |
|
|
|
652 |
|
|
mi_gdb_test "-var-update L" \
|
653 |
|
|
{\^done,changelist=\[]} \
|
654 |
|
|
"in-and-out-of-scope: out of scope now, not changed"
|
655 |
|
|
|
656 |
|
|
mi_continue_to do_locals_tests
|
657 |
|
|
|
658 |
|
|
mi_gdb_test "-var-update L" \
|
659 |
|
|
{\^done,changelist=\[{name="L",in_scope="true",type_changed="false",has_more="0"}\]} \
|
660 |
|
|
"in-and-out-of-scope: in scope now"
|
661 |
|
|
|
662 |
|
|
mi_gdb_test "-var-update L" \
|
663 |
|
|
{\^done,changelist=\[\]} \
|
664 |
|
|
"in-and-out-of-scope: in scope now, not changed"
|
665 |
|
|
|
666 |
|
|
mi_gdb_exit
|
667 |
|
|
return 0
|