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