Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 1988-2020 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 | ||
c906108c SS |
30 | # Define a procedure to set up an xfail for all targets that put out a |
31 | # `long' type as an `int' type. | |
09dd9a69 | 32 | # Sun cc has this problem. |
c906108c SS |
33 | # It was said that COFF targets can not distinguish int from long either. |
34 | ||
35 | proc setup_xfail_on_long_vs_int {} { | |
36 | global gcc_compiled | |
37 | ||
38 | if {!$gcc_compiled} { | |
09dd9a69 | 39 | setup_xfail "*-sun-sunos4*" "i*86-sequent-bsd*" |
c906108c SS |
40 | } |
41 | } | |
42 | ||
0b8dbf3f AB |
43 | # Compile the test using OPTIONS into a sub-directory DIR, and then |
44 | # run the test. | |
45 | proc do_test {dir options} { | |
46 | global srcfile testfile gcc_compiled | |
085dd6e6 | 47 | |
0b8dbf3f AB |
48 | set binfile [standard_output_file ${dir}/${testfile}] |
49 | if { [prepare_for_testing "failed to prepare" ${binfile} \ | |
50 | [list $srcfile] $options] } { | |
51 | return 0 | |
52 | } | |
64b2fa04 | 53 | |
0b8dbf3f AB |
54 | clean_restart ${binfile} |
55 | ||
56 | # | |
57 | # Test whatis command with basic C types | |
58 | # | |
59 | # The name printed now (as of 23 May 1993) is whatever name the compiler | |
60 | # uses in the stabs. So we need to deal with names both from gcc and | |
61 | # native compilers. | |
62 | # | |
63 | ||
64 | gdb_test "whatis v_char" \ | |
65 | "type = (unsigned char|char)" \ | |
66 | "whatis char" | |
67 | ||
68 | gdb_test "whatis v_signed_char" \ | |
69 | "type = (signed char|char)" \ | |
70 | "whatis signed char" | |
71 | ||
72 | gdb_test "whatis v_unsigned_char" \ | |
73 | "type = unsigned char" \ | |
74 | "whatis unsigned char" | |
75 | ||
76 | gdb_test "whatis v_short" \ | |
77 | "type = (short|short int)" \ | |
78 | "whatis short" | |
79 | ||
80 | gdb_test "whatis v_signed_short" \ | |
81 | "type = (short|short int|signed short|signed short int)" \ | |
82 | "whatis signed short" | |
83 | ||
84 | gdb_test "whatis v_unsigned_short" \ | |
85 | "type = (unsigned short|short unsigned int)" \ | |
86 | "whatis unsigned short" | |
87 | ||
88 | gdb_test "whatis v_int" \ | |
89 | "type = int" \ | |
90 | "whatis int" | |
91 | ||
92 | gdb_test "whatis v_signed_int" \ | |
93 | "type = (signed |)int" \ | |
94 | "whatis signed int" | |
95 | ||
96 | gdb_test "whatis v_unsigned_int" \ | |
97 | "type = unsigned int" \ | |
98 | "whatis unsigned int" | |
99 | ||
100 | setup_xfail_on_long_vs_int | |
101 | # AIX xlc gets this wrong and unsigned long right. Go figure. | |
102 | if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"} | |
103 | gdb_test "whatis v_long" \ | |
104 | "type = (long|long int)" \ | |
105 | "whatis long" | |
106 | ||
107 | setup_xfail_on_long_vs_int | |
108 | # AIX xlc gets this wrong and unsigned long right. Go figure. | |
109 | if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"} | |
110 | gdb_test "whatis v_signed_long" \ | |
111 | "type = (signed |)(long|long int)" \ | |
112 | "whatis signed long" | |
113 | ||
114 | setup_xfail_on_long_vs_int | |
115 | gdb_test "whatis v_unsigned_long" \ | |
116 | "type = (unsigned long|long unsigned int)" \ | |
117 | "whatis unsigned long" | |
118 | ||
119 | ||
120 | if ![target_info exists no_long_long] { | |
121 | gdb_test "whatis v_unsigned_long_long" \ | |
122 | "type = (unsigned long long|long long unsigned int)" \ | |
123 | "whatis unsigned long long" | |
124 | } | |
c906108c | 125 | |
0b8dbf3f AB |
126 | gdb_test "whatis v_float" \ |
127 | "type = float" \ | |
128 | "whatis float" | |
c906108c | 129 | |
0b8dbf3f AB |
130 | gdb_test "whatis v_double" \ |
131 | "type = double" \ | |
132 | "whatis double" | |
c906108c | 133 | |
64b2fa04 | 134 | |
0b8dbf3f AB |
135 | # test whatis command with arrays |
136 | # | |
137 | # We already tested whether char prints as "char", so here we accept | |
138 | # "unsigned char", "signed char", and other perversions. No need for more | |
139 | # than one xfail for the same thing. | |
140 | gdb_test "whatis v_char_array" \ | |
141 | "type = (signed |unsigned |)char \\\[2\\\]" \ | |
142 | "whatis char array" | |
c906108c | 143 | |
0b8dbf3f AB |
144 | gdb_test "whatis v_signed_char_array" \ |
145 | "type = (signed |unsigned |)char \\\[2\\\]" \ | |
146 | "whatis signed char array" | |
c906108c | 147 | |
0b8dbf3f AB |
148 | gdb_test "whatis v_unsigned_char_array" \ |
149 | "type = unsigned char \\\[2\\\]" \ | |
150 | "whatis unsigned char array" | |
c906108c | 151 | |
0b8dbf3f AB |
152 | gdb_test "whatis v_short_array" \ |
153 | "type = (short|short int) \\\[2\\\]" \ | |
154 | "whatis short array" | |
64b2fa04 | 155 | |
0b8dbf3f AB |
156 | gdb_test "whatis v_signed_short_array" \ |
157 | "type = (signed |)(short|short int) \\\[2\\\]" \ | |
158 | "whatis signed short array" | |
c906108c | 159 | |
0b8dbf3f AB |
160 | gdb_test "whatis v_unsigned_short_array" \ |
161 | "type = (unsigned short|short unsigned int) \\\[2\\\]" \ | |
162 | "whatis unsigned short array" | |
c906108c | 163 | |
0b8dbf3f AB |
164 | gdb_test "whatis v_int_array" \ |
165 | "type = int \\\[2\\\]" \ | |
166 | "whatis int array" | |
c906108c | 167 | |
0b8dbf3f AB |
168 | gdb_test "whatis v_signed_int_array" \ |
169 | "type = (signed |)int \\\[2\\\]" \ | |
170 | "whatis signed int array" | |
5c319bb2 | 171 | |
0b8dbf3f AB |
172 | gdb_test "whatis v_unsigned_int_array" \ |
173 | "type = unsigned int \\\[2\\\]" \ | |
174 | "whatis unsigned int array" | |
5c319bb2 | 175 | |
0b8dbf3f AB |
176 | # We already tested whether long prints as long, so here we accept int |
177 | # No need for more than one xfail for the same thing. | |
178 | gdb_test "whatis v_long_array" \ | |
179 | "type = (int|long|long int) \\\[2\\\]" \ | |
180 | "whatis long array" | |
5c319bb2 | 181 | |
0b8dbf3f AB |
182 | gdb_test "whatis v_signed_long_array" \ |
183 | "type = (signed |)(int|long|long int) \\\[2\\\]" \ | |
184 | "whatis signed long array" | |
5c319bb2 | 185 | |
0b8dbf3f AB |
186 | gdb_test "whatis v_unsigned_long_array" \ |
187 | "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \ | |
188 | "whatis unsigned long array" | |
5c319bb2 | 189 | |
0b8dbf3f AB |
190 | if ![target_info exists no_long_long] { |
191 | gdb_test "whatis v_unsigned_long_long_array" \ | |
192 | "type = (unsigned long long|long long unsigned int) \\\[2\\\]" \ | |
193 | "whatis unsigned long long array" | |
194 | } | |
5c319bb2 | 195 | |
0b8dbf3f AB |
196 | gdb_test "whatis v_float_array" \ |
197 | "type = float \\\[2\\\]" \ | |
198 | "whatis float array" | |
199 | ||
200 | gdb_test "whatis v_double_array" \ | |
201 | "type = double \\\[2\\\]" \ | |
202 | "whatis double array" | |
203 | ||
204 | # test whatis command with pointers | |
205 | # | |
206 | # We already tested whether char prints as char, so accept various perversions | |
207 | # here. We especially want to make sure we test that it doesn't print as | |
208 | # caddr_t. | |
209 | gdb_test "whatis v_char_pointer" \ | |
210 | "type = (unsigned |signed |)char \\*" \ | |
211 | "whatis char pointer" | |
212 | ||
213 | gdb_test "whatis v_signed_char_pointer" \ | |
214 | "type = (unsigned |signed |)char \\*" \ | |
215 | "whatis signed char pointer" | |
216 | ||
217 | gdb_test "whatis v_unsigned_char_pointer" \ | |
218 | "type = unsigned char \\*" \ | |
219 | "whatis unsigned char pointer" | |
220 | ||
221 | gdb_test "whatis v_short_pointer" \ | |
222 | "type = (short|short int) \\*" \ | |
223 | "whatis short pointer" | |
224 | ||
225 | gdb_test "whatis v_signed_short_pointer" \ | |
226 | "type = (signed |)(short|short int) \\*" \ | |
227 | "whatis signed short pointer" | |
228 | ||
229 | gdb_test "whatis v_unsigned_short_pointer" \ | |
230 | "type = (unsigned short|short unsigned int) \\*" \ | |
231 | "whatis unsigned short pointer" | |
232 | ||
233 | gdb_test "whatis v_int_pointer" \ | |
234 | "type = int \\*" \ | |
235 | "whatis int pointer" | |
236 | ||
237 | gdb_test "whatis v_signed_int_pointer" \ | |
238 | "type = (signed |)int \\*" \ | |
239 | "whatis signed int pointer" | |
240 | ||
241 | gdb_test "whatis v_unsigned_int_pointer" \ | |
242 | "type = unsigned int \\*" \ | |
243 | "whatis unsigned int pointer" | |
244 | ||
245 | # We already tested whether long prints as long, so here we accept int | |
246 | gdb_test "whatis v_long_pointer" \ | |
247 | "type = (long|int|long int) \\*" \ | |
248 | "whatis long pointer" | |
249 | ||
250 | gdb_test "whatis v_signed_long_pointer" \ | |
251 | "type = (signed |)(long|int|long int) \\*" \ | |
252 | "whatis signed long pointer" | |
253 | ||
254 | gdb_test "whatis v_unsigned_long_pointer" \ | |
255 | "type = (unsigned (int|long|long int)|long unsigned int) \\*" \ | |
256 | "whatis unsigned long pointer" | |
257 | ||
258 | if ![target_info exists no_long_long] { | |
259 | gdb_test "whatis v_long_long_pointer" \ | |
260 | "type = long long(| int) \\*" \ | |
261 | "whatis long long pointer" | |
262 | ||
263 | gdb_test "whatis v_signed_long_long_pointer" \ | |
264 | "type = (signed |)long long(| int) \\*" \ | |
265 | "whatis signed long long pointer" | |
266 | ||
267 | gdb_test "whatis v_unsigned_long_long_pointer" \ | |
268 | "type = (unsigned long long|long long unsigned int) \\*" \ | |
269 | "whatis unsigned long long pointer" | |
270 | } | |
c906108c | 271 | |
0b8dbf3f AB |
272 | gdb_test "whatis v_float_pointer" \ |
273 | "type = float \\*" \ | |
274 | "whatis float pointer" | |
c906108c | 275 | |
0b8dbf3f AB |
276 | gdb_test "whatis v_double_pointer" \ |
277 | "type = double \\*" \ | |
278 | "whatis double pointer" | |
ac775bf4 | 279 | |
ac775bf4 | 280 | |
0b8dbf3f | 281 | # test whatis command with structure types |
ac775bf4 | 282 | |
0b8dbf3f AB |
283 | # First with a type argument, with both "set print object" set to "on" |
284 | # and "off", ending with "off" for the following tests. | |
285 | foreach_with_prefix print_object {"on" "off"} { | |
286 | gdb_test_no_output "set print object $print_object" | |
ac775bf4 | 287 | |
0b8dbf3f AB |
288 | gdb_test "whatis struct t_struct" \ |
289 | "type = struct t_struct" \ | |
290 | "whatis named structure using type name" | |
ac775bf4 | 291 | |
0b8dbf3f AB |
292 | gdb_test "whatis struct t_struct *" \ |
293 | "type = struct t_struct \\*" \ | |
294 | "whatis named structure using type name and pointer" | |
ac775bf4 | 295 | |
0b8dbf3f AB |
296 | gdb_test "whatis struct t_struct &" \ |
297 | "type = struct t_struct &" \ | |
298 | "whatis named structure using type name and reference" | |
299 | } | |
ac775bf4 | 300 | |
0b8dbf3f | 301 | # Now with an expression argument. |
ac775bf4 | 302 | |
0b8dbf3f AB |
303 | gdb_test "whatis v_struct1" \ |
304 | "type = struct t_struct" \ | |
305 | "whatis named structure" | |
ac775bf4 | 306 | |
0b8dbf3f AB |
307 | gdb_test "whatis v_struct2" \ |
308 | "type = struct \{\.\.\.\}" \ | |
309 | "whatis unnamed structure" | |
ac775bf4 | 310 | |
0b8dbf3f AB |
311 | gdb_test "whatis &v_struct1" \ |
312 | "type = struct t_struct \\*" | |
ac775bf4 | 313 | |
0b8dbf3f AB |
314 | gdb_test "whatis &v_struct2" \ |
315 | "type = struct {\\.\\.\\.} \\*" | |
ac775bf4 | 316 | |
0b8dbf3f AB |
317 | gdb_test "whatis v_struct_ptr1" \ |
318 | "type = struct t_struct \\*" | |
ac775bf4 | 319 | |
0b8dbf3f AB |
320 | gdb_test "whatis v_struct_ptr2" \ |
321 | "type = struct {\\.\\.\\.} \\*" | |
c906108c | 322 | |
0b8dbf3f AB |
323 | gdb_test "whatis &v_struct_ptr1" \ |
324 | "type = struct t_struct \\*\\*" | |
c906108c | 325 | |
0b8dbf3f AB |
326 | gdb_test "whatis &v_struct_ptr2" \ |
327 | "type = struct {\\.\\.\\.} \\*\\*" | |
f8261448 | 328 | |
0b8dbf3f AB |
329 | gdb_test "whatis v_struct1.v_char_member" \ |
330 | "type = char" | |
c906108c | 331 | |
0b8dbf3f AB |
332 | gdb_test "whatis v_struct2.v_char_member" \ |
333 | "type = char" | |
ac775bf4 | 334 | |
0b8dbf3f AB |
335 | gdb_test "whatis v_struct_ptr1->v_char_member" \ |
336 | "type = char" | |
ac775bf4 | 337 | |
0b8dbf3f AB |
338 | gdb_test "whatis v_struct_ptr2->v_char_member" \ |
339 | "type = char" | |
ac775bf4 | 340 | |
0b8dbf3f AB |
341 | gdb_test "whatis &(v_struct1.v_char_member)" \ |
342 | "type = char \\*" | |
ac775bf4 | 343 | |
0b8dbf3f AB |
344 | gdb_test "whatis &(v_struct2.v_char_member)" \ |
345 | "type = char \\*" | |
ac775bf4 | 346 | |
0b8dbf3f AB |
347 | gdb_test "whatis &(v_struct_ptr1->v_char_member)" \ |
348 | "type = char \\*" | |
ac775bf4 | 349 | |
0b8dbf3f AB |
350 | gdb_test "whatis &(v_struct_ptr2->v_char_member)" \ |
351 | "type = char \\*" | |
ac775bf4 | 352 | |
0b8dbf3f AB |
353 | # test whatis command with union types |
354 | gdb_test "whatis v_union" \ | |
355 | "type = union t_union" \ | |
356 | "whatis named union" | |
ac775bf4 | 357 | |
0b8dbf3f AB |
358 | gdb_test "whatis union t_union" \ |
359 | "type = union t_union" \ | |
360 | "whatis named union using type name" | |
ac775bf4 | 361 | |
0b8dbf3f AB |
362 | gdb_test "whatis v_union2" \ |
363 | "type = union \{\.\.\.\}" \ | |
364 | "whatis unnamed union" | |
ac775bf4 | 365 | |
0b8dbf3f AB |
366 | gdb_test "whatis &v_union" \ |
367 | "type = union t_union \\*" | |
ac775bf4 | 368 | |
0b8dbf3f AB |
369 | gdb_test "whatis &v_union2" \ |
370 | "type = union {\\.\\.\\.} \\*" | |
ac775bf4 | 371 | |
0b8dbf3f AB |
372 | gdb_test "whatis v_union_ptr" \ |
373 | "type = union t_union \\*" | |
ac775bf4 | 374 | |
0b8dbf3f AB |
375 | gdb_test "whatis v_union_ptr2" \ |
376 | "type = union {\\.\\.\\.} \\*" | |
ac775bf4 | 377 | |
0b8dbf3f AB |
378 | gdb_test "whatis &v_union_ptr" \ |
379 | "type = union t_union \\*\\*" | |
c906108c | 380 | |
0b8dbf3f AB |
381 | gdb_test "whatis &v_union_ptr2" \ |
382 | "type = union {\\.\\.\\.} \\*\\*" | |
c906108c | 383 | |
0b8dbf3f AB |
384 | gdb_test "whatis v_union.v_char_member" \ |
385 | "type = char" | |
c906108c | 386 | |
0b8dbf3f AB |
387 | gdb_test "whatis v_union2.v_char_member" \ |
388 | "type = char" | |
c906108c | 389 | |
0b8dbf3f AB |
390 | gdb_test "whatis v_union_ptr->v_char_member" \ |
391 | "type = char" | |
c906108c | 392 | |
0b8dbf3f AB |
393 | gdb_test "whatis v_union_ptr2->v_char_member" \ |
394 | "type = char" | |
c906108c | 395 | |
0b8dbf3f AB |
396 | gdb_test "whatis &(v_union.v_char_member)" \ |
397 | "type = char \\*" | |
c906108c | 398 | |
0b8dbf3f AB |
399 | gdb_test "whatis &(v_union2.v_char_member)" \ |
400 | "type = char \\*" | |
c906108c | 401 | |
0b8dbf3f AB |
402 | gdb_test "whatis &(v_union_ptr->v_char_member)" \ |
403 | "type = char \\*" | |
c906108c | 404 | |
0b8dbf3f AB |
405 | gdb_test "whatis &(v_union_ptr2->v_char_member)" \ |
406 | "type = char \\*" | |
c906108c | 407 | |
0b8dbf3f AB |
408 | if { $dir == "dwarf" } { |
409 | # Using stabs we will mark these functions as prototyped. This | |
410 | # is harmless but causes an extra VOID to be printed. | |
411 | set void "(void|)" | |
c906108c | 412 | |
0b8dbf3f AB |
413 | # test whatis command with functions return type |
414 | gdb_test "whatis v_char_func" \ | |
415 | "type = (signed |unsigned |)char \\($void\\)" \ | |
416 | "whatis char function" | |
c906108c | 417 | |
0b8dbf3f AB |
418 | gdb_test "whatis v_signed_char_func" \ |
419 | "type = (signed |unsigned |)char \\($void\\)" \ | |
420 | "whatis signed char function" | |
c906108c | 421 | |
0b8dbf3f AB |
422 | gdb_test "whatis v_unsigned_char_func" \ |
423 | "type = unsigned char \\($void\\)" \ | |
424 | "whatis unsigned char function" | |
c906108c | 425 | |
0b8dbf3f AB |
426 | gdb_test "whatis v_short_func" \ |
427 | "type = short (int |)\\($void\\)" \ | |
428 | "whatis short function" | |
64b2fa04 | 429 | |
0b8dbf3f AB |
430 | gdb_test "whatis v_signed_short_func" \ |
431 | "type = (signed |)short (int |)\\($void\\)" \ | |
432 | "whatis signed short function" | |
64b2fa04 | 433 | |
0b8dbf3f AB |
434 | gdb_test "whatis v_unsigned_short_func" \ |
435 | "type = (unsigned short|short unsigned int) \\($void\\)" \ | |
436 | "whatis unsigned short function" | |
64b2fa04 | 437 | |
0b8dbf3f AB |
438 | gdb_test "whatis v_int_func" \ |
439 | "type = int \\($void\\)" \ | |
440 | "whatis int function" | |
c906108c | 441 | |
0b8dbf3f AB |
442 | gdb_test "whatis v_signed_int_func" \ |
443 | "type = (signed |)int \\($void\\)" \ | |
444 | "whatis signed int function" | |
c906108c | 445 | |
0b8dbf3f AB |
446 | gdb_test "whatis v_unsigned_int_func" \ |
447 | "type = unsigned int \\($void\\)" \ | |
448 | "whatis unsigned int function" | |
c906108c | 449 | |
0b8dbf3f AB |
450 | gdb_test "whatis v_long_func" \ |
451 | "type = (long|int|long int) \\($void\\)" \ | |
452 | "whatis long function" | |
c906108c | 453 | |
0b8dbf3f AB |
454 | gdb_test "whatis v_signed_long_func" \ |
455 | "type = (signed |)(int|long|long int) \\($void\\)" \ | |
456 | "whatis signed long function" | |
c906108c | 457 | |
0b8dbf3f AB |
458 | gdb_test "whatis v_unsigned_long_func" \ |
459 | "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \ | |
460 | "whatis unsigned long function" | |
c906108c | 461 | |
0b8dbf3f AB |
462 | if ![target_info exists no_long_long] { |
463 | gdb_test "whatis v_long_long_func" \ | |
464 | "type = long long(| int) \\($void\\)" \ | |
465 | "whatis long long function" | |
c906108c | 466 | |
0b8dbf3f AB |
467 | gdb_test "whatis v_signed_long_long_func" \ |
468 | "type = (signed |)long long(| int) \\($void\\)" \ | |
469 | "whatis signed long long function" | |
f8261448 | 470 | |
0b8dbf3f AB |
471 | gdb_test "whatis v_unsigned_long_long_func" \ |
472 | "type = (unsigned long long(| int)|long long unsigned int) \\($void\\)" \ | |
473 | "whatis unsigned long long function" | |
474 | } | |
c906108c | 475 | |
0b8dbf3f AB |
476 | # Sun /bin/cc calls this a function returning double. |
477 | if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"} | |
478 | gdb_test "whatis v_float_func" \ | |
479 | "type = float \\($void\\)" \ | |
480 | "whatis float function" | |
c906108c | 481 | |
0b8dbf3f AB |
482 | gdb_test "whatis v_double_func" \ |
483 | "type = double \\($void\\)" \ | |
484 | "whatis double function" \ | |
485 | } | |
c906108c | 486 | |
0b8dbf3f AB |
487 | # test whatis command with some misc complicated types |
488 | gdb_test "whatis s_link" \ | |
489 | "type = struct link \\*" \ | |
490 | "whatis complicated structure" | |
c906108c | 491 | |
0b8dbf3f AB |
492 | gdb_test "whatis u_link" \ |
493 | "type = union tu_link" \ | |
494 | "whatis complicated union" | |
c906108c | 495 | |
c906108c | 496 | |
0b8dbf3f AB |
497 | # test whatis command with enumerations |
498 | gdb_test "whatis clunker" \ | |
499 | "type = enum cars" \ | |
500 | "whatis enumeration" | |
f8261448 | 501 | |
0b8dbf3f AB |
502 | gdb_test "whatis enum cars" \ |
503 | "type = enum cars" \ | |
504 | "whatis enumeration using type name" | |
505 | ||
506 | ||
507 | # test whatis command with nested struct and union | |
508 | gdb_test "whatis nested_su" \ | |
509 | "type = struct outer_struct" \ | |
510 | "whatis outer structure" | |
f8261448 | 511 | |
0b8dbf3f AB |
512 | gdb_test "whatis nested_su.outer_int" \ |
513 | "type = int" \ | |
514 | "whatis outer structure member" | |
f8261448 | 515 | |
0b8dbf3f AB |
516 | gdb_test "whatis nested_su.inner_struct_instance" \ |
517 | "type = struct inner_struct" \ | |
518 | "whatis inner structure" | |
95c391b6 | 519 | |
0b8dbf3f AB |
520 | gdb_test "whatis nested_su.inner_struct_instance.inner_int" \ |
521 | "type = int" \ | |
522 | "whatis inner structure member" | |
95c391b6 | 523 | |
0b8dbf3f AB |
524 | gdb_test "whatis nested_su.inner_union_instance" \ |
525 | "type = union inner_union" \ | |
526 | "whatis inner union" | |
527 | ||
528 | gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \ | |
529 | "type = int" \ | |
530 | "whatis inner union member" | |
531 | ||
532 | # test whatis command with typedefs | |
533 | ||
534 | gdb_test "whatis char_addr" \ | |
535 | "type = char \\*" \ | |
536 | "whatis using typedef type name" | |
537 | ||
538 | if { $dir == "dwarf" } { | |
539 | gdb_test "whatis a_char_addr" \ | |
540 | "type = char_addr" \ | |
541 | "whatis applied to variable defined by typedef" | |
542 | } | |
95c391b6 | 543 | |
0b8dbf3f | 544 | # Regression tests for PR 9514. |
95c391b6 | 545 | |
0b8dbf3f AB |
546 | gdb_test "whatis void (**)()" \ |
547 | "type = void \\(\\*\\*\\)\\(\\)" \ | |
548 | "whatis applied to pointer to pointer to function" | |
fcde5961 | 549 | |
0b8dbf3f AB |
550 | gdb_test "whatis void (** const)()" \ |
551 | "type = void \\(\\*\\* const\\)\\(\\)" \ | |
552 | "whatis applied to const pointer to pointer to function" | |
fcde5961 | 553 | |
0b8dbf3f AB |
554 | gdb_test "whatis void (* const *)()" \ |
555 | "type = void \\(\\* const \\*\\)\\(\\)" \ | |
556 | "whatis applied to pointer to const pointer to function" | |
fcde5961 | 557 | |
0b8dbf3f AB |
558 | gdb_test "whatis int *(*)()" \ |
559 | "type = int \\*\\(\\*\\)\\(\\)" \ | |
560 | "whatis applied to pointer to function returning pointer to int" | |
71918a86 | 561 | |
0b8dbf3f AB |
562 | gdb_test "whatis int *(**)()" \ |
563 | "type = int \\*\\(\\*\\*\\)\\(\\)" \ | |
564 | "whatis applied to pointer to pointer to function returning pointer to int" | |
a6fb9c08 | 565 | |
0b8dbf3f AB |
566 | gdb_test "whatis char (*(*)())\[23\]" \ |
567 | "type = char \\(\\*\\(\\*\\)\\(\\)\\)\\\[23\\\]" \ | |
568 | "whatis applied to pointer to function returning pointer to array" | |
e314d629 | 569 | |
0b8dbf3f AB |
570 | gdb_test "whatis int (*)(int, int)" \ |
571 | "type = int \\(\\*\\)\\(int, int\\)" \ | |
572 | "whatis applied to pointer to function taking int,int and returning int" | |
e314d629 | 573 | |
0b8dbf3f AB |
574 | gdb_test "whatis int (*)(const int *, ...)" \ |
575 | "type = int \\(\\*\\)\\(const int \\*, \\.\\.\\.\\)" \ | |
576 | "whatis applied to pointer to function taking const int ptr and varargs and returning int" | |
577 | ||
578 | gdb_test "whatis int (*)(void, int, int)" \ | |
579 | "parameter types following 'void'" \ | |
580 | "whatis applied to function with types trailing 'void'" | |
581 | ||
582 | gdb_test "whatis int (*)(int, void, int)" \ | |
583 | "'void' invalid as parameter type" \ | |
584 | "whatis applied to function with 'void' parameter type" | |
585 | } | |
586 | ||
587 | # Build up the set of debug formats for which we will run this test. | |
588 | set specs { {dwarf {debug}} } | |
589 | if ![skip_ctf_tests] { | |
590 | lappend specs {ctf {"additional_flags=-gt"}} | |
591 | } | |
592 | ||
593 | # Setup and run the test for each debug format. | |
594 | foreach testspec $specs { | |
595 | set prefix [lindex $testspec 0] | |
596 | set opts [lindex $testspec 1] | |
597 | ||
598 | with_test_prefix $prefix { | |
599 | remote_exec host "mkdir -p [standard_output_file ${prefix}]" | |
600 | do_test $prefix $opts | |
601 | } | |
602 | } |