* gdb.arch/i386-prologue.exp (skip_breakpoint): New function. Use
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.exp
CommitLineData
1e698235 1# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002, 2003
b9c07f0f 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
88if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
89gdb_test "whatis v_signed_char" \
90 "type = $signed_char" \
91 "whatis signed char"
92
93gdb_test "whatis v_unsigned_char" \
94 "type = unsigned char" \
95 "whatis unsigned char"
96
97gdb_test "whatis v_short" \
98 "type = (short|short int)" \
99 "whatis short"
100
101gdb_test "whatis v_signed_short" \
102 "type = (short|short int|signed short|signed short int)" \
103 "whatis signed short"
104
105gdb_test "whatis v_unsigned_short" \
106 "type = (unsigned short|short unsigned int)" \
107 "whatis unsigned short"
108
109gdb_test "whatis v_int" \
110 "type = int" \
111 "whatis int"
112
113gdb_test "whatis v_signed_int" \
114 "type = (signed |)int" \
115 "whatis signed int"
116
117gdb_test "whatis v_unsigned_int" \
118 "type = unsigned int" \
119 "whatis unsigned int"
120
121setup_xfail_on_long_vs_int
122# AIX xlc gets this wrong and unsigned long right. Go figure.
123if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
124gdb_test "whatis v_long" \
125 "type = (long|long int)" \
126 "whatis long"
127
128setup_xfail_on_long_vs_int
129# AIX xlc gets this wrong and unsigned long right. Go figure.
130if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
131gdb_test "whatis v_signed_long" \
132 "type = (signed |)(long|long int)" \
133 "whatis signed long"
134
135setup_xfail_on_long_vs_int
136gdb_test "whatis v_unsigned_long" \
137 "type = (unsigned long|long unsigned int)" \
138 "whatis unsigned long"
139
140gdb_test "whatis v_float" \
141 "type = float" \
142 "whatis float"
143
144gdb_test "whatis v_double" \
145 "type = double" \
146 "whatis double"
147
148
149# test whatis command with arrays
150#
151# We already tested whether char prints as "char", so here we accept
152# "unsigned char", "signed char", and other perversions. No need for more
153# than one xfail for the same thing.
154gdb_test "whatis v_char_array" \
155 "type = (signed |unsigned |)char \\\[2\\\]" \
156 "whatis char array"
157
158gdb_test "whatis v_signed_char_array" \
159 "type = (signed |unsigned |)char \\\[2\\\]" \
160 "whatis signed char array"
161
162gdb_test "whatis v_unsigned_char_array" \
163 "type = unsigned char \\\[2\\\]" \
164 "whatis unsigned char array"
165
166gdb_test "whatis v_short_array" \
167 "type = (short|short int) \\\[2\\\]" \
168 "whatis short array"
169
170gdb_test "whatis v_signed_short_array" \
171 "type = (signed |)(short|short int) \\\[2\\\]" \
172 "whatis signed short array"
173
174gdb_test "whatis v_unsigned_short_array" \
175 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
176 "whatis unsigned short array"
177
178gdb_test "whatis v_int_array" \
179 "type = int \\\[2\\\]" \
180 "whatis int array"
181
182gdb_test "whatis v_signed_int_array" \
183 "type = (signed |)int \\\[2\\\]" \
184 "whatis signed int array"
185
186gdb_test "whatis v_unsigned_int_array" \
187 "type = unsigned int \\\[2\\\]" \
188 "whatis unsigned int array"
189
190# We already tested whether long prints as long, so here we accept int
191# No need for more than one xfail for the same thing.
192gdb_test "whatis v_long_array" \
193 "type = (int|long|long int) \\\[2\\\]" \
194 "whatis long array"
195
196gdb_test "whatis v_signed_long_array" \
197 "type = (signed |)(int|long|long int) \\\[2\\\]" \
198 "whatis signed long array"
199
200gdb_test "whatis v_unsigned_long_array" \
201 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
202 "whatis unsigned long array"
203
204gdb_test "whatis v_float_array" \
205 "type = float \\\[2\\\]" \
206 "whatis float array"
207
208gdb_test "whatis v_double_array" \
209 "type = double \\\[2\\\]" \
210 "whatis double array"
211
212
213# test whatis command with pointers
214#
215# We already tested whether char prints as char, so accept various perversions
216# here. We especially want to make sure we test that it doesn't print as
217# caddr_t.
218gdb_test "whatis v_char_pointer" \
219 "type = (unsigned |signed |)char \\*" \
220 "whatis char pointer"
221
222gdb_test "whatis v_signed_char_pointer" \
223 "type = (unsigned |signed |)char \\*" \
224 "whatis signed char pointer"
225
226gdb_test "whatis v_unsigned_char_pointer" \
227 "type = unsigned char \\*" \
228 "whatis unsigned char pointer"
229
230gdb_test "whatis v_short_pointer" \
231 "type = (short|short int) \\*" \
232 "whatis short pointer"
233
234gdb_test "whatis v_signed_short_pointer" \
235 "type = (signed |)(short|short int) \\*" \
236 "whatis signed short pointer"
237
238gdb_test "whatis v_unsigned_short_pointer" \
239 "type = (unsigned short|short unsigned int) \\*" \
240 "whatis unsigned short pointer"
241
242gdb_test "whatis v_int_pointer" \
243 "type = int \\*" \
244 "whatis int pointer"
245
246gdb_test "whatis v_signed_int_pointer" \
247 "type = (signed |)int \\*" \
248 "whatis signed int pointer"
249
250gdb_test "whatis v_unsigned_int_pointer" \
251 "type = unsigned int \\*" \
252 "whatis unsigned int pointer"
253
254# We already tested whether long prints as long, so here we accept int
255gdb_test "whatis v_long_pointer" \
256 "type = (long|int|long int) \\*" \
257 "whatis long pointer"
258
259gdb_test "whatis v_signed_long_pointer" \
260 "type = (signed |)(long|int|long int) \\*" \
261 "whatis signed long pointer"
262
263gdb_test "whatis v_unsigned_long_pointer" \
264 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
265 "whatis unsigned long pointer"
266
267gdb_test "whatis v_float_pointer" \
268 "type = float \\*" \
269 "whatis float pointer"
270
271gdb_test "whatis v_double_pointer" \
272 "type = double \\*" \
273 "whatis double pointer"
274
275
085dd6e6
JM
276if { $hp_aCC_compiler } {
277 set unstruct "unnamed\.struct\..*"
278 set ununion "unnamed\.union\..*"
279} else {
280 set unstruct "\.\.\."
281 set ununion "\.\.\."
282}
283
c906108c
SS
284# test whatis command with structure types
285gdb_test "whatis v_struct1" \
286 "type = struct t_struct" \
287 "whatis named structure"
288
289gdb_test "whatis v_struct2" \
085dd6e6 290 "type = struct \{$unstruct\}" \
c906108c
SS
291 "whatis unnamed structure"
292
293
294# test whatis command with union types
295gdb_test "whatis v_union" \
296 "type = union t_union" \
297 "whatis named union"
298
299gdb_test "whatis v_union2" \
085dd6e6 300 "type = union \{$ununion\}" \
c906108c
SS
301 "whatis unnamed union"
302
303
1e698235
DJ
304# HP-UX: HP aCC compiler w/ +objdebug option detects language as
305# c++, so we need the 'void' pattern here.
306# Without +objdebug compilation option we still need to match ''.
307# - guo
308# Also, using stabs we will mark these functions as prototyped. This
309# is harmless but causes an extra VOID to be printed.
310set void "(void|)"
c906108c
SS
311
312# test whatis command with functions return type
313gdb_test "whatis v_char_func" \
085dd6e6 314 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
315 "whatis char function"
316
317gdb_test "whatis v_signed_char_func" \
085dd6e6 318 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
319 "whatis signed char function"
320
321gdb_test "whatis v_unsigned_char_func" \
085dd6e6 322 "type = unsigned char \\($void\\)" \
c906108c
SS
323 "whatis unsigned char function"
324
325gdb_test "whatis v_short_func" \
085dd6e6 326 "type = short (int |)\\($void\\)" \
c906108c
SS
327 "whatis short function"
328
329gdb_test "whatis v_signed_short_func" \
085dd6e6 330 "type = (signed |)short (int |)\\($void\\)" \
c906108c
SS
331 "whatis signed short function"
332
333gdb_test "whatis v_unsigned_short_func" \
085dd6e6 334 "type = (unsigned short|short unsigned int) \\($void\\)" \
c906108c
SS
335 "whatis unsigned short function"
336
337gdb_test "whatis v_int_func" \
085dd6e6 338 "type = int \\($void\\)" \
c906108c
SS
339 "whatis int function"
340
341gdb_test "whatis v_signed_int_func" \
085dd6e6 342 "type = (signed |)int \\($void\\)" \
c906108c
SS
343 "whatis signed int function"
344
345gdb_test "whatis v_unsigned_int_func" \
085dd6e6 346 "type = unsigned int \\($void\\)" \
c906108c
SS
347 "whatis unsigned int function"
348
349gdb_test "whatis v_long_func" \
085dd6e6 350 "type = (long|int|long int) \\($void\\)" \
c906108c
SS
351 "whatis long function"
352
353gdb_test "whatis v_signed_long_func" \
085dd6e6 354 "type = (signed |)(int|long|long int) \\($void\\)" \
c906108c
SS
355 "whatis signed long function"
356
357gdb_test "whatis v_unsigned_long_func" \
085dd6e6 358 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
c906108c
SS
359 "whatis unsigned long function"
360
361# Sun /bin/cc calls this a function returning double.
362if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
363gdb_test "whatis v_float_func" \
085dd6e6 364 "type = float \\($void\\)" \
c906108c
SS
365 "whatis float function"
366
367gdb_test "whatis v_double_func" \
085dd6e6 368 "type = double \\($void\\)" \
c906108c
SS
369 "whatis double function" \
370
371
372# test whatis command with some misc complicated types
373gdb_test "whatis s_link" \
374 "type = struct link \\*" \
375 "whatis complicated structure"
376
377gdb_test "whatis u_link" \
378 "type = union tu_link" \
379 "whatis complicated union"
380
381
382# test whatis command with enumerations
383gdb_test "whatis clunker" \
384 "type = enum cars" \
385 "whatis enumeration"
386
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"
This page took 0.477489 seconds and 4 git commands to generate.