Commit | Line | Data |
---|---|---|
091c48f6 MC |
1 | # Copyright 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001 |
2 | # Free Software Foundation, Inc. | |
c906108c SS |
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 | ||
99ebe9ac | 141 | test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.0\'" "set variable char=0" |
c906108c SS |
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 | # | |
99ebe9ac | 152 | test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.0\'" "set variable signed char=0" |
c906108c SS |
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 | # | |
99ebe9ac | 171 | test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.0\'" "set variable unsigned char=0" |
c906108c SS |
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 | # | |
49c890fc | 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" |
c906108c SS |
262 | # |
263 | # test "set variable" for "signed short array[2]" | |
264 | # | |
49c890fc | 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" |
c906108c SS |
266 | # |
267 | # test "set variable" for "unsigned short array[2]" | |
268 | # | |
49c890fc | 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" |
c906108c SS |
270 | # |
271 | # test "set variable" for "int array[2]" | |
272 | # | |
49c890fc | 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" |
c906108c SS |
274 | # |
275 | # test "set variable" for "signed int array[2]" | |
276 | # | |
49c890fc | 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" |
c906108c SS |
278 | # |
279 | # test "set variable" for "unsigned int array[2]" | |
280 | # | |
49c890fc | 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" |
c906108c SS |
282 | # |
283 | # test "set variable" for "long array[2]" | |
284 | # | |
49c890fc | 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" |
c906108c SS |
286 | # |
287 | # test "set variable" for "signed long array[2]" | |
288 | # | |
49c890fc | 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" |
c906108c SS |
290 | # |
291 | # test "set variable" for "unsigned long array[2]" | |
292 | # | |
49c890fc | 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" |
c906108c SS |
294 | # |
295 | # test "set variable" for "float array[2]" | |
296 | # | |
49c890fc | 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" |
c906108c SS |
298 | # |
299 | # test "set variable" for "double array[2]" | |
300 | # | |
49c890fc | 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" |
c906108c SS |
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 | # | |
49c890fc | 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" |
c906108c SS |
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" "" | |
cb135b83 | 324 | gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\\{123,.*-456\\}" \ |
c906108c SS |
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" "" | |
085dd6e6 | 333 | # DTS 10060CLLbs - bad type info from cc |
a0b3c4fd | 334 | if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs} |
cb135b83 | 335 | gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\\{123,.*65080\\}" \ |
c906108c | 336 | "set variable unsigned short pointer" |
085dd6e6 | 337 | # DTS 10060CLLbs - bad type info from cc |
a0b3c4fd | 338 | if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs} |
c906108c SS |
339 | gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080" |
340 | # | |
341 | # test "set variable" for type "int *" | |
342 | # | |
49c890fc | 343 | 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" |
c906108c SS |
344 | # |
345 | # test "set variable" for type "signed int *" | |
346 | # | |
49c890fc | 347 | 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" |
c906108c SS |
348 | # |
349 | # test "set variable" for type "unsigned int *" | |
350 | # | |
49c890fc | 351 | 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" |
c906108c SS |
352 | test_set "" "print *(v_unsigned_int_pointer+1)" ".*.\[0-9\]* = (4294966840|65080)" "print variable unsigned int pointer+1" |
353 | # | |
354 | # test "set variable" for type "long *" | |
355 | # | |
49c890fc | 356 | 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" |
c906108c SS |
357 | # |
358 | # test "set variable" for type "signed long *" | |
359 | # | |
49c890fc | 360 | 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" |
c906108c SS |
361 | # |
362 | # test "set variable" for type "unsigned long *" | |
363 | # | |
49c890fc | 364 | 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" |
c906108c SS |
365 | # |
366 | # test "set variable" for type "float *" | |
367 | # | |
49c890fc | 368 | 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" |
c906108c SS |
369 | # |
370 | # test "set variable" for type "double *" | |
371 | # | |
49c890fc | 372 | 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" |
c906108c SS |
373 | # |
374 | # test "set variable" for struct members | |
375 | # | |
376 | 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" | |
377 | test_set "set variable v_struct1.v_short_member=1" "print v_struct1.v_short_member" ".*.\[0-9\]* = 1" "set variable structure short member" | |
378 | test_set "set variable v_struct1.v_int_member=2" "print v_struct1.v_int_member" ".*.\[0-9\]* = 2" "set variable structure int member" | |
379 | test_set "set variable v_struct1.v_long_member=3" "print v_struct1.v_long_member" ".*.\[0-9\]* = 3" "set variable structure long member" | |
380 | 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" | |
381 | 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" | |
382 | ||
383 | gdb_test "print v_struct1" \ | |
384 | ".*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\ | |
385 | .*v_int_member = 2,.*\ | |
386 | v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \ | |
387 | "set print structure #1" | |
388 | ||
c4093a6a JM |
389 | # Some believe that the following should be an error. GCC extensions for |
390 | # structure constants require the type of the structure to be specified, as in | |
c906108c | 391 | # v_struct1 = (struct t_struct) {32, 33, 34, 35, 36, 37} |
c4093a6a JM |
392 | # The argument is that GDB should do the same if it wants to provide this |
393 | # feature, i.e., require the cast. | |
394 | # We decided that we don't want the debugger to be as picky as a | |
395 | # compiler and make us type complex casts. | |
396 | ||
9846de1b JM |
397 | # We need to up this because this can be really slow on some boards. |
398 | # (malloc() is called as part of the test). | |
399 | set timeout 60; | |
c906108c | 400 | |
c4093a6a JM |
401 | # Change the values |
402 | test_set "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" \ | |
403 | "print v_struct1" \ | |
49c890fc | 404 | ".*.\[0-9\]* = \\{.*v_char_member = 32 \' \',.*v_short_member = 33,\ |
c4093a6a | 405 | .*v_int_member = 34,.*\ |
49c890fc | 406 | v_long_member = 35,.*v_float_member = 36,.*v_double_member = 37.*\\}" \ |
c4093a6a JM |
407 | "set print structure #2" |
408 | ||
409 | # Change them back | |
410 | test_set "set variable v_struct1 = {'h', 1, 2, 3, 4.0, 5.0}" \ | |
411 | "print v_struct1" \ | |
49c890fc | 412 | ".*.\[0-9\]* = \\{.*v_char_member = 104 \'h\',.*v_short_member = 1,\ |
c906108c | 413 | .*v_int_member = 2,.*\ |
49c890fc | 414 | v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\\}" \ |
c4093a6a | 415 | "set print structure #3" |
c906108c SS |
416 | |
417 | # Test printing of enumeration bitfields. | |
418 | # GNU C supports them, some other compilers don't. | |
419 | ||
420 | if {$gcc_compiled} then { | |
421 | gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1" | |
422 | gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)" | |
423 | gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1" | |
424 | gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field (s1)" | |
425 | gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2" | |
426 | gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field (u2)" | |
427 | gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1" | |
428 | gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field (u1)" | |
429 | ||
430 | # Test for truncation when assigning invalid values to bitfields. | |
431 | gdb_test "print sef.field=7" \ | |
432 | ".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1" | |
433 | gdb_test "print uef.field=6" \ | |
434 | ".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2" | |
435 | } |