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