Commit | Line | Data |
---|---|---|
d782e0bf MC |
1 | # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002, |
2 | # 2003, 2004 Free Software Foundation, Inc. | |
c906108c SS |
3 | |
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. | |
8 | # | |
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. | |
13 | # | |
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. | |
17 | ||
c906108c SS |
18 | # This file was written by Rob Savoye. (rob@cygnus.com) |
19 | ||
20 | if $tracelevel { | |
21 | strace $tracelevel | |
22 | } | |
23 | ||
24 | # | |
25 | # test running programs | |
26 | # | |
27 | set prms_id 0 | |
28 | set bug_id 0 | |
29 | ||
30 | set testfile whatis | |
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." | |
35 | } | |
36 | ||
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}] { | |
40 | return -1; | |
41 | } | |
42 | ||
43 | # Start with a fresh gdb. | |
44 | ||
45 | gdb_exit | |
46 | gdb_start | |
47 | gdb_reinitialize_dir $srcdir/$subdir | |
48 | gdb_load $binfile | |
49 | ||
c906108c SS |
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. | |
54 | ||
55 | proc setup_xfail_on_long_vs_int {} { | |
56 | global gcc_compiled | |
57 | ||
58 | if {!$gcc_compiled} { | |
59 | setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*" | |
60 | } | |
61 | } | |
62 | ||
63 | # | |
64 | # Test whatis command with basic C types | |
65 | # | |
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 | |
68 | # native compilers. | |
69 | # | |
085dd6e6 | 70 | |
c906108c SS |
71 | gdb_test "whatis v_char" \ |
72 | "type = (unsigned char|char)" \ | |
73 | "whatis char" | |
74 | ||
c906108c SS |
75 | if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" } |
76 | gdb_test "whatis v_signed_char" \ | |
d782e0bf | 77 | "type = (signed char|char)" \ |
c906108c SS |
78 | "whatis signed char" |
79 | ||
80 | gdb_test "whatis v_unsigned_char" \ | |
81 | "type = unsigned char" \ | |
82 | "whatis unsigned char" | |
83 | ||
84 | gdb_test "whatis v_short" \ | |
85 | "type = (short|short int)" \ | |
86 | "whatis short" | |
87 | ||
88 | gdb_test "whatis v_signed_short" \ | |
89 | "type = (short|short int|signed short|signed short int)" \ | |
90 | "whatis signed short" | |
91 | ||
92 | gdb_test "whatis v_unsigned_short" \ | |
93 | "type = (unsigned short|short unsigned int)" \ | |
94 | "whatis unsigned short" | |
95 | ||
96 | gdb_test "whatis v_int" \ | |
97 | "type = int" \ | |
98 | "whatis int" | |
99 | ||
100 | gdb_test "whatis v_signed_int" \ | |
101 | "type = (signed |)int" \ | |
102 | "whatis signed int" | |
103 | ||
104 | gdb_test "whatis v_unsigned_int" \ | |
105 | "type = unsigned int" \ | |
106 | "whatis unsigned int" | |
107 | ||
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)" \ | |
113 | "whatis long" | |
114 | ||
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)" \ | |
120 | "whatis signed long" | |
121 | ||
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" | |
126 | ||
127 | gdb_test "whatis v_float" \ | |
128 | "type = float" \ | |
129 | "whatis float" | |
130 | ||
131 | gdb_test "whatis v_double" \ | |
132 | "type = double" \ | |
133 | "whatis double" | |
134 | ||
135 | ||
136 | # test whatis command with arrays | |
137 | # | |
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\\\]" \ | |
143 | "whatis char array" | |
144 | ||
145 | gdb_test "whatis v_signed_char_array" \ | |
146 | "type = (signed |unsigned |)char \\\[2\\\]" \ | |
147 | "whatis signed char array" | |
148 | ||
149 | gdb_test "whatis v_unsigned_char_array" \ | |
150 | "type = unsigned char \\\[2\\\]" \ | |
151 | "whatis unsigned char array" | |
152 | ||
153 | gdb_test "whatis v_short_array" \ | |
154 | "type = (short|short int) \\\[2\\\]" \ | |
155 | "whatis short array" | |
156 | ||
157 | gdb_test "whatis v_signed_short_array" \ | |
158 | "type = (signed |)(short|short int) \\\[2\\\]" \ | |
159 | "whatis signed short array" | |
160 | ||
161 | gdb_test "whatis v_unsigned_short_array" \ | |
162 | "type = (unsigned short|short unsigned int) \\\[2\\\]" \ | |
163 | "whatis unsigned short array" | |
164 | ||
165 | gdb_test "whatis v_int_array" \ | |
166 | "type = int \\\[2\\\]" \ | |
167 | "whatis int array" | |
168 | ||
169 | gdb_test "whatis v_signed_int_array" \ | |
170 | "type = (signed |)int \\\[2\\\]" \ | |
171 | "whatis signed int array" | |
172 | ||
173 | gdb_test "whatis v_unsigned_int_array" \ | |
174 | "type = unsigned int \\\[2\\\]" \ | |
175 | "whatis unsigned int array" | |
176 | ||
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\\\]" \ | |
181 | "whatis long array" | |
182 | ||
183 | gdb_test "whatis v_signed_long_array" \ | |
184 | "type = (signed |)(int|long|long int) \\\[2\\\]" \ | |
185 | "whatis signed long array" | |
186 | ||
187 | gdb_test "whatis v_unsigned_long_array" \ | |
188 | "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \ | |
189 | "whatis unsigned long array" | |
190 | ||
191 | gdb_test "whatis v_float_array" \ | |
192 | "type = float \\\[2\\\]" \ | |
193 | "whatis float array" | |
194 | ||
195 | gdb_test "whatis v_double_array" \ | |
196 | "type = double \\\[2\\\]" \ | |
197 | "whatis double array" | |
198 | ||
199 | ||
200 | # test whatis command with pointers | |
201 | # | |
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 | |
204 | # caddr_t. | |
205 | gdb_test "whatis v_char_pointer" \ | |
206 | "type = (unsigned |signed |)char \\*" \ | |
207 | "whatis char pointer" | |
208 | ||
209 | gdb_test "whatis v_signed_char_pointer" \ | |
210 | "type = (unsigned |signed |)char \\*" \ | |
211 | "whatis signed char pointer" | |
212 | ||
213 | gdb_test "whatis v_unsigned_char_pointer" \ | |
214 | "type = unsigned char \\*" \ | |
215 | "whatis unsigned char pointer" | |
216 | ||
217 | gdb_test "whatis v_short_pointer" \ | |
218 | "type = (short|short int) \\*" \ | |
219 | "whatis short pointer" | |
220 | ||
221 | gdb_test "whatis v_signed_short_pointer" \ | |
222 | "type = (signed |)(short|short int) \\*" \ | |
223 | "whatis signed short pointer" | |
224 | ||
225 | gdb_test "whatis v_unsigned_short_pointer" \ | |
226 | "type = (unsigned short|short unsigned int) \\*" \ | |
227 | "whatis unsigned short pointer" | |
228 | ||
229 | gdb_test "whatis v_int_pointer" \ | |
230 | "type = int \\*" \ | |
231 | "whatis int pointer" | |
232 | ||
233 | gdb_test "whatis v_signed_int_pointer" \ | |
234 | "type = (signed |)int \\*" \ | |
235 | "whatis signed int pointer" | |
236 | ||
237 | gdb_test "whatis v_unsigned_int_pointer" \ | |
238 | "type = unsigned int \\*" \ | |
239 | "whatis unsigned int pointer" | |
240 | ||
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" | |
245 | ||
246 | gdb_test "whatis v_signed_long_pointer" \ | |
247 | "type = (signed |)(long|int|long int) \\*" \ | |
248 | "whatis signed long pointer" | |
249 | ||
250 | gdb_test "whatis v_unsigned_long_pointer" \ | |
251 | "type = (unsigned (int|long|long int)|long unsigned int) \\*" \ | |
252 | "whatis unsigned long pointer" | |
253 | ||
254 | gdb_test "whatis v_float_pointer" \ | |
255 | "type = float \\*" \ | |
256 | "whatis float pointer" | |
257 | ||
258 | gdb_test "whatis v_double_pointer" \ | |
259 | "type = double \\*" \ | |
260 | "whatis double pointer" | |
261 | ||
262 | ||
085dd6e6 JM |
263 | if { $hp_aCC_compiler } { |
264 | set unstruct "unnamed\.struct\..*" | |
265 | set ununion "unnamed\.union\..*" | |
266 | } else { | |
267 | set unstruct "\.\.\." | |
268 | set ununion "\.\.\." | |
269 | } | |
270 | ||
c906108c SS |
271 | # test whatis command with structure types |
272 | gdb_test "whatis v_struct1" \ | |
273 | "type = struct t_struct" \ | |
274 | "whatis named structure" | |
275 | ||
f8261448 FF |
276 | gdb_test "whatis struct t_struct" \ |
277 | "type = struct t_struct" \ | |
278 | "whatis named structure using type name" | |
279 | ||
c906108c | 280 | gdb_test "whatis v_struct2" \ |
085dd6e6 | 281 | "type = struct \{$unstruct\}" \ |
c906108c SS |
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 | ||
f8261448 FF |
290 | gdb_test "whatis union t_union" \ |
291 | "type = union t_union" \ | |
292 | "whatis named union using type name" | |
293 | ||
c906108c | 294 | gdb_test "whatis v_union2" \ |
085dd6e6 | 295 | "type = union \{$ununion\}" \ |
c906108c SS |
296 | "whatis unnamed union" |
297 | ||
298 | ||
1e698235 DJ |
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 ''. | |
302 | # - guo | |
303 | # Also, using stabs we will mark these functions as prototyped. This | |
304 | # is harmless but causes an extra VOID to be printed. | |
305 | set void "(void|)" | |
c906108c SS |
306 | |
307 | # test whatis command with functions return type | |
308 | gdb_test "whatis v_char_func" \ | |
085dd6e6 | 309 | "type = (signed |unsigned |)char \\($void\\)" \ |
c906108c SS |
310 | "whatis char function" |
311 | ||
312 | gdb_test "whatis v_signed_char_func" \ | |
085dd6e6 | 313 | "type = (signed |unsigned |)char \\($void\\)" \ |
c906108c SS |
314 | "whatis signed char function" |
315 | ||
316 | gdb_test "whatis v_unsigned_char_func" \ | |
085dd6e6 | 317 | "type = unsigned char \\($void\\)" \ |
c906108c SS |
318 | "whatis unsigned char function" |
319 | ||
320 | gdb_test "whatis v_short_func" \ | |
085dd6e6 | 321 | "type = short (int |)\\($void\\)" \ |
c906108c SS |
322 | "whatis short function" |
323 | ||
324 | gdb_test "whatis v_signed_short_func" \ | |
085dd6e6 | 325 | "type = (signed |)short (int |)\\($void\\)" \ |
c906108c SS |
326 | "whatis signed short function" |
327 | ||
328 | gdb_test "whatis v_unsigned_short_func" \ | |
085dd6e6 | 329 | "type = (unsigned short|short unsigned int) \\($void\\)" \ |
c906108c SS |
330 | "whatis unsigned short function" |
331 | ||
332 | gdb_test "whatis v_int_func" \ | |
085dd6e6 | 333 | "type = int \\($void\\)" \ |
c906108c SS |
334 | "whatis int function" |
335 | ||
336 | gdb_test "whatis v_signed_int_func" \ | |
085dd6e6 | 337 | "type = (signed |)int \\($void\\)" \ |
c906108c SS |
338 | "whatis signed int function" |
339 | ||
340 | gdb_test "whatis v_unsigned_int_func" \ | |
085dd6e6 | 341 | "type = unsigned int \\($void\\)" \ |
c906108c SS |
342 | "whatis unsigned int function" |
343 | ||
344 | gdb_test "whatis v_long_func" \ | |
085dd6e6 | 345 | "type = (long|int|long int) \\($void\\)" \ |
c906108c SS |
346 | "whatis long function" |
347 | ||
348 | gdb_test "whatis v_signed_long_func" \ | |
085dd6e6 | 349 | "type = (signed |)(int|long|long int) \\($void\\)" \ |
c906108c SS |
350 | "whatis signed long function" |
351 | ||
352 | gdb_test "whatis v_unsigned_long_func" \ | |
085dd6e6 | 353 | "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \ |
c906108c SS |
354 | "whatis unsigned long function" |
355 | ||
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" \ | |
085dd6e6 | 359 | "type = float \\($void\\)" \ |
c906108c SS |
360 | "whatis float function" |
361 | ||
362 | gdb_test "whatis v_double_func" \ | |
085dd6e6 | 363 | "type = double \\($void\\)" \ |
c906108c SS |
364 | "whatis double function" \ |
365 | ||
366 | ||
367 | # test whatis command with some misc complicated types | |
368 | gdb_test "whatis s_link" \ | |
369 | "type = struct link \\*" \ | |
370 | "whatis complicated structure" | |
371 | ||
372 | gdb_test "whatis u_link" \ | |
373 | "type = union tu_link" \ | |
374 | "whatis complicated union" | |
375 | ||
376 | ||
377 | # test whatis command with enumerations | |
378 | gdb_test "whatis clunker" \ | |
379 | "type = enum cars" \ | |
380 | "whatis enumeration" | |
381 | ||
f8261448 FF |
382 | gdb_test "whatis enum cars" \ |
383 | "type = enum cars" \ | |
384 | "whatis enumeration using type name" | |
385 | ||
c906108c SS |
386 | |
387 | # test whatis command with nested struct and union | |
388 | gdb_test "whatis nested_su" \ | |
389 | "type = struct outer_struct" \ | |
390 | "whatis outer structure" | |
391 | ||
392 | gdb_test "whatis nested_su.outer_int" \ | |
393 | "type = int" \ | |
394 | "whatis outer structure member" | |
395 | ||
085dd6e6 JM |
396 | if {$hp_aCC_compiler} { |
397 | set outer "outer_struct::" | |
398 | } else { | |
399 | set outer "" | |
400 | } | |
401 | ||
c906108c | 402 | gdb_test "whatis nested_su.inner_struct_instance" \ |
085dd6e6 | 403 | "type = struct ${outer}inner_struct" \ |
c906108c SS |
404 | "whatis inner structure" |
405 | ||
406 | gdb_test "whatis nested_su.inner_struct_instance.inner_int" \ | |
407 | "type = int" \ | |
408 | "whatis inner structure member" | |
409 | ||
410 | gdb_test "whatis nested_su.inner_union_instance" \ | |
085dd6e6 | 411 | "type = union ${outer}inner_union" \ |
c906108c SS |
412 | "whatis inner union" |
413 | ||
414 | gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \ | |
415 | "type = int" \ | |
416 | "whatis inner union member" | |
f8261448 FF |
417 | |
418 | # test whatis command with typedefs | |
419 | ||
420 | gdb_test "whatis char_addr" \ | |
421 | "type = char \\*" \ | |
422 | "whatis using typedef type name" | |
423 | ||
424 | gdb_test "whatis a_char_addr" \ | |
425 | "type = char_addr" \ | |
426 | "whatis applied to variable defined by typedef" |