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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
27 # test running programs
33 set srcfile ${srcdir}/$subdir/${testfile}.c
34 set binfile ${objdir}/${subdir}/${testfile}
35 if { [compile "${srcfile} -g -o ${binfile}"] != "" } {
36 perror "Couldn't compile ${srcfile}"
40 execute_anywhere "rm -f ${binfile}.ci"
41 if { [compile "-E ${srcdir}/${subdir}/compiler.c > ${binfile}.ci"] != "" } {
42 perror "Couldn't make ${testfile}.ci file"
46 # Start with a fresh gdb.
50 gdb_reinitialize_dir $srcdir/$subdir
55 # If we did not use the signed keyword when compiling the file, don't
56 # expect GDB to know that char is signed.
57 if $signed_keyword_not_used then {
58 set signed_char "char"
60 set signed_char "signed char"
63 # Define a procedure to set up an xfail for all targets that put out a
64 # `long' type as an `int' type.
65 # Sun/Ultrix cc have this problem.
66 # It was said that COFF targets can not distinguish int from long either.
68 proc setup_xfail_on_long_vs_int {} {
72 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
77 # Test whatis command with basic C types
79 # The name printed now (as of 23 May 1993) is whatever name the compiler
80 # uses in the stabs. So we need to deal with names both from gcc and
83 gdb_test "whatis v_char" \
84 "type = (unsigned char|char)" \
87 setup_xfail "a29k-*-*"
88 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
89 gdb_test "whatis v_signed_char" \
90 "type = $signed_char" \
93 gdb_test "whatis v_unsigned_char" \
94 "type = unsigned char" \
95 "whatis unsigned char"
97 gdb_test "whatis v_short" \
98 "type = (short|short int)" \
101 gdb_test "whatis v_signed_short" \
102 "type = (short|short int|signed short|signed short int)" \
103 "whatis signed short"
105 gdb_test "whatis v_unsigned_short" \
106 "type = (unsigned short|short unsigned int)" \
107 "whatis unsigned short"
109 gdb_test "whatis v_int" \
113 gdb_test "whatis v_signed_int" \
114 "type = (signed |)int" \
117 gdb_test "whatis v_unsigned_int" \
118 "type = unsigned int" \
119 "whatis unsigned int"
121 setup_xfail_on_long_vs_int
122 # AIX xlc gets this wrong and unsigned long right. Go figure.
123 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
124 gdb_test "whatis v_long" \
125 "type = (long|long int)" \
128 setup_xfail_on_long_vs_int
129 # AIX xlc gets this wrong and unsigned long right. Go figure.
130 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
131 gdb_test "whatis v_signed_long" \
132 "type = (signed |)(long|long int)" \
135 setup_xfail_on_long_vs_int
136 gdb_test "whatis v_unsigned_long" \
137 "type = (unsigned long|long unsigned int)" \
138 "whatis unsigned long"
140 gdb_test "whatis v_float" \
144 gdb_test "whatis v_double" \
149 # test whatis command with arrays
151 # We already tested whether char prints as "char", so here we accept
152 # "unsigned char", "signed char", and other perversions. No need for more
153 # than one xfail for the same thing.
154 gdb_test "whatis v_char_array" \
155 "type = (signed |unsigned |)char \\\[2\\\]" \
158 gdb_test "whatis v_signed_char_array" \
159 "type = (signed |unsigned |)char \\\[2\\\]" \
160 "whatis signed char array"
162 gdb_test "whatis v_unsigned_char_array" \
163 "type = unsigned char \\\[2\\\]" \
164 "whatis unsigned char array"
166 gdb_test "whatis v_short_array" \
167 "type = (short|short int) \\\[2\\\]" \
168 pass "whatis short array"
170 gdb_test "whatis v_signed_short_array" \
171 "type = (signed |)(short|short int) \\\[2\\\]" \
172 "whatis signed short array"
174 gdb_test "whatis v_unsigned_short_array" \
175 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
176 "whatis unsigned short array"
178 gdb_test "whatis v_int_array" \
179 "type = int \\\[2\\\]" \
182 gdb_test "whatis v_signed_int_array" \
183 "type = (signed |)int \\\[2\\\]" \
184 "whatis signed int array"
186 gdb_test "whatis v_unsigned_int_array" \
187 "type = unsigned int \\\[2\\\]" \
188 "whatis unsigned int array"
190 # We already tested whether long prints as long, so here we accept int
191 # No need for more than one xfail for the same thing.
192 gdb_test "whatis v_long_array" \
193 "type = (int|long|long int) \\\[2\\\]" \
196 gdb_test "whatis v_signed_long_array" \
197 "type = (signed |)(int|long|long int) \\\[2\\\]" \
198 "whatis signed long array"
200 gdb_test "whatis v_unsigned_long_array" \
201 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
202 "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 pass "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 gdb_test "whatis v_float_pointer" \
269 "whatis float pointer"
271 gdb_test "whatis v_double_pointer" \
272 "type = double \\*" \
273 "whatis double pointer"
276 # test whatis command with structure types
277 gdb_test "whatis v_struct1" \
278 "type = struct t_struct" \
279 "whatis named structure"
281 gdb_test "whatis v_struct2" \
282 "type = struct \{...\}" \
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 v_union2" \
292 "type = union \{...\}" \
293 "whatis unnamed union"
297 # test whatis command with functions return type
298 gdb_test "whatis v_char_func" \
299 "type = (signed |unsigned |)char \\(\\)" \
300 "whatis char function"
302 gdb_test "whatis v_signed_char_func" \
303 "type = (signed |unsigned |)char \\(\\)" \
304 "whatis signed char function"
306 gdb_test "whatis v_unsigned_char_func" \
307 "type = unsigned char \\(\\)" \
308 "whatis unsigned char function"
310 gdb_test "whatis v_short_func" \
311 "type = short (int |)\\(\\)" \
312 "whatis short function"
314 gdb_test "whatis v_signed_short_func" \
315 "type = (signed |)short (int |)\\(\\)" \
316 "whatis signed short function"
318 gdb_test "whatis v_unsigned_short_func" \
319 "type = (unsigned short|short unsigned int) \\(\\)" \
320 "whatis unsigned short function"
322 gdb_test "whatis v_int_func" \
323 "type = int \\(\\)" \
324 "whatis int function"
326 gdb_test "whatis v_signed_int_func" \
327 "type = (signed |)int \\(\\)" \
328 "whatis signed int function"
330 gdb_test "whatis v_unsigned_int_func" \
331 "type = unsigned int \\(\\)" \
332 "whatis unsigned int function"
334 gdb_test "whatis v_long_func" \
335 "type = (long|int|long int) \\(\\)" \
336 "whatis long function"
338 gdb_test "whatis v_signed_long_func" \
339 "type = (signed |)(int|long|long int) \\(\\)" \
340 "whatis signed long function"
342 gdb_test "whatis v_unsigned_long_func" \
343 "type = (unsigned (int|long|long int)|long unsigned int) \\(\\)" \
344 "whatis unsigned long function"
346 # Sun /bin/cc calls this a function returning double.
347 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
348 gdb_test "whatis v_float_func" \
349 "type = float \\(\\)" \
350 "whatis float function"
352 gdb_test "whatis v_double_func" \
353 "type = double \\(\\)" \
354 "whatis double function" \
357 # test whatis command with some misc complicated types
358 gdb_test "whatis s_link" \
359 "type = struct link \\*" \
360 "whatis complicated structure"
362 gdb_test "whatis u_link" \
363 "type = union tu_link" \
364 "whatis complicated union"
367 # test whatis command with enumerations
368 gdb_test "whatis clunker" \
373 # test whatis command with nested struct and union
374 gdb_test "whatis nested_su" \
375 "type = struct outer_struct" \
376 "whatis outer structure"
378 gdb_test "whatis nested_su.outer_int" \
380 "whatis outer structure member"
382 gdb_test "whatis nested_su.inner_struct_instance" \
383 "type = struct inner_struct" \
384 "whatis inner structure"
386 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
388 "whatis inner structure member"
390 gdb_test "whatis nested_su.inner_union_instance" \
391 "type = union inner_union" \
394 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
396 "whatis inner union member"