Commit | Line | Data |
---|---|---|
3c88a10a PS |
1 | # Copyright (C) 1988, 1990, 1991, 1992, 1994, 1995 |
2 | # Free Software Foundation, Inc. | |
ef44eed1 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 | |
3c88a10a | 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
ef44eed1 SS |
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 | ||
782445c7 | 33 | set testfile "setvar" |
787f6220 | 34 | set srcfile ${testfile}.c |
782445c7 | 35 | set binfile ${objdir}/${subdir}/${testfile} |
787f6220 | 36 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
782445c7 FF |
37 | perror "Couldn't compile ${srcfile}" |
38 | return -1 | |
39 | } | |
ef44eed1 | 40 | |
787f6220 BM |
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; | |
ef44eed1 SS |
45 | } |
46 | ||
47 | gdb_exit | |
48 | gdb_start | |
49 | gdb_reinitialize_dir $srcdir/$subdir | |
782445c7 | 50 | gdb_load $binfile |
ef44eed1 SS |
51 | |
52 | # | |
53 | # set it up at a breakpoint so we canplay with the variable values | |
54 | # | |
85fbaa74 | 55 | send_gdb "set print sevenbit-strings\n" ; expect -re "$gdb_prompt $" |
ef44eed1 | 56 | |
3c88a10a | 57 | if ![runto_main] then { |
ef44eed1 SS |
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 | |
787f6220 | 67 | send_gdb "print sizeof (unsigned long)\n" |
ef44eed1 | 68 | expect { |
85fbaa74 BM |
69 | -re ".\[0-9\]* = 4.*$gdb_prompt $" {} |
70 | -re ".\[0-9\]* = 8.*$gdb_prompt $" { | |
ef44eed1 SS |
71 | set ulong_minus_1 18446744073709551615 |
72 | set ulong_minus_456 18446744073709551160 | |
73 | } | |
85fbaa74 | 74 | -re ".*$gdb_prompt $" { |
ef44eed1 SS |
75 | fail "getting sizeof unsigned long" |
76 | } | |
77 | default { fail "(timeout) getting sizeof unsigned long" } | |
78 | } | |
79 | ||
787f6220 | 80 | proc test_set { args } { |
85fbaa74 | 81 | global gdb_prompt |
787f6220 BM |
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]" | |
c309781f BM |
92 | if [gdb_test "[lindex $args $x]" "" ""] { |
93 | fail "$message [lindex $args $x]"; | |
94 | return 1; | |
95 | } | |
787f6220 BM |
96 | } |
97 | } | |
98 | verbose "expecting $print_result from '$print_cmd'" | |
99 | # Now run the test. | |
c309781f | 100 | return [gdb_test "$print_cmd" "$print_result" "$message"]; |
787f6220 BM |
101 | } |
102 | ||
ef44eed1 SS |
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 | # | |
ef44eed1 | 109 | |
787f6220 BM |
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)" | |
ef44eed1 SS |
118 | # |
119 | # test "set variable" for type "signed char" | |
120 | # | |
787f6220 BM |
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)" | |
3c88a10a | 129 | gdb_test "set variable v_signed_char=-1" "" |
5762d8c6 | 130 | if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" } |
3c88a10a PS |
131 | gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \ |
132 | "set variable signed char=-1 (-1)" | |
3c88a10a | 133 | gdb_test "set variable v_signed_char=0xFF" "" |
5762d8c6 | 134 | if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" } |
3c88a10a PS |
135 | gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \ |
136 | "set variable signed char=0xFF (0xFF)" | |
ef44eed1 SS |
137 | # |
138 | # test "set variable" for type "unsigned char" | |
139 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
148 | # |
149 | # test "set variable" for type "short" | |
150 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
154 | # |
155 | # test "set variable" for type "signed short" | |
156 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
160 | # |
161 | # test "set variable" for type "unsigned short" | |
162 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
166 | # |
167 | # test "set variable" for type "int" | |
168 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
172 | # |
173 | # test "set variable" for type "signed int" | |
174 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
178 | # |
179 | # test "set variable" for type "unsigned int" | |
180 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
185 | # |
186 | # test "set variable" for type "long" | |
187 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
191 | # |
192 | # test "set variable" for type "signed long" | |
193 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
197 | # |
198 | # test "set variable" for type "unsigned long" | |
199 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
203 | # |
204 | # test "set variable" for type "float" | |
205 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
209 | # |
210 | # test "set variable" for type "double" | |
211 | # | |
787f6220 BM |
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)" | |
ef44eed1 SS |
215 | # |
216 | # test "set variable" for "char array[2]" | |
217 | # | |
787f6220 | 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)" |
ef44eed1 SS |
219 | # |
220 | # test "set variable" for "signed char array[2]" | |
221 | # | |
787f6220 | 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)" |
ef44eed1 SS |
223 | # |
224 | # test "set variable" for "unsigned char array[2]" | |
225 | # | |
787f6220 | 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)" |
ef44eed1 SS |
227 | # |
228 | # test "set variable" for "short array[2]" | |
229 | # | |
787f6220 | 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" |
ef44eed1 SS |
231 | # |
232 | # test "set variable" for "signed short array[2]" | |
233 | # | |
787f6220 | 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" |
ef44eed1 SS |
235 | # |
236 | # test "set variable" for "unsigned short array[2]" | |
237 | # | |
787f6220 | 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" |
ef44eed1 SS |
239 | # |
240 | # test "set variable" for "int array[2]" | |
241 | # | |
787f6220 | 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" |
ef44eed1 SS |
243 | # |
244 | # test "set variable" for "signed int array[2]" | |
245 | # | |
787f6220 | 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" |
ef44eed1 SS |
247 | # |
248 | # test "set variable" for "unsigned int array[2]" | |
249 | # | |
787f6220 | 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" |
ef44eed1 SS |
251 | # |
252 | # test "set variable" for "long array[2]" | |
253 | # | |
787f6220 | 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" |
ef44eed1 SS |
255 | # |
256 | # test "set variable" for "signed long array[2]" | |
257 | # | |
787f6220 | 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" |
ef44eed1 SS |
259 | # |
260 | # test "set variable" for "unsigned long array[2]" | |
261 | # | |
787f6220 | 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" |
ef44eed1 SS |
263 | # |
264 | # test "set variable" for "float array[2]" | |
265 | # | |
787f6220 | 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" |
ef44eed1 SS |
267 | # |
268 | # test "set variable" for "double array[2]" | |
269 | # | |
787f6220 | 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" |
ef44eed1 SS |
271 | # |
272 | # test "set variable" for type "char *" | |
273 | # | |
787f6220 | 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)" |
ef44eed1 SS |
275 | # |
276 | # test "set variable" for type "signed char *" | |
277 | # | |
787f6220 | 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)" |
ef44eed1 SS |
279 | # |
280 | # test "set variable" for type "unsigned char *" | |
281 | # | |
787f6220 | 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)" |
ef44eed1 SS |
283 | # |
284 | # test "set variable" for type "short *" | |
285 | # | |
787f6220 | 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" |
ef44eed1 SS |
287 | # |
288 | # test "set variable" for type "signed short *" | |
289 | # | |
3c88a10a PS |
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" | |
ef44eed1 SS |
296 | # |
297 | # test "set variable" for type "unsigned short *" | |
298 | # | |
3c88a10a PS |
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" | |
ef44eed1 SS |
305 | # |
306 | # test "set variable" for type "int *" | |
307 | # | |
787f6220 | 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" |
ef44eed1 SS |
309 | # |
310 | # test "set variable" for type "signed int *" | |
311 | # | |
787f6220 | 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" |
ef44eed1 SS |
313 | # |
314 | # test "set variable" for type "unsigned int *" | |
315 | # | |
787f6220 BM |
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" | |
ef44eed1 SS |
318 | # |
319 | # test "set variable" for type "long *" | |
320 | # | |
787f6220 | 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" |
ef44eed1 SS |
322 | # |
323 | # test "set variable" for type "signed long *" | |
324 | # | |
787f6220 | 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" |
ef44eed1 SS |
326 | # |
327 | # test "set variable" for type "unsigned long *" | |
328 | # | |
787f6220 | 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" |
ef44eed1 SS |
330 | # |
331 | # test "set variable" for type "float *" | |
332 | # | |
787f6220 | 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" |
ef44eed1 SS |
334 | # |
335 | # test "set variable" for type "double *" | |
336 | # | |
787f6220 | 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" |
ef44eed1 SS |
338 | # |
339 | # test "set variable" for struct members | |
340 | # | |
787f6220 BM |
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" | |
ef44eed1 | 347 | |
3c88a10a PS |
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. | |
c309781f BM |
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 | } | |
3c88a10a PS |
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)" | |
3c88a10a PS |
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)" | |
782445c7 FF |
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" | |
ef44eed1 | 390 | } |