* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / setvar.exp
1 # Copyright (C) 1988, 1990, 1991, 1992, 1994, 1995
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 # This file was written by Rob Savoye. (rob@cygnus.com)
22
23 if $tracelevel then {
24 strace $tracelevel
25 }
26
27 #
28 # test running programs
29 #
30 set prms_id 0
31 set bug_id 0
32
33 set testfile "setvar"
34 set srcfile ${testfile}.c
35 set binfile ${objdir}/${subdir}/${testfile}
36 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37 perror "Couldn't compile ${srcfile}"
38 return -1
39 }
40
41 # Create and source the file that provides information about the compiler
42 # used to compile the test case.
43 if [get_compiler_info ${binfile}] {
44 return -1;
45 }
46
47 gdb_exit
48 gdb_start
49 gdb_reinitialize_dir $srcdir/$subdir
50 gdb_load $binfile
51
52 #
53 # set it up at a breakpoint so we canplay with the variable values
54 #
55 send_gdb "set print sevenbit-strings\n" ; expect -re "$gdb_prompt $"
56
57 if ![runto_main] then {
58 perror "couldn't run to breakpoint"
59 continue
60 }
61
62 # Determine expected output for unsigned long variables,
63 # the output varies with sizeof (unsigned long).
64
65 set ulong_minus_1 4294967295
66 set ulong_minus_456 4294966840
67 send_gdb "print sizeof (unsigned long)\n"
68 expect {
69 -re ".\[0-9\]* = 4.*$gdb_prompt $" {}
70 -re ".\[0-9\]* = 8.*$gdb_prompt $" {
71 set ulong_minus_1 18446744073709551615
72 set ulong_minus_456 18446744073709551160
73 }
74 -re ".*$gdb_prompt $" {
75 fail "getting sizeof unsigned long"
76 }
77 default { fail "(timeout) getting sizeof unsigned long" }
78 }
79
80 proc test_set { args } {
81 global gdb_prompt
82
83 set length [expr [llength $args] - 3];
84 set print_cmd "[lindex $args $length]";
85 set print_result "[lindex $args [expr $length + 1]]";
86 set message "[lindex $args [expr $length + 2]]";
87
88 # Set up the variables.
89 for {set x 0;} {$x < $length} {incr x;} {
90 if { "[lindex $args $x]" != "" } {
91 verbose "doing [lindex $args $x]"
92 if [gdb_test "[lindex $args $x]" "" ""] {
93 fail "$message [lindex $args $x]";
94 return 1;
95 }
96 }
97 }
98 verbose "expecting $print_result from '$print_cmd'"
99 # Now run the test.
100 return [gdb_test "$print_cmd" "$print_result" "$message"];
101 }
102
103 #
104 # test "set variable" for type "char"
105 #
106 # Because bare char types can be either signed or unsigned, we just test the
107 # range of values that are common to both (0-127).
108 #
109
110 test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.000\'" "set variable char=0"
111 test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'" "set variable char=1"
112 test_set "set variable v_char=27" "print v_char" ".\[0-9\]* = 27 \'.e\'" "set variable char=27 (Esc)"
113 test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'" "set variable char=32 (SPC)"
114 test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'" "set variable char=65 ('A')"
115 test_set "set variable v_char=97" "print v_char" ".\[0-9\]* = 97 \'a\'" "set variable char=97 ('a')"
116 test_set "set variable v_char=126" "print v_char" ".\[0-9\]* = 126 \'~\'" "set variable char=126 ('~')"
117 test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'" "set variable char=127 (8-bit)"
118 #
119 # test "set variable" for type "signed char"
120 #
121 test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.000\'" "set variable signed char=0"
122 test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'" "set variable signed char=1"
123 test_set "set variable v_signed_char=27" "print v_signed_char" ".\[0-9\]* = 27 \'.e\'" "set variable signed char=27 (Esc)"
124 test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'" "set variable signed char=32 (SPC)"
125 test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'" "set variable signed char=65 ('A')"
126 test_set "set variable v_signed_char=97" "print v_signed_char" ".\[0-9\]* = 97 \'a\'" "set variable signed char=97 ('a')"
127 test_set "set variable v_signed_char=126" "print v_signed_char" ".\[0-9\]* = 126 \'~\'" "set variable signed char=126 ('~')"
128 test_set "set variable v_signed_char=127" "print v_signed_char" ".\[0-9\]* = 127 \'.177\'" "set variable signed char=127 (8-bit)"
129 gdb_test "set variable v_signed_char=-1" ""
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=-1 (-1)"
133 gdb_test "set variable v_signed_char=0xFF" ""
134 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
135 gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
136 "set variable signed char=0xFF (0xFF)"
137 #
138 # test "set variable" for type "unsigned char"
139 #
140 test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.000\'" "set variable unsigned char=0"
141 test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'" "set variable unsigned char=1"
142 test_set "set variable v_unsigned_char=27" "print v_unsigned_char" ".\[0-9\]* = 27 \'.e\'" "set variable unsigned char=27 (Esc)"
143 test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'" "set variable unsigned char=32 (SPC)"
144 test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'" "set variable unsigned char=65 ('A')"
145 test_set "set variable v_unsigned_char=97" "print v_unsigned_char" ".\[0-9\]* = 97 \'a\'" "set variable unsigned char=97 ('a')"
146 test_set "set variable v_unsigned_char=126" "print v_unsigned_char" ".\[0-9\]* = 126 \'~\'" "set variable unsigned char=126 ('~')"
147 test_set "set variable v_unsigned_char=~0" "print v_unsigned_char" ".\[0-9\]* = 255 \'.377\'" "set variable unsigned char=255 (8-bit)"
148 #
149 # test "set variable" for type "short"
150 #
151 test_set "set variable v_short=0" "print v_short" ".\[0-9\]* = 0" "set variable short=0"
152 test_set "set variable v_short=1" "print v_short" ".\[0-9\]* = 1" "set variable short=1"
153 test_set "set variable v_short=-1" "print v_short" ".\[0-9\]* = -1" "set variable short=-1 (minus)"
154 #
155 # test "set variable" for type "signed short"
156 #
157 test_set "set variable v_signed_short=0" "print v_signed_short" ".\[0-9\]* = 0" "set variable signed short=0"
158 test_set "set variable v_signed_short=1" "print v_signed_short" ".\[0-9\]* = 1" "set variable signed short=1"
159 test_set "set variable v_signed_short=-1" "print v_signed_short" ".\[0-9\]* = -1" "set variable signed short=-1 (minus)"
160 #
161 # test "set variable" for type "unsigned short"
162 #
163 test_set "set variable v_unsigned_short=0" "print v_unsigned_short" ".\[0-9\]* = 0" "set variable unsigned short=0"
164 test_set "set variable v_unsigned_short=1" "print v_unsigned_short" ".\[0-9\]* = 1" "set variable unsigned short=1"
165 test_set "set variable v_unsigned_short=~0" "print v_unsigned_short" ".\[0-9\]* = 65535" "set variable unsigned short=~0 (minus)"
166 #
167 # test "set variable" for type "int"
168 #
169 test_set "set variable v_int=0" "print v_int" ".\[0-9\]* = 0" "set variable int=0"
170 test_set "set variable v_int=1" "print v_int" ".\[0-9\]* = 1" "set variable int=1"
171 test_set "set variable v_int=-1" "print v_int" ".\[0-9\]* = -1" "set variable int=-1 (minus)"
172 #
173 # test "set variable" for type "signed int"
174 #
175 test_set "set variable v_signed_int=0" "print v_signed_int" ".\[0-9\]* = 0" "set variable signed int=0"
176 test_set "set variable v_signed_int=1" "print v_signed_int" ".\[0-9\]* = 1" "set variable signed int=1"
177 test_set "set variable v_signed_int=-1" "print v_signed_int" ".\[0-9\]* = -1" "set variable signed int=-1 (minus)"
178 #
179 # test "set variable" for type "unsigned int"
180 #
181 test_set "set variable v_unsigned_int=0" "print v_unsigned_int" ".\[0-9\]* = 0" "set variable unsigned int=0"
182 test_set "set variable v_unsigned_int=1" "print v_unsigned_int" ".\[0-9\]* = 1" "set variable unsigned int=1"
183 test_set "set variable v_unsigned_int=~0" "print v_unsigned_int" ".\[0-9\]* = (4294967295|65535)" "set variable unsigned int=~0 (minus)"
184 #test_set ".\[0-9\]* = 65535" "set variable unsigned int=~0 (minus)"
185 #
186 # test "set variable" for type "long"
187 #
188 test_set "set variable v_long=0" "print v_long" ".\[0-9\]* = 0" "set variable long=0"
189 test_set "set variable v_long=1" "print v_long" ".\[0-9\]* = 1" "set variable long=1"
190 test_set "set variable v_long=-1" "print v_long" ".\[0-9\]* = -1" "set variable long=-1 (minus)"
191 #
192 # test "set variable" for type "signed long"
193 #
194 test_set "set variable v_signed_long=0" "print v_signed_long" ".\[0-9\]* = 0" "set variable signed long=0"
195 test_set "set variable v_signed_long=1" "print v_signed_long" ".\[0-9\]* = 1" "set variable signed long=1"
196 test_set "set variable v_signed_long=-1" "print v_signed_long" ".\[0-9\]* = -1" "set variable signed long=-1 (minus)"
197 #
198 # test "set variable" for type "unsigned long"
199 #
200 test_set "set variable v_unsigned_long=0" "print v_unsigned_long" ".\[0-9\]* = 0" "set variable unsigned long=0"
201 test_set "set variable v_unsigned_long=1" "print v_unsigned_long" ".\[0-9\]* = 1" "set variable unsigned long=1"
202 test_set "set variable v_unsigned_long=~0" "print v_unsigned_long" ".\[0-9\]* = $ulong_minus_1" "set variable unsigned long=~0 (minus)"
203 #
204 # test "set variable" for type "float"
205 #
206 test_set "set variable v_float=0.0" "print v_float" ".\[0-9\]* = 0" "set variable float=0"
207 test_set "set variable v_float=1.0" "print v_float" ".\[0-9\]* = 1" "set variable float=1"
208 test_set "set variable v_float=-1.0" "print v_float" ".\[0-9\]* = -1" "set variable float=-1 (minus)"
209 #
210 # test "set variable" for type "double"
211 #
212 test_set "set variable v_double=0.0" "print v_double" ".\[0-9\]* = 0" "set variable double=0"
213 test_set "set variable v_double=1.0" "print v_double" ".\[0-9\]* = 1" "set variable double=1"
214 test_set "set variable v_double=-1.0" "print v_double" "print.*.\[0-9\]* = -1" "set variable double=-1 (minus)"
215 #
216 # test "set variable" for "char array[2]"
217 #
218 test_set "set variable v_char_array\[0\]='h'" "set variable v_char_array\[1\]='i'" "print v_char_array" "print.*.\[0-9\]* =.*\"hi\"" "set variable char array=\"hi\" (string)"
219 #
220 # test "set variable" for "signed char array[2]"
221 #
222 test_set "set variable v_signed_char_array\[0\]='h'" "set variable v_signed_char_array\[1\]='i'" "print v_signed_char_array" "print.*.\[0-9\]* =.*\"hi\"" "set variable signed char array=\"hi\" (string)"
223 #
224 # test "set variable" for "unsigned char array[2]"
225 #
226 test_set "set variable v_unsigned_char_array\[0\]='h'" "set variable v_unsigned_char_array\[1\]='i'" "print v_unsigned_char_array" "print.*.\[0-9\]* =.*\"hi\"" "set variable unsigned char array=\"hi\" (string)"
227 #
228 # test "set variable" for "short array[2]"
229 #
230 test_set "set variable v_short_array\[0\]=123" "set variable v_short_array\[1\]=-456" "print v_short_array" "print.*.\[0-9\]* =.*\{123,.*-456\}" "set variable short array"
231 #
232 # test "set variable" for "signed short array[2]"
233 #
234 test_set "set variable v_signed_short_array\[0\]=123" "set variable v_signed_short_array\[1\]=-456" "print v_signed_short_array" "print.*.\[0-9\]* =.*\{123,.*-456\}" "set variable signed short array"
235 #
236 # test "set variable" for "unsigned short array[2]"
237 #
238 test_set "set variable v_unsigned_short_array\[0\]=123" "set variable v_unsigned_short_array\[1\]=-456" "print v_unsigned_short_array" "print.*.\[0-9\]* =.*\{123,.*65080\}" "set variable unsigned short array"
239 #
240 # test "set variable" for "int array[2]"
241 #
242 test_set "set variable v_int_array\[0\]=123" "set variable v_int_array\[1\]=-456" "print v_int_array" "print.*.\[0-9\]* =.*\{123,.*-456\}" "set variable int array"
243 #
244 # test "set variable" for "signed int array[2]"
245 #
246 test_set "set variable v_signed_int_array\[0\]=123" "set variable v_signed_int_array\[1\]=-456" "print v_signed_int_array" "print.*.\[0-9\]* =.*\{123,.*-456\}" "set variable signed int array"
247 #
248 # test "set variable" for "unsigned int array[2]"
249 #
250 test_set "set variable v_unsigned_int_array\[0\]=123" "set variable v_unsigned_int_array\[1\]=-456" "print v_unsigned_int_array" "print.*.\[0-9\]* =.*\{123,.*(4294966840|65080)\}" "set variable unsigned int array"
251 #
252 # test "set variable" for "long array[2]"
253 #
254 test_set "set variable v_long_array\[0\]=123" "set variable v_long_array\[1\]=-456" "print v_long_array" "print.*.\[0-9\]* =.*\{123,.*-456\}" "set variable long array"
255 #
256 # test "set variable" for "signed long array[2]"
257 #
258 test_set "set variable v_signed_long_array\[0\]=123" "set variable v_signed_long_array\[1\]=-456" "print v_signed_long_array" "print.*.\[0-9\]* =.*\{123,.*-456\}" "set variable signed long array"
259 #
260 # test "set variable" for "unsigned long array[2]"
261 #
262 test_set "set variable v_unsigned_long_array\[0\]=123" "set variable v_unsigned_long_array\[1\]=-456" "print v_unsigned_long_array" "print.*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}" "set variable unsigned long array"
263 #
264 # test "set variable" for "float array[2]"
265 #
266 test_set "set variable v_float_array\[0\]=123.0" "set variable v_float_array\[1\]=-456.0" "print v_float_array" "print.*.\[0-9\]* =.*\{123,.*-456\}" "set variable float array"
267 #
268 # test "set variable" for "double array[2]"
269 #
270 test_set "set variable v_double_array\[0\]=123.0" "set variable v_double_array\[1\]=-456.0" "print v_double_array" "print.*.\[0-9\]* =.*\{123,.*-456\}" "set variable double array"
271 #
272 # test "set variable" for type "char *"
273 #
274 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" "print.*.\[0-9\]* =.*\"hi\"" "print *(v_char_pointer+1)" "print.*.\[0-9\]* = 105 \'i\'" "set variable char pointer=\"hi\" (string)"
275 #
276 # test "set variable" for type "signed char *"
277 #
278 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" "print.*.\[0-9\]* =.*\"hi\"" "print *(v_signed_char_pointer+1)" "print.*.\[0-9\]* = 105 \'i\'" "set variable signed char pointer=\"hi\" (string)"
279 #
280 # test "set variable" for type "unsigned char *"
281 #
282 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" "print.*.\[0-9\]* =.*\"hi\"" "print *(v_unsigned_char_pointer+1)" "print.*.\[0-9\]* = 105 \'i\'" "set variable unsigned char pointer=\"hi\" (string)"
283 #
284 # test "set variable" for type "short *"
285 #
286 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" "print.*.\[0-9\]* =.*\{123,.*-456\}" "print *(v_short_pointer+1)" "print.*.\[0-9\]* = -456" "set variable short pointer"
287 #
288 # test "set variable" for type "signed short *"
289 #
290 gdb_test "set v_signed_short_pointer=v_signed_short_array" ""
291 gdb_test "set variable *(v_signed_short_pointer)=123" ""
292 gdb_test "set variable *(v_signed_short_pointer+1)=-456" ""
293 gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\{123,.*-456\}" \
294 "set variable signed short pointer"
295 gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
296 #
297 # test "set variable" for type "unsigned short *"
298 #
299 gdb_test "set v_unsigned_short_pointer=v_unsigned_short_array" ""
300 gdb_test "set variable *(v_unsigned_short_pointer)=123" ""
301 gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" ""
302 gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\{123,.*65080\}" \
303 "set variable unsigned short pointer"
304 gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080"
305 #
306 # test "set variable" for type "int *"
307 #
308 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" "print.*.\[0-9\]* =.*\{123,.*-456\}" "print *(v_int_pointer+1)" "print.*.\[0-9\]* = -456" "set variable int pointer"
309 #
310 # test "set variable" for type "signed int *"
311 #
312 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" "print.*.\[0-9\]* =.*\{123,.*-456\}" "print *(v_signed_int_pointer+1)" "print.*.\[0-9\]* = -456" "set variable signed int pointer"
313 #
314 # test "set variable" for type "unsigned int *"
315 #
316 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" "print.*.\[0-9\]* =.*\{123,.*(4294966840|65080)\}" "set variable unsigned int pointer"
317 test_set "" "print *(v_unsigned_int_pointer+1)" "print.*.\[0-9\]* = (4294966840|65080)" "print variable unsigned int pointer+1"
318 #
319 # test "set variable" for type "long *"
320 #
321 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" "print.*.\[0-9\]* =.*\{123,.*-456\}" "print *(v_long_pointer+1)" "print.*.\[0-9\]* = -456" "set variable long pointer"
322 #
323 # test "set variable" for type "signed long *"
324 #
325 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" "print.*.\[0-9\]* =.*\{123,.*-456\}" "print *(v_signed_long_pointer+1)" "print.*.\[0-9\]* = -456" "set variable signed long pointer"
326 #
327 # test "set variable" for type "unsigned long *"
328 #
329 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" "print.*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}" "print *(v_unsigned_long_pointer+1)" "print.*.\[0-9\]* = $ulong_minus_456" "set variable unsigned long pointer"
330 #
331 # test "set variable" for type "float *"
332 #
333 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" "print.*.\[0-9\]* =.*\{123,.*-456\}" "print *(v_float_pointer+1)" "print.*.\[0-9\]* = -456" "set variable float pointer"
334 #
335 # test "set variable" for type "double *"
336 #
337 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" "print.*.\[0-9\]* =.*\{123,.*-456\}" "print *(v_double_pointer+1)" "print.*.\[0-9\]* = -456" "set variable double pointer"
338 #
339 # test "set variable" for struct members
340 #
341 test_set "set variable v_struct1.v_char_member='h'" "print v_struct1.v_char_member" "print.*.\[0-9\]* = 104 \'h\'" "set variable structure char member"
342 test_set "set variable v_struct1.v_short_member=1" "print v_struct1.v_short_member" "print.*.\[0-9\]* = 1" "set variable structure short member"
343 test_set "set variable v_struct1.v_int_member=2" "print v_struct1.v_int_member" "print.*.\[0-9\]* = 2" "set variable structure int member"
344 test_set "set variable v_struct1.v_long_member=3" "print v_struct1.v_long_member" "print.*.\[0-9\]* = 3" "set variable structure long member"
345 test_set "set variable v_struct1.v_float_member=4.0" "print v_struct1.v_float_member" "print.*.\[0-9\]* = 4" "set variable structure float member"
346 test_set "set variable v_struct1.v_double_member=5.0" "print v_struct1.v_double_member" "print.*.\[0-9\]* = 5" "set variable structure double member"
347
348 gdb_test "print v_struct1" \
349 "print.*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
350 .*v_int_member = 2,.*\
351 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
352 "set print structure #1"
353
354 # This should be an error. GCC extensions for structure constants require
355 # the type of the structure to be specified, as in
356 # v_struct1 = (struct t_struct) {32, 33, 34, 35, 36, 37}
357 # GDB should do the same if it wants to provide this feature.
358 if [target_info exists gdb,cannot_call_functions] {
359 setup_xfail "*-*-*" 2416
360 fail "set variable v_struct1 = {32, 33, 34, 35, 36, 37}"
361 continue
362 }
363 gdb_test "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" "Invalid.*"
364
365 # And after the error the structure should be unchanged.
366 gdb_test "print v_struct1" \
367 "print.*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
368 .*v_int_member = 2,.*\
369 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
370 "set print structure #2"
371
372 # Test printing of enumeration bitfields.
373 # GNU C supports them, some other compilers don't.
374
375 if {$gcc_compiled} then {
376 gdb_test "print sef.field=sm1" "print.*.\[0-9\]* = sm1"
377 gdb_test "print sef.field" "print.*.\[0-9\]* = sm1" "print sef.field (sm1)"
378 gdb_test "print sef.field=s1" "print.*.\[0-9\]* = s1"
379 gdb_test "print sef.field" "print.*.\[0-9\]* = s1" "print sef.field (s1)"
380 gdb_test "print uef.field=u2" "print.*.\[0-9\]* = u2"
381 gdb_test "print uef.field" "print.*.\[0-9\]* = u2" "print uef.field (u2)"
382 gdb_test "print uef.field=u1" "print.*.\[0-9\]* = u1"
383 gdb_test "print uef.field" "print.*.\[0-9\]* = u1" "print uef.field (u1)"
384
385 # Test for truncation when assigning invalid values to bitfields.
386 gdb_test "print sef.field=7" \
387 "print.*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1"
388 gdb_test "print uef.field=6" \
389 "print.*warning: Value does not fit in 2 bits.*\[0-9\]* = u2"
390 }
This page took 0.040903 seconds and 5 git commands to generate.