ChangeLog:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.exp
CommitLineData
6aba47ca 1# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002, 2003,
0fb0cc75 2# 2004, 2007, 2008, 2009 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
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
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.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17# This file was written by Rob Savoye. (rob@cygnus.com)
18
19if $tracelevel {
20 strace $tracelevel
21}
22
23#
24# test running programs
25#
26set prms_id 0
27set bug_id 0
28
64b2fa04
PA
29if [target_info exists no_long_long] {
30 set exec_opts [list debug additional_flags=-DNO_LONG_LONG]
31} else {
32 set exec_opts [list debug]
33}
34
c906108c
SS
35set testfile whatis
36set srcfile ${testfile}.c
37set binfile ${objdir}/${subdir}/${testfile}
64b2fa04 38if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $exec_opts] != "" } {
b60f0898
JB
39 untested whatis.exp
40 return -1
c906108c
SS
41}
42
43# Create and source the file that provides information about the compiler
44# used to compile the test case.
45if [get_compiler_info ${binfile}] {
46 return -1;
47}
48
49# Start with a fresh gdb.
50
51gdb_exit
52gdb_start
53gdb_reinitialize_dir $srcdir/$subdir
54gdb_load $binfile
55
c906108c
SS
56# Define a procedure to set up an xfail for all targets that put out a
57# `long' type as an `int' type.
58# Sun/Ultrix cc have this problem.
59# It was said that COFF targets can not distinguish int from long either.
60
61proc setup_xfail_on_long_vs_int {} {
62 global gcc_compiled
63
64 if {!$gcc_compiled} {
65 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
66 }
67}
68
69#
70# Test whatis command with basic C types
71#
72# The name printed now (as of 23 May 1993) is whatever name the compiler
73# uses in the stabs. So we need to deal with names both from gcc and
74# native compilers.
75#
085dd6e6 76
c906108c
SS
77gdb_test "whatis v_char" \
78 "type = (unsigned char|char)" \
79 "whatis char"
80
c906108c
SS
81if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
82gdb_test "whatis v_signed_char" \
d782e0bf 83 "type = (signed char|char)" \
c906108c
SS
84 "whatis signed char"
85
86gdb_test "whatis v_unsigned_char" \
87 "type = unsigned char" \
88 "whatis unsigned char"
89
90gdb_test "whatis v_short" \
91 "type = (short|short int)" \
92 "whatis short"
93
94gdb_test "whatis v_signed_short" \
95 "type = (short|short int|signed short|signed short int)" \
96 "whatis signed short"
97
98gdb_test "whatis v_unsigned_short" \
99 "type = (unsigned short|short unsigned int)" \
100 "whatis unsigned short"
101
102gdb_test "whatis v_int" \
103 "type = int" \
104 "whatis int"
105
106gdb_test "whatis v_signed_int" \
107 "type = (signed |)int" \
108 "whatis signed int"
109
110gdb_test "whatis v_unsigned_int" \
111 "type = unsigned int" \
112 "whatis unsigned int"
113
114setup_xfail_on_long_vs_int
115# AIX xlc gets this wrong and unsigned long right. Go figure.
116if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
117gdb_test "whatis v_long" \
118 "type = (long|long int)" \
119 "whatis long"
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_signed_long" \
125 "type = (signed |)(long|long int)" \
126 "whatis signed long"
127
128setup_xfail_on_long_vs_int
129gdb_test "whatis v_unsigned_long" \
130 "type = (unsigned long|long unsigned int)" \
131 "whatis unsigned long"
132
64b2fa04
PA
133
134if ![target_info exists no_long_long] {
135 gdb_test "whatis v_unsigned_long_long" \
136 "type = (unsigned long long|long long unsigned int)" \
137 "whatis unsigned long long"
138}
139
c906108c
SS
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
64b2fa04
PA
204if ![target_info exists no_long_long] {
205 gdb_test "whatis v_unsigned_long_long_array" \
206 "type = (unsigned long long|long long unsigned int) \\\[2\\\]" \
207 "whatis unsigned long array"
208}
209
c906108c
SS
210gdb_test "whatis v_float_array" \
211 "type = float \\\[2\\\]" \
212 "whatis float array"
213
214gdb_test "whatis v_double_array" \
215 "type = double \\\[2\\\]" \
216 "whatis double array"
217
218
219# test whatis command with pointers
220#
221# We already tested whether char prints as char, so accept various perversions
222# here. We especially want to make sure we test that it doesn't print as
223# caddr_t.
224gdb_test "whatis v_char_pointer" \
225 "type = (unsigned |signed |)char \\*" \
226 "whatis char pointer"
227
228gdb_test "whatis v_signed_char_pointer" \
229 "type = (unsigned |signed |)char \\*" \
230 "whatis signed char pointer"
231
232gdb_test "whatis v_unsigned_char_pointer" \
233 "type = unsigned char \\*" \
234 "whatis unsigned char pointer"
235
236gdb_test "whatis v_short_pointer" \
237 "type = (short|short int) \\*" \
238 "whatis short pointer"
239
240gdb_test "whatis v_signed_short_pointer" \
241 "type = (signed |)(short|short int) \\*" \
242 "whatis signed short pointer"
243
244gdb_test "whatis v_unsigned_short_pointer" \
245 "type = (unsigned short|short unsigned int) \\*" \
246 "whatis unsigned short pointer"
247
248gdb_test "whatis v_int_pointer" \
249 "type = int \\*" \
250 "whatis int pointer"
251
252gdb_test "whatis v_signed_int_pointer" \
253 "type = (signed |)int \\*" \
254 "whatis signed int pointer"
255
256gdb_test "whatis v_unsigned_int_pointer" \
257 "type = unsigned int \\*" \
258 "whatis unsigned int pointer"
259
260# We already tested whether long prints as long, so here we accept int
261gdb_test "whatis v_long_pointer" \
262 "type = (long|int|long int) \\*" \
263 "whatis long pointer"
264
265gdb_test "whatis v_signed_long_pointer" \
266 "type = (signed |)(long|int|long int) \\*" \
267 "whatis signed long pointer"
268
269gdb_test "whatis v_unsigned_long_pointer" \
270 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
271 "whatis unsigned long pointer"
272
64b2fa04
PA
273if ![target_info exists no_long_long] {
274 gdb_test "whatis v_long_long_pointer" \
275 "type = long long(| int) \\*" \
276 "whatis long long pointer"
277
278 gdb_test "whatis v_signed_long_long_pointer" \
279 "type = (signed |)long long(| int) \\*" \
280 "whatis signed long long pointer"
281
282 gdb_test "whatis v_unsigned_long_long_pointer" \
283 "type = (unsigned long long|long long unsigned int) \\*" \
284 "whatis unsigned long long pointer"
285}
286
c906108c
SS
287gdb_test "whatis v_float_pointer" \
288 "type = float \\*" \
289 "whatis float pointer"
290
291gdb_test "whatis v_double_pointer" \
292 "type = double \\*" \
293 "whatis double pointer"
294
295
085dd6e6
JM
296if { $hp_aCC_compiler } {
297 set unstruct "unnamed\.struct\..*"
298 set ununion "unnamed\.union\..*"
299} else {
300 set unstruct "\.\.\."
301 set ununion "\.\.\."
302}
303
c906108c
SS
304# test whatis command with structure types
305gdb_test "whatis v_struct1" \
306 "type = struct t_struct" \
307 "whatis named structure"
308
f8261448
FF
309gdb_test "whatis struct t_struct" \
310 "type = struct t_struct" \
311 "whatis named structure using type name"
312
c906108c 313gdb_test "whatis v_struct2" \
085dd6e6 314 "type = struct \{$unstruct\}" \
c906108c
SS
315 "whatis unnamed structure"
316
317
318# test whatis command with union types
319gdb_test "whatis v_union" \
320 "type = union t_union" \
321 "whatis named union"
322
f8261448
FF
323gdb_test "whatis union t_union" \
324 "type = union t_union" \
325 "whatis named union using type name"
326
c906108c 327gdb_test "whatis v_union2" \
085dd6e6 328 "type = union \{$ununion\}" \
c906108c
SS
329 "whatis unnamed union"
330
331
1e698235
DJ
332# HP-UX: HP aCC compiler w/ +objdebug option detects language as
333# c++, so we need the 'void' pattern here.
334# Without +objdebug compilation option we still need to match ''.
335# - guo
336# Also, using stabs we will mark these functions as prototyped. This
337# is harmless but causes an extra VOID to be printed.
338set void "(void|)"
c906108c
SS
339
340# test whatis command with functions return type
341gdb_test "whatis v_char_func" \
085dd6e6 342 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
343 "whatis char function"
344
345gdb_test "whatis v_signed_char_func" \
085dd6e6 346 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
347 "whatis signed char function"
348
349gdb_test "whatis v_unsigned_char_func" \
085dd6e6 350 "type = unsigned char \\($void\\)" \
c906108c
SS
351 "whatis unsigned char function"
352
353gdb_test "whatis v_short_func" \
085dd6e6 354 "type = short (int |)\\($void\\)" \
c906108c
SS
355 "whatis short function"
356
357gdb_test "whatis v_signed_short_func" \
085dd6e6 358 "type = (signed |)short (int |)\\($void\\)" \
c906108c
SS
359 "whatis signed short function"
360
361gdb_test "whatis v_unsigned_short_func" \
085dd6e6 362 "type = (unsigned short|short unsigned int) \\($void\\)" \
c906108c
SS
363 "whatis unsigned short function"
364
365gdb_test "whatis v_int_func" \
085dd6e6 366 "type = int \\($void\\)" \
c906108c
SS
367 "whatis int function"
368
369gdb_test "whatis v_signed_int_func" \
085dd6e6 370 "type = (signed |)int \\($void\\)" \
c906108c
SS
371 "whatis signed int function"
372
373gdb_test "whatis v_unsigned_int_func" \
085dd6e6 374 "type = unsigned int \\($void\\)" \
c906108c
SS
375 "whatis unsigned int function"
376
377gdb_test "whatis v_long_func" \
085dd6e6 378 "type = (long|int|long int) \\($void\\)" \
c906108c
SS
379 "whatis long function"
380
381gdb_test "whatis v_signed_long_func" \
085dd6e6 382 "type = (signed |)(int|long|long int) \\($void\\)" \
c906108c
SS
383 "whatis signed long function"
384
385gdb_test "whatis v_unsigned_long_func" \
085dd6e6 386 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
c906108c
SS
387 "whatis unsigned long function"
388
64b2fa04
PA
389if ![target_info exists no_long_long] {
390 gdb_test "whatis v_long_long_func" \
391 "type = long long(| int) \\($void\\)" \
392 "whatis long long function"
393
394 gdb_test "whatis v_signed_long_long_func" \
395 "type = (signed |)long long(| int) \\($void\\)" \
396 "whatis signed long long function"
397
398 gdb_test "whatis v_unsigned_long_long_func" \
399 "type = (unsigned long long(| int)|long long unsigned int) \\($void\\)" \
400 "whatis unsigned long long function"
401}
402
c906108c
SS
403# Sun /bin/cc calls this a function returning double.
404if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
405gdb_test "whatis v_float_func" \
085dd6e6 406 "type = float \\($void\\)" \
c906108c
SS
407 "whatis float function"
408
409gdb_test "whatis v_double_func" \
085dd6e6 410 "type = double \\($void\\)" \
c906108c
SS
411 "whatis double function" \
412
413
414# test whatis command with some misc complicated types
415gdb_test "whatis s_link" \
416 "type = struct link \\*" \
417 "whatis complicated structure"
418
419gdb_test "whatis u_link" \
420 "type = union tu_link" \
421 "whatis complicated union"
422
423
424# test whatis command with enumerations
425gdb_test "whatis clunker" \
426 "type = enum cars" \
427 "whatis enumeration"
428
f8261448
FF
429gdb_test "whatis enum cars" \
430 "type = enum cars" \
431 "whatis enumeration using type name"
432
c906108c
SS
433
434# test whatis command with nested struct and union
435gdb_test "whatis nested_su" \
436 "type = struct outer_struct" \
437 "whatis outer structure"
438
439gdb_test "whatis nested_su.outer_int" \
440 "type = int" \
441 "whatis outer structure member"
442
085dd6e6
JM
443if {$hp_aCC_compiler} {
444 set outer "outer_struct::"
445} else {
446 set outer ""
447}
448
c906108c 449gdb_test "whatis nested_su.inner_struct_instance" \
085dd6e6 450 "type = struct ${outer}inner_struct" \
c906108c
SS
451 "whatis inner structure"
452
453gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
454 "type = int" \
455 "whatis inner structure member"
456
457gdb_test "whatis nested_su.inner_union_instance" \
085dd6e6 458 "type = union ${outer}inner_union" \
c906108c
SS
459 "whatis inner union"
460
461gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
462 "type = int" \
463 "whatis inner union member"
f8261448
FF
464
465# test whatis command with typedefs
466
467gdb_test "whatis char_addr" \
468 "type = char \\*" \
469 "whatis using typedef type name"
470
471gdb_test "whatis a_char_addr" \
472 "type = char_addr" \
473 "whatis applied to variable defined by typedef"
This page took 1.319775 seconds and 4 git commands to generate.