1 # Copyright (C) 1988, 1990, 1991, 1992, 1995, 1997 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:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Rob Savoye. (rob@cygnus.com)
27 # test running programs
33 set srcfile ${testfile}.c
34 set binfile ${objdir}/${subdir}/${testfile}
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
39 # Create and source the file that provides information about the compiler
40 # used to compile the test case.
41 if [get_compiler_info ${binfile}] {
45 # Start with a fresh gdb.
49 gdb_reinitialize_dir $srcdir/$subdir
52 # If we did not use the signed keyword when compiling the file, don't
53 # expect GDB to know that char is signed.
54 if $signed_keyword_not_used then {
55 set signed_char "char"
57 set signed_char "signed char"
60 # Define a procedure to set up an xfail for all targets that put out a
61 # `long' type as an `int' type.
62 # Sun/Ultrix cc have this problem.
63 # It was said that COFF targets can not distinguish int from long either.
65 proc setup_xfail_on_long_vs_int {} {
69 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
74 # Test whatis command with basic C types
76 # The name printed now (as of 23 May 1993) is whatever name the compiler
77 # uses in the stabs. So we need to deal with names both from gcc and
80 gdb_test "whatis v_char" \
81 "type = (unsigned char|char)" \
84 setup_xfail "a29k-*-*"
85 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
86 gdb_test "whatis v_signed_char" \
87 "type = $signed_char" \
90 gdb_test "whatis v_unsigned_char" \
91 "type = unsigned char" \
92 "whatis unsigned char"
94 gdb_test "whatis v_short" \
95 "type = (short|short int)" \
98 gdb_test "whatis v_signed_short" \
99 "type = (short|short int|signed short|signed short int)" \
100 "whatis signed short"
102 gdb_test "whatis v_unsigned_short" \
103 "type = (unsigned short|short unsigned int)" \
104 "whatis unsigned short"
106 gdb_test "whatis v_int" \
110 gdb_test "whatis v_signed_int" \
111 "type = (signed |)int" \
114 gdb_test "whatis v_unsigned_int" \
115 "type = unsigned int" \
116 "whatis unsigned int"
118 setup_xfail_on_long_vs_int
119 # AIX xlc gets this wrong and unsigned long right. Go figure.
120 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
121 gdb_test "whatis v_long" \
122 "type = (long|long int)" \
125 setup_xfail_on_long_vs_int
126 # AIX xlc gets this wrong and unsigned long right. Go figure.
127 if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"}
128 gdb_test "whatis v_signed_long" \
129 "type = (signed |)(long|long int)" \
132 setup_xfail_on_long_vs_int
133 gdb_test "whatis v_unsigned_long" \
134 "type = (unsigned long|long unsigned int)" \
135 "whatis unsigned long"
137 gdb_test "whatis v_float" \
141 gdb_test "whatis v_double" \
146 # test whatis command with arrays
148 # We already tested whether char prints as "char", so here we accept
149 # "unsigned char", "signed char", and other perversions. No need for more
150 # than one xfail for the same thing.
151 gdb_test "whatis v_char_array" \
152 "type = (signed |unsigned |)char \\\[2\\\]" \
155 gdb_test "whatis v_signed_char_array" \
156 "type = (signed |unsigned |)char \\\[2\\\]" \
157 "whatis signed char array"
159 gdb_test "whatis v_unsigned_char_array" \
160 "type = unsigned char \\\[2\\\]" \
161 "whatis unsigned char array"
163 gdb_test "whatis v_short_array" \
164 "type = (short|short int) \\\[2\\\]" \
167 gdb_test "whatis v_signed_short_array" \
168 "type = (signed |)(short|short int) \\\[2\\\]" \
169 "whatis signed short array"
171 gdb_test "whatis v_unsigned_short_array" \
172 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
173 "whatis unsigned short array"
175 gdb_test "whatis v_int_array" \
176 "type = int \\\[2\\\]" \
179 gdb_test "whatis v_signed_int_array" \
180 "type = (signed |)int \\\[2\\\]" \
181 "whatis signed int array"
183 gdb_test "whatis v_unsigned_int_array" \
184 "type = unsigned int \\\[2\\\]" \
185 "whatis unsigned int array"
187 # We already tested whether long prints as long, so here we accept int
188 # No need for more than one xfail for the same thing.
189 gdb_test "whatis v_long_array" \
190 "type = (int|long|long int) \\\[2\\\]" \
193 gdb_test "whatis v_signed_long_array" \
194 "type = (signed |)(int|long|long int) \\\[2\\\]" \
195 "whatis signed long array"
197 gdb_test "whatis v_unsigned_long_array" \
198 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
199 "whatis unsigned long array"
201 gdb_test "whatis v_float_array" \
202 "type = float \\\[2\\\]" \
205 gdb_test "whatis v_double_array" \
206 "type = double \\\[2\\\]" \
207 "whatis double array"
210 # test whatis command with pointers
212 # We already tested whether char prints as char, so accept various perversions
213 # here. We especially want to make sure we test that it doesn't print as
215 gdb_test "whatis v_char_pointer" \
216 "type = (unsigned |signed |)char \\*" \
217 "whatis char pointer"
219 gdb_test "whatis v_signed_char_pointer" \
220 "type = (unsigned |signed |)char \\*" \
221 "whatis signed char pointer"
223 gdb_test "whatis v_unsigned_char_pointer" \
224 "type = unsigned char \\*" \
225 "whatis unsigned char pointer"
227 gdb_test "whatis v_short_pointer" \
228 "type = (short|short int) \\*" \
229 "whatis short pointer"
231 gdb_test "whatis v_signed_short_pointer" \
232 "type = (signed |)(short|short int) \\*" \
233 "whatis signed short pointer"
235 gdb_test "whatis v_unsigned_short_pointer" \
236 "type = (unsigned short|short unsigned int) \\*" \
237 "whatis unsigned short pointer"
239 gdb_test "whatis v_int_pointer" \
243 gdb_test "whatis v_signed_int_pointer" \
244 "type = (signed |)int \\*" \
245 "whatis signed int pointer"
247 gdb_test "whatis v_unsigned_int_pointer" \
248 "type = unsigned int \\*" \
249 "whatis unsigned int pointer"
251 # We already tested whether long prints as long, so here we accept int
252 gdb_test "whatis v_long_pointer" \
253 "type = (long|int|long int) \\*" \
254 "whatis long pointer"
256 gdb_test "whatis v_signed_long_pointer" \
257 "type = (signed |)(long|int|long int) \\*" \
258 "whatis signed long pointer"
260 gdb_test "whatis v_unsigned_long_pointer" \
261 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
262 "whatis unsigned long pointer"
264 gdb_test "whatis v_float_pointer" \
266 "whatis float pointer"
268 gdb_test "whatis v_double_pointer" \
269 "type = double \\*" \
270 "whatis double pointer"
273 # test whatis command with structure types
274 gdb_test "whatis v_struct1" \
275 "type = struct t_struct" \
276 "whatis named structure"
278 gdb_test "whatis v_struct2" \
279 "type = struct \{...\}" \
280 "whatis unnamed structure"
283 # test whatis command with union types
284 gdb_test "whatis v_union" \
285 "type = union t_union" \
288 gdb_test "whatis v_union2" \
289 "type = union \{...\}" \
290 "whatis unnamed union"
294 # test whatis command with functions return type
295 gdb_test "whatis v_char_func" \
296 "type = (signed |unsigned |)char \\(\\)" \
297 "whatis char function"
299 gdb_test "whatis v_signed_char_func" \
300 "type = (signed |unsigned |)char \\(\\)" \
301 "whatis signed char function"
303 gdb_test "whatis v_unsigned_char_func" \
304 "type = unsigned char \\(\\)" \
305 "whatis unsigned char function"
307 gdb_test "whatis v_short_func" \
308 "type = short (int |)\\(\\)" \
309 "whatis short function"
311 gdb_test "whatis v_signed_short_func" \
312 "type = (signed |)short (int |)\\(\\)" \
313 "whatis signed short function"
315 gdb_test "whatis v_unsigned_short_func" \
316 "type = (unsigned short|short unsigned int) \\(\\)" \
317 "whatis unsigned short function"
319 gdb_test "whatis v_int_func" \
320 "type = int \\(\\)" \
321 "whatis int function"
323 gdb_test "whatis v_signed_int_func" \
324 "type = (signed |)int \\(\\)" \
325 "whatis signed int function"
327 gdb_test "whatis v_unsigned_int_func" \
328 "type = unsigned int \\(\\)" \
329 "whatis unsigned int function"
331 gdb_test "whatis v_long_func" \
332 "type = (long|int|long int) \\(\\)" \
333 "whatis long function"
335 gdb_test "whatis v_signed_long_func" \
336 "type = (signed |)(int|long|long int) \\(\\)" \
337 "whatis signed long function"
339 gdb_test "whatis v_unsigned_long_func" \
340 "type = (unsigned (int|long|long int)|long unsigned int) \\(\\)" \
341 "whatis unsigned long function"
343 # Sun /bin/cc calls this a function returning double.
344 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
345 gdb_test "whatis v_float_func" \
346 "type = float \\(\\)" \
347 "whatis float function"
349 gdb_test "whatis v_double_func" \
350 "type = double \\(\\)" \
351 "whatis double function" \
354 # test whatis command with some misc complicated types
355 gdb_test "whatis s_link" \
356 "type = struct link \\*" \
357 "whatis complicated structure"
359 gdb_test "whatis u_link" \
360 "type = union tu_link" \
361 "whatis complicated union"
364 # test whatis command with enumerations
365 gdb_test "whatis clunker" \
370 # test whatis command with nested struct and union
371 gdb_test "whatis nested_su" \
372 "type = struct outer_struct" \
373 "whatis outer structure"
375 gdb_test "whatis nested_su.outer_int" \
377 "whatis outer structure member"
379 gdb_test "whatis nested_su.inner_struct_instance" \
380 "type = struct inner_struct" \
381 "whatis inner structure"
383 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
385 "whatis inner structure member"
387 gdb_test "whatis nested_su.inner_union_instance" \
388 "type = union inner_union" \
391 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
393 "whatis inner union member"