* gdb.base/help.exp: Replace most of docstring for "define" with ".*".
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.exp
CommitLineData
316567f0
C
1# Copyright (C) 1988, 1990, 1991, 1992 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Rob Savoye. (rob@cygnus.com)
21
22if $tracelevel then {
23 strace $tracelevel
24}
25
26#
27# test running programs
28#
29set prms_id 0
30set bug_id 0
31
32set binfile "whatis"
33
34if ![file exists $objdir/$subdir/$binfile] then {
35 perror "$objdir/$subdir/$binfile does not exist."
36 return 0
37}
38
39gdb_reinitialize_dir $srcdir/$subdir
40gdb_load $objdir/$subdir/$binfile
41
42source gdb.base/whatis-info.exp
43
44# If we did not use the signed keyword when compiling the file, don't
45# expect GDB to know that char is signed.
46if $signed_keyword_not_used then {
47 set signed_char "char"
48} else {
49 set signed_char "signed char"
50}
51
52# Define a procedure to set up an xfail for all targets that put out a
53# `long' type as an `int' type.
54# Sun/Ultrix cc have this problem.
55# It was said that COFF targets can not distinguish int from long either.
56
57proc setup_xfail_on_long_vs_int {} {
58 global gcc_compiled
59
60 if {!$gcc_compiled} then {
61 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
62 }
63}
64
65#
66# Test whatis command with basic C types
67#
68# The name printed now (as of 23 May 1993) is whatever name the compiler
69# uses in the stabs. So we need to deal with names both from gcc and
70# native compilers.
71#
72# On the i960, which defaults to unsigned characters, gdb
73# misinterprets char as unsigned char.
74# Likewise with the rs6000; the compiler doesn't give us enough information
75# to distinguish between char and unsigned char
76setup_xfail "rs6000-*-*"
77setup_xfail "i960-*-*" 1821
78setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*"
79gdb_test "whatis v_char" \
80 "type = char" \
81 "whatis char"
82
83setup_xfail "a29k-*-*"
84gdb_test "whatis v_signed_char" \
85 "type = $signed_char" \
86 "whatis signed char"
87
88gdb_test "whatis v_unsigned_char" \
89 "type = unsigned char" \
90 "whatis unsigned char"
91
92gdb_test "whatis v_short" \
93 "type = short" \
94 "whatis short"
95
96gdb_test "whatis v_signed_short" \
97 "type = short" \
98 "whatis signed short"
99
100gdb_test "whatis v_unsigned_short" \
101 "type = (unsigned short|short unsigned int)" \
102 "whatis unsigned short"
103
104gdb_test "whatis v_int" \
105 "type = int" \
106 "whatis int"
107
108gdb_test "whatis v_signed_int" \
109 "type = int" \
110 "whatis signed int"
111
112gdb_test "whatis v_unsigned_int" \
113 "type = unsigned int" \
114 "whatis unsigned int"
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_long" \
120 "type = long" \
121 "whatis long"
122
123setup_xfail_on_long_vs_int
124# AIX xlc gets this wrong and unsigned long right. Go figure.
125if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
126gdb_test "whatis v_signed_long" \
127 "type = long" \
128 "whatis signed long"
129
130setup_xfail_on_long_vs_int
131gdb_test "whatis v_unsigned_long" \
132 "type = (unsigned long|long unsigned int)" \
133 "whatis unsigned long"
134
135gdb_test "whatis v_float" \
136 "type = float" \
137 "whatis float"
138
139gdb_test "whatis v_double" \
140 "type = double" \
141 "whatis double"
142
143
144# test whatis command with arrays
145#
146# We already tested whether char prints as "char", so here we accept
147# "unsigned char", "signed char", and other perversions. No need for more
148# than one xfail for the same thing.
149gdb_test "whatis v_char_array" \
150 "type = (signed |unsigned |)char \\\[2\\\]" \
151 "whatis char array"
152
153gdb_test "whatis v_signed_char_array" \
154 "type = (signed |unsigned |)char \\\[2\\\]" \
155 "whatis signed char array"
156
157gdb_test "whatis v_unsigned_char_array" \
158 "type = unsigned char \\\[2\\\]" \
159 "whatis unsigned char array"
160
161gdb_test "whatis v_short_array" \
162 "type = (short|short int) \\\[2\\\]" \
163 pass "whatis short array"
164
165gdb_test "whatis v_signed_short_array" \
166 "type = (short|shirt int) \\\[2\\\]" \
167 "whatis signed short array"
168
169gdb_test "whatis v_unsigned_short_array" \
170 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
171 "whatis unsigned short array"
172
173gdb_test "whatis v_int_array" \
174 "type = int \\\[2\\\]" \
175 "whatis int array"
176
177gdb_test "whatis v_signed_int_array" \
178 "type = int \\\[2\\\]" \
179 "whatis signed int array"
180
181gdb_test "whatis v_unsigned_int_array" \
182 "type = unsigned int \\\[2\\\]" \
183 "whatis unsigned int array"
184
185# We already tested whether long prints as long, so here we accept int
186# No need for more than one xfail for the same thing.
187gdb_test "whatis v_long_array" \
188 "type = (int|long|long int) \\\[2\\\]" \
189 "whatis long array"
190
191gdb_test "whatis v_signed_long_array" \
192 "type = (signed |)(int|long|long int) \\\[2\\\]" \
193 "whatis signed long array"
194
195gdb_test "whatis v_unsigned_long_array" \
196 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
197 "whatis unsigned long array"
198
199gdb_test "whatis v_float_array" \
200 "type = float \\\[2\\\]" \
201 "whatis float array"
202
203gdb_test "whatis v_double_array" \
204 "type = double \\\[2\\\]" \
205 "whatis double array"
206
207
208# test whatis command with pointers
209#
210# We already tested whether char prints as char, so accept various perversions
211# here. We especially want to make sure we test that it doesn't print as
212# caddr_t.
213gdb_test "whatis v_char_pointer" \
214 "type = (unsigned |signed |)char \*" \
215 "whatis char pointer"
216
217gdb_test "whatis v_signed_char_pointer" \
218 "type = (unsigned |signed |)char \*" \
219 "whatis signed char pointer"
220
221gdb_test "whatis v_unsigned_char_pointer" \
222 "type = unsigned char \*" \
223 "whatis unsigned char pointer"
224
225gdb_test "whatis v_short_pointer" \
226 "type = (short|short int) \*" \
227 pass "whatis short pointer"
228
229gdb_test "whatis v_signed_short_pointer" \
230 "type = (short|short int) \*" \
231 "whatis signed short pointer"
232
233gdb_test "whatis v_unsigned_short_pointer" \
234 "type = (unsigned short|short unsigned int) \*" \
235 "whatis unsigned short pointer"
236
237gdb_test "whatis v_int_pointer" \
238 "type = int \*" \
239 "whatis int pointer"
240
241gdb_test "whatis v_signed_int_pointer" \
242 "type = int \*" \
243 "whatis signed int pointer"
244
245gdb_test "whatis v_unsigned_int_pointer" \
246 "type = unsigned int \*" \
247 "whatis unsigned int pointer"
248
249# We already tested whether long prints as long, so here we accept int
250gdb_test "whatis v_long_pointer" \
251 "type = (long|int|long int) \*" \
252 "whatis long pointer"
253
254gdb_test "whatis v_signed_long_pointer" \
255 "type = (signed |)(long|int|long int) \*" \
256 "whatis signed long pointer"
257
258gdb_test "whatis v_unsigned_long_pointer" \
259 "type = (unsigned (int|long|long int)|long unsigned int) \*" \
260 "whatis unsigned long pointer"
261
262gdb_test "whatis v_float_pointer" \
263 "type = float \*" \
264 "whatis float pointer"
265
266gdb_test "whatis v_double_pointer" \
267 "type = double \*" \
268 "whatis double pointer"
269
270
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" \
277 "type = struct \{...\}" \
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" \
287 "type = union \{...\}" \
288 "whatis unnamed union"
289
290
291
292# test whatis command with functions return type
293gdb_test "whatis v_char_func" \
294 "type = (signed |unsigned |)char \(\)" \
295 "whatis char function"
296
297gdb_test "whatis v_signed_char_func" \
298 "type = (signed |unsigned |)char \(\)" \
299 "whatis signed char function"
300
301gdb_test "whatis v_unsigned_char_func" \
302 "type = unsigned char \(\)" \
303 "whatis unsigned char function"
304
305gdb_test "whatis v_short_func" \
306 "type = short (int |)\(\)" \
307 "whatis short function"
308
309gdb_test "whatis v_signed_short_func" \
310 "type = short (int |)\(\)" \
311 "whatis signed short function"
312
313gdb_test "whatis v_unsigned_short_func" \
314 "type = (unsigned short|short unsigned int) \(\)" \
315 "whatis unsigned short function"
316
317gdb_test "whatis v_int_func" \
318 "type = int \(\)" \
319 "whatis int function"
320
321gdb_test "whatis v_signed_int_func" \
322 "type = int \(\)" \
323 "whatis signed int function"
324
325gdb_test "whatis v_unsigned_int_func" \
326 "type = unsigned int \(\)" \
327 "whatis unsigned int function"
328
329gdb_test "whatis v_long_func" \
330 "type = (long|int|long int) \(\)" \
331 "whatis long function"
332
333gdb_test "whatis v_signed_long_func" \
334 "type = (int|long|long int) \(\)" \
335 "whatis signed long function"
336
337gdb_test "whatis v_unsigned_long_func" \
338 "type = (unsigned (int|long|long int)|long unsigned int) \(\)" \
339 "whatis unsigned long function"
340
341# Sun /bin/cc calls this a function returning double.
342if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
343gdb_test "whatis v_float_func" \
344 "type = float \(\)" \
345 "whatis float function"
346
347gdb_test "whatis v_double_func" \
348 "type = double \(\)" \
349 "whatis double function" \
350
351
352# test whatis command with some misc complicated types
353gdb_test "whatis s_link" \
354 "type = struct link" \
355 "whatis complicated structure"
356
357gdb_test "whatis u_link" \
358 "type = union tu_link" \
359 "whatis complicated union"
360
361
362# test whatis command with enumerations
363gdb_test "whatis clunker" \
364 "type = enum cars" \
365 "whatis enumeration"
366
367
368# test whatis command with nested struct and union
369gdb_test "whatis nested_su" \
370 "type = struct outer_struct" \
371 "whatis outer structure"
372
373gdb_test "whatis nested_su.outer_int" \
374 "type = int" \
375 "whatis outer structure member"
376
377gdb_test "whatis nested_su.inner_struct_instance" \
378 "type = struct inner_struct" \
379 "whatis inner structure"
380
381gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
382 "type = int" \
383 "whatis inner structure member"
384
385gdb_test "whatis nested_su.inner_union_instance" \
386 "type = union inner_union" \
387 "whatis inner union"
388
389gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
390 "type = int" \
391 "whatis inner union member"
This page took 0.059652 seconds and 4 git commands to generate.