]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/code-expr.exp
Updated copyright notices for most files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / code-expr.exp
1 # Copyright (C) 2001, 2007, 2008 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@prep.ai.mit.edu
18
19 # Written by Michael Snyder, Red Hat, Inc., 9/20/2001
20
21 # This file is part of the gdb testsuite
22 # Tests for type expressions using the new "@code" and "@data" modifiers.
23
24 if $tracelevel then {
25 strace $tracelevel
26 }
27
28 #
29 # test running programs
30 #
31 set prms_id 0
32 set bug_id 0
33
34 set testfile "cvexpr"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39 untested code-expr.exp
40 return -1
41 }
42
43 gdb_exit
44 gdb_start
45 gdb_reinitialize_dir $srcdir/$subdir
46 gdb_load ${binfile}
47
48 if [target_info exists gdb_stub] {
49 gdb_step_for_stub;
50 }
51
52 gdb_test "set print sevenbit-strings" "" ""
53 gdb_test "set print address off" "" ""
54 gdb_test "set width 0" "" ""
55
56 set ws "\[ \t\]*"
57
58 #
59 # Test casting a scalar to const
60 #
61
62 gdb_test "whatis (@code char) v_char" \
63 "type = @code char" \
64 "(@code char)"
65 gdb_test "whatis (@code signed char) v_signed_char" \
66 "type = @code signed char" \
67 "(@code signed char)"
68 gdb_test "whatis (@code unsigned char) v_unsigned_char" \
69 "type = @code (unsigned char|char)" \
70 "(@code unsigned char)"
71 gdb_test "whatis (@code short) v_short" \
72 "type = @code (short|short int)" \
73 "(@code short)"
74 gdb_test "whatis (@code signed short) v_signed_short" \
75 "type = @code (short|short int|signed short|signed short int)" \
76 "(@code signed short)"
77 gdb_test "whatis (@code unsigned short) v_unsigned_short" \
78 "type = @code (unsigned short|short unsigned int)" \
79 "(@code unsigned short)"
80 gdb_test "whatis (@code int) v_int" \
81 "type = @code int" \
82 "(@code int)"
83 gdb_test "whatis (@code signed int) v_signed_int" \
84 "type = @code (signed int|int)" \
85 "(@code signed int)"
86 gdb_test "whatis (@code unsigned int) v_unsigned_int" \
87 "type = @code unsigned int" \
88 "(@code unsigned int)"
89 gdb_test "whatis (@code long) v_long" \
90 "type = @code (long|long int)" \
91 "(@code long)"
92 gdb_test "whatis (@code signed long) v_signed_long" \
93 "type = @code (signed |)long( int|)" \
94 "(@code signed long)"
95 gdb_test "whatis (@code unsigned long) v_unsigned_long" \
96 "type = @code (unsigned long|long unsigned int)" \
97 "(@code unsigned long)"
98 gdb_test "whatis (@code long long) v_long_long" \
99 "type = @code long long( int|)" \
100 "(@code long long)"
101 gdb_test "whatis (@code signed long long) v_signed_long_long" \
102 "type = @code (signed |)long long( int|)" \
103 "(@code signed long long)"
104 gdb_test "whatis (@code unsigned long long) v_unsigned_long_long" \
105 "type = @code (unsigned long long|long long unsigned int)" \
106 "(@code unsigned long long)"
107 gdb_test "whatis (@code float) v_float" \
108 "type = @code float" \
109 "(@code float)"
110 gdb_test "whatis (@code double) v_double" \
111 "type = @code double" \
112 "(@code double)"
113
114 #
115 # Test casting a scalar to @data
116 #
117
118 gdb_test "whatis (@data char) v_char" \
119 "type = @data char" \
120 "(@data char)"
121 gdb_test "whatis (@data signed char) v_signed_char" \
122 "type = @data signed char" \
123 "(@data signed char)"
124 gdb_test "whatis (@data unsigned char) v_unsigned_char" \
125 "type = @data (unsigned char|char)" \
126 "(@data unsigned char)"
127 gdb_test "whatis (@data short) v_short" \
128 "type = @data (short|short int)" \
129 "(@data short)"
130 gdb_test "whatis (@data signed short) v_signed_short" \
131 "type = @data (short|short int|signed short|signed short int)" \
132 "(@data signed short)"
133 gdb_test "whatis (@data unsigned short) v_unsigned_short" \
134 "type = @data (unsigned short|short unsigned int)" \
135 "(@data unsigned short)"
136 gdb_test "whatis (@data int) v_int" \
137 "type = @data int" \
138 "(@data int)"
139 gdb_test "whatis (@data signed int) v_signed_int" \
140 "type = @data (signed int|int)" \
141 "(@data signed int)"
142 gdb_test "whatis (@data unsigned int) v_unsigned_int" \
143 "type = @data unsigned int" \
144 "(@data unsigned int)"
145 gdb_test "whatis (@data long) v_long" \
146 "type = @data (long|long int)" \
147 "(@data long)"
148 gdb_test "whatis (@data signed long) v_signed_long" \
149 "type = @data (signed |)long( int|)" \
150 "(@data signed long)"
151 gdb_test "whatis (@data unsigned long) v_unsigned_long" \
152 "type = @data (unsigned long|long unsigned int)" \
153 "(@data unsigned long)"
154 gdb_test "whatis (@data long long) v_long_long" \
155 "type = @data long long( int|)" \
156 "(@data long long)"
157 gdb_test "whatis (@data signed long long) v_signed_long_long" \
158 "type = @data (signed |)long long( int|)" \
159 "(@data signed long long)"
160 gdb_test "whatis (@data unsigned long long) v_unsigned_long_long" \
161 "type = @data (unsigned long long|long long unsigned int)" \
162 "(@data unsigned long long)"
163 gdb_test "whatis (@data float) v_float" \
164 "type = @data float" \
165 "(@data float)"
166 gdb_test "whatis (@data double) v_double" \
167 "type = @data double" \
168 "(@data double)"
169
170 #
171 # Now put the '@code' and '@data' keywords after the base type.
172 #
173
174 gdb_test "whatis (char @code) v_char" \
175 "type = @code char" \
176 "(char @code)"
177 gdb_test "whatis (signed char @code) v_signed_char" \
178 "type = @code signed char" \
179 "(signed char @code)"
180 gdb_test "whatis (unsigned char @code) v_unsigned_char" \
181 "type = @code (unsigned char|char)" \
182 "(unsigned char @code)"
183 gdb_test "whatis (short @code) v_short" \
184 "type = @code (short|short int)" \
185 "(short @code)"
186 gdb_test "whatis (signed short @code) v_signed_short" \
187 "type = @code (short|short int|signed short|signed short int)" \
188 "(signed short @code)"
189 gdb_test "whatis (unsigned short @code) v_unsigned_short" \
190 "type = @code (unsigned short|short unsigned int)" \
191 "(unsigned short @code)"
192 gdb_test "whatis (int @code) v_int" \
193 "type = @code int" \
194 "(int @code)"
195 gdb_test "whatis (signed int @code) v_signed_int" \
196 "type = @code (signed int|int)" \
197 "(signed int @code)"
198 gdb_test "whatis (unsigned int @code) v_unsigned_int" \
199 "type = @code unsigned int" \
200 "(unsigned int @code)"
201 gdb_test "whatis (long @code) v_long" \
202 "type = @code (long|long int)" \
203 "(long @code)"
204 gdb_test "whatis (signed long @code) v_signed_long" \
205 "type = @code (signed |)long( int|)" \
206 "(signed long @code)"
207 gdb_test "whatis (unsigned long @code) v_unsigned_long" \
208 "type = @code (unsigned long|long unsigned int)" \
209 "(unsigned long @code)"
210 gdb_test "whatis (long long @code) v_long_long" \
211 "type = @code long long( int|)" \
212 "(long long @code)"
213 gdb_test "whatis (signed long long @code) v_signed_long_long" \
214 "type = @code (signed |)long long( int|)" \
215 "(signed long long @code)"
216 gdb_test "whatis (unsigned long long @code) v_unsigned_long_long" \
217 "type = @code (unsigned long long|long long unsigned int)" \
218 "(unsigned long long @code)"
219 gdb_test "whatis (float @code) v_float" \
220 "type = @code float" \
221 "(float @code)"
222 gdb_test "whatis (double @code) v_double" \
223 "type = @code double" \
224 "(double @code)"
225
226 gdb_test "whatis (char @data) v_char" \
227 "type = @data char" \
228 "(char @data)"
229 gdb_test "whatis (signed char @data) v_signed_char" \
230 "type = @data signed char" \
231 "(signed char @data)"
232 gdb_test "whatis (unsigned char @data) v_unsigned_char" \
233 "type = @data (unsigned char|char)" \
234 "(unsigned char @data)"
235 gdb_test "whatis (short @data) v_short" \
236 "type = @data (short|short int)" \
237 "(short @data)"
238 gdb_test "whatis (signed short @data) v_signed_short" \
239 "type = @data (short|short int|signed short|signed short int)" \
240 "(signed short @data)"
241 gdb_test "whatis (unsigned short @data) v_unsigned_short" \
242 "type = @data (unsigned short|short unsigned int)" \
243 "(unsigned short @data)"
244 gdb_test "whatis (int @data) v_int" \
245 "type = @data int" \
246 "(int @data)"
247 gdb_test "whatis (signed int @data) v_signed_int" \
248 "type = @data (signed int|int)" \
249 "(signed int @data)"
250 gdb_test "whatis (unsigned int @data) v_unsigned_int" \
251 "type = @data unsigned int" \
252 "(unsigned int @data)"
253 gdb_test "whatis (long @data) v_long" \
254 "type = @data (long|long int)" \
255 "(long @data)"
256 gdb_test "whatis (signed long @data) v_signed_long" \
257 "type = @data (signed |)long( int|)" \
258 "(signed long @data)"
259 gdb_test "whatis (unsigned long @data) v_unsigned_long" \
260 "type = @data (unsigned long|long unsigned int)" \
261 "(unsigned long @data)"
262 gdb_test "whatis (long long @data) v_long_long" \
263 "type = @data long long( int|)" \
264 "(long long @data)"
265 gdb_test "whatis (signed long long @data) v_signed_long_long" \
266 "type = @data (signed |)long long( int|)" \
267 "(signed long long @data)"
268 gdb_test "whatis (unsigned long long @data) v_unsigned_long_long" \
269 "type = @data (unsigned long long|long long unsigned int)" \
270 "(unsigned long long @data)"
271 gdb_test "whatis (float @data) v_float" \
272 "type = @data float" \
273 "(float @data)"
274 gdb_test "whatis (double @data) v_double" \
275 "type = @data double" \
276 "(double @data)"
277
278 #
279 # enums
280 #
281
282 gdb_test "whatis (@code enum misordered) v_misordered" \
283 "type = @code enum misordered" \
284 "(@code enum misordered)"
285 gdb_test "whatis (enum misordered @code) v_misordered" \
286 "type = @code enum misordered" \
287 "(enum misordered @code)"
288 gdb_test "whatis (@data enum misordered) v_misordered" \
289 "type = @data enum misordered" \
290 "(@data enum misordered)"
291 gdb_test "whatis (enum misordered @data) v_misordered" \
292 "type = @data enum misordered" \
293 "(enum misordered @data)"
294
295 #
296 # Pointers
297 #
298
299 gdb_test "whatis (@code int *) v_int_pointer" \
300 "type = @code int${ws}\\*" \
301 "(@code int *)"
302 gdb_test "whatis (int @code *) v_int_pointer" \
303 "type = @code int${ws}\\*" \
304 "(int @code *)"
305 gdb_test "whatis (int * @code) v_int_pointer" \
306 "type = int \\*${ws}@code" \
307 "(int * @code)"
308 gdb_test "whatis (@code int * @code) v_int_pointer" \
309 "type = @code int${ws}\\*${ws}@code" \
310 "(@code int * @code)"
311 gdb_test "whatis (int @code * @code) v_int_pointer" \
312 "type = @code int${ws}\\*${ws}@code" \
313 "(int @code * @code)"
314
315 gdb_test "whatis (@code int **) v_int_pointer_pointer" \
316 "type = @code int${ws}\\*${ws}\\*" \
317 "(@code int **)"
318 gdb_test "whatis (int @code **) v_int_pointer_pointer" \
319 "type = @code int${ws}\\*${ws}\\*" \
320 "(int @code **)"
321 gdb_test "whatis (int ** @code) v_int_pointer_pointer" \
322 "type = int \\*${ws}\\*${ws}@code" \
323 "(int ** @code)"
324 gdb_test "whatis (@code int * @code *) v_int_pointer_pointer" \
325 "type = @code int${ws}\\*${ws}@code${ws}\\*" \
326 "(@code int * @code *)"
327 gdb_test "whatis (int @code * @code *) v_int_pointer_pointer" \
328 "type = @code int${ws}\\*${ws}@code${ws}\\*" \
329 "(int @code * @code *)"
330 gdb_test "whatis (@code int * @code * @code) v_int_pointer_pointer" \
331 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \
332 "(@code int * @code * @code)"
333 gdb_test "whatis (int @code * @code * @code) v_int_pointer_pointer" \
334 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \
335 "(int @code * @code * @code)"
336
337 #
338 # Arrays TODO
339 #
340
341 #
342 # Pointers to arrays, arrays of pointers TODO
343 #
344
345 #
346 # Structs and Unions
347 #
348
349 gdb_test "whatis (@code struct t_struct) v_struct1" \
350 "type = @code struct t_struct" \
351 "(@code struct t_struct)"
352 gdb_test "whatis (@code union t_union) v_union" \
353 "type = @code union t_union" \
354 "(@code union t_union)"
355 gdb_test "whatis (struct t_struct @code) v_struct1" \
356 "type = @code struct t_struct" \
357 "(struct t_struct @code)"
358 gdb_test "whatis (union t_union @code) v_union" \
359 "type = @code union t_union" \
360 "(union t_union @code)"
361 gdb_test "whatis (@code struct t_struct *) &v_struct1" \
362 "type = @code struct t_struct${ws}\\*" \
363 "(@code struct t_struct *)"
364 gdb_test "whatis (@code union t_union *) &v_union" \
365 "type = @code union t_union${ws}\\*" \
366 "(@code union t_union *)"
367 gdb_test "whatis (struct t_struct @code *) &v_struct1" \
368 "type = @code struct t_struct${ws}\\*" \
369 "(struct t_struct @code *)"
370 gdb_test "whatis (union t_union @code *) &v_union" \
371 "type = @code union t_union${ws}\\*" \
372 "(union t_union @code *)"
373 gdb_test "whatis (struct t_struct * @code) &v_struct1" \
374 "type = struct t_struct${ws}\\*${ws}@code" \
375 "(struct t_struct * @code)"
376 gdb_test "whatis (union t_union * @code) &v_union" \
377 "type = union t_union${ws}\\*${ws}@code" \
378 "(union t_union * @code)"
379 gdb_test "whatis (@code struct t_struct * @code) &v_struct1" \
380 "type = @code struct t_struct${ws}\\*${ws}@code" \
381 "(@code struct t_struct * @code)"
382 gdb_test "whatis (@code union t_union * @code) &v_union" \
383 "type = @code union t_union${ws}\\*${ws}@code" \
384 "(@code union t_union * @code)"
385 gdb_test "whatis (struct t_struct @code * @code) &v_struct1" \
386 "type = @code struct t_struct${ws}\\*${ws}@code" \
387 "(struct t_struct @code * @code)"
388 gdb_test "whatis (union t_union @code * @code) &v_union" \
389 "type = @code union t_union${ws}\\*${ws}@code" \
390 "(union t_union @code * @code)"
391
392 #
393 # Function pointers TODO
394 #
395