]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/whatis.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.exp
1 # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002, 2003,
2 # 2004, 2007 Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 # This file was written by Rob Savoye. (rob@cygnus.com)
19
20 if $tracelevel {
21 strace $tracelevel
22 }
23
24 #
25 # test running programs
26 #
27 set prms_id 0
28 set bug_id 0
29
30 set testfile whatis
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
33 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
34 untested whatis.exp
35 return -1
36 }
37
38 # Create and source the file that provides information about the compiler
39 # used to compile the test case.
40 if [get_compiler_info ${binfile}] {
41 return -1;
42 }
43
44 # Start with a fresh gdb.
45
46 gdb_exit
47 gdb_start
48 gdb_reinitialize_dir $srcdir/$subdir
49 gdb_load $binfile
50
51 # Define a procedure to set up an xfail for all targets that put out a
52 # `long' type as an `int' type.
53 # Sun/Ultrix cc have this problem.
54 # It was said that COFF targets can not distinguish int from long either.
55
56 proc setup_xfail_on_long_vs_int {} {
57 global gcc_compiled
58
59 if {!$gcc_compiled} {
60 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
61 }
62 }
63
64 #
65 # Test whatis command with basic C types
66 #
67 # The name printed now (as of 23 May 1993) is whatever name the compiler
68 # uses in the stabs. So we need to deal with names both from gcc and
69 # native compilers.
70 #
71
72 gdb_test "whatis v_char" \
73 "type = (unsigned char|char)" \
74 "whatis char"
75
76 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
77 gdb_test "whatis v_signed_char" \
78 "type = (signed char|char)" \
79 "whatis signed char"
80
81 gdb_test "whatis v_unsigned_char" \
82 "type = unsigned char" \
83 "whatis unsigned char"
84
85 gdb_test "whatis v_short" \
86 "type = (short|short int)" \
87 "whatis short"
88
89 gdb_test "whatis v_signed_short" \
90 "type = (short|short int|signed short|signed short int)" \
91 "whatis signed short"
92
93 gdb_test "whatis v_unsigned_short" \
94 "type = (unsigned short|short unsigned int)" \
95 "whatis unsigned short"
96
97 gdb_test "whatis v_int" \
98 "type = int" \
99 "whatis int"
100
101 gdb_test "whatis v_signed_int" \
102 "type = (signed |)int" \
103 "whatis signed int"
104
105 gdb_test "whatis v_unsigned_int" \
106 "type = unsigned int" \
107 "whatis unsigned int"
108
109 setup_xfail_on_long_vs_int
110 # AIX xlc gets this wrong and unsigned long right. Go figure.
111 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
112 gdb_test "whatis v_long" \
113 "type = (long|long int)" \
114 "whatis long"
115
116 setup_xfail_on_long_vs_int
117 # AIX xlc gets this wrong and unsigned long right. Go figure.
118 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
119 gdb_test "whatis v_signed_long" \
120 "type = (signed |)(long|long int)" \
121 "whatis signed long"
122
123 setup_xfail_on_long_vs_int
124 gdb_test "whatis v_unsigned_long" \
125 "type = (unsigned long|long unsigned int)" \
126 "whatis unsigned long"
127
128 gdb_test "whatis v_float" \
129 "type = float" \
130 "whatis float"
131
132 gdb_test "whatis v_double" \
133 "type = double" \
134 "whatis double"
135
136
137 # test whatis command with arrays
138 #
139 # We already tested whether char prints as "char", so here we accept
140 # "unsigned char", "signed char", and other perversions. No need for more
141 # than one xfail for the same thing.
142 gdb_test "whatis v_char_array" \
143 "type = (signed |unsigned |)char \\\[2\\\]" \
144 "whatis char array"
145
146 gdb_test "whatis v_signed_char_array" \
147 "type = (signed |unsigned |)char \\\[2\\\]" \
148 "whatis signed char array"
149
150 gdb_test "whatis v_unsigned_char_array" \
151 "type = unsigned char \\\[2\\\]" \
152 "whatis unsigned char array"
153
154 gdb_test "whatis v_short_array" \
155 "type = (short|short int) \\\[2\\\]" \
156 "whatis short array"
157
158 gdb_test "whatis v_signed_short_array" \
159 "type = (signed |)(short|short int) \\\[2\\\]" \
160 "whatis signed short array"
161
162 gdb_test "whatis v_unsigned_short_array" \
163 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
164 "whatis unsigned short array"
165
166 gdb_test "whatis v_int_array" \
167 "type = int \\\[2\\\]" \
168 "whatis int array"
169
170 gdb_test "whatis v_signed_int_array" \
171 "type = (signed |)int \\\[2\\\]" \
172 "whatis signed int array"
173
174 gdb_test "whatis v_unsigned_int_array" \
175 "type = unsigned int \\\[2\\\]" \
176 "whatis unsigned int array"
177
178 # We already tested whether long prints as long, so here we accept int
179 # No need for more than one xfail for the same thing.
180 gdb_test "whatis v_long_array" \
181 "type = (int|long|long int) \\\[2\\\]" \
182 "whatis long array"
183
184 gdb_test "whatis v_signed_long_array" \
185 "type = (signed |)(int|long|long int) \\\[2\\\]" \
186 "whatis signed long array"
187
188 gdb_test "whatis v_unsigned_long_array" \
189 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
190 "whatis unsigned long array"
191
192 gdb_test "whatis v_float_array" \
193 "type = float \\\[2\\\]" \
194 "whatis float array"
195
196 gdb_test "whatis v_double_array" \
197 "type = double \\\[2\\\]" \
198 "whatis double array"
199
200
201 # test whatis command with pointers
202 #
203 # We already tested whether char prints as char, so accept various perversions
204 # here. We especially want to make sure we test that it doesn't print as
205 # caddr_t.
206 gdb_test "whatis v_char_pointer" \
207 "type = (unsigned |signed |)char \\*" \
208 "whatis char pointer"
209
210 gdb_test "whatis v_signed_char_pointer" \
211 "type = (unsigned |signed |)char \\*" \
212 "whatis signed char pointer"
213
214 gdb_test "whatis v_unsigned_char_pointer" \
215 "type = unsigned char \\*" \
216 "whatis unsigned char pointer"
217
218 gdb_test "whatis v_short_pointer" \
219 "type = (short|short int) \\*" \
220 "whatis short pointer"
221
222 gdb_test "whatis v_signed_short_pointer" \
223 "type = (signed |)(short|short int) \\*" \
224 "whatis signed short pointer"
225
226 gdb_test "whatis v_unsigned_short_pointer" \
227 "type = (unsigned short|short unsigned int) \\*" \
228 "whatis unsigned short pointer"
229
230 gdb_test "whatis v_int_pointer" \
231 "type = int \\*" \
232 "whatis int pointer"
233
234 gdb_test "whatis v_signed_int_pointer" \
235 "type = (signed |)int \\*" \
236 "whatis signed int pointer"
237
238 gdb_test "whatis v_unsigned_int_pointer" \
239 "type = unsigned int \\*" \
240 "whatis unsigned int pointer"
241
242 # We already tested whether long prints as long, so here we accept int
243 gdb_test "whatis v_long_pointer" \
244 "type = (long|int|long int) \\*" \
245 "whatis long pointer"
246
247 gdb_test "whatis v_signed_long_pointer" \
248 "type = (signed |)(long|int|long int) \\*" \
249 "whatis signed long pointer"
250
251 gdb_test "whatis v_unsigned_long_pointer" \
252 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
253 "whatis unsigned long pointer"
254
255 gdb_test "whatis v_float_pointer" \
256 "type = float \\*" \
257 "whatis float pointer"
258
259 gdb_test "whatis v_double_pointer" \
260 "type = double \\*" \
261 "whatis double pointer"
262
263
264 if { $hp_aCC_compiler } {
265 set unstruct "unnamed\.struct\..*"
266 set ununion "unnamed\.union\..*"
267 } else {
268 set unstruct "\.\.\."
269 set ununion "\.\.\."
270 }
271
272 # test whatis command with structure types
273 gdb_test "whatis v_struct1" \
274 "type = struct t_struct" \
275 "whatis named structure"
276
277 gdb_test "whatis struct t_struct" \
278 "type = struct t_struct" \
279 "whatis named structure using type name"
280
281 gdb_test "whatis v_struct2" \
282 "type = struct \{$unstruct\}" \
283 "whatis unnamed structure"
284
285
286 # test whatis command with union types
287 gdb_test "whatis v_union" \
288 "type = union t_union" \
289 "whatis named union"
290
291 gdb_test "whatis union t_union" \
292 "type = union t_union" \
293 "whatis named union using type name"
294
295 gdb_test "whatis v_union2" \
296 "type = union \{$ununion\}" \
297 "whatis unnamed union"
298
299
300 # HP-UX: HP aCC compiler w/ +objdebug option detects language as
301 # c++, so we need the 'void' pattern here.
302 # Without +objdebug compilation option we still need to match ''.
303 # - guo
304 # Also, using stabs we will mark these functions as prototyped. This
305 # is harmless but causes an extra VOID to be printed.
306 set void "(void|)"
307
308 # test whatis command with functions return type
309 gdb_test "whatis v_char_func" \
310 "type = (signed |unsigned |)char \\($void\\)" \
311 "whatis char function"
312
313 gdb_test "whatis v_signed_char_func" \
314 "type = (signed |unsigned |)char \\($void\\)" \
315 "whatis signed char function"
316
317 gdb_test "whatis v_unsigned_char_func" \
318 "type = unsigned char \\($void\\)" \
319 "whatis unsigned char function"
320
321 gdb_test "whatis v_short_func" \
322 "type = short (int |)\\($void\\)" \
323 "whatis short function"
324
325 gdb_test "whatis v_signed_short_func" \
326 "type = (signed |)short (int |)\\($void\\)" \
327 "whatis signed short function"
328
329 gdb_test "whatis v_unsigned_short_func" \
330 "type = (unsigned short|short unsigned int) \\($void\\)" \
331 "whatis unsigned short function"
332
333 gdb_test "whatis v_int_func" \
334 "type = int \\($void\\)" \
335 "whatis int function"
336
337 gdb_test "whatis v_signed_int_func" \
338 "type = (signed |)int \\($void\\)" \
339 "whatis signed int function"
340
341 gdb_test "whatis v_unsigned_int_func" \
342 "type = unsigned int \\($void\\)" \
343 "whatis unsigned int function"
344
345 gdb_test "whatis v_long_func" \
346 "type = (long|int|long int) \\($void\\)" \
347 "whatis long function"
348
349 gdb_test "whatis v_signed_long_func" \
350 "type = (signed |)(int|long|long int) \\($void\\)" \
351 "whatis signed long function"
352
353 gdb_test "whatis v_unsigned_long_func" \
354 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
355 "whatis unsigned long function"
356
357 # Sun /bin/cc calls this a function returning double.
358 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
359 gdb_test "whatis v_float_func" \
360 "type = float \\($void\\)" \
361 "whatis float function"
362
363 gdb_test "whatis v_double_func" \
364 "type = double \\($void\\)" \
365 "whatis double function" \
366
367
368 # test whatis command with some misc complicated types
369 gdb_test "whatis s_link" \
370 "type = struct link \\*" \
371 "whatis complicated structure"
372
373 gdb_test "whatis u_link" \
374 "type = union tu_link" \
375 "whatis complicated union"
376
377
378 # test whatis command with enumerations
379 gdb_test "whatis clunker" \
380 "type = enum cars" \
381 "whatis enumeration"
382
383 gdb_test "whatis enum cars" \
384 "type = enum cars" \
385 "whatis enumeration using type name"
386
387
388 # test whatis command with nested struct and union
389 gdb_test "whatis nested_su" \
390 "type = struct outer_struct" \
391 "whatis outer structure"
392
393 gdb_test "whatis nested_su.outer_int" \
394 "type = int" \
395 "whatis outer structure member"
396
397 if {$hp_aCC_compiler} {
398 set outer "outer_struct::"
399 } else {
400 set outer ""
401 }
402
403 gdb_test "whatis nested_su.inner_struct_instance" \
404 "type = struct ${outer}inner_struct" \
405 "whatis inner structure"
406
407 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
408 "type = int" \
409 "whatis inner structure member"
410
411 gdb_test "whatis nested_su.inner_union_instance" \
412 "type = union ${outer}inner_union" \
413 "whatis inner union"
414
415 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
416 "type = int" \
417 "whatis inner union member"
418
419 # test whatis command with typedefs
420
421 gdb_test "whatis char_addr" \
422 "type = char \\*" \
423 "whatis using typedef type name"
424
425 gdb_test "whatis a_char_addr" \
426 "type = char_addr" \
427 "whatis applied to variable defined by typedef"