2013-09-20 Chung-Lin Tang <cltang@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / setvar.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 1988-2013 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@gnu.org
20
21 # This file was written by Rob Savoye. (rob@cygnus.com)
22
23 #
24 # test running programs
25 #
26
27 standard_testfile
28
29 # Create and source the file that provides information about the compiler
30 # used to compile the test case.
31 if [get_compiler_info] {
32 return -1
33 }
34
35 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
36 untested $testfile.exp
37 return -1
38 }
39
40 #
41 # set it up at a breakpoint so we canplay with the variable values
42 #
43 gdb_test_no_output "set print sevenbit-strings"
44
45 if ![runto_main] then {
46 perror "couldn't run to breakpoint"
47 continue
48 }
49
50 # Determine expected output for unsigned long variables,
51 # the output varies with sizeof (unsigned long).
52
53 gdb_test_multiple "print sizeof (unsigned long)" "sizeof ulong" {
54 -re ".\[0-9\]* = 4.*$gdb_prompt $" {
55 set ulong_minus_1 4294967295
56 set ulong_minus_456 4294966840
57 }
58 -re ".\[0-9\]* = 8.*$gdb_prompt $" {
59 set ulong_minus_1 18446744073709551615
60 set ulong_minus_456 18446744073709551160
61 }
62 }
63
64 proc test_set { args } {
65 global gdb_prompt
66
67 set length [expr [llength $args] - 1]
68 set message "[lindex $args $length]"
69 set final [expr $length - 2]
70 set count 1
71
72 # Set up the variables.
73 for {set x 0} {$x < $length} {incr x} {
74 if { "[lindex $args $x]" != "" } {
75 set arg [lindex $args $x]
76 if { ($x == $final) || ([string first ".*" [lindex $args [expr $x + 1]]] >= 0) } {
77 set match [lindex $args [expr $x + 1]]
78 if { $count == 1 } {
79 set mess "$message"
80 } else {
81 set mess "$message (#$count)"
82 }
83 incr count
84 incr x
85 } else {
86 set mess ""
87 set match ""
88 }
89 verbose "doing $arg $match"
90 if [gdb_test "$arg" "$match" "$mess"] {
91 fail "$message -- $match"
92 return 1
93 }
94 }
95 }
96 return 0
97 }
98
99 #
100 # test "set variable" for type "char"
101 #
102 # Because bare char types can be either signed or unsigned, we just test the
103 # range of values that are common to both (0-127).
104 #
105
106 test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.000\'" "set variable char=0"
107 test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'" "set variable char=1"
108 test_set "set variable v_char=7" "print v_char" ".\[0-9\]* = 7 \'.a\'" "set variable char=7 (Bel)"
109 test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'" "set variable char=32 (SPC)"
110 test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'" "set variable char=65 ('A')"
111 test_set "set variable v_char=97" "print v_char" ".\[0-9\]* = 97 \'a\'" "set variable char=97 ('a')"
112 test_set "set variable v_char=126" "print v_char" ".\[0-9\]* = 126 \'~\'" "set variable char=126 ('~')"
113 test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'" "set variable char=127 (8-bit)"
114 #
115 # test "set variable" for type "signed char"
116 #
117 test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.000\'" "set variable signed char=0"
118 test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'" "set variable signed char=1"
119 test_set "set variable v_signed_char=7" "print v_signed_char" ".\[0-9\]* = 7 \'.a\'" "set variable signed char=7 (Bel)"
120 test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'" "set variable signed char=32 (SPC)"
121 test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'" "set variable signed char=65 ('A')"
122 test_set "set variable v_signed_char=97" "print v_signed_char" ".\[0-9\]* = 97 \'a\'" "set variable signed char=97 ('a')"
123 test_set "set variable v_signed_char=126" "print v_signed_char" ".\[0-9\]* = 126 \'~\'" "set variable signed char=126 ('~')"
124 test_set "set variable v_signed_char=127" "print v_signed_char" ".\[0-9\]* = 127 \'.177\'" "set variable signed char=127 (8-bit)"
125 gdb_test_no_output "set variable v_signed_char=-1"
126 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
127 gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
128 "set variable signed char=-1 (-1)"
129 gdb_test_no_output "set variable v_signed_char=0xFF"
130 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
131 gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
132 "set variable signed char=0xFF (0xFF)"
133 #
134 # test "set variable" for type "unsigned char"
135 #
136 test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.000\'" "set variable unsigned char=0"
137 test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'" "set variable unsigned char=1"
138 test_set "set variable v_unsigned_char=7" "print v_unsigned_char" ".\[0-9\]* = 7 \'.a\'" "set variable unsigned char=7 (Bel)"
139 test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'" "set variable unsigned char=32 (SPC)"
140 test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'" "set variable unsigned char=65 ('A')"
141 test_set "set variable v_unsigned_char=97" "print v_unsigned_char" ".\[0-9\]* = 97 \'a\'" "set variable unsigned char=97 ('a')"
142 test_set "set variable v_unsigned_char=126" "print v_unsigned_char" ".\[0-9\]* = 126 \'~\'" "set variable unsigned char=126 ('~')"
143 test_set "set variable v_unsigned_char=~0" "print v_unsigned_char" ".\[0-9\]* = 255 \'.377\'" "set variable unsigned char=255 (8-bit)"
144 #
145 # test "set variable" for type "short"
146 #
147 test_set "set variable v_short=0" "print v_short" ".\[0-9\]* = 0" "set variable short=0"
148 test_set "set variable v_short=1" "print v_short" ".\[0-9\]* = 1" "set variable short=1"
149 test_set "set variable v_short=-1" "print v_short" ".\[0-9\]* = -1" "set variable short=-1 (minus)"
150 #
151 # test "set variable" for type "signed short"
152 #
153 test_set "set variable v_signed_short=0" "print v_signed_short" ".\[0-9\]* = 0" "set variable signed short=0"
154 test_set "set variable v_signed_short=1" "print v_signed_short" ".\[0-9\]* = 1" "set variable signed short=1"
155 test_set "set variable v_signed_short=-1" "print v_signed_short" ".\[0-9\]* = -1" "set variable signed short=-1 (minus)"
156 #
157 # test "set variable" for type "unsigned short"
158 #
159 test_set "set variable v_unsigned_short=0" "print v_unsigned_short" ".\[0-9\]* = 0" "set variable unsigned short=0"
160 test_set "set variable v_unsigned_short=1" "print v_unsigned_short" ".\[0-9\]* = 1" "set variable unsigned short=1"
161 test_set "set variable v_unsigned_short=~0" "print v_unsigned_short" ".\[0-9\]* = 65535" "set variable unsigned short=~0 (minus)"
162 #
163 # test "set variable" for type "int"
164 #
165 test_set "set variable v_int=0" "print v_int" ".\[0-9\]* = 0" "set variable int=0"
166 test_set "set variable v_int=1" "print v_int" ".\[0-9\]* = 1" "set variable int=1"
167 test_set "set variable v_int=-1" "print v_int" ".\[0-9\]* = -1" "set variable int=-1 (minus)"
168 #
169 # test "set variable" for type "signed int"
170 #
171 test_set "set variable v_signed_int=0" "print v_signed_int" ".\[0-9\]* = 0" "set variable signed int=0"
172 test_set "set variable v_signed_int=1" "print v_signed_int" ".\[0-9\]* = 1" "set variable signed int=1"
173 test_set "set variable v_signed_int=-1" "print v_signed_int" ".\[0-9\]* = -1" "set variable signed int=-1 (minus)"
174 #
175 # test "set variable" for type "unsigned int"
176 #
177 test_set "set variable v_unsigned_int=0" "print v_unsigned_int" ".\[0-9\]* = 0" "set variable unsigned int=0"
178 test_set "set variable v_unsigned_int=1" "print v_unsigned_int" ".\[0-9\]* = 1" "set variable unsigned int=1"
179 test_set "set variable v_unsigned_int=~0" "print v_unsigned_int" ".\[0-9\]* = (4294967295|65535)" "set variable unsigned int=~0 (minus)"
180 #test_set ".\[0-9\]* = 65535" "set variable unsigned int=~0 (minus)"
181 #
182 # test "set variable" for type "long"
183 #
184 test_set "set variable v_long=0" "print v_long" ".\[0-9\]* = 0" "set variable long=0"
185 test_set "set variable v_long=1" "print v_long" ".\[0-9\]* = 1" "set variable long=1"
186 test_set "set variable v_long=-1" "print v_long" ".\[0-9\]* = -1" "set variable long=-1 (minus)"
187 #
188 # test "set variable" for type "signed long"
189 #
190 test_set "set variable v_signed_long=0" "print v_signed_long" ".\[0-9\]* = 0" "set variable signed long=0"
191 test_set "set variable v_signed_long=1" "print v_signed_long" ".\[0-9\]* = 1" "set variable signed long=1"
192 test_set "set variable v_signed_long=-1" "print v_signed_long" ".\[0-9\]* = -1" "set variable signed long=-1 (minus)"
193 #
194 # test "set variable" for type "unsigned long"
195 #
196 test_set "set variable v_unsigned_long=0" "print v_unsigned_long" ".\[0-9\]* = 0" "set variable unsigned long=0"
197 test_set "set variable v_unsigned_long=1" "print v_unsigned_long" ".\[0-9\]* = 1" "set variable unsigned long=1"
198 test_set "set variable v_unsigned_long=~0" "print v_unsigned_long" ".\[0-9\]* = $ulong_minus_1" "set variable unsigned long=~0 (minus)"
199 #
200 # test "set variable" for type "float"
201 #
202 test_set "set variable v_float=0.0" "print v_float" ".\[0-9\]* = 0" "set variable float=0"
203 test_set "set variable v_float=1.0" "print v_float" ".\[0-9\]* = 1" "set variable float=1"
204 test_set "set variable v_float=-1.0" "print v_float" ".\[0-9\]* = -1" "set variable float=-1 (minus)"
205 #
206 # test "set variable" for type "double"
207 #
208 test_set "set variable v_double=0.0" "print v_double" ".\[0-9\]* = 0" "set variable double=0"
209 test_set "set variable v_double=1.0" "print v_double" ".\[0-9\]* = 1" "set variable double=1"
210 test_set "set variable v_double=-1.0" "print v_double" ".*.\[0-9\]* = -1" "set variable double=-1 (minus)"
211 #
212 # test "set variable" for "char array[2]"
213 #
214 test_set "set variable v_char_array\[0\]='h'" "set variable v_char_array\[1\]='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable char array=\"hi\" (string)"
215 #
216 # test "set variable" for "signed char array[2]"
217 #
218 test_set "set variable v_signed_char_array\[0\]='h'" "set variable v_signed_char_array\[1\]='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable signed char array=\"hi\" (string)"
219 #
220 # test "set variable" for "unsigned char array[2]"
221 #
222 test_set "set variable v_unsigned_char_array\[0\]='h'" "set variable v_unsigned_char_array\[1\]='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable unsigned char array=\"hi\" (string)"
223 #
224 # test "set variable" for "short array[2]"
225 #
226 test_set "set variable v_short_array\[0\]=123" "set variable v_short_array\[1\]=-456" "print v_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable short array"
227 #
228 # test "set variable" for "signed short array[2]"
229 #
230 test_set "set variable v_signed_short_array\[0\]=123" "set variable v_signed_short_array\[1\]=-456" "print v_signed_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed short array"
231 #
232 # test "set variable" for "unsigned short array[2]"
233 #
234 test_set "set variable v_unsigned_short_array\[0\]=123" "set variable v_unsigned_short_array\[1\]=-456" "print v_unsigned_short_array" ".*.\[0-9\]* =.*\\{123,.*65080\\}" "set variable unsigned short array"
235 #
236 # test "set variable" for "int array[2]"
237 #
238 test_set "set variable v_int_array\[0\]=123" "set variable v_int_array\[1\]=-456" "print v_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable int array"
239 #
240 # test "set variable" for "signed int array[2]"
241 #
242 test_set "set variable v_signed_int_array\[0\]=123" "set variable v_signed_int_array\[1\]=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed int array"
243 #
244 # test "set variable" for "unsigned int array[2]"
245 #
246 test_set "set variable v_unsigned_int_array\[0\]=123" "set variable v_unsigned_int_array\[1\]=-456" "print v_unsigned_int_array" ".*.\[0-9\]* =.*\\{123,.*(4294966840|65080)\\}" "set variable unsigned int array"
247 #
248 # test "set variable" for "long array[2]"
249 #
250 test_set "set variable v_long_array\[0\]=123" "set variable v_long_array\[1\]=-456" "print v_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable long array"
251 #
252 # test "set variable" for "signed long array[2]"
253 #
254 test_set "set variable v_signed_long_array\[0\]=123" "set variable v_signed_long_array\[1\]=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed long array"
255 #
256 # test "set variable" for "unsigned long array[2]"
257 #
258 test_set "set variable v_unsigned_long_array\[0\]=123" "set variable v_unsigned_long_array\[1\]=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\\{123,.*$ulong_minus_456\\}" "set variable unsigned long array"
259 #
260 # test "set variable" for "float array[2]"
261 #
262 test_set "set variable v_float_array\[0\]=123.0" "set variable v_float_array\[1\]=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable float array"
263 #
264 # test "set variable" for "double array[2]"
265 #
266 test_set "set variable v_double_array\[0\]=123.0" "set variable v_double_array\[1\]=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable double array"
267 #
268 # test "set variable" for type "char *"
269 #
270 test_set "set v_char_pointer=v_char_array" "set variable *(v_char_pointer)='h'" "set variable *(v_char_pointer+1)='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable char pointer=\"hi\" (string)"
271 #
272 # test "set variable" for type "signed char *"
273 #
274 test_set "set v_signed_char_pointer=v_signed_char_array" "set variable *(v_signed_char_pointer)='h'" "set variable *(v_signed_char_pointer+1)='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_signed_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable signed char pointer=\"hi\" (string)"
275 #
276 # test "set variable" for type "unsigned char *"
277 #
278 test_set "set v_unsigned_char_pointer=v_unsigned_char_array" "set variable *(v_unsigned_char_pointer)='h'" "set variable *(v_unsigned_char_pointer+1)='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_unsigned_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable unsigned char pointer=\"hi\" (string)"
279 #
280 # test "set variable" for type "short *"
281 #
282 test_set "set v_short_pointer=v_short_array" "set variable *(v_short_pointer)=123" "set variable *(v_short_pointer+1)=-456" "print v_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_short_pointer+1)" ".*.\[0-9\]* = -456" "set variable short pointer"
283 #
284 # test "set variable" for type "signed short *"
285 #
286 gdb_test_no_output "set v_signed_short_pointer=v_signed_short_array"
287 gdb_test_no_output "set variable *(v_signed_short_pointer)=123"
288 gdb_test_no_output "set variable *(v_signed_short_pointer+1)=-456"
289 gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\\{123,.*-456\\}" \
290 "set variable signed short pointer"
291 gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
292 #
293 # test "set variable" for type "unsigned short *"
294 #
295 gdb_test_no_output "set v_unsigned_short_pointer=v_unsigned_short_array"
296 gdb_test_no_output "set variable *(v_unsigned_short_pointer)=123"
297 gdb_test_no_output "set variable *(v_unsigned_short_pointer+1)=-456"
298 gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\\{123,.*65080\\}" \
299 "set variable unsigned short pointer"
300 gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080"
301 #
302 # test "set variable" for type "int *"
303 #
304 test_set "set v_int_pointer=v_int_array" "set variable *(v_int_pointer)=123" "set variable *(v_int_pointer+1)=-456" "print v_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_int_pointer+1)" ".*.\[0-9\]* = -456" "set variable int pointer"
305 #
306 # test "set variable" for type "signed int *"
307 #
308 test_set "set v_signed_int_pointer=v_signed_int_array" "set variable *(v_signed_int_pointer)=123" "set variable *(v_signed_int_pointer+1)=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_signed_int_pointer+1)" ".*.\[0-9\]* = -456" "set variable signed int pointer"
309 #
310 # test "set variable" for type "unsigned int *"
311 #
312 test_set "set v_unsigned_int_pointer=v_unsigned_int_array" "set variable *(v_unsigned_int_pointer)=123" "set variable *(v_unsigned_int_pointer+1)=-456" "print v_unsigned_int_array" ".*.\[0-9\]* =.*\\{123,.*(4294966840|65080)\\}" "set variable unsigned int pointer"
313 test_set "" "print *(v_unsigned_int_pointer+1)" ".*.\[0-9\]* = (4294966840|65080)" "print variable unsigned int pointer+1"
314 #
315 # test "set variable" for type "long *"
316 #
317 test_set "set v_long_pointer=v_long_array" "set variable *(v_long_pointer)=123" "set variable *(v_long_pointer+1)=-456" "print v_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_long_pointer+1)" ".*.\[0-9\]* = -456" "set variable long pointer"
318 #
319 # test "set variable" for type "signed long *"
320 #
321 test_set "set v_signed_long_pointer=v_signed_long_array" "set variable *(v_signed_long_pointer)=123" "set variable *(v_signed_long_pointer+1)=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_signed_long_pointer+1)" ".*.\[0-9\]* = -456" "set variable signed long pointer"
322 #
323 # test "set variable" for type "unsigned long *"
324 #
325 test_set "set v_unsigned_long_pointer=v_unsigned_long_array" "set variable *(v_unsigned_long_pointer)=123" "set variable *(v_unsigned_long_pointer+1)=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\\{123,.*$ulong_minus_456\\}" "print *(v_unsigned_long_pointer+1)" ".*.\[0-9\]* = $ulong_minus_456" "set variable unsigned long pointer"
326 #
327 # test "set variable" for type "float *"
328 #
329 test_set "set v_float_pointer=v_float_array" "set variable *(v_float_pointer)=123.0" "set variable *(v_float_pointer+1)=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_float_pointer+1)" ".*.\[0-9\]* = -456" "set variable float pointer"
330 #
331 # test "set variable" for type "double *"
332 #
333 test_set "set v_double_pointer=v_double_array" "set variable *(v_double_pointer)=123.0" "set variable *(v_double_pointer+1)=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_double_pointer+1)" ".*.\[0-9\]* = -456" "set variable double pointer"
334 #
335 # test "set variable" for struct members
336 #
337 test_set "set variable v_struct1.v_char_member='h'" "print v_struct1.v_char_member" ".*.\[0-9\]* = 104 \'h\'" "set variable structure char member"
338 test_set "set variable v_struct1.v_short_member=1" "print v_struct1.v_short_member" ".*.\[0-9\]* = 1" "set variable structure short member"
339 test_set "set variable v_struct1.v_int_member=2" "print v_struct1.v_int_member" ".*.\[0-9\]* = 2" "set variable structure int member"
340 test_set "set variable v_struct1.v_long_member=3" "print v_struct1.v_long_member" ".*.\[0-9\]* = 3" "set variable structure long member"
341 test_set "set variable v_struct1.v_float_member=4.0" "print v_struct1.v_float_member" ".*.\[0-9\]* = 4" "set variable structure float member"
342 test_set "set variable v_struct1.v_double_member=5.0" "print v_struct1.v_double_member" ".*.\[0-9\]* = 5" "set variable structure double member"
343
344 gdb_test "print v_struct1" \
345 ".*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
346 .*v_int_member = 2,.*\
347 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
348 "set print structure #1"
349
350 # Some believe that the following should be an error. GCC extensions for
351 # structure constants require the type of the structure to be specified, as in
352 # v_struct1 = (struct t_struct) {32, 33, 34, 35, 36, 37}
353 # The argument is that GDB should do the same if it wants to provide this
354 # feature, i.e., require the cast.
355 # We decided that we don't want the debugger to be as picky as a
356 # compiler and make us type complex casts.
357
358 # We need to up this because this can be really slow on some boards.
359 # (malloc() is called as part of the test).
360 set prev_timeout $timeout
361 set timeout 60
362
363 # Change the values
364 test_set "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" \
365 "print v_struct1" \
366 ".*.\[0-9\]* = \\{.*v_char_member = 32 \' \',.*v_short_member = 33,\
367 .*v_int_member = 34,.*\
368 v_long_member = 35,.*v_float_member = 36,.*v_double_member = 37.*\\}" \
369 "set print structure #2"
370
371 # Change them back
372 test_set "set variable v_struct1 = {'h', 1, 2, 3, 4.0, 5.0}" \
373 "print v_struct1" \
374 ".*.\[0-9\]* = \\{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
375 .*v_int_member = 2,.*\
376 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\\}" \
377 "set print structure #3"
378
379 #
380 # test "set variable" for nested struct
381 #
382 test_set "set variable v_struct3 = {1, {'h', 1, 2, 3, 4.0, 5.0}, 37}" \
383 "print v_struct3" \
384 ".*.\[0-9\]* = \\{.*v_long_member = 1,.*t = \\{.*v_char_member = 104 \'h\',.*v_short_member = 1,.*v_int_member = 2,.*v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\\},.*v_char_member = 37 \'%\'\\}" \
385 "set print structure #4"
386
387 set timeout $prev_timeout
388
389 # Test printing of enumeration bitfields.
390 # GNU C supports them, some other compilers don't.
391
392 if {$gcc_compiled} then {
393 gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1"
394 gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)"
395 gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1"
396 gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field (s1)"
397 gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2"
398 gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field (u2)"
399 gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1"
400 gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field (u1)"
401
402 # Test for truncation when assigning invalid values to bitfields.
403 gdb_test "print sef.field=7" \
404 ".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1"
405 gdb_test "print uef.field=6" \
406 ".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2"
407 }
This page took 0.038789 seconds and 4 git commands to generate.