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