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