1 # Copyright 1988-2014 Free Software Foundation, Inc.
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 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This file was written by Rob Savoye. (rob@cygnus.com)
19 # test running programs
22 if [target_info exists no_long_long] {
23 set exec_opts [list debug additional_flags=-DNO_LONG_LONG]
25 set exec_opts [list debug]
30 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $exec_opts] != "" } {
35 # Create and source the file that provides information about the compiler
36 # used to compile the test case.
37 if [get_compiler_info] {
41 # Start with a fresh gdb.
43 clean_restart $binfile
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.
50 proc setup_xfail_on_long_vs_int {} {
54 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
59 # Test whatis command with basic C types
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
66 gdb_test "whatis v_char" \
67 "type = (unsigned char|char)" \
70 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
71 gdb_test "whatis v_signed_char" \
72 "type = (signed char|char)" \
75 gdb_test "whatis v_unsigned_char" \
76 "type = unsigned char" \
77 "whatis unsigned char"
79 gdb_test "whatis v_short" \
80 "type = (short|short int)" \
83 gdb_test "whatis v_signed_short" \
84 "type = (short|short int|signed short|signed short int)" \
87 gdb_test "whatis v_unsigned_short" \
88 "type = (unsigned short|short unsigned int)" \
89 "whatis unsigned short"
91 gdb_test "whatis v_int" \
95 gdb_test "whatis v_signed_int" \
96 "type = (signed |)int" \
99 gdb_test "whatis v_unsigned_int" \
100 "type = unsigned int" \
101 "whatis unsigned int"
103 setup_xfail_on_long_vs_int
104 # AIX xlc gets this wrong and unsigned long right. Go figure.
105 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
106 gdb_test "whatis v_long" \
107 "type = (long|long int)" \
110 setup_xfail_on_long_vs_int
111 # AIX xlc gets this wrong and unsigned long right. Go figure.
112 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
113 gdb_test "whatis v_signed_long" \
114 "type = (signed |)(long|long int)" \
117 setup_xfail_on_long_vs_int
118 gdb_test "whatis v_unsigned_long" \
119 "type = (unsigned long|long unsigned int)" \
120 "whatis unsigned long"
123 if ![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"
129 gdb_test "whatis v_float" \
133 gdb_test "whatis v_double" \
138 # test whatis command with arrays
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.
143 gdb_test "whatis v_char_array" \
144 "type = (signed |unsigned |)char \\\[2\\\]" \
147 gdb_test "whatis v_signed_char_array" \
148 "type = (signed |unsigned |)char \\\[2\\\]" \
149 "whatis signed char array"
151 gdb_test "whatis v_unsigned_char_array" \
152 "type = unsigned char \\\[2\\\]" \
153 "whatis unsigned char array"
155 gdb_test "whatis v_short_array" \
156 "type = (short|short int) \\\[2\\\]" \
159 gdb_test "whatis v_signed_short_array" \
160 "type = (signed |)(short|short int) \\\[2\\\]" \
161 "whatis signed short array"
163 gdb_test "whatis v_unsigned_short_array" \
164 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
165 "whatis unsigned short array"
167 gdb_test "whatis v_int_array" \
168 "type = int \\\[2\\\]" \
171 gdb_test "whatis v_signed_int_array" \
172 "type = (signed |)int \\\[2\\\]" \
173 "whatis signed int array"
175 gdb_test "whatis v_unsigned_int_array" \
176 "type = unsigned int \\\[2\\\]" \
177 "whatis unsigned int array"
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.
181 gdb_test "whatis v_long_array" \
182 "type = (int|long|long int) \\\[2\\\]" \
185 gdb_test "whatis v_signed_long_array" \
186 "type = (signed |)(int|long|long int) \\\[2\\\]" \
187 "whatis signed long array"
189 gdb_test "whatis v_unsigned_long_array" \
190 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
191 "whatis unsigned long array"
193 if ![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"
199 gdb_test "whatis v_float_array" \
200 "type = float \\\[2\\\]" \
203 gdb_test "whatis v_double_array" \
204 "type = double \\\[2\\\]" \
205 "whatis double array"
208 # test whatis command with pointers
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
213 gdb_test "whatis v_char_pointer" \
214 "type = (unsigned |signed |)char \\*" \
215 "whatis char pointer"
217 gdb_test "whatis v_signed_char_pointer" \
218 "type = (unsigned |signed |)char \\*" \
219 "whatis signed char pointer"
221 gdb_test "whatis v_unsigned_char_pointer" \
222 "type = unsigned char \\*" \
223 "whatis unsigned char pointer"
225 gdb_test "whatis v_short_pointer" \
226 "type = (short|short int) \\*" \
227 "whatis short pointer"
229 gdb_test "whatis v_signed_short_pointer" \
230 "type = (signed |)(short|short int) \\*" \
231 "whatis signed short pointer"
233 gdb_test "whatis v_unsigned_short_pointer" \
234 "type = (unsigned short|short unsigned int) \\*" \
235 "whatis unsigned short pointer"
237 gdb_test "whatis v_int_pointer" \
241 gdb_test "whatis v_signed_int_pointer" \
242 "type = (signed |)int \\*" \
243 "whatis signed int pointer"
245 gdb_test "whatis v_unsigned_int_pointer" \
246 "type = unsigned int \\*" \
247 "whatis unsigned int pointer"
249 # We already tested whether long prints as long, so here we accept int
250 gdb_test "whatis v_long_pointer" \
251 "type = (long|int|long int) \\*" \
252 "whatis long pointer"
254 gdb_test "whatis v_signed_long_pointer" \
255 "type = (signed |)(long|int|long int) \\*" \
256 "whatis signed long pointer"
258 gdb_test "whatis v_unsigned_long_pointer" \
259 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
260 "whatis unsigned long pointer"
262 if ![target_info exists no_long_long] {
263 gdb_test "whatis v_long_long_pointer" \
264 "type = long long(| int) \\*" \
265 "whatis long long pointer"
267 gdb_test "whatis v_signed_long_long_pointer" \
268 "type = (signed |)long long(| int) \\*" \
269 "whatis signed long long pointer"
271 gdb_test "whatis v_unsigned_long_long_pointer" \
272 "type = (unsigned long long|long long unsigned int) \\*" \
273 "whatis unsigned long long pointer"
276 gdb_test "whatis v_float_pointer" \
278 "whatis float pointer"
280 gdb_test "whatis v_double_pointer" \
281 "type = double \\*" \
282 "whatis double pointer"
285 if { $hp_aCC_compiler } {
286 set unstruct "unnamed\.struct\..*"
287 set ununion "unnamed\.union\..*"
289 set unstruct "\.\.\."
293 # test whatis command with structure types
294 gdb_test "whatis v_struct1" \
295 "type = struct t_struct" \
296 "whatis named structure"
298 gdb_test "whatis struct t_struct" \
299 "type = struct t_struct" \
300 "whatis named structure using type name"
302 gdb_test "whatis v_struct2" \
303 "type = struct \{$unstruct\}" \
304 "whatis unnamed structure"
307 # test whatis command with union types
308 gdb_test "whatis v_union" \
309 "type = union t_union" \
312 gdb_test "whatis union t_union" \
313 "type = union t_union" \
314 "whatis named union using type name"
316 gdb_test "whatis v_union2" \
317 "type = union \{$ununion\}" \
318 "whatis unnamed union"
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 ''.
325 # Also, using stabs we will mark these functions as prototyped. This
326 # is harmless but causes an extra VOID to be printed.
329 # test whatis command with functions return type
330 gdb_test "whatis v_char_func" \
331 "type = (signed |unsigned |)char \\($void\\)" \
332 "whatis char function"
334 gdb_test "whatis v_signed_char_func" \
335 "type = (signed |unsigned |)char \\($void\\)" \
336 "whatis signed char function"
338 gdb_test "whatis v_unsigned_char_func" \
339 "type = unsigned char \\($void\\)" \
340 "whatis unsigned char function"
342 gdb_test "whatis v_short_func" \
343 "type = short (int |)\\($void\\)" \
344 "whatis short function"
346 gdb_test "whatis v_signed_short_func" \
347 "type = (signed |)short (int |)\\($void\\)" \
348 "whatis signed short function"
350 gdb_test "whatis v_unsigned_short_func" \
351 "type = (unsigned short|short unsigned int) \\($void\\)" \
352 "whatis unsigned short function"
354 gdb_test "whatis v_int_func" \
355 "type = int \\($void\\)" \
356 "whatis int function"
358 gdb_test "whatis v_signed_int_func" \
359 "type = (signed |)int \\($void\\)" \
360 "whatis signed int function"
362 gdb_test "whatis v_unsigned_int_func" \
363 "type = unsigned int \\($void\\)" \
364 "whatis unsigned int function"
366 gdb_test "whatis v_long_func" \
367 "type = (long|int|long int) \\($void\\)" \
368 "whatis long function"
370 gdb_test "whatis v_signed_long_func" \
371 "type = (signed |)(int|long|long int) \\($void\\)" \
372 "whatis signed long function"
374 gdb_test "whatis v_unsigned_long_func" \
375 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
376 "whatis unsigned long function"
378 if ![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"
383 gdb_test "whatis v_signed_long_long_func" \
384 "type = (signed |)long long(| int) \\($void\\)" \
385 "whatis signed long long function"
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"
392 # Sun /bin/cc calls this a function returning double.
393 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
394 gdb_test "whatis v_float_func" \
395 "type = float \\($void\\)" \
396 "whatis float function"
398 gdb_test "whatis v_double_func" \
399 "type = double \\($void\\)" \
400 "whatis double function" \
403 # test whatis command with some misc complicated types
404 gdb_test "whatis s_link" \
405 "type = struct link \\*" \
406 "whatis complicated structure"
408 gdb_test "whatis u_link" \
409 "type = union tu_link" \
410 "whatis complicated union"
413 # test whatis command with enumerations
414 gdb_test "whatis clunker" \
418 gdb_test "whatis enum cars" \
420 "whatis enumeration using type name"
423 # test whatis command with nested struct and union
424 gdb_test "whatis nested_su" \
425 "type = struct outer_struct" \
426 "whatis outer structure"
428 gdb_test "whatis nested_su.outer_int" \
430 "whatis outer structure member"
432 if {$hp_aCC_compiler} {
433 set outer "outer_struct::"
438 gdb_test "whatis nested_su.inner_struct_instance" \
439 "type = struct ${outer}inner_struct" \
440 "whatis inner structure"
442 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
444 "whatis inner structure member"
446 gdb_test "whatis nested_su.inner_union_instance" \
447 "type = union ${outer}inner_union" \
450 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
452 "whatis inner union member"
454 # test whatis command with typedefs
456 gdb_test "whatis char_addr" \
458 "whatis using typedef type name"
460 gdb_test "whatis a_char_addr" \
462 "whatis applied to variable defined by typedef"
464 # Regression tests for PR 9514.
466 gdb_test "whatis void (**)()" \
467 "type = void \\(\\*\\*\\)\\(\\)" \
468 "whatis applied to pointer to pointer to function"
470 gdb_test "whatis void (** const)()" \
471 "type = void \\(\\*\\* const\\)\\(\\)" \
472 "whatis applied to const pointer to pointer to function"
474 gdb_test "whatis void (* const *)()" \
475 "type = void \\(\\* const \\*\\)\\(\\)" \
476 "whatis applied to pointer to const pointer to function"
478 gdb_test "whatis int *(*)()" \
479 "type = int \\*\\(\\*\\)\\(\\)" \
480 "whatis applied to pointer to function returning pointer to int"
482 gdb_test "whatis int *(**)()" \
483 "type = int \\*\\(\\*\\*\\)\\(\\)" \
484 "whatis applied to pointer to pointer to function returning pointer to int"
486 gdb_test "whatis char (*(*)())\[23\]" \
487 "type = char \\(\\*\\(\\*\\)\\(\\)\\)\\\[23\\\]" \
488 "whatis applied to pointer to function returning pointer to array"
490 gdb_test "whatis int (*)(int, int)" \
491 "type = int \\(\\*\\)\\(int, int\\)" \
492 "whatis applied to pointer to function taking int,int and returning int"
494 gdb_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"
498 gdb_test "whatis int (*)(void, int, int)" \
499 "parameter types following 'void'" \
500 "whatis applied to function with types trailing 'void'"
502 gdb_test "whatis int (*)(int, void, int)" \
503 "'void' invalid as parameter type" \
504 "whatis applied to function with 'void' parameter type"