summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/setvar.exp
blob: 986ac17a8734aa779992ca87d2e6dd1d380ff711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# This testcase is part of GDB, the GNU debugger.

# Copyright 1988, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000,
# 2001, 2004, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@gnu.org

# This file was written by Rob Savoye. (rob@cygnus.com)

if $tracelevel then {
	strace $tracelevel
	}

#
# test running programs
#

set testfile "setvar"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested setvar.exp
     return -1
}

# Create and source the file that provides information about the compiler
# used to compile the test case.
if [get_compiler_info ${binfile}] {
    return -1;
}

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $binfile

#
# set it up at a breakpoint so we canplay with the variable values
#
gdb_test_no_output "set print sevenbit-strings" 

if ![runto_main] then {
    perror "couldn't run to breakpoint"
    continue
}

# Determine expected output for unsigned long variables,
# the output varies with sizeof (unsigned long).

gdb_test_multiple "print sizeof (unsigned long)" "sizeof ulong" {
    -re ".\[0-9\]* = 4.*$gdb_prompt $" {
	set ulong_minus_1 4294967295
	set ulong_minus_456 4294966840
    }
    -re ".\[0-9\]* = 8.*$gdb_prompt $" {
	set ulong_minus_1 18446744073709551615
	set ulong_minus_456 18446744073709551160
    }
}    

proc test_set { args } {
    global gdb_prompt

    set length [expr [llength $args] - 1];
    set message "[lindex $args $length]";
    set final [expr $length - 2];
    set count 1;

    # Set up the variables.
    for {set x 0;} {$x < $length} {incr x;} {
	if { "[lindex $args $x]" != "" } {
	    set arg [lindex $args $x];
	    if { ($x == $final) || ([string first ".*" [lindex $args [expr $x + 1]]] >= 0) } {
		set match [lindex $args [expr $x + 1]];
		if { $count == 1 } {
		    set mess "$message"
		} else {
		    set mess "$message (#$count)";
		}
		incr count;
		incr x;
	    } else {
		set mess "";
		set match ""
	    }
	    verbose "doing $arg $match"
	    if [gdb_test "$arg" "$match" "$mess"] {
		fail "$message -- $match";
		return 1;
	    }
	}
    }
    return 0;
}

#
# test "set variable" for type "char"
#
# Because bare char types can be either signed or unsigned, we just test the
# range of values that are common to both (0-127).
#    

test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.000\'"        "set variable char=0" 
test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'"        "set variable char=1" 
test_set "set variable v_char=7" "print v_char" ".\[0-9\]* = 7 \'.a\'"        "set variable char=7 (Bel)" 
test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'"        "set variable char=32 (SPC)" 
test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'"        "set variable char=65 ('A')" 
test_set "set variable v_char=97" "print v_char" ".\[0-9\]* = 97 \'a\'"        "set variable char=97 ('a')" 
test_set "set variable v_char=126" "print v_char" ".\[0-9\]* = 126 \'~\'"        "set variable char=126 ('~')" 
test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'"        "set variable char=127 (8-bit)" 
#
# test "set variable" for type "signed char"
#    
test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.000\'"                 "set variable signed char=0" 
test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'"        "set variable signed char=1" 
test_set "set variable v_signed_char=7" "print v_signed_char" ".\[0-9\]* = 7 \'.a\'"        "set variable signed char=7 (Bel)" 
test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'"        "set variable signed char=32 (SPC)" 
test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'"        "set variable signed char=65 ('A')" 
test_set "set variable v_signed_char=97" "print v_signed_char" ".\[0-9\]* = 97 \'a\'"        "set variable signed char=97 ('a')" 
test_set "set variable v_signed_char=126" "print v_signed_char" ".\[0-9\]* = 126 \'~\'"        "set variable signed char=126 ('~')" 
test_set "set variable v_signed_char=127" "print v_signed_char" ".\[0-9\]* = 127 \'.177\'"        "set variable signed char=127 (8-bit)" 
gdb_test_no_output "set variable v_signed_char=-1"
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
    "set variable signed char=-1 (-1)"
gdb_test_no_output "set variable v_signed_char=0xFF"
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
    "set variable signed char=0xFF (0xFF)"
#
# test "set variable" for type "unsigned char"
#
test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.000\'"        "set variable unsigned char=0" 
test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'"        "set variable unsigned char=1" 
test_set "set variable v_unsigned_char=7" "print v_unsigned_char" ".\[0-9\]* = 7 \'.a\'"        "set variable unsigned char=7 (Bel)" 
test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'"        "set variable unsigned char=32 (SPC)" 
test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'"        "set variable unsigned char=65 ('A')" 
test_set "set variable v_unsigned_char=97" "print v_unsigned_char" ".\[0-9\]* = 97 \'a\'"        "set variable unsigned char=97 ('a')" 
test_set "set variable v_unsigned_char=126" "print v_unsigned_char" ".\[0-9\]* = 126 \'~\'"        "set variable unsigned char=126 ('~')" 
test_set "set variable v_unsigned_char=~0" "print v_unsigned_char" ".\[0-9\]* = 255 \'.377\'"        "set variable unsigned char=255 (8-bit)" 
#
# test "set variable" for type "short"
#
test_set "set variable v_short=0" "print v_short" ".\[0-9\]* = 0"        "set variable short=0" 
test_set "set variable v_short=1" "print v_short" ".\[0-9\]* = 1"        "set variable short=1" 
test_set "set variable v_short=-1" "print v_short" ".\[0-9\]* = -1"        "set variable short=-1 (minus)" 
#
# test "set variable" for type "signed short"
#
test_set "set variable v_signed_short=0" "print v_signed_short" ".\[0-9\]* = 0"        "set variable signed short=0" 
test_set "set variable v_signed_short=1" "print v_signed_short" ".\[0-9\]* = 1"        "set variable signed short=1" 
test_set "set variable v_signed_short=-1" "print v_signed_short" ".\[0-9\]* = -1"        "set variable signed short=-1 (minus)" 
#
# test "set variable" for type "unsigned short"
#
test_set "set variable v_unsigned_short=0" "print v_unsigned_short" ".\[0-9\]* = 0"        "set variable unsigned short=0" 
test_set "set variable v_unsigned_short=1" "print v_unsigned_short" ".\[0-9\]* = 1"        "set variable unsigned short=1" 
test_set "set variable v_unsigned_short=~0" "print v_unsigned_short" ".\[0-9\]* = 65535"        "set variable unsigned short=~0 (minus)" 
#
# test "set variable" for type "int"
#
test_set "set variable v_int=0" "print v_int" ".\[0-9\]* = 0"        "set variable int=0" 
test_set "set variable v_int=1" "print v_int" ".\[0-9\]* = 1"        "set variable int=1" 
test_set "set variable v_int=-1" "print v_int" ".\[0-9\]* = -1"        "set variable int=-1 (minus)" 
#
# test "set variable" for type "signed int"
#
test_set "set variable v_signed_int=0" "print v_signed_int" ".\[0-9\]* = 0"        "set variable signed int=0" 
test_set "set variable v_signed_int=1" "print v_signed_int" ".\[0-9\]* = 1"        "set variable signed int=1" 
test_set "set variable v_signed_int=-1" "print v_signed_int" ".\[0-9\]* = -1"        "set variable signed int=-1 (minus)" 
#
# test "set variable" for type "unsigned int"
#
test_set "set variable v_unsigned_int=0" "print v_unsigned_int" ".\[0-9\]* = 0"        "set variable unsigned int=0" 
test_set "set variable v_unsigned_int=1" "print v_unsigned_int" ".\[0-9\]* = 1"        "set variable unsigned int=1" 
test_set "set variable v_unsigned_int=~0" "print v_unsigned_int" ".\[0-9\]* = (4294967295|65535)"        "set variable unsigned int=~0 (minus)" 
#test_set ".\[0-9\]* = 65535"        "set variable unsigned int=~0 (minus)" 
#
# test "set variable" for type "long"
#
test_set "set variable v_long=0" "print v_long" ".\[0-9\]* = 0"        "set variable long=0" 
test_set "set variable v_long=1" "print v_long" ".\[0-9\]* = 1"        "set variable long=1" 
test_set "set variable v_long=-1" "print v_long" ".\[0-9\]* = -1"        "set variable long=-1 (minus)" 
#
# test "set variable" for type "signed long"
#
test_set "set variable v_signed_long=0" "print v_signed_long" ".\[0-9\]* = 0"        "set variable signed long=0" 
test_set "set variable v_signed_long=1" "print v_signed_long" ".\[0-9\]* = 1"        "set variable signed long=1" 
test_set "set variable v_signed_long=-1" "print v_signed_long" ".\[0-9\]* = -1"        "set variable signed long=-1 (minus)" 
#
# test "set variable" for type "unsigned long"
#
test_set "set variable v_unsigned_long=0" "print v_unsigned_long" ".\[0-9\]* = 0"        "set variable unsigned long=0" 
test_set "set variable v_unsigned_long=1" "print v_unsigned_long" ".\[0-9\]* = 1"        "set variable unsigned long=1" 
test_set "set variable v_unsigned_long=~0" "print v_unsigned_long" ".\[0-9\]* = $ulong_minus_1"        "set variable unsigned long=~0 (minus)" 
#
# test "set variable" for type "float"
#
test_set "set variable v_float=0.0" "print v_float" ".\[0-9\]* = 0"        "set variable float=0" 
test_set "set variable v_float=1.0" "print v_float" ".\[0-9\]* = 1"        "set variable float=1" 
test_set "set variable v_float=-1.0" "print v_float" ".\[0-9\]* = -1"        "set variable float=-1 (minus)" 
#
# test "set variable" for type "double"
#
test_set "set variable v_double=0.0" "print v_double" ".\[0-9\]* = 0"        "set variable double=0" 
test_set "set variable v_double=1.0" "print v_double" ".\[0-9\]* = 1"        "set variable double=1" 
test_set "set variable v_double=-1.0" "print v_double" ".*.\[0-9\]* = -1"        "set variable double=-1 (minus)" 
#
# test "set variable" for "char array[2]"
#
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)" 
#
# test "set variable" for "signed char array[2]"
#
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)" 
#
# test "set variable" for "unsigned char array[2]"
#
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)" 
#
# test "set variable" for "short array[2]"
#
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" 
#
# test "set variable" for "signed short array[2]"
#
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" 
#
# test "set variable" for "unsigned short array[2]"
#
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" 
#
# test "set variable" for "int array[2]"
#
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" 
#
# test "set variable" for "signed int array[2]"
#
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" 
#
# test "set variable" for "unsigned int array[2]"
#
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" 
#
# test "set variable" for "long array[2]"
#
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" 
#
# test "set variable" for "signed long array[2]"
#
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" 
#
# test "set variable" for "unsigned long array[2]"
#
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" 
#
# test "set variable" for "float array[2]"
#
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" 
#
# test "set variable" for "double array[2]"
#
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" 
#
# test "set variable" for type "char *"
#
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)" 
#
# test "set variable" for type "signed char *"
#
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)" 
#
# test "set variable" for type "unsigned char *"
#
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)" 
#
# test "set variable" for type "short *"
#
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" 
#
# test "set variable" for type "signed short *"
#
gdb_test_no_output "set v_signed_short_pointer=v_signed_short_array"
gdb_test_no_output "set variable *(v_signed_short_pointer)=123"
gdb_test_no_output "set variable *(v_signed_short_pointer+1)=-456"
gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\\{123,.*-456\\}" \
    "set variable signed short pointer"
gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
#
# test "set variable" for type "unsigned short *"
#
gdb_test_no_output "set v_unsigned_short_pointer=v_unsigned_short_array"
gdb_test_no_output "set variable *(v_unsigned_short_pointer)=123"
gdb_test_no_output "set variable *(v_unsigned_short_pointer+1)=-456"
gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\\{123,.*65080\\}" \
    "set variable unsigned short pointer"
gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080"
#
# test "set variable" for type "int *"
#
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" 
#
# test "set variable" for type "signed int *"
#
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" 
#
# test "set variable" for type "unsigned int *"
#
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"
test_set "" "print *(v_unsigned_int_pointer+1)" ".*.\[0-9\]* = (4294966840|65080)"     "print variable unsigned int pointer+1"
#
# test "set variable" for type "long *"
#
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" 
#
# test "set variable" for type "signed long *"
#
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" 
#
# test "set variable" for type "unsigned long *"
#
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" 
#
# test "set variable" for type "float *"
#
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" 
#
# test "set variable" for type "double *"
#
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" 
#
# test "set variable" for struct members
#
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" 
test_set "set variable v_struct1.v_short_member=1" "print v_struct1.v_short_member" ".*.\[0-9\]* = 1"        "set variable structure short member" 
test_set "set variable v_struct1.v_int_member=2" "print v_struct1.v_int_member" ".*.\[0-9\]* = 2"        "set variable structure int member" 
test_set "set variable v_struct1.v_long_member=3" "print v_struct1.v_long_member" ".*.\[0-9\]* = 3"        "set variable structure long member" 
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" 
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" 

gdb_test "print v_struct1" \
  ".*.\[0-9\]* = \{.*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.*\}" \
  "set print structure #1"

# Some believe that the following  should be an error.  GCC extensions for
# structure constants require the type of the structure to be specified, as in
# v_struct1 = (struct t_struct) {32, 33, 34, 35, 36, 37}
# The argument is that GDB should do the same if it wants to provide this
# feature, i.e., require the cast.
# We decided that we don't want the debugger to be as picky as a
# compiler and make us type complex casts.

# We need to up this because this can be really slow on some boards.
# (malloc() is called as part of the test).
set prev_timeout $timeout
set timeout 60

# Change the values
test_set "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" \
  "print v_struct1" \
  ".*.\[0-9\]* = \\{.*v_char_member = 32 \' \',.*v_short_member = 33,\
.*v_int_member = 34,.*\
v_long_member = 35,.*v_float_member = 36,.*v_double_member = 37.*\\}" \
  "set print structure #2"

# Change them back
test_set "set variable v_struct1 = {'h', 1, 2, 3, 4.0, 5.0}" \
  "print v_struct1" \
  ".*.\[0-9\]* = \\{.*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.*\\}" \
  "set print structure #3"

set timeout $prev_timeout

# Test printing of enumeration bitfields.
# GNU C supports them, some other compilers don't.

if {$gcc_compiled} then {
    gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1"
    gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)"
    gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1"
    gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field (s1)"
    gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2"
    gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field (u2)"
    gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1"
    gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field (u1)"

    # Test for truncation when assigning invalid values to bitfields.
    gdb_test "print sef.field=7" \
	".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1"
    gdb_test "print uef.field=6" \
	".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2"
}