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