1 # Copyright 1988, 1990-1992, 1994-1997, 1999, 2002-2004, 2007-2012 Free
2 # Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This file was written by Rob Savoye. (rob@cygnus.com)
20 # test running programs
23 if [target_info exists no_long_long] {
24 set exec_opts [list debug additional_flags=-DNO_LONG_LONG]
26 set exec_opts [list debug]
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $exec_opts] != "" } {
37 # Create and source the file that provides information about the compiler
38 # used to compile the test case.
39 if [get_compiler_info ${binfile}] {
43 # Start with a fresh gdb.
47 gdb_reinitialize_dir $srcdir/$subdir
50 # Define a procedure to set up an xfail for all targets that put out a
51 # `long' type as an `int' type.
52 # Sun/Ultrix cc have this problem.
53 # It was said that COFF targets can not distinguish int from long either.
55 proc setup_xfail_on_long_vs_int {} {
59 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
64 # Test whatis command with basic C types
66 # The name printed now (as of 23 May 1993) is whatever name the compiler
67 # uses in the stabs. So we need to deal with names both from gcc and
71 gdb_test "whatis v_char" \
72 "type = (unsigned char|char)" \
75 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
76 gdb_test "whatis v_signed_char" \
77 "type = (signed char|char)" \
80 gdb_test "whatis v_unsigned_char" \
81 "type = unsigned char" \
82 "whatis unsigned char"
84 gdb_test "whatis v_short" \
85 "type = (short|short int)" \
88 gdb_test "whatis v_signed_short" \
89 "type = (short|short int|signed short|signed short int)" \
92 gdb_test "whatis v_unsigned_short" \
93 "type = (unsigned short|short unsigned int)" \
94 "whatis unsigned short"
96 gdb_test "whatis v_int" \
100 gdb_test "whatis v_signed_int" \
101 "type = (signed |)int" \
104 gdb_test "whatis v_unsigned_int" \
105 "type = unsigned int" \
106 "whatis unsigned int"
108 setup_xfail_on_long_vs_int
109 # AIX xlc gets this wrong and unsigned long right. Go figure.
110 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
111 gdb_test "whatis v_long" \
112 "type = (long|long int)" \
115 setup_xfail_on_long_vs_int
116 # AIX xlc gets this wrong and unsigned long right. Go figure.
117 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
118 gdb_test "whatis v_signed_long" \
119 "type = (signed |)(long|long int)" \
122 setup_xfail_on_long_vs_int
123 gdb_test "whatis v_unsigned_long" \
124 "type = (unsigned long|long unsigned int)" \
125 "whatis unsigned long"
128 if ![target_info exists no_long_long] {
129 gdb_test "whatis v_unsigned_long_long" \
130 "type = (unsigned long long|long long unsigned int)" \
131 "whatis unsigned long long"
134 gdb_test "whatis v_float" \
138 gdb_test "whatis v_double" \
143 # test whatis command with arrays
145 # We already tested whether char prints as "char", so here we accept
146 # "unsigned char", "signed char", and other perversions. No need for more
147 # than one xfail for the same thing.
148 gdb_test "whatis v_char_array" \
149 "type = (signed |unsigned |)char \\\[2\\\]" \
152 gdb_test "whatis v_signed_char_array" \
153 "type = (signed |unsigned |)char \\\[2\\\]" \
154 "whatis signed char array"
156 gdb_test "whatis v_unsigned_char_array" \
157 "type = unsigned char \\\[2\\\]" \
158 "whatis unsigned char array"
160 gdb_test "whatis v_short_array" \
161 "type = (short|short int) \\\[2\\\]" \
164 gdb_test "whatis v_signed_short_array" \
165 "type = (signed |)(short|short int) \\\[2\\\]" \
166 "whatis signed short array"
168 gdb_test "whatis v_unsigned_short_array" \
169 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
170 "whatis unsigned short array"
172 gdb_test "whatis v_int_array" \
173 "type = int \\\[2\\\]" \
176 gdb_test "whatis v_signed_int_array" \
177 "type = (signed |)int \\\[2\\\]" \
178 "whatis signed int array"
180 gdb_test "whatis v_unsigned_int_array" \
181 "type = unsigned int \\\[2\\\]" \
182 "whatis unsigned int array"
184 # We already tested whether long prints as long, so here we accept int
185 # No need for more than one xfail for the same thing.
186 gdb_test "whatis v_long_array" \
187 "type = (int|long|long int) \\\[2\\\]" \
190 gdb_test "whatis v_signed_long_array" \
191 "type = (signed |)(int|long|long int) \\\[2\\\]" \
192 "whatis signed long array"
194 gdb_test "whatis v_unsigned_long_array" \
195 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
196 "whatis unsigned long array"
198 if ![target_info exists no_long_long] {
199 gdb_test "whatis v_unsigned_long_long_array" \
200 "type = (unsigned long long|long long unsigned int) \\\[2\\\]" \
201 "whatis unsigned long array"
204 gdb_test "whatis v_float_array" \
205 "type = float \\\[2\\\]" \
208 gdb_test "whatis v_double_array" \
209 "type = double \\\[2\\\]" \
210 "whatis double array"
213 # test whatis command with pointers
215 # We already tested whether char prints as char, so accept various perversions
216 # here. We especially want to make sure we test that it doesn't print as
218 gdb_test "whatis v_char_pointer" \
219 "type = (unsigned |signed |)char \\*" \
220 "whatis char pointer"
222 gdb_test "whatis v_signed_char_pointer" \
223 "type = (unsigned |signed |)char \\*" \
224 "whatis signed char pointer"
226 gdb_test "whatis v_unsigned_char_pointer" \
227 "type = unsigned char \\*" \
228 "whatis unsigned char pointer"
230 gdb_test "whatis v_short_pointer" \
231 "type = (short|short int) \\*" \
232 "whatis short pointer"
234 gdb_test "whatis v_signed_short_pointer" \
235 "type = (signed |)(short|short int) \\*" \
236 "whatis signed short pointer"
238 gdb_test "whatis v_unsigned_short_pointer" \
239 "type = (unsigned short|short unsigned int) \\*" \
240 "whatis unsigned short pointer"
242 gdb_test "whatis v_int_pointer" \
246 gdb_test "whatis v_signed_int_pointer" \
247 "type = (signed |)int \\*" \
248 "whatis signed int pointer"
250 gdb_test "whatis v_unsigned_int_pointer" \
251 "type = unsigned int \\*" \
252 "whatis unsigned int pointer"
254 # We already tested whether long prints as long, so here we accept int
255 gdb_test "whatis v_long_pointer" \
256 "type = (long|int|long int) \\*" \
257 "whatis long pointer"
259 gdb_test "whatis v_signed_long_pointer" \
260 "type = (signed |)(long|int|long int) \\*" \
261 "whatis signed long pointer"
263 gdb_test "whatis v_unsigned_long_pointer" \
264 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
265 "whatis unsigned long pointer"
267 if ![target_info exists no_long_long] {
268 gdb_test "whatis v_long_long_pointer" \
269 "type = long long(| int) \\*" \
270 "whatis long long pointer"
272 gdb_test "whatis v_signed_long_long_pointer" \
273 "type = (signed |)long long(| int) \\*" \
274 "whatis signed long long pointer"
276 gdb_test "whatis v_unsigned_long_long_pointer" \
277 "type = (unsigned long long|long long unsigned int) \\*" \
278 "whatis unsigned long long pointer"
281 gdb_test "whatis v_float_pointer" \
283 "whatis float pointer"
285 gdb_test "whatis v_double_pointer" \
286 "type = double \\*" \
287 "whatis double pointer"
290 if { $hp_aCC_compiler } {
291 set unstruct "unnamed\.struct\..*"
292 set ununion "unnamed\.union\..*"
294 set unstruct "\.\.\."
298 # test whatis command with structure types
299 gdb_test "whatis v_struct1" \
300 "type = struct t_struct" \
301 "whatis named structure"
303 gdb_test "whatis struct t_struct" \
304 "type = struct t_struct" \
305 "whatis named structure using type name"
307 gdb_test "whatis v_struct2" \
308 "type = struct \{$unstruct\}" \
309 "whatis unnamed structure"
312 # test whatis command with union types
313 gdb_test "whatis v_union" \
314 "type = union t_union" \
317 gdb_test "whatis union t_union" \
318 "type = union t_union" \
319 "whatis named union using type name"
321 gdb_test "whatis v_union2" \
322 "type = union \{$ununion\}" \
323 "whatis unnamed union"
326 # HP-UX: HP aCC compiler w/ +objdebug option detects language as
327 # c++, so we need the 'void' pattern here.
328 # Without +objdebug compilation option we still need to match ''.
330 # Also, using stabs we will mark these functions as prototyped. This
331 # is harmless but causes an extra VOID to be printed.
334 # test whatis command with functions return type
335 gdb_test "whatis v_char_func" \
336 "type = (signed |unsigned |)char \\($void\\)" \
337 "whatis char function"
339 gdb_test "whatis v_signed_char_func" \
340 "type = (signed |unsigned |)char \\($void\\)" \
341 "whatis signed char function"
343 gdb_test "whatis v_unsigned_char_func" \
344 "type = unsigned char \\($void\\)" \
345 "whatis unsigned char function"
347 gdb_test "whatis v_short_func" \
348 "type = short (int |)\\($void\\)" \
349 "whatis short function"
351 gdb_test "whatis v_signed_short_func" \
352 "type = (signed |)short (int |)\\($void\\)" \
353 "whatis signed short function"
355 gdb_test "whatis v_unsigned_short_func" \
356 "type = (unsigned short|short unsigned int) \\($void\\)" \
357 "whatis unsigned short function"
359 gdb_test "whatis v_int_func" \
360 "type = int \\($void\\)" \
361 "whatis int function"
363 gdb_test "whatis v_signed_int_func" \
364 "type = (signed |)int \\($void\\)" \
365 "whatis signed int function"
367 gdb_test "whatis v_unsigned_int_func" \
368 "type = unsigned int \\($void\\)" \
369 "whatis unsigned int function"
371 gdb_test "whatis v_long_func" \
372 "type = (long|int|long int) \\($void\\)" \
373 "whatis long function"
375 gdb_test "whatis v_signed_long_func" \
376 "type = (signed |)(int|long|long int) \\($void\\)" \
377 "whatis signed long function"
379 gdb_test "whatis v_unsigned_long_func" \
380 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
381 "whatis unsigned long function"
383 if ![target_info exists no_long_long] {
384 gdb_test "whatis v_long_long_func" \
385 "type = long long(| int) \\($void\\)" \
386 "whatis long long function"
388 gdb_test "whatis v_signed_long_long_func" \
389 "type = (signed |)long long(| int) \\($void\\)" \
390 "whatis signed long long function"
392 gdb_test "whatis v_unsigned_long_long_func" \
393 "type = (unsigned long long(| int)|long long unsigned int) \\($void\\)" \
394 "whatis unsigned long long function"
397 # Sun /bin/cc calls this a function returning double.
398 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
399 gdb_test "whatis v_float_func" \
400 "type = float \\($void\\)" \
401 "whatis float function"
403 gdb_test "whatis v_double_func" \
404 "type = double \\($void\\)" \
405 "whatis double function" \
408 # test whatis command with some misc complicated types
409 gdb_test "whatis s_link" \
410 "type = struct link \\*" \
411 "whatis complicated structure"
413 gdb_test "whatis u_link" \
414 "type = union tu_link" \
415 "whatis complicated union"
418 # test whatis command with enumerations
419 gdb_test "whatis clunker" \
423 gdb_test "whatis enum cars" \
425 "whatis enumeration using type name"
428 # test whatis command with nested struct and union
429 gdb_test "whatis nested_su" \
430 "type = struct outer_struct" \
431 "whatis outer structure"
433 gdb_test "whatis nested_su.outer_int" \
435 "whatis outer structure member"
437 if {$hp_aCC_compiler} {
438 set outer "outer_struct::"
443 gdb_test "whatis nested_su.inner_struct_instance" \
444 "type = struct ${outer}inner_struct" \
445 "whatis inner structure"
447 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
449 "whatis inner structure member"
451 gdb_test "whatis nested_su.inner_union_instance" \
452 "type = union ${outer}inner_union" \
455 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
457 "whatis inner union member"
459 # test whatis command with typedefs
461 gdb_test "whatis char_addr" \
463 "whatis using typedef type name"
465 gdb_test "whatis a_char_addr" \
467 "whatis applied to variable defined by typedef"