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