1 # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002, 2003,
2 # 2004, 2007 Free 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 2 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, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # This file was written by Rob Savoye. (rob@cygnus.com)
25 # test running programs
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
33 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
38 # Create and source the file that provides information about the compiler
39 # used to compile the test case.
40 if [get_compiler_info ${binfile}] {
44 # Start with a fresh gdb.
48 gdb_reinitialize_dir $srcdir/$subdir
51 # Define a procedure to set up an xfail for all targets that put out a
52 # `long' type as an `int' type.
53 # Sun/Ultrix cc have this problem.
54 # It was said that COFF targets can not distinguish int from long either.
56 proc setup_xfail_on_long_vs_int {} {
60 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
65 # Test whatis command with basic C types
67 # The name printed now (as of 23 May 1993) is whatever name the compiler
68 # uses in the stabs. So we need to deal with names both from gcc and
72 gdb_test "whatis v_char" \
73 "type = (unsigned char|char)" \
76 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
77 gdb_test "whatis v_signed_char" \
78 "type = (signed char|char)" \
81 gdb_test "whatis v_unsigned_char" \
82 "type = unsigned char" \
83 "whatis unsigned char"
85 gdb_test "whatis v_short" \
86 "type = (short|short int)" \
89 gdb_test "whatis v_signed_short" \
90 "type = (short|short int|signed short|signed short int)" \
93 gdb_test "whatis v_unsigned_short" \
94 "type = (unsigned short|short unsigned int)" \
95 "whatis unsigned short"
97 gdb_test "whatis v_int" \
101 gdb_test "whatis v_signed_int" \
102 "type = (signed |)int" \
105 gdb_test "whatis v_unsigned_int" \
106 "type = unsigned int" \
107 "whatis unsigned int"
109 setup_xfail_on_long_vs_int
110 # AIX xlc gets this wrong and unsigned long right. Go figure.
111 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
112 gdb_test "whatis v_long" \
113 "type = (long|long int)" \
116 setup_xfail_on_long_vs_int
117 # AIX xlc gets this wrong and unsigned long right. Go figure.
118 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
119 gdb_test "whatis v_signed_long" \
120 "type = (signed |)(long|long int)" \
123 setup_xfail_on_long_vs_int
124 gdb_test "whatis v_unsigned_long" \
125 "type = (unsigned long|long unsigned int)" \
126 "whatis unsigned long"
128 gdb_test "whatis v_float" \
132 gdb_test "whatis v_double" \
137 # test whatis command with arrays
139 # We already tested whether char prints as "char", so here we accept
140 # "unsigned char", "signed char", and other perversions. No need for more
141 # than one xfail for the same thing.
142 gdb_test "whatis v_char_array" \
143 "type = (signed |unsigned |)char \\\[2\\\]" \
146 gdb_test "whatis v_signed_char_array" \
147 "type = (signed |unsigned |)char \\\[2\\\]" \
148 "whatis signed char array"
150 gdb_test "whatis v_unsigned_char_array" \
151 "type = unsigned char \\\[2\\\]" \
152 "whatis unsigned char array"
154 gdb_test "whatis v_short_array" \
155 "type = (short|short int) \\\[2\\\]" \
158 gdb_test "whatis v_signed_short_array" \
159 "type = (signed |)(short|short int) \\\[2\\\]" \
160 "whatis signed short array"
162 gdb_test "whatis v_unsigned_short_array" \
163 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
164 "whatis unsigned short array"
166 gdb_test "whatis v_int_array" \
167 "type = int \\\[2\\\]" \
170 gdb_test "whatis v_signed_int_array" \
171 "type = (signed |)int \\\[2\\\]" \
172 "whatis signed int array"
174 gdb_test "whatis v_unsigned_int_array" \
175 "type = unsigned int \\\[2\\\]" \
176 "whatis unsigned int array"
178 # We already tested whether long prints as long, so here we accept int
179 # No need for more than one xfail for the same thing.
180 gdb_test "whatis v_long_array" \
181 "type = (int|long|long int) \\\[2\\\]" \
184 gdb_test "whatis v_signed_long_array" \
185 "type = (signed |)(int|long|long int) \\\[2\\\]" \
186 "whatis signed long array"
188 gdb_test "whatis v_unsigned_long_array" \
189 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
190 "whatis unsigned long array"
192 gdb_test "whatis v_float_array" \
193 "type = float \\\[2\\\]" \
196 gdb_test "whatis v_double_array" \
197 "type = double \\\[2\\\]" \
198 "whatis double array"
201 # test whatis command with pointers
203 # We already tested whether char prints as char, so accept various perversions
204 # here. We especially want to make sure we test that it doesn't print as
206 gdb_test "whatis v_char_pointer" \
207 "type = (unsigned |signed |)char \\*" \
208 "whatis char pointer"
210 gdb_test "whatis v_signed_char_pointer" \
211 "type = (unsigned |signed |)char \\*" \
212 "whatis signed char pointer"
214 gdb_test "whatis v_unsigned_char_pointer" \
215 "type = unsigned char \\*" \
216 "whatis unsigned char pointer"
218 gdb_test "whatis v_short_pointer" \
219 "type = (short|short int) \\*" \
220 "whatis short pointer"
222 gdb_test "whatis v_signed_short_pointer" \
223 "type = (signed |)(short|short int) \\*" \
224 "whatis signed short pointer"
226 gdb_test "whatis v_unsigned_short_pointer" \
227 "type = (unsigned short|short unsigned int) \\*" \
228 "whatis unsigned short pointer"
230 gdb_test "whatis v_int_pointer" \
234 gdb_test "whatis v_signed_int_pointer" \
235 "type = (signed |)int \\*" \
236 "whatis signed int pointer"
238 gdb_test "whatis v_unsigned_int_pointer" \
239 "type = unsigned int \\*" \
240 "whatis unsigned int pointer"
242 # We already tested whether long prints as long, so here we accept int
243 gdb_test "whatis v_long_pointer" \
244 "type = (long|int|long int) \\*" \
245 "whatis long pointer"
247 gdb_test "whatis v_signed_long_pointer" \
248 "type = (signed |)(long|int|long int) \\*" \
249 "whatis signed long pointer"
251 gdb_test "whatis v_unsigned_long_pointer" \
252 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
253 "whatis unsigned long pointer"
255 gdb_test "whatis v_float_pointer" \
257 "whatis float pointer"
259 gdb_test "whatis v_double_pointer" \
260 "type = double \\*" \
261 "whatis double pointer"
264 if { $hp_aCC_compiler } {
265 set unstruct "unnamed\.struct\..*"
266 set ununion "unnamed\.union\..*"
268 set unstruct "\.\.\."
272 # test whatis command with structure types
273 gdb_test "whatis v_struct1" \
274 "type = struct t_struct" \
275 "whatis named structure"
277 gdb_test "whatis struct t_struct" \
278 "type = struct t_struct" \
279 "whatis named structure using type name"
281 gdb_test "whatis v_struct2" \
282 "type = struct \{$unstruct\}" \
283 "whatis unnamed structure"
286 # test whatis command with union types
287 gdb_test "whatis v_union" \
288 "type = union t_union" \
291 gdb_test "whatis union t_union" \
292 "type = union t_union" \
293 "whatis named union using type name"
295 gdb_test "whatis v_union2" \
296 "type = union \{$ununion\}" \
297 "whatis unnamed union"
300 # HP-UX: HP aCC compiler w/ +objdebug option detects language as
301 # c++, so we need the 'void' pattern here.
302 # Without +objdebug compilation option we still need to match ''.
304 # Also, using stabs we will mark these functions as prototyped. This
305 # is harmless but causes an extra VOID to be printed.
308 # test whatis command with functions return type
309 gdb_test "whatis v_char_func" \
310 "type = (signed |unsigned |)char \\($void\\)" \
311 "whatis char function"
313 gdb_test "whatis v_signed_char_func" \
314 "type = (signed |unsigned |)char \\($void\\)" \
315 "whatis signed char function"
317 gdb_test "whatis v_unsigned_char_func" \
318 "type = unsigned char \\($void\\)" \
319 "whatis unsigned char function"
321 gdb_test "whatis v_short_func" \
322 "type = short (int |)\\($void\\)" \
323 "whatis short function"
325 gdb_test "whatis v_signed_short_func" \
326 "type = (signed |)short (int |)\\($void\\)" \
327 "whatis signed short function"
329 gdb_test "whatis v_unsigned_short_func" \
330 "type = (unsigned short|short unsigned int) \\($void\\)" \
331 "whatis unsigned short function"
333 gdb_test "whatis v_int_func" \
334 "type = int \\($void\\)" \
335 "whatis int function"
337 gdb_test "whatis v_signed_int_func" \
338 "type = (signed |)int \\($void\\)" \
339 "whatis signed int function"
341 gdb_test "whatis v_unsigned_int_func" \
342 "type = unsigned int \\($void\\)" \
343 "whatis unsigned int function"
345 gdb_test "whatis v_long_func" \
346 "type = (long|int|long int) \\($void\\)" \
347 "whatis long function"
349 gdb_test "whatis v_signed_long_func" \
350 "type = (signed |)(int|long|long int) \\($void\\)" \
351 "whatis signed long function"
353 gdb_test "whatis v_unsigned_long_func" \
354 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
355 "whatis unsigned long function"
357 # Sun /bin/cc calls this a function returning double.
358 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
359 gdb_test "whatis v_float_func" \
360 "type = float \\($void\\)" \
361 "whatis float function"
363 gdb_test "whatis v_double_func" \
364 "type = double \\($void\\)" \
365 "whatis double function" \
368 # test whatis command with some misc complicated types
369 gdb_test "whatis s_link" \
370 "type = struct link \\*" \
371 "whatis complicated structure"
373 gdb_test "whatis u_link" \
374 "type = union tu_link" \
375 "whatis complicated union"
378 # test whatis command with enumerations
379 gdb_test "whatis clunker" \
383 gdb_test "whatis enum cars" \
385 "whatis enumeration using type name"
388 # test whatis command with nested struct and union
389 gdb_test "whatis nested_su" \
390 "type = struct outer_struct" \
391 "whatis outer structure"
393 gdb_test "whatis nested_su.outer_int" \
395 "whatis outer structure member"
397 if {$hp_aCC_compiler} {
398 set outer "outer_struct::"
403 gdb_test "whatis nested_su.inner_struct_instance" \
404 "type = struct ${outer}inner_struct" \
405 "whatis inner structure"
407 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
409 "whatis inner structure member"
411 gdb_test "whatis nested_su.inner_union_instance" \
412 "type = union ${outer}inner_union" \
415 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
417 "whatis inner union member"
419 # test whatis command with typedefs
421 gdb_test "whatis char_addr" \
423 "whatis using typedef type name"
425 gdb_test "whatis a_char_addr" \
427 "whatis applied to variable defined by typedef"