Commit | Line | Data |
---|---|---|
0b302171 JB |
1 | # Copyright 1988, 1990-1992, 1994-1997, 1999, 2002-2004, 2007-2012 Free |
2 | # 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 | ||
c906108c SS |
19 | # |
20 | # test running programs | |
21 | # | |
c906108c | 22 | |
64b2fa04 PA |
23 | if [target_info exists no_long_long] { |
24 | set exec_opts [list debug additional_flags=-DNO_LONG_LONG] | |
25 | } else { | |
26 | set exec_opts [list debug] | |
27 | } | |
28 | ||
c906108c SS |
29 | set testfile whatis |
30 | set srcfile ${testfile}.c | |
31 | set binfile ${objdir}/${subdir}/${testfile} | |
64b2fa04 | 32 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $exec_opts] != "" } { |
b60f0898 JB |
33 | untested whatis.exp |
34 | return -1 | |
c906108c SS |
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 | ||
64b2fa04 PA |
127 | |
128 | if ![target_info exists no_long_long] { | |
129 | gdb_test "whatis v_unsigned_long_long" \ | |
130 | "type = (unsigned long long|long long unsigned int)" \ | |
131 | "whatis unsigned long long" | |
132 | } | |
133 | ||
c906108c SS |
134 | gdb_test "whatis v_float" \ |
135 | "type = float" \ | |
136 | "whatis float" | |
137 | ||
138 | gdb_test "whatis v_double" \ | |
139 | "type = double" \ | |
140 | "whatis double" | |
141 | ||
142 | ||
143 | # test whatis command with arrays | |
144 | # | |
145 | # We already tested whether char prints as "char", so here we accept | |
146 | # "unsigned char", "signed char", and other perversions. No need for more | |
147 | # than one xfail for the same thing. | |
148 | gdb_test "whatis v_char_array" \ | |
149 | "type = (signed |unsigned |)char \\\[2\\\]" \ | |
150 | "whatis char array" | |
151 | ||
152 | gdb_test "whatis v_signed_char_array" \ | |
153 | "type = (signed |unsigned |)char \\\[2\\\]" \ | |
154 | "whatis signed char array" | |
155 | ||
156 | gdb_test "whatis v_unsigned_char_array" \ | |
157 | "type = unsigned char \\\[2\\\]" \ | |
158 | "whatis unsigned char array" | |
159 | ||
160 | gdb_test "whatis v_short_array" \ | |
161 | "type = (short|short int) \\\[2\\\]" \ | |
162 | "whatis short array" | |
163 | ||
164 | gdb_test "whatis v_signed_short_array" \ | |
165 | "type = (signed |)(short|short int) \\\[2\\\]" \ | |
166 | "whatis signed short array" | |
167 | ||
168 | gdb_test "whatis v_unsigned_short_array" \ | |
169 | "type = (unsigned short|short unsigned int) \\\[2\\\]" \ | |
170 | "whatis unsigned short array" | |
171 | ||
172 | gdb_test "whatis v_int_array" \ | |
173 | "type = int \\\[2\\\]" \ | |
174 | "whatis int array" | |
175 | ||
176 | gdb_test "whatis v_signed_int_array" \ | |
177 | "type = (signed |)int \\\[2\\\]" \ | |
178 | "whatis signed int array" | |
179 | ||
180 | gdb_test "whatis v_unsigned_int_array" \ | |
181 | "type = unsigned int \\\[2\\\]" \ | |
182 | "whatis unsigned int array" | |
183 | ||
184 | # We already tested whether long prints as long, so here we accept int | |
185 | # No need for more than one xfail for the same thing. | |
186 | gdb_test "whatis v_long_array" \ | |
187 | "type = (int|long|long int) \\\[2\\\]" \ | |
188 | "whatis long array" | |
189 | ||
190 | gdb_test "whatis v_signed_long_array" \ | |
191 | "type = (signed |)(int|long|long int) \\\[2\\\]" \ | |
192 | "whatis signed long array" | |
193 | ||
194 | gdb_test "whatis v_unsigned_long_array" \ | |
195 | "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \ | |
196 | "whatis unsigned long array" | |
197 | ||
64b2fa04 PA |
198 | if ![target_info exists no_long_long] { |
199 | gdb_test "whatis v_unsigned_long_long_array" \ | |
200 | "type = (unsigned long long|long long unsigned int) \\\[2\\\]" \ | |
201 | "whatis unsigned long array" | |
202 | } | |
203 | ||
c906108c SS |
204 | gdb_test "whatis v_float_array" \ |
205 | "type = float \\\[2\\\]" \ | |
206 | "whatis float array" | |
207 | ||
208 | gdb_test "whatis v_double_array" \ | |
209 | "type = double \\\[2\\\]" \ | |
210 | "whatis double array" | |
211 | ||
212 | ||
213 | # test whatis command with pointers | |
214 | # | |
215 | # We already tested whether char prints as char, so accept various perversions | |
216 | # here. We especially want to make sure we test that it doesn't print as | |
217 | # caddr_t. | |
218 | gdb_test "whatis v_char_pointer" \ | |
219 | "type = (unsigned |signed |)char \\*" \ | |
220 | "whatis char pointer" | |
221 | ||
222 | gdb_test "whatis v_signed_char_pointer" \ | |
223 | "type = (unsigned |signed |)char \\*" \ | |
224 | "whatis signed char pointer" | |
225 | ||
226 | gdb_test "whatis v_unsigned_char_pointer" \ | |
227 | "type = unsigned char \\*" \ | |
228 | "whatis unsigned char pointer" | |
229 | ||
230 | gdb_test "whatis v_short_pointer" \ | |
231 | "type = (short|short int) \\*" \ | |
232 | "whatis short pointer" | |
233 | ||
234 | gdb_test "whatis v_signed_short_pointer" \ | |
235 | "type = (signed |)(short|short int) \\*" \ | |
236 | "whatis signed short pointer" | |
237 | ||
238 | gdb_test "whatis v_unsigned_short_pointer" \ | |
239 | "type = (unsigned short|short unsigned int) \\*" \ | |
240 | "whatis unsigned short pointer" | |
241 | ||
242 | gdb_test "whatis v_int_pointer" \ | |
243 | "type = int \\*" \ | |
244 | "whatis int pointer" | |
245 | ||
246 | gdb_test "whatis v_signed_int_pointer" \ | |
247 | "type = (signed |)int \\*" \ | |
248 | "whatis signed int pointer" | |
249 | ||
250 | gdb_test "whatis v_unsigned_int_pointer" \ | |
251 | "type = unsigned int \\*" \ | |
252 | "whatis unsigned int pointer" | |
253 | ||
254 | # We already tested whether long prints as long, so here we accept int | |
255 | gdb_test "whatis v_long_pointer" \ | |
256 | "type = (long|int|long int) \\*" \ | |
257 | "whatis long pointer" | |
258 | ||
259 | gdb_test "whatis v_signed_long_pointer" \ | |
260 | "type = (signed |)(long|int|long int) \\*" \ | |
261 | "whatis signed long pointer" | |
262 | ||
263 | gdb_test "whatis v_unsigned_long_pointer" \ | |
264 | "type = (unsigned (int|long|long int)|long unsigned int) \\*" \ | |
265 | "whatis unsigned long pointer" | |
266 | ||
64b2fa04 PA |
267 | if ![target_info exists no_long_long] { |
268 | gdb_test "whatis v_long_long_pointer" \ | |
269 | "type = long long(| int) \\*" \ | |
270 | "whatis long long pointer" | |
271 | ||
272 | gdb_test "whatis v_signed_long_long_pointer" \ | |
273 | "type = (signed |)long long(| int) \\*" \ | |
274 | "whatis signed long long pointer" | |
275 | ||
276 | gdb_test "whatis v_unsigned_long_long_pointer" \ | |
277 | "type = (unsigned long long|long long unsigned int) \\*" \ | |
278 | "whatis unsigned long long pointer" | |
279 | } | |
280 | ||
c906108c SS |
281 | gdb_test "whatis v_float_pointer" \ |
282 | "type = float \\*" \ | |
283 | "whatis float pointer" | |
284 | ||
285 | gdb_test "whatis v_double_pointer" \ | |
286 | "type = double \\*" \ | |
287 | "whatis double pointer" | |
288 | ||
289 | ||
085dd6e6 JM |
290 | if { $hp_aCC_compiler } { |
291 | set unstruct "unnamed\.struct\..*" | |
292 | set ununion "unnamed\.union\..*" | |
293 | } else { | |
294 | set unstruct "\.\.\." | |
295 | set ununion "\.\.\." | |
296 | } | |
297 | ||
c906108c SS |
298 | # test whatis command with structure types |
299 | gdb_test "whatis v_struct1" \ | |
300 | "type = struct t_struct" \ | |
301 | "whatis named structure" | |
302 | ||
f8261448 FF |
303 | gdb_test "whatis struct t_struct" \ |
304 | "type = struct t_struct" \ | |
305 | "whatis named structure using type name" | |
306 | ||
c906108c | 307 | gdb_test "whatis v_struct2" \ |
085dd6e6 | 308 | "type = struct \{$unstruct\}" \ |
c906108c SS |
309 | "whatis unnamed structure" |
310 | ||
311 | ||
312 | # test whatis command with union types | |
313 | gdb_test "whatis v_union" \ | |
314 | "type = union t_union" \ | |
315 | "whatis named union" | |
316 | ||
f8261448 FF |
317 | gdb_test "whatis union t_union" \ |
318 | "type = union t_union" \ | |
319 | "whatis named union using type name" | |
320 | ||
c906108c | 321 | gdb_test "whatis v_union2" \ |
085dd6e6 | 322 | "type = union \{$ununion\}" \ |
c906108c SS |
323 | "whatis unnamed union" |
324 | ||
325 | ||
1e698235 DJ |
326 | # HP-UX: HP aCC compiler w/ +objdebug option detects language as |
327 | # c++, so we need the 'void' pattern here. | |
328 | # Without +objdebug compilation option we still need to match ''. | |
329 | # - guo | |
330 | # Also, using stabs we will mark these functions as prototyped. This | |
331 | # is harmless but causes an extra VOID to be printed. | |
332 | set void "(void|)" | |
c906108c SS |
333 | |
334 | # test whatis command with functions return type | |
335 | gdb_test "whatis v_char_func" \ | |
085dd6e6 | 336 | "type = (signed |unsigned |)char \\($void\\)" \ |
c906108c SS |
337 | "whatis char function" |
338 | ||
339 | gdb_test "whatis v_signed_char_func" \ | |
085dd6e6 | 340 | "type = (signed |unsigned |)char \\($void\\)" \ |
c906108c SS |
341 | "whatis signed char function" |
342 | ||
343 | gdb_test "whatis v_unsigned_char_func" \ | |
085dd6e6 | 344 | "type = unsigned char \\($void\\)" \ |
c906108c SS |
345 | "whatis unsigned char function" |
346 | ||
347 | gdb_test "whatis v_short_func" \ | |
085dd6e6 | 348 | "type = short (int |)\\($void\\)" \ |
c906108c SS |
349 | "whatis short function" |
350 | ||
351 | gdb_test "whatis v_signed_short_func" \ | |
085dd6e6 | 352 | "type = (signed |)short (int |)\\($void\\)" \ |
c906108c SS |
353 | "whatis signed short function" |
354 | ||
355 | gdb_test "whatis v_unsigned_short_func" \ | |
085dd6e6 | 356 | "type = (unsigned short|short unsigned int) \\($void\\)" \ |
c906108c SS |
357 | "whatis unsigned short function" |
358 | ||
359 | gdb_test "whatis v_int_func" \ | |
085dd6e6 | 360 | "type = int \\($void\\)" \ |
c906108c SS |
361 | "whatis int function" |
362 | ||
363 | gdb_test "whatis v_signed_int_func" \ | |
085dd6e6 | 364 | "type = (signed |)int \\($void\\)" \ |
c906108c SS |
365 | "whatis signed int function" |
366 | ||
367 | gdb_test "whatis v_unsigned_int_func" \ | |
085dd6e6 | 368 | "type = unsigned int \\($void\\)" \ |
c906108c SS |
369 | "whatis unsigned int function" |
370 | ||
371 | gdb_test "whatis v_long_func" \ | |
085dd6e6 | 372 | "type = (long|int|long int) \\($void\\)" \ |
c906108c SS |
373 | "whatis long function" |
374 | ||
375 | gdb_test "whatis v_signed_long_func" \ | |
085dd6e6 | 376 | "type = (signed |)(int|long|long int) \\($void\\)" \ |
c906108c SS |
377 | "whatis signed long function" |
378 | ||
379 | gdb_test "whatis v_unsigned_long_func" \ | |
085dd6e6 | 380 | "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \ |
c906108c SS |
381 | "whatis unsigned long function" |
382 | ||
64b2fa04 PA |
383 | if ![target_info exists no_long_long] { |
384 | gdb_test "whatis v_long_long_func" \ | |
385 | "type = long long(| int) \\($void\\)" \ | |
386 | "whatis long long function" | |
387 | ||
388 | gdb_test "whatis v_signed_long_long_func" \ | |
389 | "type = (signed |)long long(| int) \\($void\\)" \ | |
390 | "whatis signed long long function" | |
391 | ||
392 | gdb_test "whatis v_unsigned_long_long_func" \ | |
393 | "type = (unsigned long long(| int)|long long unsigned int) \\($void\\)" \ | |
394 | "whatis unsigned long long function" | |
395 | } | |
396 | ||
c906108c SS |
397 | # Sun /bin/cc calls this a function returning double. |
398 | if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"} | |
399 | gdb_test "whatis v_float_func" \ | |
085dd6e6 | 400 | "type = float \\($void\\)" \ |
c906108c SS |
401 | "whatis float function" |
402 | ||
403 | gdb_test "whatis v_double_func" \ | |
085dd6e6 | 404 | "type = double \\($void\\)" \ |
c906108c SS |
405 | "whatis double function" \ |
406 | ||
407 | ||
408 | # test whatis command with some misc complicated types | |
409 | gdb_test "whatis s_link" \ | |
410 | "type = struct link \\*" \ | |
411 | "whatis complicated structure" | |
412 | ||
413 | gdb_test "whatis u_link" \ | |
414 | "type = union tu_link" \ | |
415 | "whatis complicated union" | |
416 | ||
417 | ||
418 | # test whatis command with enumerations | |
419 | gdb_test "whatis clunker" \ | |
420 | "type = enum cars" \ | |
421 | "whatis enumeration" | |
422 | ||
f8261448 FF |
423 | gdb_test "whatis enum cars" \ |
424 | "type = enum cars" \ | |
425 | "whatis enumeration using type name" | |
426 | ||
c906108c SS |
427 | |
428 | # test whatis command with nested struct and union | |
429 | gdb_test "whatis nested_su" \ | |
430 | "type = struct outer_struct" \ | |
431 | "whatis outer structure" | |
432 | ||
433 | gdb_test "whatis nested_su.outer_int" \ | |
434 | "type = int" \ | |
435 | "whatis outer structure member" | |
436 | ||
085dd6e6 JM |
437 | if {$hp_aCC_compiler} { |
438 | set outer "outer_struct::" | |
439 | } else { | |
440 | set outer "" | |
441 | } | |
442 | ||
c906108c | 443 | gdb_test "whatis nested_su.inner_struct_instance" \ |
085dd6e6 | 444 | "type = struct ${outer}inner_struct" \ |
c906108c SS |
445 | "whatis inner structure" |
446 | ||
447 | gdb_test "whatis nested_su.inner_struct_instance.inner_int" \ | |
448 | "type = int" \ | |
449 | "whatis inner structure member" | |
450 | ||
451 | gdb_test "whatis nested_su.inner_union_instance" \ | |
085dd6e6 | 452 | "type = union ${outer}inner_union" \ |
c906108c SS |
453 | "whatis inner union" |
454 | ||
455 | gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \ | |
456 | "type = int" \ | |
457 | "whatis inner union member" | |
f8261448 FF |
458 | |
459 | # test whatis command with typedefs | |
460 | ||
461 | gdb_test "whatis char_addr" \ | |
462 | "type = char \\*" \ | |
463 | "whatis using typedef type name" | |
464 | ||
465 | gdb_test "whatis a_char_addr" \ | |
466 | "type = char_addr" \ | |
467 | "whatis applied to variable defined by typedef" | |
95c391b6 TT |
468 | |
469 | # Regression tests for PR 9514. | |
470 | ||
471 | gdb_test "whatis void (**)()" \ | |
472 | "type = void \\(\\*\\*\\)\\(\\)" \ | |
473 | "whatis applied to pointer to pointer to function" | |
474 | ||
475 | gdb_test "whatis void (** const)()" \ | |
476 | "type = void \\(\\*\\* const\\)\\(\\)" \ | |
477 | "whatis applied to const pointer to pointer to function" | |
478 | ||
479 | gdb_test "whatis void (* const *)()" \ | |
480 | "type = void \\(\\* const \\*\\)\\(\\)" \ | |
481 | "whatis applied to pointer to const pointer to function" |