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