* gdb.arch/altivec-abi.exp: Replace gdb_suppress_entire_file with
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.exp
CommitLineData
d782e0bf
MC
1# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002,
2# 2003, 2004 Free Software Foundation, Inc.
c906108c
SS
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
c906108c
SS
18# This file was written by Rob Savoye. (rob@cygnus.com)
19
20if $tracelevel {
21 strace $tracelevel
22}
23
24#
25# test running programs
26#
27set prms_id 0
28set bug_id 0
29
30set testfile whatis
31set srcfile ${testfile}.c
32set binfile ${objdir}/${subdir}/${testfile}
33if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
34 untested whatis.exp
35 return -1
c906108c
SS
36}
37
38# Create and source the file that provides information about the compiler
39# used to compile the test case.
40if [get_compiler_info ${binfile}] {
41 return -1;
42}
43
44# Start with a fresh gdb.
45
46gdb_exit
47gdb_start
48gdb_reinitialize_dir $srcdir/$subdir
49gdb_load $binfile
50
c906108c
SS
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
56proc 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#
085dd6e6 71
c906108c
SS
72gdb_test "whatis v_char" \
73 "type = (unsigned char|char)" \
74 "whatis char"
75
c906108c
SS
76if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
77gdb_test "whatis v_signed_char" \
d782e0bf 78 "type = (signed char|char)" \
c906108c
SS
79 "whatis signed char"
80
81gdb_test "whatis v_unsigned_char" \
82 "type = unsigned char" \
83 "whatis unsigned char"
84
85gdb_test "whatis v_short" \
86 "type = (short|short int)" \
87 "whatis short"
88
89gdb_test "whatis v_signed_short" \
90 "type = (short|short int|signed short|signed short int)" \
91 "whatis signed short"
92
93gdb_test "whatis v_unsigned_short" \
94 "type = (unsigned short|short unsigned int)" \
95 "whatis unsigned short"
96
97gdb_test "whatis v_int" \
98 "type = int" \
99 "whatis int"
100
101gdb_test "whatis v_signed_int" \
102 "type = (signed |)int" \
103 "whatis signed int"
104
105gdb_test "whatis v_unsigned_int" \
106 "type = unsigned int" \
107 "whatis unsigned int"
108
109setup_xfail_on_long_vs_int
110# AIX xlc gets this wrong and unsigned long right. Go figure.
111if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
112gdb_test "whatis v_long" \
113 "type = (long|long int)" \
114 "whatis long"
115
116setup_xfail_on_long_vs_int
117# AIX xlc gets this wrong and unsigned long right. Go figure.
118if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
119gdb_test "whatis v_signed_long" \
120 "type = (signed |)(long|long int)" \
121 "whatis signed long"
122
123setup_xfail_on_long_vs_int
124gdb_test "whatis v_unsigned_long" \
125 "type = (unsigned long|long unsigned int)" \
126 "whatis unsigned long"
127
128gdb_test "whatis v_float" \
129 "type = float" \
130 "whatis float"
131
132gdb_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.
142gdb_test "whatis v_char_array" \
143 "type = (signed |unsigned |)char \\\[2\\\]" \
144 "whatis char array"
145
146gdb_test "whatis v_signed_char_array" \
147 "type = (signed |unsigned |)char \\\[2\\\]" \
148 "whatis signed char array"
149
150gdb_test "whatis v_unsigned_char_array" \
151 "type = unsigned char \\\[2\\\]" \
152 "whatis unsigned char array"
153
154gdb_test "whatis v_short_array" \
155 "type = (short|short int) \\\[2\\\]" \
156 "whatis short array"
157
158gdb_test "whatis v_signed_short_array" \
159 "type = (signed |)(short|short int) \\\[2\\\]" \
160 "whatis signed short array"
161
162gdb_test "whatis v_unsigned_short_array" \
163 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
164 "whatis unsigned short array"
165
166gdb_test "whatis v_int_array" \
167 "type = int \\\[2\\\]" \
168 "whatis int array"
169
170gdb_test "whatis v_signed_int_array" \
171 "type = (signed |)int \\\[2\\\]" \
172 "whatis signed int array"
173
174gdb_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.
180gdb_test "whatis v_long_array" \
181 "type = (int|long|long int) \\\[2\\\]" \
182 "whatis long array"
183
184gdb_test "whatis v_signed_long_array" \
185 "type = (signed |)(int|long|long int) \\\[2\\\]" \
186 "whatis signed long array"
187
188gdb_test "whatis v_unsigned_long_array" \
189 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
190 "whatis unsigned long array"
191
192gdb_test "whatis v_float_array" \
193 "type = float \\\[2\\\]" \
194 "whatis float array"
195
196gdb_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.
206gdb_test "whatis v_char_pointer" \
207 "type = (unsigned |signed |)char \\*" \
208 "whatis char pointer"
209
210gdb_test "whatis v_signed_char_pointer" \
211 "type = (unsigned |signed |)char \\*" \
212 "whatis signed char pointer"
213
214gdb_test "whatis v_unsigned_char_pointer" \
215 "type = unsigned char \\*" \
216 "whatis unsigned char pointer"
217
218gdb_test "whatis v_short_pointer" \
219 "type = (short|short int) \\*" \
220 "whatis short pointer"
221
222gdb_test "whatis v_signed_short_pointer" \
223 "type = (signed |)(short|short int) \\*" \
224 "whatis signed short pointer"
225
226gdb_test "whatis v_unsigned_short_pointer" \
227 "type = (unsigned short|short unsigned int) \\*" \
228 "whatis unsigned short pointer"
229
230gdb_test "whatis v_int_pointer" \
231 "type = int \\*" \
232 "whatis int pointer"
233
234gdb_test "whatis v_signed_int_pointer" \
235 "type = (signed |)int \\*" \
236 "whatis signed int pointer"
237
238gdb_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
243gdb_test "whatis v_long_pointer" \
244 "type = (long|int|long int) \\*" \
245 "whatis long pointer"
246
247gdb_test "whatis v_signed_long_pointer" \
248 "type = (signed |)(long|int|long int) \\*" \
249 "whatis signed long pointer"
250
251gdb_test "whatis v_unsigned_long_pointer" \
252 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
253 "whatis unsigned long pointer"
254
255gdb_test "whatis v_float_pointer" \
256 "type = float \\*" \
257 "whatis float pointer"
258
259gdb_test "whatis v_double_pointer" \
260 "type = double \\*" \
261 "whatis double pointer"
262
263
085dd6e6
JM
264if { $hp_aCC_compiler } {
265 set unstruct "unnamed\.struct\..*"
266 set ununion "unnamed\.union\..*"
267} else {
268 set unstruct "\.\.\."
269 set ununion "\.\.\."
270}
271
c906108c
SS
272# test whatis command with structure types
273gdb_test "whatis v_struct1" \
274 "type = struct t_struct" \
275 "whatis named structure"
276
f8261448
FF
277gdb_test "whatis struct t_struct" \
278 "type = struct t_struct" \
279 "whatis named structure using type name"
280
c906108c 281gdb_test "whatis v_struct2" \
085dd6e6 282 "type = struct \{$unstruct\}" \
c906108c
SS
283 "whatis unnamed structure"
284
285
286# test whatis command with union types
287gdb_test "whatis v_union" \
288 "type = union t_union" \
289 "whatis named union"
290
f8261448
FF
291gdb_test "whatis union t_union" \
292 "type = union t_union" \
293 "whatis named union using type name"
294
c906108c 295gdb_test "whatis v_union2" \
085dd6e6 296 "type = union \{$ununion\}" \
c906108c
SS
297 "whatis unnamed union"
298
299
1e698235
DJ
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.
306set void "(void|)"
c906108c
SS
307
308# test whatis command with functions return type
309gdb_test "whatis v_char_func" \
085dd6e6 310 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
311 "whatis char function"
312
313gdb_test "whatis v_signed_char_func" \
085dd6e6 314 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
315 "whatis signed char function"
316
317gdb_test "whatis v_unsigned_char_func" \
085dd6e6 318 "type = unsigned char \\($void\\)" \
c906108c
SS
319 "whatis unsigned char function"
320
321gdb_test "whatis v_short_func" \
085dd6e6 322 "type = short (int |)\\($void\\)" \
c906108c
SS
323 "whatis short function"
324
325gdb_test "whatis v_signed_short_func" \
085dd6e6 326 "type = (signed |)short (int |)\\($void\\)" \
c906108c
SS
327 "whatis signed short function"
328
329gdb_test "whatis v_unsigned_short_func" \
085dd6e6 330 "type = (unsigned short|short unsigned int) \\($void\\)" \
c906108c
SS
331 "whatis unsigned short function"
332
333gdb_test "whatis v_int_func" \
085dd6e6 334 "type = int \\($void\\)" \
c906108c
SS
335 "whatis int function"
336
337gdb_test "whatis v_signed_int_func" \
085dd6e6 338 "type = (signed |)int \\($void\\)" \
c906108c
SS
339 "whatis signed int function"
340
341gdb_test "whatis v_unsigned_int_func" \
085dd6e6 342 "type = unsigned int \\($void\\)" \
c906108c
SS
343 "whatis unsigned int function"
344
345gdb_test "whatis v_long_func" \
085dd6e6 346 "type = (long|int|long int) \\($void\\)" \
c906108c
SS
347 "whatis long function"
348
349gdb_test "whatis v_signed_long_func" \
085dd6e6 350 "type = (signed |)(int|long|long int) \\($void\\)" \
c906108c
SS
351 "whatis signed long function"
352
353gdb_test "whatis v_unsigned_long_func" \
085dd6e6 354 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
c906108c
SS
355 "whatis unsigned long function"
356
357# Sun /bin/cc calls this a function returning double.
358if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
359gdb_test "whatis v_float_func" \
085dd6e6 360 "type = float \\($void\\)" \
c906108c
SS
361 "whatis float function"
362
363gdb_test "whatis v_double_func" \
085dd6e6 364 "type = double \\($void\\)" \
c906108c
SS
365 "whatis double function" \
366
367
368# test whatis command with some misc complicated types
369gdb_test "whatis s_link" \
370 "type = struct link \\*" \
371 "whatis complicated structure"
372
373gdb_test "whatis u_link" \
374 "type = union tu_link" \
375 "whatis complicated union"
376
377
378# test whatis command with enumerations
379gdb_test "whatis clunker" \
380 "type = enum cars" \
381 "whatis enumeration"
382
f8261448
FF
383gdb_test "whatis enum cars" \
384 "type = enum cars" \
385 "whatis enumeration using type name"
386
c906108c
SS
387
388# test whatis command with nested struct and union
389gdb_test "whatis nested_su" \
390 "type = struct outer_struct" \
391 "whatis outer structure"
392
393gdb_test "whatis nested_su.outer_int" \
394 "type = int" \
395 "whatis outer structure member"
396
085dd6e6
JM
397if {$hp_aCC_compiler} {
398 set outer "outer_struct::"
399} else {
400 set outer ""
401}
402
c906108c 403gdb_test "whatis nested_su.inner_struct_instance" \
085dd6e6 404 "type = struct ${outer}inner_struct" \
c906108c
SS
405 "whatis inner structure"
406
407gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
408 "type = int" \
409 "whatis inner structure member"
410
411gdb_test "whatis nested_su.inner_union_instance" \
085dd6e6 412 "type = union ${outer}inner_union" \
c906108c
SS
413 "whatis inner union"
414
415gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
416 "type = int" \
417 "whatis inner union member"
f8261448
FF
418
419# test whatis command with typedefs
420
421gdb_test "whatis char_addr" \
422 "type = char \\*" \
423 "whatis using typedef type name"
424
425gdb_test "whatis a_char_addr" \
426 "type = char_addr" \
427 "whatis applied to variable defined by typedef"
This page took 0.634006 seconds and 4 git commands to generate.