* hppa-hpux-tdep.c: Update copyright notice and year.
[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}] != "" } {
34 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
35}
36
37# Create and source the file that provides information about the compiler
38# used to compile the test case.
39if [get_compiler_info ${binfile}] {
40 return -1;
41}
42
43# Start with a fresh gdb.
44
45gdb_exit
46gdb_start
47gdb_reinitialize_dir $srcdir/$subdir
48gdb_load $binfile
49
c906108c
SS
50# Define a procedure to set up an xfail for all targets that put out a
51# `long' type as an `int' type.
52# Sun/Ultrix cc have this problem.
53# It was said that COFF targets can not distinguish int from long either.
54
55proc setup_xfail_on_long_vs_int {} {
56 global gcc_compiled
57
58 if {!$gcc_compiled} {
59 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
60 }
61}
62
63#
64# Test whatis command with basic C types
65#
66# The name printed now (as of 23 May 1993) is whatever name the compiler
67# uses in the stabs. So we need to deal with names both from gcc and
68# native compilers.
69#
085dd6e6 70
c906108c
SS
71gdb_test "whatis v_char" \
72 "type = (unsigned char|char)" \
73 "whatis char"
74
c906108c
SS
75if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
76gdb_test "whatis v_signed_char" \
d782e0bf 77 "type = (signed char|char)" \
c906108c
SS
78 "whatis signed char"
79
80gdb_test "whatis v_unsigned_char" \
81 "type = unsigned char" \
82 "whatis unsigned char"
83
84gdb_test "whatis v_short" \
85 "type = (short|short int)" \
86 "whatis short"
87
88gdb_test "whatis v_signed_short" \
89 "type = (short|short int|signed short|signed short int)" \
90 "whatis signed short"
91
92gdb_test "whatis v_unsigned_short" \
93 "type = (unsigned short|short unsigned int)" \
94 "whatis unsigned short"
95
96gdb_test "whatis v_int" \
97 "type = int" \
98 "whatis int"
99
100gdb_test "whatis v_signed_int" \
101 "type = (signed |)int" \
102 "whatis signed int"
103
104gdb_test "whatis v_unsigned_int" \
105 "type = unsigned int" \
106 "whatis unsigned int"
107
108setup_xfail_on_long_vs_int
109# AIX xlc gets this wrong and unsigned long right. Go figure.
110if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
111gdb_test "whatis v_long" \
112 "type = (long|long int)" \
113 "whatis long"
114
115setup_xfail_on_long_vs_int
116# AIX xlc gets this wrong and unsigned long right. Go figure.
117if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
118gdb_test "whatis v_signed_long" \
119 "type = (signed |)(long|long int)" \
120 "whatis signed long"
121
122setup_xfail_on_long_vs_int
123gdb_test "whatis v_unsigned_long" \
124 "type = (unsigned long|long unsigned int)" \
125 "whatis unsigned long"
126
127gdb_test "whatis v_float" \
128 "type = float" \
129 "whatis float"
130
131gdb_test "whatis v_double" \
132 "type = double" \
133 "whatis double"
134
135
136# test whatis command with arrays
137#
138# We already tested whether char prints as "char", so here we accept
139# "unsigned char", "signed char", and other perversions. No need for more
140# than one xfail for the same thing.
141gdb_test "whatis v_char_array" \
142 "type = (signed |unsigned |)char \\\[2\\\]" \
143 "whatis char array"
144
145gdb_test "whatis v_signed_char_array" \
146 "type = (signed |unsigned |)char \\\[2\\\]" \
147 "whatis signed char array"
148
149gdb_test "whatis v_unsigned_char_array" \
150 "type = unsigned char \\\[2\\\]" \
151 "whatis unsigned char array"
152
153gdb_test "whatis v_short_array" \
154 "type = (short|short int) \\\[2\\\]" \
155 "whatis short array"
156
157gdb_test "whatis v_signed_short_array" \
158 "type = (signed |)(short|short int) \\\[2\\\]" \
159 "whatis signed short array"
160
161gdb_test "whatis v_unsigned_short_array" \
162 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
163 "whatis unsigned short array"
164
165gdb_test "whatis v_int_array" \
166 "type = int \\\[2\\\]" \
167 "whatis int array"
168
169gdb_test "whatis v_signed_int_array" \
170 "type = (signed |)int \\\[2\\\]" \
171 "whatis signed int array"
172
173gdb_test "whatis v_unsigned_int_array" \
174 "type = unsigned int \\\[2\\\]" \
175 "whatis unsigned int array"
176
177# We already tested whether long prints as long, so here we accept int
178# No need for more than one xfail for the same thing.
179gdb_test "whatis v_long_array" \
180 "type = (int|long|long int) \\\[2\\\]" \
181 "whatis long array"
182
183gdb_test "whatis v_signed_long_array" \
184 "type = (signed |)(int|long|long int) \\\[2\\\]" \
185 "whatis signed long array"
186
187gdb_test "whatis v_unsigned_long_array" \
188 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
189 "whatis unsigned long array"
190
191gdb_test "whatis v_float_array" \
192 "type = float \\\[2\\\]" \
193 "whatis float array"
194
195gdb_test "whatis v_double_array" \
196 "type = double \\\[2\\\]" \
197 "whatis double array"
198
199
200# test whatis command with pointers
201#
202# We already tested whether char prints as char, so accept various perversions
203# here. We especially want to make sure we test that it doesn't print as
204# caddr_t.
205gdb_test "whatis v_char_pointer" \
206 "type = (unsigned |signed |)char \\*" \
207 "whatis char pointer"
208
209gdb_test "whatis v_signed_char_pointer" \
210 "type = (unsigned |signed |)char \\*" \
211 "whatis signed char pointer"
212
213gdb_test "whatis v_unsigned_char_pointer" \
214 "type = unsigned char \\*" \
215 "whatis unsigned char pointer"
216
217gdb_test "whatis v_short_pointer" \
218 "type = (short|short int) \\*" \
219 "whatis short pointer"
220
221gdb_test "whatis v_signed_short_pointer" \
222 "type = (signed |)(short|short int) \\*" \
223 "whatis signed short pointer"
224
225gdb_test "whatis v_unsigned_short_pointer" \
226 "type = (unsigned short|short unsigned int) \\*" \
227 "whatis unsigned short pointer"
228
229gdb_test "whatis v_int_pointer" \
230 "type = int \\*" \
231 "whatis int pointer"
232
233gdb_test "whatis v_signed_int_pointer" \
234 "type = (signed |)int \\*" \
235 "whatis signed int pointer"
236
237gdb_test "whatis v_unsigned_int_pointer" \
238 "type = unsigned int \\*" \
239 "whatis unsigned int pointer"
240
241# We already tested whether long prints as long, so here we accept int
242gdb_test "whatis v_long_pointer" \
243 "type = (long|int|long int) \\*" \
244 "whatis long pointer"
245
246gdb_test "whatis v_signed_long_pointer" \
247 "type = (signed |)(long|int|long int) \\*" \
248 "whatis signed long pointer"
249
250gdb_test "whatis v_unsigned_long_pointer" \
251 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
252 "whatis unsigned long pointer"
253
254gdb_test "whatis v_float_pointer" \
255 "type = float \\*" \
256 "whatis float pointer"
257
258gdb_test "whatis v_double_pointer" \
259 "type = double \\*" \
260 "whatis double pointer"
261
262
085dd6e6
JM
263if { $hp_aCC_compiler } {
264 set unstruct "unnamed\.struct\..*"
265 set ununion "unnamed\.union\..*"
266} else {
267 set unstruct "\.\.\."
268 set ununion "\.\.\."
269}
270
c906108c
SS
271# test whatis command with structure types
272gdb_test "whatis v_struct1" \
273 "type = struct t_struct" \
274 "whatis named structure"
275
276gdb_test "whatis v_struct2" \
085dd6e6 277 "type = struct \{$unstruct\}" \
c906108c
SS
278 "whatis unnamed structure"
279
280
281# test whatis command with union types
282gdb_test "whatis v_union" \
283 "type = union t_union" \
284 "whatis named union"
285
286gdb_test "whatis v_union2" \
085dd6e6 287 "type = union \{$ununion\}" \
c906108c
SS
288 "whatis unnamed union"
289
290
1e698235
DJ
291# HP-UX: HP aCC compiler w/ +objdebug option detects language as
292# c++, so we need the 'void' pattern here.
293# Without +objdebug compilation option we still need to match ''.
294# - guo
295# Also, using stabs we will mark these functions as prototyped. This
296# is harmless but causes an extra VOID to be printed.
297set void "(void|)"
c906108c
SS
298
299# test whatis command with functions return type
300gdb_test "whatis v_char_func" \
085dd6e6 301 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
302 "whatis char function"
303
304gdb_test "whatis v_signed_char_func" \
085dd6e6 305 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
306 "whatis signed char function"
307
308gdb_test "whatis v_unsigned_char_func" \
085dd6e6 309 "type = unsigned char \\($void\\)" \
c906108c
SS
310 "whatis unsigned char function"
311
312gdb_test "whatis v_short_func" \
085dd6e6 313 "type = short (int |)\\($void\\)" \
c906108c
SS
314 "whatis short function"
315
316gdb_test "whatis v_signed_short_func" \
085dd6e6 317 "type = (signed |)short (int |)\\($void\\)" \
c906108c
SS
318 "whatis signed short function"
319
320gdb_test "whatis v_unsigned_short_func" \
085dd6e6 321 "type = (unsigned short|short unsigned int) \\($void\\)" \
c906108c
SS
322 "whatis unsigned short function"
323
324gdb_test "whatis v_int_func" \
085dd6e6 325 "type = int \\($void\\)" \
c906108c
SS
326 "whatis int function"
327
328gdb_test "whatis v_signed_int_func" \
085dd6e6 329 "type = (signed |)int \\($void\\)" \
c906108c
SS
330 "whatis signed int function"
331
332gdb_test "whatis v_unsigned_int_func" \
085dd6e6 333 "type = unsigned int \\($void\\)" \
c906108c
SS
334 "whatis unsigned int function"
335
336gdb_test "whatis v_long_func" \
085dd6e6 337 "type = (long|int|long int) \\($void\\)" \
c906108c
SS
338 "whatis long function"
339
340gdb_test "whatis v_signed_long_func" \
085dd6e6 341 "type = (signed |)(int|long|long int) \\($void\\)" \
c906108c
SS
342 "whatis signed long function"
343
344gdb_test "whatis v_unsigned_long_func" \
085dd6e6 345 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
c906108c
SS
346 "whatis unsigned long function"
347
348# Sun /bin/cc calls this a function returning double.
349if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
350gdb_test "whatis v_float_func" \
085dd6e6 351 "type = float \\($void\\)" \
c906108c
SS
352 "whatis float function"
353
354gdb_test "whatis v_double_func" \
085dd6e6 355 "type = double \\($void\\)" \
c906108c
SS
356 "whatis double function" \
357
358
359# test whatis command with some misc complicated types
360gdb_test "whatis s_link" \
361 "type = struct link \\*" \
362 "whatis complicated structure"
363
364gdb_test "whatis u_link" \
365 "type = union tu_link" \
366 "whatis complicated union"
367
368
369# test whatis command with enumerations
370gdb_test "whatis clunker" \
371 "type = enum cars" \
372 "whatis enumeration"
373
374
375# test whatis command with nested struct and union
376gdb_test "whatis nested_su" \
377 "type = struct outer_struct" \
378 "whatis outer structure"
379
380gdb_test "whatis nested_su.outer_int" \
381 "type = int" \
382 "whatis outer structure member"
383
085dd6e6
JM
384if {$hp_aCC_compiler} {
385 set outer "outer_struct::"
386} else {
387 set outer ""
388}
389
c906108c 390gdb_test "whatis nested_su.inner_struct_instance" \
085dd6e6 391 "type = struct ${outer}inner_struct" \
c906108c
SS
392 "whatis inner structure"
393
394gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
395 "type = int" \
396 "whatis inner structure member"
397
398gdb_test "whatis nested_su.inner_union_instance" \
085dd6e6 399 "type = union ${outer}inner_union" \
c906108c
SS
400 "whatis inner union"
401
402gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
403 "type = int" \
404 "whatis inner union member"
This page took 0.547964 seconds and 4 git commands to generate.