OSDN Git Service

Use datarootdir for locales.
[pf3gnuchains/pf3gnuchains4x.git] / gdb / testsuite / gdb.base / whatis.exp
1 # Copyright 1988, 1990-1992, 1994-1997, 1999, 2002-2004, 2007-2012 Free
2 # Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
16
17 # This file was written by Rob Savoye. (rob@cygnus.com)
18
19 #
20 # test running programs
21 #
22
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
29 set testfile whatis
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $exec_opts] != "" } {
33      untested whatis.exp
34      return -1
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
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 #
70
71 gdb_test "whatis v_char" \
72     "type = (unsigned char|char)" \
73     "whatis char"
74
75 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
76 gdb_test "whatis v_signed_char" \
77     "type = (signed char|char)" \
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
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
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
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
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
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
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
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
298 # test whatis command with structure types
299 gdb_test "whatis v_struct1" \
300     "type = struct t_struct" \
301     "whatis named structure"
302
303 gdb_test "whatis struct t_struct" \
304     "type = struct t_struct" \
305     "whatis named structure using type name"
306
307 gdb_test "whatis v_struct2" \
308     "type = struct \{$unstruct\}" \
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
317 gdb_test "whatis union t_union" \
318     "type = union t_union" \
319     "whatis named union using type name"
320
321 gdb_test "whatis v_union2" \
322     "type = union \{$ununion\}" \
323     "whatis unnamed union"
324
325
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|)"
333
334 # test whatis command with functions return type
335 gdb_test "whatis v_char_func" \
336     "type = (signed |unsigned |)char \\($void\\)" \
337     "whatis char function"
338
339 gdb_test "whatis v_signed_char_func" \
340     "type = (signed |unsigned |)char \\($void\\)" \
341     "whatis signed char function"
342
343 gdb_test "whatis v_unsigned_char_func" \
344     "type = unsigned char \\($void\\)"  \
345     "whatis unsigned char function"
346
347 gdb_test "whatis v_short_func" \
348     "type = short (int |)\\($void\\)" \
349     "whatis short function"
350
351 gdb_test "whatis v_signed_short_func" \
352     "type = (signed |)short (int |)\\($void\\)" \
353     "whatis signed short function"
354
355 gdb_test "whatis v_unsigned_short_func" \
356     "type = (unsigned short|short unsigned int) \\($void\\)" \
357     "whatis unsigned short function"
358
359 gdb_test "whatis v_int_func" \
360     "type = int \\($void\\)" \
361     "whatis int function"
362
363 gdb_test "whatis v_signed_int_func" \
364     "type = (signed |)int \\($void\\)" \
365     "whatis signed int function"
366
367 gdb_test "whatis v_unsigned_int_func" \
368     "type = unsigned int \\($void\\)" \
369     "whatis unsigned int function"
370
371 gdb_test "whatis v_long_func" \
372     "type = (long|int|long int) \\($void\\)" \
373     "whatis long function"
374
375 gdb_test "whatis v_signed_long_func" \
376     "type = (signed |)(int|long|long int) \\($void\\)" \
377     "whatis signed long function"
378
379 gdb_test "whatis v_unsigned_long_func" \
380     "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
381     "whatis unsigned long function"
382
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
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" \
400     "type = float \\($void\\)" \
401     "whatis float function"
402
403 gdb_test "whatis v_double_func" \
404     "type = double \\($void\\)" \
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
423 gdb_test "whatis enum cars" \
424     "type = enum cars" \
425     "whatis enumeration using type name"
426
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
437 if {$hp_aCC_compiler} {
438     set outer "outer_struct::"
439 } else {
440     set outer ""
441 }
442
443 gdb_test "whatis nested_su.inner_struct_instance" \
444     "type = struct ${outer}inner_struct" \
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" \
452     "type = union ${outer}inner_union" \
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"
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"