]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/whatis.exp
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.exp
1 # Copyright (C) 1988, 1990, 1991, 1992, 1995, 1997 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Rob Savoye. (rob@cygnus.com)
21
22 if $tracelevel {
23 strace $tracelevel
24 }
25
26 #
27 # test running programs
28 #
29 set prms_id 0
30 set bug_id 0
31
32 set testfile whatis
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."
37 }
38
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}] {
42 return -1;
43 }
44
45 # Start with a fresh gdb.
46
47 gdb_exit
48 gdb_start
49 gdb_reinitialize_dir $srcdir/$subdir
50 gdb_load $binfile
51
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"
56 } else {
57 set signed_char "signed char"
58 }
59
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.
64
65 proc setup_xfail_on_long_vs_int {} {
66 global gcc_compiled
67
68 if {!$gcc_compiled} {
69 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
70 }
71 }
72
73 #
74 # Test whatis command with basic C types
75 #
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
78 # native compilers.
79 #
80 gdb_test "whatis v_char" \
81 "type = (unsigned char|char)" \
82 "whatis char"
83
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" \
88 "whatis signed char"
89
90 gdb_test "whatis v_unsigned_char" \
91 "type = unsigned char" \
92 "whatis unsigned char"
93
94 gdb_test "whatis v_short" \
95 "type = (short|short int)" \
96 "whatis short"
97
98 gdb_test "whatis v_signed_short" \
99 "type = (short|short int|signed short|signed short int)" \
100 "whatis signed short"
101
102 gdb_test "whatis v_unsigned_short" \
103 "type = (unsigned short|short unsigned int)" \
104 "whatis unsigned short"
105
106 gdb_test "whatis v_int" \
107 "type = int" \
108 "whatis int"
109
110 gdb_test "whatis v_signed_int" \
111 "type = (signed |)int" \
112 "whatis signed int"
113
114 gdb_test "whatis v_unsigned_int" \
115 "type = unsigned int" \
116 "whatis unsigned int"
117
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)" \
123 "whatis long"
124
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)" \
130 "whatis signed long"
131
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"
136
137 gdb_test "whatis v_float" \
138 "type = float" \
139 "whatis float"
140
141 gdb_test "whatis v_double" \
142 "type = double" \
143 "whatis double"
144
145
146 # test whatis command with arrays
147 #
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\\\]" \
153 "whatis char array"
154
155 gdb_test "whatis v_signed_char_array" \
156 "type = (signed |unsigned |)char \\\[2\\\]" \
157 "whatis signed char array"
158
159 gdb_test "whatis v_unsigned_char_array" \
160 "type = unsigned char \\\[2\\\]" \
161 "whatis unsigned char array"
162
163 gdb_test "whatis v_short_array" \
164 "type = (short|short int) \\\[2\\\]" \
165 "whatis short array"
166
167 gdb_test "whatis v_signed_short_array" \
168 "type = (signed |)(short|short int) \\\[2\\\]" \
169 "whatis signed short array"
170
171 gdb_test "whatis v_unsigned_short_array" \
172 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
173 "whatis unsigned short array"
174
175 gdb_test "whatis v_int_array" \
176 "type = int \\\[2\\\]" \
177 "whatis int array"
178
179 gdb_test "whatis v_signed_int_array" \
180 "type = (signed |)int \\\[2\\\]" \
181 "whatis signed int array"
182
183 gdb_test "whatis v_unsigned_int_array" \
184 "type = unsigned int \\\[2\\\]" \
185 "whatis unsigned int array"
186
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\\\]" \
191 "whatis long array"
192
193 gdb_test "whatis v_signed_long_array" \
194 "type = (signed |)(int|long|long int) \\\[2\\\]" \
195 "whatis signed long array"
196
197 gdb_test "whatis v_unsigned_long_array" \
198 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
199 "whatis unsigned long array"
200
201 gdb_test "whatis v_float_array" \
202 "type = float \\\[2\\\]" \
203 "whatis float array"
204
205 gdb_test "whatis v_double_array" \
206 "type = double \\\[2\\\]" \
207 "whatis double array"
208
209
210 # test whatis command with pointers
211 #
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
214 # caddr_t.
215 gdb_test "whatis v_char_pointer" \
216 "type = (unsigned |signed |)char \\*" \
217 "whatis char pointer"
218
219 gdb_test "whatis v_signed_char_pointer" \
220 "type = (unsigned |signed |)char \\*" \
221 "whatis signed char pointer"
222
223 gdb_test "whatis v_unsigned_char_pointer" \
224 "type = unsigned char \\*" \
225 "whatis unsigned char pointer"
226
227 gdb_test "whatis v_short_pointer" \
228 "type = (short|short int) \\*" \
229 "whatis short pointer"
230
231 gdb_test "whatis v_signed_short_pointer" \
232 "type = (signed |)(short|short int) \\*" \
233 "whatis signed short pointer"
234
235 gdb_test "whatis v_unsigned_short_pointer" \
236 "type = (unsigned short|short unsigned int) \\*" \
237 "whatis unsigned short pointer"
238
239 gdb_test "whatis v_int_pointer" \
240 "type = int \\*" \
241 "whatis int pointer"
242
243 gdb_test "whatis v_signed_int_pointer" \
244 "type = (signed |)int \\*" \
245 "whatis signed int pointer"
246
247 gdb_test "whatis v_unsigned_int_pointer" \
248 "type = unsigned int \\*" \
249 "whatis unsigned int pointer"
250
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"
255
256 gdb_test "whatis v_signed_long_pointer" \
257 "type = (signed |)(long|int|long int) \\*" \
258 "whatis signed long pointer"
259
260 gdb_test "whatis v_unsigned_long_pointer" \
261 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
262 "whatis unsigned long pointer"
263
264 gdb_test "whatis v_float_pointer" \
265 "type = float \\*" \
266 "whatis float pointer"
267
268 gdb_test "whatis v_double_pointer" \
269 "type = double \\*" \
270 "whatis double pointer"
271
272
273 # test whatis command with structure types
274 gdb_test "whatis v_struct1" \
275 "type = struct t_struct" \
276 "whatis named structure"
277
278 gdb_test "whatis v_struct2" \
279 "type = struct \{...\}" \
280 "whatis unnamed structure"
281
282
283 # test whatis command with union types
284 gdb_test "whatis v_union" \
285 "type = union t_union" \
286 "whatis named union"
287
288 gdb_test "whatis v_union2" \
289 "type = union \{...\}" \
290 "whatis unnamed union"
291
292
293
294 # test whatis command with functions return type
295 gdb_test "whatis v_char_func" \
296 "type = (signed |unsigned |)char \\(\\)" \
297 "whatis char function"
298
299 gdb_test "whatis v_signed_char_func" \
300 "type = (signed |unsigned |)char \\(\\)" \
301 "whatis signed char function"
302
303 gdb_test "whatis v_unsigned_char_func" \
304 "type = unsigned char \\(\\)" \
305 "whatis unsigned char function"
306
307 gdb_test "whatis v_short_func" \
308 "type = short (int |)\\(\\)" \
309 "whatis short function"
310
311 gdb_test "whatis v_signed_short_func" \
312 "type = (signed |)short (int |)\\(\\)" \
313 "whatis signed short function"
314
315 gdb_test "whatis v_unsigned_short_func" \
316 "type = (unsigned short|short unsigned int) \\(\\)" \
317 "whatis unsigned short function"
318
319 gdb_test "whatis v_int_func" \
320 "type = int \\(\\)" \
321 "whatis int function"
322
323 gdb_test "whatis v_signed_int_func" \
324 "type = (signed |)int \\(\\)" \
325 "whatis signed int function"
326
327 gdb_test "whatis v_unsigned_int_func" \
328 "type = unsigned int \\(\\)" \
329 "whatis unsigned int function"
330
331 gdb_test "whatis v_long_func" \
332 "type = (long|int|long int) \\(\\)" \
333 "whatis long function"
334
335 gdb_test "whatis v_signed_long_func" \
336 "type = (signed |)(int|long|long int) \\(\\)" \
337 "whatis signed long function"
338
339 gdb_test "whatis v_unsigned_long_func" \
340 "type = (unsigned (int|long|long int)|long unsigned int) \\(\\)" \
341 "whatis unsigned long function"
342
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"
348
349 gdb_test "whatis v_double_func" \
350 "type = double \\(\\)" \
351 "whatis double function" \
352
353
354 # test whatis command with some misc complicated types
355 gdb_test "whatis s_link" \
356 "type = struct link \\*" \
357 "whatis complicated structure"
358
359 gdb_test "whatis u_link" \
360 "type = union tu_link" \
361 "whatis complicated union"
362
363
364 # test whatis command with enumerations
365 gdb_test "whatis clunker" \
366 "type = enum cars" \
367 "whatis enumeration"
368
369
370 # test whatis command with nested struct and union
371 gdb_test "whatis nested_su" \
372 "type = struct outer_struct" \
373 "whatis outer structure"
374
375 gdb_test "whatis nested_su.outer_int" \
376 "type = int" \
377 "whatis outer structure member"
378
379 gdb_test "whatis nested_su.inner_struct_instance" \
380 "type = struct inner_struct" \
381 "whatis inner structure"
382
383 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
384 "type = int" \
385 "whatis inner structure member"
386
387 gdb_test "whatis nested_su.inner_union_instance" \
388 "type = union inner_union" \
389 "whatis inner union"
390
391 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
392 "type = int" \
393 "whatis inner union member"