* lib/gdb.exp (gdb_test): Between $pattern and $prompt, expect
[binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.exp
1 # Copyright (C) 1988, 1990, 1991, 1992, 1995 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., 675 Mass Ave, Cambridge, MA 02139, 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 then {
23 strace $tracelevel
24 }
25
26 #
27 # test running programs
28 #
29 set prms_id 0
30 set bug_id 0
31
32 set binfile "whatis"
33
34 if ![file exists $objdir/$subdir/$binfile] then {
35 perror "$objdir/$subdir/$binfile does not exist."
36 return 0
37 }
38
39 # Start with a fresh gdb.
40
41 gdb_exit
42 gdb_start
43 gdb_reinitialize_dir $srcdir/$subdir
44 gdb_load $objdir/$subdir/$binfile
45
46 source gdb.base/whatis-info.exp
47
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"
52 } else {
53 set signed_char "signed char"
54 }
55
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.
60
61 proc setup_xfail_on_long_vs_int {} {
62 global gcc_compiled
63
64 if {!$gcc_compiled} then {
65 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*"
66 }
67 }
68
69 #
70 # Test whatis command with basic C types
71 #
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
74 # native compilers.
75 #
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" \
84 "type = char" \
85 "whatis char"
86
87 setup_xfail "a29k-*-*"
88 gdb_test "whatis v_signed_char" \
89 "type = $signed_char" \
90 "whatis signed char"
91
92 gdb_test "whatis v_unsigned_char" \
93 "type = unsigned char" \
94 "whatis unsigned char"
95
96 gdb_test "whatis v_short" \
97 "type = (short|short int)" \
98 "whatis short"
99
100 gdb_test "whatis v_signed_short" \
101 "type = (short|short int|signed short|signed short int)" \
102 "whatis signed short"
103
104 gdb_test "whatis v_unsigned_short" \
105 "type = (unsigned short|short unsigned int)" \
106 "whatis unsigned short"
107
108 gdb_test "whatis v_int" \
109 "type = int" \
110 "whatis int"
111
112 gdb_test "whatis v_signed_int" \
113 "type = int" \
114 "whatis signed int"
115
116 gdb_test "whatis v_unsigned_int" \
117 "type = unsigned int" \
118 "whatis unsigned int"
119
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)" \
125 "whatis long"
126
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)" \
132 "whatis signed long"
133
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"
138
139 gdb_test "whatis v_float" \
140 "type = float" \
141 "whatis float"
142
143 gdb_test "whatis v_double" \
144 "type = double" \
145 "whatis double"
146
147
148 # test whatis command with arrays
149 #
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\\\]" \
155 "whatis char array"
156
157 gdb_test "whatis v_signed_char_array" \
158 "type = (signed |unsigned |)char \\\[2\\\]" \
159 "whatis signed char array"
160
161 gdb_test "whatis v_unsigned_char_array" \
162 "type = unsigned char \\\[2\\\]" \
163 "whatis unsigned char array"
164
165 gdb_test "whatis v_short_array" \
166 "type = (short|short int) \\\[2\\\]" \
167 pass "whatis short array"
168
169 gdb_test "whatis v_signed_short_array" \
170 "type = (short|short int) \\\[2\\\]" \
171 "whatis signed short array"
172
173 gdb_test "whatis v_unsigned_short_array" \
174 "type = (unsigned short|short unsigned int) \\\[2\\\]" \
175 "whatis unsigned short array"
176
177 gdb_test "whatis v_int_array" \
178 "type = int \\\[2\\\]" \
179 "whatis int array"
180
181 gdb_test "whatis v_signed_int_array" \
182 "type = int \\\[2\\\]" \
183 "whatis signed int array"
184
185 gdb_test "whatis v_unsigned_int_array" \
186 "type = unsigned int \\\[2\\\]" \
187 "whatis unsigned int array"
188
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\\\]" \
193 "whatis long array"
194
195 gdb_test "whatis v_signed_long_array" \
196 "type = (signed |)(int|long|long int) \\\[2\\\]" \
197 "whatis signed long array"
198
199 gdb_test "whatis v_unsigned_long_array" \
200 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \
201 "whatis unsigned long array"
202
203 gdb_test "whatis v_float_array" \
204 "type = float \\\[2\\\]" \
205 "whatis float array"
206
207 gdb_test "whatis v_double_array" \
208 "type = double \\\[2\\\]" \
209 "whatis double array"
210
211
212 # test whatis command with pointers
213 #
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
216 # caddr_t.
217 gdb_test "whatis v_char_pointer" \
218 "type = (unsigned |signed |)char \\*" \
219 "whatis char pointer"
220
221 gdb_test "whatis v_signed_char_pointer" \
222 "type = (unsigned |signed |)char \\*" \
223 "whatis signed char pointer"
224
225 gdb_test "whatis v_unsigned_char_pointer" \
226 "type = unsigned char \\*" \
227 "whatis unsigned char pointer"
228
229 gdb_test "whatis v_short_pointer" \
230 "type = (short|short int) \\*" \
231 pass "whatis short pointer"
232
233 gdb_test "whatis v_signed_short_pointer" \
234 "type = (short|short int) \\*" \
235 "whatis signed short pointer"
236
237 gdb_test "whatis v_unsigned_short_pointer" \
238 "type = (unsigned short|short unsigned int) \\*" \
239 "whatis unsigned short pointer"
240
241 gdb_test "whatis v_int_pointer" \
242 "type = int \\*" \
243 "whatis int pointer"
244
245 gdb_test "whatis v_signed_int_pointer" \
246 "type = int \\*" \
247 "whatis signed int pointer"
248
249 gdb_test "whatis v_unsigned_int_pointer" \
250 "type = unsigned int \\*" \
251 "whatis unsigned int pointer"
252
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"
257
258 gdb_test "whatis v_signed_long_pointer" \
259 "type = (signed |)(long|int|long int) \\*" \
260 "whatis signed long pointer"
261
262 gdb_test "whatis v_unsigned_long_pointer" \
263 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \
264 "whatis unsigned long pointer"
265
266 gdb_test "whatis v_float_pointer" \
267 "type = float \\*" \
268 "whatis float pointer"
269
270 gdb_test "whatis v_double_pointer" \
271 "type = double \\*" \
272 "whatis double pointer"
273
274
275 # test whatis command with structure types
276 gdb_test "whatis v_struct1" \
277 "type = struct t_struct" \
278 "whatis named structure"
279
280 gdb_test "whatis v_struct2" \
281 "type = struct \{...\}" \
282 "whatis unnamed structure"
283
284
285 # test whatis command with union types
286 gdb_test "whatis v_union" \
287 "type = union t_union" \
288 "whatis named union"
289
290 gdb_test "whatis v_union2" \
291 "type = union \{...\}" \
292 "whatis unnamed union"
293
294
295
296 # test whatis command with functions return type
297 gdb_test "whatis v_char_func" \
298 "type = (signed |unsigned |)char \\(\\)" \
299 "whatis char function"
300
301 gdb_test "whatis v_signed_char_func" \
302 "type = (signed |unsigned |)char \\(\\)" \
303 "whatis signed char function"
304
305 gdb_test "whatis v_unsigned_char_func" \
306 "type = unsigned char \\(\\)" \
307 "whatis unsigned char function"
308
309 gdb_test "whatis v_short_func" \
310 "type = short (int |)\\(\\)" \
311 "whatis short function"
312
313 gdb_test "whatis v_signed_short_func" \
314 "type = short (int |)\\(\\)" \
315 "whatis signed short function"
316
317 gdb_test "whatis v_unsigned_short_func" \
318 "type = (unsigned short|short unsigned int) \\(\\)" \
319 "whatis unsigned short function"
320
321 gdb_test "whatis v_int_func" \
322 "type = int \\(\\)" \
323 "whatis int function"
324
325 gdb_test "whatis v_signed_int_func" \
326 "type = int \\(\\)" \
327 "whatis signed int function"
328
329 gdb_test "whatis v_unsigned_int_func" \
330 "type = unsigned int \\(\\)" \
331 "whatis unsigned int function"
332
333 gdb_test "whatis v_long_func" \
334 "type = (long|int|long int) \\(\\)" \
335 "whatis long function"
336
337 gdb_test "whatis v_signed_long_func" \
338 "type = (int|long|long int) \\(\\)" \
339 "whatis signed long function"
340
341 gdb_test "whatis v_unsigned_long_func" \
342 "type = (unsigned (int|long|long int)|long unsigned int) \\(\\)" \
343 "whatis unsigned long function"
344
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"
350
351 gdb_test "whatis v_double_func" \
352 "type = double \\(\\)" \
353 "whatis double function" \
354
355
356 # test whatis command with some misc complicated types
357 gdb_test "whatis s_link" \
358 "type = struct link \\*" \
359 "whatis complicated structure"
360
361 gdb_test "whatis u_link" \
362 "type = union tu_link" \
363 "whatis complicated union"
364
365
366 # test whatis command with enumerations
367 gdb_test "whatis clunker" \
368 "type = enum cars" \
369 "whatis enumeration"
370
371
372 # test whatis command with nested struct and union
373 gdb_test "whatis nested_su" \
374 "type = struct outer_struct" \
375 "whatis outer structure"
376
377 gdb_test "whatis nested_su.outer_int" \
378 "type = int" \
379 "whatis outer structure member"
380
381 gdb_test "whatis nested_su.inner_struct_instance" \
382 "type = struct inner_struct" \
383 "whatis inner structure"
384
385 gdb_test "whatis nested_su.inner_struct_instance.inner_int" \
386 "type = int" \
387 "whatis inner structure member"
388
389 gdb_test "whatis nested_su.inner_union_instance" \
390 "type = union inner_union" \
391 "whatis inner union"
392
393 gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \
394 "type = int" \
395 "whatis inner union member"