1 # Copyright (C) 1988, 1990, 1991, 1992, 1995 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 2 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, write to the Free Software
15 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Rob Savoye. (rob@cygnus.com)
27 # test running programs
34 if ![file exists $objdir/$subdir/$binfile] then {
35 perror "$objdir/$subdir/$binfile does not exist."
39 # Start with a fresh gdb.
43 gdb_reinitialize_dir $srcdir/$subdir
44 gdb_load $objdir/$subdir/$binfile
46 source gdb.base/whatis-info.exp
48 # If we did not use the signed keyword when compiling the file, don't
49 # expect GDB to know that char is signed.
50 if $signed_keyword_not_used then {
51 set signed_char "char"
53 set signed_char "signed char"
56 # Define a procedure to set up an xfail for all targets that put out a
57 # `long' type as an `int' type.
58 # Sun/Ultrix cc have this problem.
59 # It was said that COFF targets can not distinguish int from long either.
61 proc setup_xfail_on_long_vs_int {} {
64 if {!$gcc_compiled} then {
65 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
70 # Test whatis command with basic C types
72 # The name printed now (as of 23 May 1993) is whatever name the compiler
73 # uses in the stabs. So we need to deal with names both from gcc and
76 # On the i960, which defaults to unsigned characters, gdb
77 # misinterprets char as unsigned char.
78 # Likewise with the rs6000; the compiler doesn't give us enough information
79 # to distinguish between char and unsigned char
80 setup_xfail "rs6000-*-*"
81 setup_xfail "i960-*-*" 1821
82 setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*"
83 gdb_test "whatis v_char" \
87 setup_xfail "a29k-*-*"
88 gdb_test "whatis v_signed_char" \
89 "type = $signed_char" \
92 gdb_test "whatis v_unsigned_char" \
93 "type = unsigned char" \
94 "whatis unsigned char"
96 gdb_test "whatis v_short" \
97 "type = (short|short int)" \
100 gdb_test "whatis v_signed_short" \
101 "type = (short|short int|signed short|signed short int)" \
102 "whatis signed short"
104 gdb_test "whatis v_unsigned_short" \
105 "type = (unsigned short|short unsigned int)" \
106 "whatis unsigned short"
108 gdb_test "whatis v_int" \
112 gdb_test "whatis v_signed_int" \
116 gdb_test "whatis v_unsigned_int" \
117 "type = unsigned int" \
118 "whatis unsigned int"
120 setup_xfail_on_long_vs_int
121 # AIX xlc gets this wrong and unsigned long right. Go figure.
122 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
123 gdb_test "whatis v_long" \
124 "type = (long|long int)" \
127 setup_xfail_on_long_vs_int
128 # AIX xlc gets this wrong and unsigned long right. Go figure.
129 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
130 gdb_test "whatis v_signed_long" \
131 "type = (long|long int)" \
134 setup_xfail_on_long_vs_int
135 gdb_test "whatis v_unsigned_long" \
136 "type = (unsigned long|long unsigned int)" \
137 "whatis unsigned long"
139 gdb_test "whatis v_float" \
143 gdb_test "whatis v_double" \
148 # test whatis command with arrays
150 # We already tested whether char prints as "char", so here we accept
151 # "unsigned char", "signed char", and other perversions. No need for more
152 # than one xfail for the same thing.
153 gdb_test "whatis v_char_array" \
154 "type = (signed |unsigned |)char \\\[2\\\]" \
157 gdb_test "whatis v_signed_char_array" \
158 "type = (signed |unsigned |)char \\\[2\\\]" \
159 "whatis signed char array"
161 gdb_test "whatis v_unsigned_char_array" \
162 "type = unsigned char \\\[2\\\]" \
163 "whatis unsigned char array"
165 gdb_test "whatis v_short_array" \
166 "type = (short|short int) \\\[2\\\]" \
167 pass "whatis short array"
169 gdb_test "whatis v_signed_short_array" \
170 "type = (short|short int) \\\[2\\\]" \
171 "whatis signed short array"
173 gdb_test "whatis v_unsigned_short_array" \
174 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
175 "whatis unsigned short array"
177 gdb_test "whatis v_int_array" \
178 "type = int \\\[2\\\]" \
181 gdb_test "whatis v_signed_int_array" \
182 "type = int \\\[2\\\]" \
183 "whatis signed int array"
185 gdb_test "whatis v_unsigned_int_array" \
186 "type = unsigned int \\\[2\\\]" \
187 "whatis unsigned int array"
189 # We already tested whether long prints as long, so here we accept int
190 # No need for more than one xfail for the same thing.
191 gdb_test "whatis v_long_array" \
192 "type = (int|long|long int) \\\[2\\\]" \
195 gdb_test "whatis v_signed_long_array" \
196 "type = (signed |)(int|long|long int) \\\[2\\\]" \
197 "whatis signed long array"
199 gdb_test "whatis v_unsigned_long_array" \
200 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
201 "whatis unsigned long array"
203 gdb_test "whatis v_float_array" \
204 "type = float \\\[2\\\]" \
207 gdb_test "whatis v_double_array" \
208 "type = double \\\[2\\\]" \
209 "whatis double array"
212 # test whatis command with pointers
214 # We already tested whether char prints as char, so accept various perversions
215 # here. We especially want to make sure we test that it doesn't print as
217 gdb_test "whatis v_char_pointer" \
218 "type = (unsigned |signed |)char \\*" \
219 "whatis char pointer"
221 gdb_test "whatis v_signed_char_pointer" \
222 "type = (unsigned |signed |)char \\*" \
223 "whatis signed char pointer"
225 gdb_test "whatis v_unsigned_char_pointer" \
226 "type = unsigned char \\*" \
227 "whatis unsigned char pointer"
229 gdb_test "whatis v_short_pointer" \
230 "type = (short|short int) \\*" \
231 pass "whatis short pointer"
233 gdb_test "whatis v_signed_short_pointer" \
234 "type = (short|short int) \\*" \
235 "whatis signed short pointer"
237 gdb_test "whatis v_unsigned_short_pointer" \
238 "type = (unsigned short|short unsigned int) \\*" \
239 "whatis unsigned short pointer"
241 gdb_test "whatis v_int_pointer" \
245 gdb_test "whatis v_signed_int_pointer" \
247 "whatis signed int pointer"
249 gdb_test "whatis v_unsigned_int_pointer" \
250 "type = unsigned int \\*" \
251 "whatis unsigned int pointer"
253 # We already tested whether long prints as long, so here we accept int
254 gdb_test "whatis v_long_pointer" \
255 "type = (long|int|long int) \\*" \
256 "whatis long pointer"
258 gdb_test "whatis v_signed_long_pointer" \
259 "type = (signed |)(long|int|long int) \\*" \
260 "whatis signed long pointer"
262 gdb_test "whatis v_unsigned_long_pointer" \
263 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
264 "whatis unsigned long pointer"
266 gdb_test "whatis v_float_pointer" \
268 "whatis float pointer"
270 gdb_test "whatis v_double_pointer" \
271 "type = double \\*" \
272 "whatis double pointer"
275 # test whatis command with structure types
276 gdb_test "whatis v_struct1" \
277 "type = struct t_struct" \
278 "whatis named structure"
280 gdb_test "whatis v_struct2" \
281 "type = struct \{...\}" \
282 "whatis unnamed structure"
285 # test whatis command with union types
286 gdb_test "whatis v_union" \
287 "type = union t_union" \
290 gdb_test "whatis v_union2" \
291 "type = union \{...\}" \
292 "whatis unnamed union"
296 # test whatis command with functions return type
297 gdb_test "whatis v_char_func" \
298 "type = (signed |unsigned |)char \\(\\)" \
299 "whatis char function"
301 gdb_test "whatis v_signed_char_func" \
302 "type = (signed |unsigned |)char \\(\\)" \
303 "whatis signed char function"
305 gdb_test "whatis v_unsigned_char_func" \
306 "type = unsigned char \\(\\)" \
307 "whatis unsigned char function"
309 gdb_test "whatis v_short_func" \
310 "type = short (int |)\\(\\)" \
311 "whatis short function"
313 gdb_test "whatis v_signed_short_func" \
314 "type = short (int |)\\(\\)" \
315 "whatis signed short function"
317 gdb_test "whatis v_unsigned_short_func" \
318 "type = (unsigned short|short unsigned int) \\(\\)" \
319 "whatis unsigned short function"
321 gdb_test "whatis v_int_func" \
322 "type = int \\(\\)" \
323 "whatis int function"
325 gdb_test "whatis v_signed_int_func" \
326 "type = int \\(\\)" \
327 "whatis signed int function"
329 gdb_test "whatis v_unsigned_int_func" \
330 "type = unsigned int \\(\\)" \
331 "whatis unsigned int function"
333 gdb_test "whatis v_long_func" \
334 "type = (long|int|long int) \\(\\)" \
335 "whatis long function"
337 gdb_test "whatis v_signed_long_func" \
338 "type = (int|long|long int) \\(\\)" \
339 "whatis signed long function"
341 gdb_test "whatis v_unsigned_long_func" \
342 "type = (unsigned (int|long|long int)|long unsigned int) \\(\\)" \
343 "whatis unsigned long function"
345 # Sun /bin/cc calls this a function returning double.
346 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
347 gdb_test "whatis v_float_func" \
348 "type = float \\(\\)" \
349 "whatis float function"
351 gdb_test "whatis v_double_func" \
352 "type = double \\(\\)" \
353 "whatis double function" \
356 # test whatis command with some misc complicated types
357 gdb_test "whatis s_link" \
358 "type = struct link \\*" \
359 "whatis complicated structure"
361 gdb_test "whatis u_link" \
362 "type = union tu_link" \
363 "whatis complicated union"
366 # test whatis command with enumerations
367 gdb_test "whatis clunker" \
372 # test whatis command with nested struct and union
373 gdb_test "whatis nested_su" \
374 "type = struct outer_struct" \
375 "whatis outer structure"
377 gdb_test "whatis nested_su.outer_int" \
379 "whatis outer structure member"
381 gdb_test "whatis nested_su.inner_struct_instance" \
382 "type = struct inner_struct" \
383 "whatis inner structure"
385 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
387 "whatis inner structure member"
389 gdb_test "whatis nested_su.inner_union_instance" \
390 "type = union inner_union" \
393 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
395 "whatis inner union member"