Commit | Line | Data |
---|---|---|
316567f0 C |
1 | # Copyright (C) 1988, 1990, 1991, 1992 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 | gdb_reinitialize_dir $srcdir/$subdir | |
40 | gdb_load $objdir/$subdir/$binfile | |
41 | ||
42 | source gdb.base/whatis-info.exp | |
43 | ||
44 | # If we did not use the signed keyword when compiling the file, don't | |
45 | # expect GDB to know that char is signed. | |
46 | if $signed_keyword_not_used then { | |
47 | set signed_char "char" | |
48 | } else { | |
49 | set signed_char "signed char" | |
50 | } | |
51 | ||
52 | # Define a procedure to set up an xfail for all targets that put out a | |
53 | # `long' type as an `int' type. | |
54 | # Sun/Ultrix cc have this problem. | |
55 | # It was said that COFF targets can not distinguish int from long either. | |
56 | ||
57 | proc setup_xfail_on_long_vs_int {} { | |
58 | global gcc_compiled | |
59 | ||
60 | if {!$gcc_compiled} then { | |
61 | setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*" | |
62 | } | |
63 | } | |
64 | ||
65 | # | |
66 | # Test whatis command with basic C types | |
67 | # | |
68 | # The name printed now (as of 23 May 1993) is whatever name the compiler | |
69 | # uses in the stabs. So we need to deal with names both from gcc and | |
70 | # native compilers. | |
71 | # | |
72 | # On the i960, which defaults to unsigned characters, gdb | |
73 | # misinterprets char as unsigned char. | |
74 | # Likewise with the rs6000; the compiler doesn't give us enough information | |
75 | # to distinguish between char and unsigned char | |
76 | setup_xfail "rs6000-*-*" | |
77 | setup_xfail "i960-*-*" 1821 | |
78 | setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*" | |
79 | gdb_test "whatis v_char" \ | |
80 | "type = char" \ | |
81 | "whatis char" | |
82 | ||
83 | setup_xfail "a29k-*-*" | |
84 | gdb_test "whatis v_signed_char" \ | |
85 | "type = $signed_char" \ | |
86 | "whatis signed char" | |
87 | ||
88 | gdb_test "whatis v_unsigned_char" \ | |
89 | "type = unsigned char" \ | |
90 | "whatis unsigned char" | |
91 | ||
92 | gdb_test "whatis v_short" \ | |
93 | "type = short" \ | |
94 | "whatis short" | |
95 | ||
96 | gdb_test "whatis v_signed_short" \ | |
97 | "type = short" \ | |
98 | "whatis signed short" | |
99 | ||
100 | gdb_test "whatis v_unsigned_short" \ | |
101 | "type = (unsigned short|short unsigned int)" \ | |
102 | "whatis unsigned short" | |
103 | ||
104 | gdb_test "whatis v_int" \ | |
105 | "type = int" \ | |
106 | "whatis int" | |
107 | ||
108 | gdb_test "whatis v_signed_int" \ | |
109 | "type = int" \ | |
110 | "whatis signed int" | |
111 | ||
112 | gdb_test "whatis v_unsigned_int" \ | |
113 | "type = unsigned int" \ | |
114 | "whatis unsigned int" | |
115 | ||
116 | setup_xfail_on_long_vs_int | |
117 | # AIX xlc gets this wrong and unsigned long right. Go figure. | |
118 | if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"} | |
119 | gdb_test "whatis v_long" \ | |
120 | "type = long" \ | |
121 | "whatis long" | |
122 | ||
123 | setup_xfail_on_long_vs_int | |
124 | # AIX xlc gets this wrong and unsigned long right. Go figure. | |
125 | if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"} | |
126 | gdb_test "whatis v_signed_long" \ | |
127 | "type = long" \ | |
128 | "whatis signed long" | |
129 | ||
130 | setup_xfail_on_long_vs_int | |
131 | gdb_test "whatis v_unsigned_long" \ | |
132 | "type = (unsigned long|long unsigned int)" \ | |
133 | "whatis unsigned long" | |
134 | ||
135 | gdb_test "whatis v_float" \ | |
136 | "type = float" \ | |
137 | "whatis float" | |
138 | ||
139 | gdb_test "whatis v_double" \ | |
140 | "type = double" \ | |
141 | "whatis double" | |
142 | ||
143 | ||
144 | # test whatis command with arrays | |
145 | # | |
146 | # We already tested whether char prints as "char", so here we accept | |
147 | # "unsigned char", "signed char", and other perversions. No need for more | |
148 | # than one xfail for the same thing. | |
149 | gdb_test "whatis v_char_array" \ | |
150 | "type = (signed |unsigned |)char \\\[2\\\]" \ | |
151 | "whatis char array" | |
152 | ||
153 | gdb_test "whatis v_signed_char_array" \ | |
154 | "type = (signed |unsigned |)char \\\[2\\\]" \ | |
155 | "whatis signed char array" | |
156 | ||
157 | gdb_test "whatis v_unsigned_char_array" \ | |
158 | "type = unsigned char \\\[2\\\]" \ | |
159 | "whatis unsigned char array" | |
160 | ||
161 | gdb_test "whatis v_short_array" \ | |
162 | "type = (short|short int) \\\[2\\\]" \ | |
163 | pass "whatis short array" | |
164 | ||
165 | gdb_test "whatis v_signed_short_array" \ | |
166 | "type = (short|shirt int) \\\[2\\\]" \ | |
167 | "whatis signed short array" | |
168 | ||
169 | gdb_test "whatis v_unsigned_short_array" \ | |
170 | "type = (unsigned short|short unsigned int) \\\[2\\\]" \ | |
171 | "whatis unsigned short array" | |
172 | ||
173 | gdb_test "whatis v_int_array" \ | |
174 | "type = int \\\[2\\\]" \ | |
175 | "whatis int array" | |
176 | ||
177 | gdb_test "whatis v_signed_int_array" \ | |
178 | "type = int \\\[2\\\]" \ | |
179 | "whatis signed int array" | |
180 | ||
181 | gdb_test "whatis v_unsigned_int_array" \ | |
182 | "type = unsigned int \\\[2\\\]" \ | |
183 | "whatis unsigned int array" | |
184 | ||
185 | # We already tested whether long prints as long, so here we accept int | |
186 | # No need for more than one xfail for the same thing. | |
187 | gdb_test "whatis v_long_array" \ | |
188 | "type = (int|long|long int) \\\[2\\\]" \ | |
189 | "whatis long array" | |
190 | ||
191 | gdb_test "whatis v_signed_long_array" \ | |
192 | "type = (signed |)(int|long|long int) \\\[2\\\]" \ | |
193 | "whatis signed long array" | |
194 | ||
195 | gdb_test "whatis v_unsigned_long_array" \ | |
196 | "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \ | |
197 | "whatis unsigned long array" | |
198 | ||
199 | gdb_test "whatis v_float_array" \ | |
200 | "type = float \\\[2\\\]" \ | |
201 | "whatis float array" | |
202 | ||
203 | gdb_test "whatis v_double_array" \ | |
204 | "type = double \\\[2\\\]" \ | |
205 | "whatis double array" | |
206 | ||
207 | ||
208 | # test whatis command with pointers | |
209 | # | |
210 | # We already tested whether char prints as char, so accept various perversions | |
211 | # here. We especially want to make sure we test that it doesn't print as | |
212 | # caddr_t. | |
213 | gdb_test "whatis v_char_pointer" \ | |
214 | "type = (unsigned |signed |)char \*" \ | |
215 | "whatis char pointer" | |
216 | ||
217 | gdb_test "whatis v_signed_char_pointer" \ | |
218 | "type = (unsigned |signed |)char \*" \ | |
219 | "whatis signed char pointer" | |
220 | ||
221 | gdb_test "whatis v_unsigned_char_pointer" \ | |
222 | "type = unsigned char \*" \ | |
223 | "whatis unsigned char pointer" | |
224 | ||
225 | gdb_test "whatis v_short_pointer" \ | |
226 | "type = (short|short int) \*" \ | |
227 | pass "whatis short pointer" | |
228 | ||
229 | gdb_test "whatis v_signed_short_pointer" \ | |
230 | "type = (short|short int) \*" \ | |
231 | "whatis signed short pointer" | |
232 | ||
233 | gdb_test "whatis v_unsigned_short_pointer" \ | |
234 | "type = (unsigned short|short unsigned int) \*" \ | |
235 | "whatis unsigned short pointer" | |
236 | ||
237 | gdb_test "whatis v_int_pointer" \ | |
238 | "type = int \*" \ | |
239 | "whatis int pointer" | |
240 | ||
241 | gdb_test "whatis v_signed_int_pointer" \ | |
242 | "type = int \*" \ | |
243 | "whatis signed int pointer" | |
244 | ||
245 | gdb_test "whatis v_unsigned_int_pointer" \ | |
246 | "type = unsigned int \*" \ | |
247 | "whatis unsigned int pointer" | |
248 | ||
249 | # We already tested whether long prints as long, so here we accept int | |
250 | gdb_test "whatis v_long_pointer" \ | |
251 | "type = (long|int|long int) \*" \ | |
252 | "whatis long pointer" | |
253 | ||
254 | gdb_test "whatis v_signed_long_pointer" \ | |
255 | "type = (signed |)(long|int|long int) \*" \ | |
256 | "whatis signed long pointer" | |
257 | ||
258 | gdb_test "whatis v_unsigned_long_pointer" \ | |
259 | "type = (unsigned (int|long|long int)|long unsigned int) \*" \ | |
260 | "whatis unsigned long pointer" | |
261 | ||
262 | gdb_test "whatis v_float_pointer" \ | |
263 | "type = float \*" \ | |
264 | "whatis float pointer" | |
265 | ||
266 | gdb_test "whatis v_double_pointer" \ | |
267 | "type = double \*" \ | |
268 | "whatis double pointer" | |
269 | ||
270 | ||
271 | # test whatis command with structure types | |
272 | gdb_test "whatis v_struct1" \ | |
273 | "type = struct t_struct" \ | |
274 | "whatis named structure" | |
275 | ||
276 | gdb_test "whatis v_struct2" \ | |
277 | "type = struct \{...\}" \ | |
278 | "whatis unnamed structure" | |
279 | ||
280 | ||
281 | # test whatis command with union types | |
282 | gdb_test "whatis v_union" \ | |
283 | "type = union t_union" \ | |
284 | "whatis named union" | |
285 | ||
286 | gdb_test "whatis v_union2" \ | |
287 | "type = union \{...\}" \ | |
288 | "whatis unnamed union" | |
289 | ||
290 | ||
291 | ||
292 | # test whatis command with functions return type | |
293 | gdb_test "whatis v_char_func" \ | |
294 | "type = (signed |unsigned |)char \(\)" \ | |
295 | "whatis char function" | |
296 | ||
297 | gdb_test "whatis v_signed_char_func" \ | |
298 | "type = (signed |unsigned |)char \(\)" \ | |
299 | "whatis signed char function" | |
300 | ||
301 | gdb_test "whatis v_unsigned_char_func" \ | |
302 | "type = unsigned char \(\)" \ | |
303 | "whatis unsigned char function" | |
304 | ||
305 | gdb_test "whatis v_short_func" \ | |
306 | "type = short (int |)\(\)" \ | |
307 | "whatis short function" | |
308 | ||
309 | gdb_test "whatis v_signed_short_func" \ | |
310 | "type = short (int |)\(\)" \ | |
311 | "whatis signed short function" | |
312 | ||
313 | gdb_test "whatis v_unsigned_short_func" \ | |
314 | "type = (unsigned short|short unsigned int) \(\)" \ | |
315 | "whatis unsigned short function" | |
316 | ||
317 | gdb_test "whatis v_int_func" \ | |
318 | "type = int \(\)" \ | |
319 | "whatis int function" | |
320 | ||
321 | gdb_test "whatis v_signed_int_func" \ | |
322 | "type = int \(\)" \ | |
323 | "whatis signed int function" | |
324 | ||
325 | gdb_test "whatis v_unsigned_int_func" \ | |
326 | "type = unsigned int \(\)" \ | |
327 | "whatis unsigned int function" | |
328 | ||
329 | gdb_test "whatis v_long_func" \ | |
330 | "type = (long|int|long int) \(\)" \ | |
331 | "whatis long function" | |
332 | ||
333 | gdb_test "whatis v_signed_long_func" \ | |
334 | "type = (int|long|long int) \(\)" \ | |
335 | "whatis signed long function" | |
336 | ||
337 | gdb_test "whatis v_unsigned_long_func" \ | |
338 | "type = (unsigned (int|long|long int)|long unsigned int) \(\)" \ | |
339 | "whatis unsigned long function" | |
340 | ||
341 | # Sun /bin/cc calls this a function returning double. | |
342 | if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"} | |
343 | gdb_test "whatis v_float_func" \ | |
344 | "type = float \(\)" \ | |
345 | "whatis float function" | |
346 | ||
347 | gdb_test "whatis v_double_func" \ | |
348 | "type = double \(\)" \ | |
349 | "whatis double function" \ | |
350 | ||
351 | ||
352 | # test whatis command with some misc complicated types | |
353 | gdb_test "whatis s_link" \ | |
354 | "type = struct link" \ | |
355 | "whatis complicated structure" | |
356 | ||
357 | gdb_test "whatis u_link" \ | |
358 | "type = union tu_link" \ | |
359 | "whatis complicated union" | |
360 | ||
361 | ||
362 | # test whatis command with enumerations | |
363 | gdb_test "whatis clunker" \ | |
364 | "type = enum cars" \ | |
365 | "whatis enumeration" | |
366 | ||
367 | ||
368 | # test whatis command with nested struct and union | |
369 | gdb_test "whatis nested_su" \ | |
370 | "type = struct outer_struct" \ | |
371 | "whatis outer structure" | |
372 | ||
373 | gdb_test "whatis nested_su.outer_int" \ | |
374 | "type = int" \ | |
375 | "whatis outer structure member" | |
376 | ||
377 | gdb_test "whatis nested_su.inner_struct_instance" \ | |
378 | "type = struct inner_struct" \ | |
379 | "whatis inner structure" | |
380 | ||
381 | gdb_test "whatis nested_su.inner_struct_instance.inner_int" \ | |
382 | "type = int" \ | |
383 | "whatis inner structure member" | |
384 | ||
385 | gdb_test "whatis nested_su.inner_union_instance" \ | |
386 | "type = union inner_union" \ | |
387 | "whatis inner union" | |
388 | ||
389 | gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \ | |
390 | "type = int" \ | |
391 | "whatis inner union member" |