]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/code-expr.exp
This commit was manufactured by cvs2svn to create branch 'gdb_7_2-branch'.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / code-expr.exp
CommitLineData
4c38e0a4 1# Copyright (C) 2001, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
bb632afb
MS
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
bb632afb 6# (at your option) any later version.
e22f8b7c 7#
bb632afb
MS
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.
e22f8b7c 12#
bb632afb 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
bb632afb 15
bb632afb
MS
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
21if $tracelevel then {
22 strace $tracelevel
23 }
24
25#
26# test running programs
27#
bb632afb
MS
28
29set testfile "cvexpr"
30set srcfile ${testfile}.c
31set binfile ${objdir}/${subdir}/${testfile}
32
33if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
34 untested code-expr.exp
35 return -1
bb632afb
MS
36}
37
38gdb_exit
39gdb_start
40gdb_reinitialize_dir $srcdir/$subdir
41gdb_load ${binfile}
42
43if [target_info exists gdb_stub] {
44 gdb_step_for_stub;
45}
46
27d3a1a2
MS
47gdb_test_no_output "set print sevenbit-strings"
48gdb_test_no_output "set print address off"
49gdb_test_no_output "set width 0"
bb632afb
MS
50
51set ws "\[ \t\]*"
52
53#
54# Test casting a scalar to const
55#
56
57gdb_test "whatis (@code char) v_char" \
58 "type = @code char" \
59 "(@code char)"
60gdb_test "whatis (@code signed char) v_signed_char" \
61 "type = @code signed char" \
62 "(@code signed char)"
63gdb_test "whatis (@code unsigned char) v_unsigned_char" \
64 "type = @code (unsigned char|char)" \
65 "(@code unsigned char)"
66gdb_test "whatis (@code short) v_short" \
67 "type = @code (short|short int)" \
68 "(@code short)"
69gdb_test "whatis (@code signed short) v_signed_short" \
70 "type = @code (short|short int|signed short|signed short int)" \
71 "(@code signed short)"
72gdb_test "whatis (@code unsigned short) v_unsigned_short" \
73 "type = @code (unsigned short|short unsigned int)" \
74 "(@code unsigned short)"
75gdb_test "whatis (@code int) v_int" \
76 "type = @code int" \
77 "(@code int)"
78gdb_test "whatis (@code signed int) v_signed_int" \
79 "type = @code (signed int|int)" \
80 "(@code signed int)"
81gdb_test "whatis (@code unsigned int) v_unsigned_int" \
82 "type = @code unsigned int" \
83 "(@code unsigned int)"
84gdb_test "whatis (@code long) v_long" \
85 "type = @code (long|long int)" \
86 "(@code long)"
87gdb_test "whatis (@code signed long) v_signed_long" \
88 "type = @code (signed |)long( int|)" \
89 "(@code signed long)"
90gdb_test "whatis (@code unsigned long) v_unsigned_long" \
91 "type = @code (unsigned long|long unsigned int)" \
92 "(@code unsigned long)"
93gdb_test "whatis (@code long long) v_long_long" \
94 "type = @code long long( int|)" \
95 "(@code long long)"
96gdb_test "whatis (@code signed long long) v_signed_long_long" \
97 "type = @code (signed |)long long( int|)" \
98 "(@code signed long long)"
99gdb_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)"
102gdb_test "whatis (@code float) v_float" \
103 "type = @code float" \
104 "(@code float)"
105gdb_test "whatis (@code double) v_double" \
106 "type = @code double" \
107 "(@code double)"
108
109#
110# Test casting a scalar to @data
111#
112
113gdb_test "whatis (@data char) v_char" \
114 "type = @data char" \
115 "(@data char)"
116gdb_test "whatis (@data signed char) v_signed_char" \
117 "type = @data signed char" \
118 "(@data signed char)"
119gdb_test "whatis (@data unsigned char) v_unsigned_char" \
120 "type = @data (unsigned char|char)" \
121 "(@data unsigned char)"
122gdb_test "whatis (@data short) v_short" \
123 "type = @data (short|short int)" \
124 "(@data short)"
125gdb_test "whatis (@data signed short) v_signed_short" \
126 "type = @data (short|short int|signed short|signed short int)" \
127 "(@data signed short)"
128gdb_test "whatis (@data unsigned short) v_unsigned_short" \
129 "type = @data (unsigned short|short unsigned int)" \
130 "(@data unsigned short)"
131gdb_test "whatis (@data int) v_int" \
132 "type = @data int" \
133 "(@data int)"
134gdb_test "whatis (@data signed int) v_signed_int" \
135 "type = @data (signed int|int)" \
136 "(@data signed int)"
137gdb_test "whatis (@data unsigned int) v_unsigned_int" \
138 "type = @data unsigned int" \
139 "(@data unsigned int)"
140gdb_test "whatis (@data long) v_long" \
141 "type = @data (long|long int)" \
142 "(@data long)"
143gdb_test "whatis (@data signed long) v_signed_long" \
144 "type = @data (signed |)long( int|)" \
145 "(@data signed long)"
146gdb_test "whatis (@data unsigned long) v_unsigned_long" \
147 "type = @data (unsigned long|long unsigned int)" \
148 "(@data unsigned long)"
149gdb_test "whatis (@data long long) v_long_long" \
150 "type = @data long long( int|)" \
151 "(@data long long)"
152gdb_test "whatis (@data signed long long) v_signed_long_long" \
153 "type = @data (signed |)long long( int|)" \
154 "(@data signed long long)"
155gdb_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)"
158gdb_test "whatis (@data float) v_float" \
159 "type = @data float" \
160 "(@data float)"
161gdb_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
169gdb_test "whatis (char @code) v_char" \
170 "type = @code char" \
171 "(char @code)"
172gdb_test "whatis (signed char @code) v_signed_char" \
173 "type = @code signed char" \
174 "(signed char @code)"
175gdb_test "whatis (unsigned char @code) v_unsigned_char" \
176 "type = @code (unsigned char|char)" \
177 "(unsigned char @code)"
178gdb_test "whatis (short @code) v_short" \
179 "type = @code (short|short int)" \
180 "(short @code)"
181gdb_test "whatis (signed short @code) v_signed_short" \
182 "type = @code (short|short int|signed short|signed short int)" \
183 "(signed short @code)"
184gdb_test "whatis (unsigned short @code) v_unsigned_short" \
185 "type = @code (unsigned short|short unsigned int)" \
186 "(unsigned short @code)"
187gdb_test "whatis (int @code) v_int" \
188 "type = @code int" \
189 "(int @code)"
190gdb_test "whatis (signed int @code) v_signed_int" \
191 "type = @code (signed int|int)" \
192 "(signed int @code)"
193gdb_test "whatis (unsigned int @code) v_unsigned_int" \
194 "type = @code unsigned int" \
195 "(unsigned int @code)"
196gdb_test "whatis (long @code) v_long" \
197 "type = @code (long|long int)" \
198 "(long @code)"
199gdb_test "whatis (signed long @code) v_signed_long" \
200 "type = @code (signed |)long( int|)" \
201 "(signed long @code)"
202gdb_test "whatis (unsigned long @code) v_unsigned_long" \
203 "type = @code (unsigned long|long unsigned int)" \
204 "(unsigned long @code)"
205gdb_test "whatis (long long @code) v_long_long" \
206 "type = @code long long( int|)" \
207 "(long long @code)"
208gdb_test "whatis (signed long long @code) v_signed_long_long" \
209 "type = @code (signed |)long long( int|)" \
210 "(signed long long @code)"
211gdb_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)"
214gdb_test "whatis (float @code) v_float" \
215 "type = @code float" \
216 "(float @code)"
217gdb_test "whatis (double @code) v_double" \
218 "type = @code double" \
219 "(double @code)"
220
221gdb_test "whatis (char @data) v_char" \
222 "type = @data char" \
223 "(char @data)"
224gdb_test "whatis (signed char @data) v_signed_char" \
225 "type = @data signed char" \
226 "(signed char @data)"
227gdb_test "whatis (unsigned char @data) v_unsigned_char" \
228 "type = @data (unsigned char|char)" \
229 "(unsigned char @data)"
230gdb_test "whatis (short @data) v_short" \
231 "type = @data (short|short int)" \
232 "(short @data)"
233gdb_test "whatis (signed short @data) v_signed_short" \
234 "type = @data (short|short int|signed short|signed short int)" \
235 "(signed short @data)"
236gdb_test "whatis (unsigned short @data) v_unsigned_short" \
237 "type = @data (unsigned short|short unsigned int)" \
238 "(unsigned short @data)"
239gdb_test "whatis (int @data) v_int" \
240 "type = @data int" \
241 "(int @data)"
242gdb_test "whatis (signed int @data) v_signed_int" \
243 "type = @data (signed int|int)" \
244 "(signed int @data)"
245gdb_test "whatis (unsigned int @data) v_unsigned_int" \
246 "type = @data unsigned int" \
247 "(unsigned int @data)"
248gdb_test "whatis (long @data) v_long" \
249 "type = @data (long|long int)" \
250 "(long @data)"
251gdb_test "whatis (signed long @data) v_signed_long" \
252 "type = @data (signed |)long( int|)" \
253 "(signed long @data)"
254gdb_test "whatis (unsigned long @data) v_unsigned_long" \
255 "type = @data (unsigned long|long unsigned int)" \
256 "(unsigned long @data)"
257gdb_test "whatis (long long @data) v_long_long" \
258 "type = @data long long( int|)" \
259 "(long long @data)"
260gdb_test "whatis (signed long long @data) v_signed_long_long" \
261 "type = @data (signed |)long long( int|)" \
262 "(signed long long @data)"
263gdb_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)"
266gdb_test "whatis (float @data) v_float" \
267 "type = @data float" \
268 "(float @data)"
269gdb_test "whatis (double @data) v_double" \
270 "type = @data double" \
271 "(double @data)"
272
273#
274# enums
275#
276
277gdb_test "whatis (@code enum misordered) v_misordered" \
278 "type = @code enum misordered" \
279 "(@code enum misordered)"
280gdb_test "whatis (enum misordered @code) v_misordered" \
281 "type = @code enum misordered" \
282 "(enum misordered @code)"
283gdb_test "whatis (@data enum misordered) v_misordered" \
284 "type = @data enum misordered" \
285 "(@data enum misordered)"
286gdb_test "whatis (enum misordered @data) v_misordered" \
287 "type = @data enum misordered" \
288 "(enum misordered @data)"
289
290#
291# Pointers
292#
293
294gdb_test "whatis (@code int *) v_int_pointer" \
295 "type = @code int${ws}\\*" \
296 "(@code int *)"
297gdb_test "whatis (int @code *) v_int_pointer" \
298 "type = @code int${ws}\\*" \
299 "(int @code *)"
300gdb_test "whatis (int * @code) v_int_pointer" \
301 "type = int \\*${ws}@code" \
302 "(int * @code)"
303gdb_test "whatis (@code int * @code) v_int_pointer" \
304 "type = @code int${ws}\\*${ws}@code" \
305 "(@code int * @code)"
306gdb_test "whatis (int @code * @code) v_int_pointer" \
307 "type = @code int${ws}\\*${ws}@code" \
308 "(int @code * @code)"
309
310gdb_test "whatis (@code int **) v_int_pointer_pointer" \
311 "type = @code int${ws}\\*${ws}\\*" \
312 "(@code int **)"
313gdb_test "whatis (int @code **) v_int_pointer_pointer" \
314 "type = @code int${ws}\\*${ws}\\*" \
315 "(int @code **)"
316gdb_test "whatis (int ** @code) v_int_pointer_pointer" \
317 "type = int \\*${ws}\\*${ws}@code" \
318 "(int ** @code)"
319gdb_test "whatis (@code int * @code *) v_int_pointer_pointer" \
320 "type = @code int${ws}\\*${ws}@code${ws}\\*" \
321 "(@code int * @code *)"
322gdb_test "whatis (int @code * @code *) v_int_pointer_pointer" \
323 "type = @code int${ws}\\*${ws}@code${ws}\\*" \
324 "(int @code * @code *)"
325gdb_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)"
328gdb_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
344gdb_test "whatis (@code struct t_struct) v_struct1" \
345 "type = @code struct t_struct" \
346 "(@code struct t_struct)"
347gdb_test "whatis (@code union t_union) v_union" \
348 "type = @code union t_union" \
349 "(@code union t_union)"
350gdb_test "whatis (struct t_struct @code) v_struct1" \
351 "type = @code struct t_struct" \
352 "(struct t_struct @code)"
353gdb_test "whatis (union t_union @code) v_union" \
354 "type = @code union t_union" \
355 "(union t_union @code)"
356gdb_test "whatis (@code struct t_struct *) &v_struct1" \
357 "type = @code struct t_struct${ws}\\*" \
358 "(@code struct t_struct *)"
359gdb_test "whatis (@code union t_union *) &v_union" \
360 "type = @code union t_union${ws}\\*" \
361 "(@code union t_union *)"
362gdb_test "whatis (struct t_struct @code *) &v_struct1" \
363 "type = @code struct t_struct${ws}\\*" \
364 "(struct t_struct @code *)"
365gdb_test "whatis (union t_union @code *) &v_union" \
366 "type = @code union t_union${ws}\\*" \
367 "(union t_union @code *)"
368gdb_test "whatis (struct t_struct * @code) &v_struct1" \
369 "type = struct t_struct${ws}\\*${ws}@code" \
370 "(struct t_struct * @code)"
371gdb_test "whatis (union t_union * @code) &v_union" \
372 "type = union t_union${ws}\\*${ws}@code" \
373 "(union t_union * @code)"
374gdb_test "whatis (@code struct t_struct * @code) &v_struct1" \
375 "type = @code struct t_struct${ws}\\*${ws}@code" \
376 "(@code struct t_struct * @code)"
377gdb_test "whatis (@code union t_union * @code) &v_union" \
378 "type = @code union t_union${ws}\\*${ws}@code" \
379 "(@code union t_union * @code)"
380gdb_test "whatis (struct t_struct @code * @code) &v_struct1" \
381 "type = @code struct t_struct${ws}\\*${ws}@code" \
382 "(struct t_struct @code * @code)"
383gdb_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