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