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