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