warn if "source" fails to open the file when from_tty == 0
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.exp
CommitLineData
28e7fd62 1# Copyright 1988-2013 Free Software Foundation, Inc.
c906108c
SS
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 15
c906108c
SS
16# This file was written by Rob Savoye. (rob@cygnus.com)
17
c906108c
SS
18#
19# test running programs
20#
c906108c 21
64b2fa04
PA
22if [target_info exists no_long_long] {
23 set exec_opts [list debug additional_flags=-DNO_LONG_LONG]
24} else {
25 set exec_opts [list debug]
26}
27
62cef515
TT
28standard_testfile .c
29
64b2fa04 30if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $exec_opts] != "" } {
b60f0898
JB
31 untested whatis.exp
32 return -1
c906108c
SS
33}
34
35# Create and source the file that provides information about the compiler
36# used to compile the test case.
4c93b1db 37if [get_compiler_info] {
ae59b1da 38 return -1
c906108c
SS
39}
40
41# Start with a fresh gdb.
42
62cef515 43clean_restart $binfile
c906108c 44
c906108c
SS
45# Define a procedure to set up an xfail for all targets that put out a
46# `long' type as an `int' type.
47# Sun/Ultrix cc have this problem.
48# It was said that COFF targets can not distinguish int from long either.
49
50proc setup_xfail_on_long_vs_int {} {
51 global gcc_compiled
52
53 if {!$gcc_compiled} {
54 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
55 }
56}
57
58#
59# Test whatis command with basic C types
60#
61# The name printed now (as of 23 May 1993) is whatever name the compiler
62# uses in the stabs. So we need to deal with names both from gcc and
63# native compilers.
64#
085dd6e6 65
c906108c
SS
66gdb_test "whatis v_char" \
67 "type = (unsigned char|char)" \
68 "whatis char"
69
c906108c
SS
70if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
71gdb_test "whatis v_signed_char" \
d782e0bf 72 "type = (signed char|char)" \
c906108c
SS
73 "whatis signed char"
74
75gdb_test "whatis v_unsigned_char" \
76 "type = unsigned char" \
77 "whatis unsigned char"
78
79gdb_test "whatis v_short" \
80 "type = (short|short int)" \
81 "whatis short"
82
83gdb_test "whatis v_signed_short" \
84 "type = (short|short int|signed short|signed short int)" \
85 "whatis signed short"
86
87gdb_test "whatis v_unsigned_short" \
88 "type = (unsigned short|short unsigned int)" \
89 "whatis unsigned short"
90
91gdb_test "whatis v_int" \
92 "type = int" \
93 "whatis int"
94
95gdb_test "whatis v_signed_int" \
96 "type = (signed |)int" \
97 "whatis signed int"
98
99gdb_test "whatis v_unsigned_int" \
100 "type = unsigned int" \
101 "whatis unsigned int"
102
103setup_xfail_on_long_vs_int
104# AIX xlc gets this wrong and unsigned long right. Go figure.
105if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
106gdb_test "whatis v_long" \
107 "type = (long|long int)" \
108 "whatis long"
109
110setup_xfail_on_long_vs_int
111# AIX xlc gets this wrong and unsigned long right. Go figure.
112if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
113gdb_test "whatis v_signed_long" \
114 "type = (signed |)(long|long int)" \
115 "whatis signed long"
116
117setup_xfail_on_long_vs_int
118gdb_test "whatis v_unsigned_long" \
119 "type = (unsigned long|long unsigned int)" \
120 "whatis unsigned long"
121
64b2fa04
PA
122
123if ![target_info exists no_long_long] {
124 gdb_test "whatis v_unsigned_long_long" \
125 "type = (unsigned long long|long long unsigned int)" \
126 "whatis unsigned long long"
127}
128
c906108c
SS
129gdb_test "whatis v_float" \
130 "type = float" \
131 "whatis float"
132
133gdb_test "whatis v_double" \
134 "type = double" \
135 "whatis double"
136
137
138# test whatis command with arrays
139#
140# We already tested whether char prints as "char", so here we accept
141# "unsigned char", "signed char", and other perversions. No need for more
142# than one xfail for the same thing.
143gdb_test "whatis v_char_array" \
144 "type = (signed |unsigned |)char \\\[2\\\]" \
145 "whatis char array"
146
147gdb_test "whatis v_signed_char_array" \
148 "type = (signed |unsigned |)char \\\[2\\\]" \
149 "whatis signed char array"
150
151gdb_test "whatis v_unsigned_char_array" \
152 "type = unsigned char \\\[2\\\]" \
153 "whatis unsigned char array"
154
155gdb_test "whatis v_short_array" \
156 "type = (short|short int) \\\[2\\\]" \
157 "whatis short array"
158
159gdb_test "whatis v_signed_short_array" \
160 "type = (signed |)(short|short int) \\\[2\\\]" \
161 "whatis signed short array"
162
163gdb_test "whatis v_unsigned_short_array" \
164 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
165 "whatis unsigned short array"
166
167gdb_test "whatis v_int_array" \
168 "type = int \\\[2\\\]" \
169 "whatis int array"
170
171gdb_test "whatis v_signed_int_array" \
172 "type = (signed |)int \\\[2\\\]" \
173 "whatis signed int array"
174
175gdb_test "whatis v_unsigned_int_array" \
176 "type = unsigned int \\\[2\\\]" \
177 "whatis unsigned int array"
178
179# We already tested whether long prints as long, so here we accept int
180# No need for more than one xfail for the same thing.
181gdb_test "whatis v_long_array" \
182 "type = (int|long|long int) \\\[2\\\]" \
183 "whatis long array"
184
185gdb_test "whatis v_signed_long_array" \
186 "type = (signed |)(int|long|long int) \\\[2\\\]" \
187 "whatis signed long array"
188
189gdb_test "whatis v_unsigned_long_array" \
190 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
191 "whatis unsigned long array"
192
64b2fa04
PA
193if ![target_info exists no_long_long] {
194 gdb_test "whatis v_unsigned_long_long_array" \
195 "type = (unsigned long long|long long unsigned int) \\\[2\\\]" \
196 "whatis unsigned long array"
197}
198
c906108c
SS
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 "whatis short pointer"
228
229gdb_test "whatis v_signed_short_pointer" \
230 "type = (signed |)(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 = (signed |)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
64b2fa04
PA
262if ![target_info exists no_long_long] {
263 gdb_test "whatis v_long_long_pointer" \
264 "type = long long(| int) \\*" \
265 "whatis long long pointer"
266
267 gdb_test "whatis v_signed_long_long_pointer" \
268 "type = (signed |)long long(| int) \\*" \
269 "whatis signed long long pointer"
270
271 gdb_test "whatis v_unsigned_long_long_pointer" \
272 "type = (unsigned long long|long long unsigned int) \\*" \
273 "whatis unsigned long long pointer"
274}
275
c906108c
SS
276gdb_test "whatis v_float_pointer" \
277 "type = float \\*" \
278 "whatis float pointer"
279
280gdb_test "whatis v_double_pointer" \
281 "type = double \\*" \
282 "whatis double pointer"
283
284
085dd6e6
JM
285if { $hp_aCC_compiler } {
286 set unstruct "unnamed\.struct\..*"
287 set ununion "unnamed\.union\..*"
288} else {
289 set unstruct "\.\.\."
290 set ununion "\.\.\."
291}
292
c906108c
SS
293# test whatis command with structure types
294gdb_test "whatis v_struct1" \
295 "type = struct t_struct" \
296 "whatis named structure"
297
f8261448
FF
298gdb_test "whatis struct t_struct" \
299 "type = struct t_struct" \
300 "whatis named structure using type name"
301
c906108c 302gdb_test "whatis v_struct2" \
085dd6e6 303 "type = struct \{$unstruct\}" \
c906108c
SS
304 "whatis unnamed structure"
305
306
307# test whatis command with union types
308gdb_test "whatis v_union" \
309 "type = union t_union" \
310 "whatis named union"
311
f8261448
FF
312gdb_test "whatis union t_union" \
313 "type = union t_union" \
314 "whatis named union using type name"
315
c906108c 316gdb_test "whatis v_union2" \
085dd6e6 317 "type = union \{$ununion\}" \
c906108c
SS
318 "whatis unnamed union"
319
320
1e698235
DJ
321# HP-UX: HP aCC compiler w/ +objdebug option detects language as
322# c++, so we need the 'void' pattern here.
323# Without +objdebug compilation option we still need to match ''.
324# - guo
325# Also, using stabs we will mark these functions as prototyped. This
326# is harmless but causes an extra VOID to be printed.
327set void "(void|)"
c906108c
SS
328
329# test whatis command with functions return type
330gdb_test "whatis v_char_func" \
085dd6e6 331 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
332 "whatis char function"
333
334gdb_test "whatis v_signed_char_func" \
085dd6e6 335 "type = (signed |unsigned |)char \\($void\\)" \
c906108c
SS
336 "whatis signed char function"
337
338gdb_test "whatis v_unsigned_char_func" \
085dd6e6 339 "type = unsigned char \\($void\\)" \
c906108c
SS
340 "whatis unsigned char function"
341
342gdb_test "whatis v_short_func" \
085dd6e6 343 "type = short (int |)\\($void\\)" \
c906108c
SS
344 "whatis short function"
345
346gdb_test "whatis v_signed_short_func" \
085dd6e6 347 "type = (signed |)short (int |)\\($void\\)" \
c906108c
SS
348 "whatis signed short function"
349
350gdb_test "whatis v_unsigned_short_func" \
085dd6e6 351 "type = (unsigned short|short unsigned int) \\($void\\)" \
c906108c
SS
352 "whatis unsigned short function"
353
354gdb_test "whatis v_int_func" \
085dd6e6 355 "type = int \\($void\\)" \
c906108c
SS
356 "whatis int function"
357
358gdb_test "whatis v_signed_int_func" \
085dd6e6 359 "type = (signed |)int \\($void\\)" \
c906108c
SS
360 "whatis signed int function"
361
362gdb_test "whatis v_unsigned_int_func" \
085dd6e6 363 "type = unsigned int \\($void\\)" \
c906108c
SS
364 "whatis unsigned int function"
365
366gdb_test "whatis v_long_func" \
085dd6e6 367 "type = (long|int|long int) \\($void\\)" \
c906108c
SS
368 "whatis long function"
369
370gdb_test "whatis v_signed_long_func" \
085dd6e6 371 "type = (signed |)(int|long|long int) \\($void\\)" \
c906108c
SS
372 "whatis signed long function"
373
374gdb_test "whatis v_unsigned_long_func" \
085dd6e6 375 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
c906108c
SS
376 "whatis unsigned long function"
377
64b2fa04
PA
378if ![target_info exists no_long_long] {
379 gdb_test "whatis v_long_long_func" \
380 "type = long long(| int) \\($void\\)" \
381 "whatis long long function"
382
383 gdb_test "whatis v_signed_long_long_func" \
384 "type = (signed |)long long(| int) \\($void\\)" \
385 "whatis signed long long function"
386
387 gdb_test "whatis v_unsigned_long_long_func" \
388 "type = (unsigned long long(| int)|long long unsigned int) \\($void\\)" \
389 "whatis unsigned long long function"
390}
391
c906108c
SS
392# Sun /bin/cc calls this a function returning double.
393if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
394gdb_test "whatis v_float_func" \
085dd6e6 395 "type = float \\($void\\)" \
c906108c
SS
396 "whatis float function"
397
398gdb_test "whatis v_double_func" \
085dd6e6 399 "type = double \\($void\\)" \
c906108c
SS
400 "whatis double function" \
401
402
403# test whatis command with some misc complicated types
404gdb_test "whatis s_link" \
405 "type = struct link \\*" \
406 "whatis complicated structure"
407
408gdb_test "whatis u_link" \
409 "type = union tu_link" \
410 "whatis complicated union"
411
412
413# test whatis command with enumerations
414gdb_test "whatis clunker" \
415 "type = enum cars" \
416 "whatis enumeration"
417
f8261448
FF
418gdb_test "whatis enum cars" \
419 "type = enum cars" \
420 "whatis enumeration using type name"
421
c906108c
SS
422
423# test whatis command with nested struct and union
424gdb_test "whatis nested_su" \
425 "type = struct outer_struct" \
426 "whatis outer structure"
427
428gdb_test "whatis nested_su.outer_int" \
429 "type = int" \
430 "whatis outer structure member"
431
085dd6e6
JM
432if {$hp_aCC_compiler} {
433 set outer "outer_struct::"
434} else {
435 set outer ""
436}
437
c906108c 438gdb_test "whatis nested_su.inner_struct_instance" \
085dd6e6 439 "type = struct ${outer}inner_struct" \
c906108c
SS
440 "whatis inner structure"
441
442gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
443 "type = int" \
444 "whatis inner structure member"
445
446gdb_test "whatis nested_su.inner_union_instance" \
085dd6e6 447 "type = union ${outer}inner_union" \
c906108c
SS
448 "whatis inner union"
449
450gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
451 "type = int" \
452 "whatis inner union member"
f8261448
FF
453
454# test whatis command with typedefs
455
456gdb_test "whatis char_addr" \
457 "type = char \\*" \
458 "whatis using typedef type name"
459
460gdb_test "whatis a_char_addr" \
461 "type = char_addr" \
462 "whatis applied to variable defined by typedef"
95c391b6
TT
463
464# Regression tests for PR 9514.
465
466gdb_test "whatis void (**)()" \
467 "type = void \\(\\*\\*\\)\\(\\)" \
468 "whatis applied to pointer to pointer to function"
469
470gdb_test "whatis void (** const)()" \
471 "type = void \\(\\*\\* const\\)\\(\\)" \
472 "whatis applied to const pointer to pointer to function"
473
474gdb_test "whatis void (* const *)()" \
475 "type = void \\(\\* const \\*\\)\\(\\)" \
476 "whatis applied to pointer to const pointer to function"
fcde5961
TT
477
478gdb_test "whatis int *(*)()" \
479 "type = int \\*\\(\\*\\)\\(\\)" \
480 "whatis applied to pointer to function returning pointer to int"
481
482gdb_test "whatis int *(**)()" \
483 "type = int \\*\\(\\*\\*\\)\\(\\)" \
484 "whatis applied to pointer to pointer to function returning pointer to int"
485
486gdb_test "whatis char (*(*)())\[23\]" \
487 "type = char \\(\\*\\(\\*\\)\\(\\)\\)\\\[23\\\]" \
488 "whatis applied to pointer to function returning pointer to array"
71918a86
TT
489
490gdb_test "whatis int (*)(int, int)" \
491 "type = int \\(\\*\\)\\(int, int\\)" \
492 "whatis applied to pointer to function taking int,int and returning int"
a6fb9c08
TT
493
494gdb_test "whatis int (*)(const int *, ...)" \
495 "type = int \\(\\*\\)\\(const int \\*, \\.\\.\\.\\)" \
496 "whatis applied to pointer to function taking const int ptr and varargs and returning int"
e314d629
TT
497
498gdb_test "whatis int (*)(void, int, int)" \
499 "parameter types following 'void'" \
500 "whatis applied to function with types trailing 'void'"
501
502gdb_test "whatis int (*)(int, void, int)" \
503 "'void' invalid as parameter type" \
504 "whatis applied to function with 'void' parameter type"
This page took 1.393971 seconds and 4 git commands to generate.