1 # Copyright
1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002,
2 #
2003, 2004 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}] != "" } {
34 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
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"
127 gdb_test
"whatis v_float" \
131 gdb_test
"whatis v_double" \
136 # test whatis command with arrays
138 # We already tested whether char prints as
"char", so here we accept
139 #
"unsigned char", "signed char", and other perversions. No need for more
140 # than one xfail
for the same thing.
141 gdb_test
"whatis v_char_array" \
142 "type = (signed |unsigned |)char \\\[2\\\]" \
145 gdb_test
"whatis v_signed_char_array" \
146 "type = (signed |unsigned |)char \\\[2\\\]" \
147 "whatis signed char array"
149 gdb_test
"whatis v_unsigned_char_array" \
150 "type = unsigned char \\\[2\\\]" \
151 "whatis unsigned char array"
153 gdb_test
"whatis v_short_array" \
154 "type = (short|short int) \\\[2\\\]" \
157 gdb_test
"whatis v_signed_short_array" \
158 "type = (signed |)(short|short int) \\\[2\\\]" \
159 "whatis signed short array"
161 gdb_test
"whatis v_unsigned_short_array" \
162 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
163 "whatis unsigned short array"
165 gdb_test
"whatis v_int_array" \
166 "type = int \\\[2\\\]" \
169 gdb_test
"whatis v_signed_int_array" \
170 "type = (signed |)int \\\[2\\\]" \
171 "whatis signed int array"
173 gdb_test
"whatis v_unsigned_int_array" \
174 "type = unsigned int \\\[2\\\]" \
175 "whatis unsigned int array"
177 # We already tested whether long prints as long
, so here we accept
int
178 # No need
for more than one xfail
for the same thing.
179 gdb_test
"whatis v_long_array" \
180 "type = (int|long|long int) \\\[2\\\]" \
183 gdb_test
"whatis v_signed_long_array" \
184 "type = (signed |)(int|long|long int) \\\[2\\\]" \
185 "whatis signed long array"
187 gdb_test
"whatis v_unsigned_long_array" \
188 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
189 "whatis unsigned long array"
191 gdb_test
"whatis v_float_array" \
192 "type = float \\\[2\\\]" \
195 gdb_test
"whatis v_double_array" \
196 "type = double \\\[2\\\]" \
197 "whatis double array"
200 # test whatis command with pointers
202 # We already tested whether char prints as char
, so accept various perversions
203 # here. We especially want to make sure we test that it doesn
't print as
205 gdb_test "whatis v_char_pointer" \
206 "type = (unsigned |signed |)char \\*" \
207 "whatis char pointer"
209 gdb_test "whatis v_signed_char_pointer" \
210 "type = (unsigned |signed |)char \\*" \
211 "whatis signed char pointer"
213 gdb_test "whatis v_unsigned_char_pointer" \
214 "type = unsigned char \\*" \
215 "whatis unsigned char pointer"
217 gdb_test "whatis v_short_pointer" \
218 "type = (short|short int) \\*" \
219 "whatis short pointer"
221 gdb_test "whatis v_signed_short_pointer" \
222 "type = (signed |)(short|short int) \\*" \
223 "whatis signed short pointer"
225 gdb_test "whatis v_unsigned_short_pointer" \
226 "type = (unsigned short|short unsigned int) \\*" \
227 "whatis unsigned short pointer"
229 gdb_test "whatis v_int_pointer" \
233 gdb_test "whatis v_signed_int_pointer" \
234 "type = (signed |)int \\*" \
235 "whatis signed int pointer"
237 gdb_test "whatis v_unsigned_int_pointer" \
238 "type = unsigned int \\*" \
239 "whatis unsigned int pointer"
241 # We already tested whether long prints as long, so here we accept int
242 gdb_test "whatis v_long_pointer" \
243 "type = (long|int|long int) \\*" \
244 "whatis long pointer"
246 gdb_test "whatis v_signed_long_pointer" \
247 "type = (signed |)(long|int|long int) \\*" \
248 "whatis signed long pointer"
250 gdb_test "whatis v_unsigned_long_pointer" \
251 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
252 "whatis unsigned long pointer"
254 gdb_test "whatis v_float_pointer" \
256 "whatis float pointer"
258 gdb_test "whatis v_double_pointer" \
259 "type = double \\*" \
260 "whatis double pointer"
263 if { $hp_aCC_compiler } {
264 set unstruct "unnamed\.struct\..*"
265 set ununion "unnamed\.union\..*"
267 set unstruct "\.\.\."
271 # test whatis command with structure types
272 gdb_test "whatis v_struct1" \
273 "type = struct t_struct" \
274 "whatis named structure"
276 gdb_test "whatis struct t_struct" \
277 "type = struct t_struct" \
278 "whatis named structure using type name"
280 gdb_test "whatis v_struct2" \
281 "type = struct \{$unstruct\}" \
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 union t_union" \
291 "type = union t_union" \
292 "whatis named union using type name"
294 gdb_test "whatis v_union2" \
295 "type = union \{$ununion\}" \
296 "whatis unnamed union"
299 # HP-UX: HP aCC compiler w/ +objdebug option detects language as
300 # c++, so we need the 'void
' pattern here.
301 # Without +objdebug compilation option we still need to match ''.
303 # Also, using stabs we will mark these functions as prototyped. This
304 # is harmless but causes an extra VOID to be printed.
307 # test whatis command with functions return type
308 gdb_test "whatis v_char_func" \
309 "type = (signed |unsigned |)char \\($void\\)" \
310 "whatis char function"
312 gdb_test "whatis v_signed_char_func" \
313 "type = (signed |unsigned |)char \\($void\\)" \
314 "whatis signed char function"
316 gdb_test "whatis v_unsigned_char_func" \
317 "type = unsigned char \\($void\\)" \
318 "whatis unsigned char function"
320 gdb_test "whatis v_short_func" \
321 "type = short (int |)\\($void\\)" \
322 "whatis short function"
324 gdb_test "whatis v_signed_short_func" \
325 "type = (signed |)short (int |)\\($void\\)" \
326 "whatis signed short function"
328 gdb_test "whatis v_unsigned_short_func" \
329 "type = (unsigned short|short unsigned int) \\($void\\)" \
330 "whatis unsigned short function"
332 gdb_test "whatis v_int_func" \
333 "type = int \\($void\\)" \
334 "whatis int function"
336 gdb_test "whatis v_signed_int_func" \
337 "type = (signed |)int \\($void\\)" \
338 "whatis signed int function"
340 gdb_test "whatis v_unsigned_int_func" \
341 "type = unsigned int \\($void\\)" \
342 "whatis unsigned int function"
344 gdb_test "whatis v_long_func" \
345 "type = (long|int|long int) \\($void\\)" \
346 "whatis long function"
348 gdb_test "whatis v_signed_long_func" \
349 "type = (signed |)(int|long|long int) \\($void\\)" \
350 "whatis signed long function"
352 gdb_test "whatis v_unsigned_long_func" \
353 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
354 "whatis unsigned long function"
356 # Sun /bin/cc calls this a function returning double.
357 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
358 gdb_test "whatis v_float_func" \
359 "type = float \\($void\\)" \
360 "whatis float function"
362 gdb_test "whatis v_double_func" \
363 "type = double \\($void\\)" \
364 "whatis double function" \
367 # test whatis command with some misc complicated types
368 gdb_test "whatis s_link" \
369 "type = struct link \\*" \
370 "whatis complicated structure"
372 gdb_test "whatis u_link" \
373 "type = union tu_link" \
374 "whatis complicated union"
377 # test whatis command with enumerations
378 gdb_test "whatis clunker" \
382 gdb_test "whatis enum cars" \
384 "whatis enumeration using type name"
387 # test whatis command with nested struct and union
388 gdb_test "whatis nested_su" \
389 "type = struct outer_struct" \
390 "whatis outer structure"
392 gdb_test "whatis nested_su.outer_int" \
394 "whatis outer structure member"
396 if {$hp_aCC_compiler} {
397 set outer "outer_struct::"
402 gdb_test "whatis nested_su.inner_struct_instance" \
403 "type = struct ${outer}inner_struct" \
404 "whatis inner structure"
406 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
408 "whatis inner structure member"
410 gdb_test "whatis nested_su.inner_union_instance" \
411 "type = union ${outer}inner_union" \
414 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
416 "whatis inner union member"
418 # test whatis command with typedefs
420 gdb_test "whatis char_addr" \
422 "whatis using typedef type name"
424 gdb_test "whatis a_char_addr" \
426 "whatis applied to variable defined by typedef"