Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002, 2003, |
0fb0cc75 | 2 | # 2004, 2007, 2008, 2009 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 | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
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. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # This file was written by Rob Savoye. (rob@cygnus.com) |
18 | ||
19 | if $tracelevel { | |
20 | strace $tracelevel | |
21 | } | |
22 | ||
23 | # | |
24 | # test running programs | |
25 | # | |
26 | set prms_id 0 | |
27 | set bug_id 0 | |
28 | ||
64b2fa04 PA |
29 | if [target_info exists no_long_long] { |
30 | set exec_opts [list debug additional_flags=-DNO_LONG_LONG] | |
31 | } else { | |
32 | set exec_opts [list debug] | |
33 | } | |
34 | ||
c906108c SS |
35 | set testfile whatis |
36 | set srcfile ${testfile}.c | |
37 | set binfile ${objdir}/${subdir}/${testfile} | |
64b2fa04 | 38 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $exec_opts] != "" } { |
b60f0898 JB |
39 | untested whatis.exp |
40 | return -1 | |
c906108c SS |
41 | } |
42 | ||
43 | # Create and source the file that provides information about the compiler | |
44 | # used to compile the test case. | |
45 | if [get_compiler_info ${binfile}] { | |
46 | return -1; | |
47 | } | |
48 | ||
49 | # Start with a fresh gdb. | |
50 | ||
51 | gdb_exit | |
52 | gdb_start | |
53 | gdb_reinitialize_dir $srcdir/$subdir | |
54 | gdb_load $binfile | |
55 | ||
c906108c SS |
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} { | |
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 | # | |
085dd6e6 | 76 | |
c906108c SS |
77 | gdb_test "whatis v_char" \ |
78 | "type = (unsigned char|char)" \ | |
79 | "whatis char" | |
80 | ||
c906108c SS |
81 | if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" } |
82 | gdb_test "whatis v_signed_char" \ | |
d782e0bf | 83 | "type = (signed char|char)" \ |
c906108c SS |
84 | "whatis signed char" |
85 | ||
86 | gdb_test "whatis v_unsigned_char" \ | |
87 | "type = unsigned char" \ | |
88 | "whatis unsigned char" | |
89 | ||
90 | gdb_test "whatis v_short" \ | |
91 | "type = (short|short int)" \ | |
92 | "whatis short" | |
93 | ||
94 | gdb_test "whatis v_signed_short" \ | |
95 | "type = (short|short int|signed short|signed short int)" \ | |
96 | "whatis signed short" | |
97 | ||
98 | gdb_test "whatis v_unsigned_short" \ | |
99 | "type = (unsigned short|short unsigned int)" \ | |
100 | "whatis unsigned short" | |
101 | ||
102 | gdb_test "whatis v_int" \ | |
103 | "type = int" \ | |
104 | "whatis int" | |
105 | ||
106 | gdb_test "whatis v_signed_int" \ | |
107 | "type = (signed |)int" \ | |
108 | "whatis signed int" | |
109 | ||
110 | gdb_test "whatis v_unsigned_int" \ | |
111 | "type = unsigned int" \ | |
112 | "whatis unsigned int" | |
113 | ||
114 | setup_xfail_on_long_vs_int | |
115 | # AIX xlc gets this wrong and unsigned long right. Go figure. | |
116 | if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"} | |
117 | gdb_test "whatis v_long" \ | |
118 | "type = (long|long int)" \ | |
119 | "whatis long" | |
120 | ||
121 | setup_xfail_on_long_vs_int | |
122 | # AIX xlc gets this wrong and unsigned long right. Go figure. | |
123 | if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"} | |
124 | gdb_test "whatis v_signed_long" \ | |
125 | "type = (signed |)(long|long int)" \ | |
126 | "whatis signed long" | |
127 | ||
128 | setup_xfail_on_long_vs_int | |
129 | gdb_test "whatis v_unsigned_long" \ | |
130 | "type = (unsigned long|long unsigned int)" \ | |
131 | "whatis unsigned long" | |
132 | ||
64b2fa04 PA |
133 | |
134 | if ![target_info exists no_long_long] { | |
135 | gdb_test "whatis v_unsigned_long_long" \ | |
136 | "type = (unsigned long long|long long unsigned int)" \ | |
137 | "whatis unsigned long long" | |
138 | } | |
139 | ||
c906108c SS |
140 | gdb_test "whatis v_float" \ |
141 | "type = float" \ | |
142 | "whatis float" | |
143 | ||
144 | gdb_test "whatis v_double" \ | |
145 | "type = double" \ | |
146 | "whatis double" | |
147 | ||
148 | ||
149 | # test whatis command with arrays | |
150 | # | |
151 | # We already tested whether char prints as "char", so here we accept | |
152 | # "unsigned char", "signed char", and other perversions. No need for more | |
153 | # than one xfail for the same thing. | |
154 | gdb_test "whatis v_char_array" \ | |
155 | "type = (signed |unsigned |)char \\\[2\\\]" \ | |
156 | "whatis char array" | |
157 | ||
158 | gdb_test "whatis v_signed_char_array" \ | |
159 | "type = (signed |unsigned |)char \\\[2\\\]" \ | |
160 | "whatis signed char array" | |
161 | ||
162 | gdb_test "whatis v_unsigned_char_array" \ | |
163 | "type = unsigned char \\\[2\\\]" \ | |
164 | "whatis unsigned char array" | |
165 | ||
166 | gdb_test "whatis v_short_array" \ | |
167 | "type = (short|short int) \\\[2\\\]" \ | |
168 | "whatis short array" | |
169 | ||
170 | gdb_test "whatis v_signed_short_array" \ | |
171 | "type = (signed |)(short|short int) \\\[2\\\]" \ | |
172 | "whatis signed short array" | |
173 | ||
174 | gdb_test "whatis v_unsigned_short_array" \ | |
175 | "type = (unsigned short|short unsigned int) \\\[2\\\]" \ | |
176 | "whatis unsigned short array" | |
177 | ||
178 | gdb_test "whatis v_int_array" \ | |
179 | "type = int \\\[2\\\]" \ | |
180 | "whatis int array" | |
181 | ||
182 | gdb_test "whatis v_signed_int_array" \ | |
183 | "type = (signed |)int \\\[2\\\]" \ | |
184 | "whatis signed int array" | |
185 | ||
186 | gdb_test "whatis v_unsigned_int_array" \ | |
187 | "type = unsigned int \\\[2\\\]" \ | |
188 | "whatis unsigned int array" | |
189 | ||
190 | # We already tested whether long prints as long, so here we accept int | |
191 | # No need for more than one xfail for the same thing. | |
192 | gdb_test "whatis v_long_array" \ | |
193 | "type = (int|long|long int) \\\[2\\\]" \ | |
194 | "whatis long array" | |
195 | ||
196 | gdb_test "whatis v_signed_long_array" \ | |
197 | "type = (signed |)(int|long|long int) \\\[2\\\]" \ | |
198 | "whatis signed long array" | |
199 | ||
200 | gdb_test "whatis v_unsigned_long_array" \ | |
201 | "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \ | |
202 | "whatis unsigned long array" | |
203 | ||
64b2fa04 PA |
204 | if ![target_info exists no_long_long] { |
205 | gdb_test "whatis v_unsigned_long_long_array" \ | |
206 | "type = (unsigned long long|long long unsigned int) \\\[2\\\]" \ | |
207 | "whatis unsigned long array" | |
208 | } | |
209 | ||
c906108c SS |
210 | gdb_test "whatis v_float_array" \ |
211 | "type = float \\\[2\\\]" \ | |
212 | "whatis float array" | |
213 | ||
214 | gdb_test "whatis v_double_array" \ | |
215 | "type = double \\\[2\\\]" \ | |
216 | "whatis double array" | |
217 | ||
218 | ||
219 | # test whatis command with pointers | |
220 | # | |
221 | # We already tested whether char prints as char, so accept various perversions | |
222 | # here. We especially want to make sure we test that it doesn't print as | |
223 | # caddr_t. | |
224 | gdb_test "whatis v_char_pointer" \ | |
225 | "type = (unsigned |signed |)char \\*" \ | |
226 | "whatis char pointer" | |
227 | ||
228 | gdb_test "whatis v_signed_char_pointer" \ | |
229 | "type = (unsigned |signed |)char \\*" \ | |
230 | "whatis signed char pointer" | |
231 | ||
232 | gdb_test "whatis v_unsigned_char_pointer" \ | |
233 | "type = unsigned char \\*" \ | |
234 | "whatis unsigned char pointer" | |
235 | ||
236 | gdb_test "whatis v_short_pointer" \ | |
237 | "type = (short|short int) \\*" \ | |
238 | "whatis short pointer" | |
239 | ||
240 | gdb_test "whatis v_signed_short_pointer" \ | |
241 | "type = (signed |)(short|short int) \\*" \ | |
242 | "whatis signed short pointer" | |
243 | ||
244 | gdb_test "whatis v_unsigned_short_pointer" \ | |
245 | "type = (unsigned short|short unsigned int) \\*" \ | |
246 | "whatis unsigned short pointer" | |
247 | ||
248 | gdb_test "whatis v_int_pointer" \ | |
249 | "type = int \\*" \ | |
250 | "whatis int pointer" | |
251 | ||
252 | gdb_test "whatis v_signed_int_pointer" \ | |
253 | "type = (signed |)int \\*" \ | |
254 | "whatis signed int pointer" | |
255 | ||
256 | gdb_test "whatis v_unsigned_int_pointer" \ | |
257 | "type = unsigned int \\*" \ | |
258 | "whatis unsigned int pointer" | |
259 | ||
260 | # We already tested whether long prints as long, so here we accept int | |
261 | gdb_test "whatis v_long_pointer" \ | |
262 | "type = (long|int|long int) \\*" \ | |
263 | "whatis long pointer" | |
264 | ||
265 | gdb_test "whatis v_signed_long_pointer" \ | |
266 | "type = (signed |)(long|int|long int) \\*" \ | |
267 | "whatis signed long pointer" | |
268 | ||
269 | gdb_test "whatis v_unsigned_long_pointer" \ | |
270 | "type = (unsigned (int|long|long int)|long unsigned int) \\*" \ | |
271 | "whatis unsigned long pointer" | |
272 | ||
64b2fa04 PA |
273 | if ![target_info exists no_long_long] { |
274 | gdb_test "whatis v_long_long_pointer" \ | |
275 | "type = long long(| int) \\*" \ | |
276 | "whatis long long pointer" | |
277 | ||
278 | gdb_test "whatis v_signed_long_long_pointer" \ | |
279 | "type = (signed |)long long(| int) \\*" \ | |
280 | "whatis signed long long pointer" | |
281 | ||
282 | gdb_test "whatis v_unsigned_long_long_pointer" \ | |
283 | "type = (unsigned long long|long long unsigned int) \\*" \ | |
284 | "whatis unsigned long long pointer" | |
285 | } | |
286 | ||
c906108c SS |
287 | gdb_test "whatis v_float_pointer" \ |
288 | "type = float \\*" \ | |
289 | "whatis float pointer" | |
290 | ||
291 | gdb_test "whatis v_double_pointer" \ | |
292 | "type = double \\*" \ | |
293 | "whatis double pointer" | |
294 | ||
295 | ||
085dd6e6 JM |
296 | if { $hp_aCC_compiler } { |
297 | set unstruct "unnamed\.struct\..*" | |
298 | set ununion "unnamed\.union\..*" | |
299 | } else { | |
300 | set unstruct "\.\.\." | |
301 | set ununion "\.\.\." | |
302 | } | |
303 | ||
c906108c SS |
304 | # test whatis command with structure types |
305 | gdb_test "whatis v_struct1" \ | |
306 | "type = struct t_struct" \ | |
307 | "whatis named structure" | |
308 | ||
f8261448 FF |
309 | gdb_test "whatis struct t_struct" \ |
310 | "type = struct t_struct" \ | |
311 | "whatis named structure using type name" | |
312 | ||
c906108c | 313 | gdb_test "whatis v_struct2" \ |
085dd6e6 | 314 | "type = struct \{$unstruct\}" \ |
c906108c SS |
315 | "whatis unnamed structure" |
316 | ||
317 | ||
318 | # test whatis command with union types | |
319 | gdb_test "whatis v_union" \ | |
320 | "type = union t_union" \ | |
321 | "whatis named union" | |
322 | ||
f8261448 FF |
323 | gdb_test "whatis union t_union" \ |
324 | "type = union t_union" \ | |
325 | "whatis named union using type name" | |
326 | ||
c906108c | 327 | gdb_test "whatis v_union2" \ |
085dd6e6 | 328 | "type = union \{$ununion\}" \ |
c906108c SS |
329 | "whatis unnamed union" |
330 | ||
331 | ||
1e698235 DJ |
332 | # HP-UX: HP aCC compiler w/ +objdebug option detects language as |
333 | # c++, so we need the 'void' pattern here. | |
334 | # Without +objdebug compilation option we still need to match ''. | |
335 | # - guo | |
336 | # Also, using stabs we will mark these functions as prototyped. This | |
337 | # is harmless but causes an extra VOID to be printed. | |
338 | set void "(void|)" | |
c906108c SS |
339 | |
340 | # test whatis command with functions return type | |
341 | gdb_test "whatis v_char_func" \ | |
085dd6e6 | 342 | "type = (signed |unsigned |)char \\($void\\)" \ |
c906108c SS |
343 | "whatis char function" |
344 | ||
345 | gdb_test "whatis v_signed_char_func" \ | |
085dd6e6 | 346 | "type = (signed |unsigned |)char \\($void\\)" \ |
c906108c SS |
347 | "whatis signed char function" |
348 | ||
349 | gdb_test "whatis v_unsigned_char_func" \ | |
085dd6e6 | 350 | "type = unsigned char \\($void\\)" \ |
c906108c SS |
351 | "whatis unsigned char function" |
352 | ||
353 | gdb_test "whatis v_short_func" \ | |
085dd6e6 | 354 | "type = short (int |)\\($void\\)" \ |
c906108c SS |
355 | "whatis short function" |
356 | ||
357 | gdb_test "whatis v_signed_short_func" \ | |
085dd6e6 | 358 | "type = (signed |)short (int |)\\($void\\)" \ |
c906108c SS |
359 | "whatis signed short function" |
360 | ||
361 | gdb_test "whatis v_unsigned_short_func" \ | |
085dd6e6 | 362 | "type = (unsigned short|short unsigned int) \\($void\\)" \ |
c906108c SS |
363 | "whatis unsigned short function" |
364 | ||
365 | gdb_test "whatis v_int_func" \ | |
085dd6e6 | 366 | "type = int \\($void\\)" \ |
c906108c SS |
367 | "whatis int function" |
368 | ||
369 | gdb_test "whatis v_signed_int_func" \ | |
085dd6e6 | 370 | "type = (signed |)int \\($void\\)" \ |
c906108c SS |
371 | "whatis signed int function" |
372 | ||
373 | gdb_test "whatis v_unsigned_int_func" \ | |
085dd6e6 | 374 | "type = unsigned int \\($void\\)" \ |
c906108c SS |
375 | "whatis unsigned int function" |
376 | ||
377 | gdb_test "whatis v_long_func" \ | |
085dd6e6 | 378 | "type = (long|int|long int) \\($void\\)" \ |
c906108c SS |
379 | "whatis long function" |
380 | ||
381 | gdb_test "whatis v_signed_long_func" \ | |
085dd6e6 | 382 | "type = (signed |)(int|long|long int) \\($void\\)" \ |
c906108c SS |
383 | "whatis signed long function" |
384 | ||
385 | gdb_test "whatis v_unsigned_long_func" \ | |
085dd6e6 | 386 | "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \ |
c906108c SS |
387 | "whatis unsigned long function" |
388 | ||
64b2fa04 PA |
389 | if ![target_info exists no_long_long] { |
390 | gdb_test "whatis v_long_long_func" \ | |
391 | "type = long long(| int) \\($void\\)" \ | |
392 | "whatis long long function" | |
393 | ||
394 | gdb_test "whatis v_signed_long_long_func" \ | |
395 | "type = (signed |)long long(| int) \\($void\\)" \ | |
396 | "whatis signed long long function" | |
397 | ||
398 | gdb_test "whatis v_unsigned_long_long_func" \ | |
399 | "type = (unsigned long long(| int)|long long unsigned int) \\($void\\)" \ | |
400 | "whatis unsigned long long function" | |
401 | } | |
402 | ||
c906108c SS |
403 | # Sun /bin/cc calls this a function returning double. |
404 | if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"} | |
405 | gdb_test "whatis v_float_func" \ | |
085dd6e6 | 406 | "type = float \\($void\\)" \ |
c906108c SS |
407 | "whatis float function" |
408 | ||
409 | gdb_test "whatis v_double_func" \ | |
085dd6e6 | 410 | "type = double \\($void\\)" \ |
c906108c SS |
411 | "whatis double function" \ |
412 | ||
413 | ||
414 | # test whatis command with some misc complicated types | |
415 | gdb_test "whatis s_link" \ | |
416 | "type = struct link \\*" \ | |
417 | "whatis complicated structure" | |
418 | ||
419 | gdb_test "whatis u_link" \ | |
420 | "type = union tu_link" \ | |
421 | "whatis complicated union" | |
422 | ||
423 | ||
424 | # test whatis command with enumerations | |
425 | gdb_test "whatis clunker" \ | |
426 | "type = enum cars" \ | |
427 | "whatis enumeration" | |
428 | ||
f8261448 FF |
429 | gdb_test "whatis enum cars" \ |
430 | "type = enum cars" \ | |
431 | "whatis enumeration using type name" | |
432 | ||
c906108c SS |
433 | |
434 | # test whatis command with nested struct and union | |
435 | gdb_test "whatis nested_su" \ | |
436 | "type = struct outer_struct" \ | |
437 | "whatis outer structure" | |
438 | ||
439 | gdb_test "whatis nested_su.outer_int" \ | |
440 | "type = int" \ | |
441 | "whatis outer structure member" | |
442 | ||
085dd6e6 JM |
443 | if {$hp_aCC_compiler} { |
444 | set outer "outer_struct::" | |
445 | } else { | |
446 | set outer "" | |
447 | } | |
448 | ||
c906108c | 449 | gdb_test "whatis nested_su.inner_struct_instance" \ |
085dd6e6 | 450 | "type = struct ${outer}inner_struct" \ |
c906108c SS |
451 | "whatis inner structure" |
452 | ||
453 | gdb_test "whatis nested_su.inner_struct_instance.inner_int" \ | |
454 | "type = int" \ | |
455 | "whatis inner structure member" | |
456 | ||
457 | gdb_test "whatis nested_su.inner_union_instance" \ | |
085dd6e6 | 458 | "type = union ${outer}inner_union" \ |
c906108c SS |
459 | "whatis inner union" |
460 | ||
461 | gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \ | |
462 | "type = int" \ | |
463 | "whatis inner union member" | |
f8261448 FF |
464 | |
465 | # test whatis command with typedefs | |
466 | ||
467 | gdb_test "whatis char_addr" \ | |
468 | "type = char \\*" \ | |
469 | "whatis using typedef type name" | |
470 | ||
471 | gdb_test "whatis a_char_addr" \ | |
472 | "type = char_addr" \ | |
473 | "whatis applied to variable defined by typedef" |