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