Update Copyright year range in all files maintained by GDB.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ptype.exp
1 # Copyright 1988-2014 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # This file was written by Rob Savoye. (rob@cygnus.com)
17
18 #
19 # test running programs
20 #
21
22 standard_testfile .c ptype1.c
23
24 if {[prepare_for_testing ${testfile}.exp ${testfile} \
25 [list $srcfile $srcfile2] {debug nowarnings}]} {
26 return -1
27 }
28
29 # Create and source the file that provides information about the compiler
30 # used to compile the test case.
31 if [get_compiler_info] {
32 return -1
33 }
34
35 # Test ptype of unnamed enumeration members before any action causes
36 # the partial symbol table to be expanded to full symbols. This fails
37 # with stabs compilers which fail to use a nameless stab (such as
38 # pre-2.4.5 versions of gcc and most non-gcc compilers).
39
40 gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" {
41 -re "type = enum primary1_tag \{red1, green1, blue1\}.*$gdb_prompt $" {
42 # The workaround is in effect. As this is a compiler, not GDB,
43 # bug, we'll make it a PASS but perhaps it should be an XFAIL.
44 pass "ptype unnamed enumeration member (worked around)"
45 }
46 -re "type = enum \{red1, green1, blue1\}.*$gdb_prompt $" {
47 pass "ptype unnamed enumeration member"
48 }
49 }
50
51 #
52 # test ptype command with structures
53 #
54 # Here and elsewhere, we accept
55 # "long", "long int", or "int" for long variables (whatis.exp already
56 # has an XFAIL for "int" (Sun cc bug), so no need to fail it here).
57 gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype structure"
58
59
60 # Test the equivalence between '.' and '->' for struct member references.
61
62 if [gdb_test "ptype v_struct1.v_float_member" "type = float"]<0 then {
63 return -1
64 }
65 if [gdb_test "ptype v_struct1->v_float_member" "type = float"]<0 then {
66 return -1
67 }
68 if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then {
69 return -1
70 }
71 if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then {
72 return -1
73 }
74
75
76 # IBM's xlc puts out bogus stabs--the stuff field is type 42,
77 # which isn't defined.
78
79 gdb_test "ptype struct link" "type = struct link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list structure"
80
81 #
82 # test ptype command with unions
83 #
84 gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype union"
85
86 # IBM's xlc puts out bogus stabs--the stuff field is type 42,
87 # which isn't defined.
88 gdb_test "ptype union tu_link" "type = union tu_link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list union"
89
90 #
91 # test ptype command with enums
92 #
93
94 gdb_test "ptype primary" "type = enum .red, green, blue.*" "ptype unnamed enumeration"
95
96 gdb_test "ptype enum colors" "type = enum colors \{yellow, purple, pink\}.*" "ptype named enumeration"
97
98
99 #
100 # test ptype command with enums as typedef
101 #
102 gdb_test "ptype boolean" "type = enum (boolean |)\{FALSE, TRUE\}.*" "ptype unnamed typedef'd enumeration"
103
104 # And check that whatis shows the name, not "enum {...}".
105 # This probably fails for all DWARF 1 cases, so assume so for now. -fnf
106 # The problem with xlc is that the stabs look like
107 # :t51=eFALSE:0,TRUE:1,;
108 # boolean:t55=51
109 # v_boolean:G51
110 # GDB's behavior is correct; the type which the variable is defined
111 # as (51) doesn't have a name. Only 55 has a name.
112
113 if {!$gcc_compiled && !$hp_aCC_compiler} {
114 setup_xfail "rs6000-*-*" "i*86-*-sysv4*"
115 setup_xfail "hppa*-*-*" CLLbs14773
116 }
117
118 # For get_debug_format to do its job, we need to have a current source file.
119 gdb_test "list main" ".*"
120 get_debug_format
121 gdb_test "whatis v_boolean" "type = (enum |)boolean" \
122 "whatis unnamed typedef'd enum (compiler bug in IBM's xlc)"
123
124 # Same thing with struct and union.
125 gdb_test "ptype t_struct3" "type = struct (t_struct3 |)\{.*
126 *double v_double_member;.*
127 *int v_int_member;.*\}" "printing typedef'd struct"
128
129 gdb_test "ptype t_union3" "type = union (t_union3 |)\{.*
130 *double v_double_member;.*
131 *int v_int_member;.*\}" "printing typedef'd union"
132
133 gdb_test "ptype enum bvals" "type = enum bvals \{my_false, my_true\}.*" "ptype named typedef'd enumf'd enum"
134
135 #
136 # test ptype command with out-of-order enum values
137 #
138 gdb_test "ptype enum misordered" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype misordered enumeration"
139
140 #
141 # test ptype command with a named enum's value
142 #
143 gdb_test "ptype three" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype named enumeration member"
144
145 gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumeration member #2"
146
147 #
148 # test ptype command with basic C types
149 #
150 # I've commented most of this out because it duplicates tests in whatis.exp.
151 # I've just left in a token test or 2 which is designed to test that ptype
152 # acts like whatis for basic types. If it is thought to be necessary to
153 # test both whatis and ptype for all the types, the tests should be
154 # merged into whatis.exp, or else maintenance will be a royal pain -kingdon
155 #setup_xfail "mips-sgi-*"
156 #send "ptype v_char\n"
157 #gdb_expect {
158 # -re "type = char.*$gdb_prompt $" { pass "ptype char" }
159 # -re ".*$gdb_prompt $" { fail "ptype char" }
160 # timeout { fail "(timeout) ptype char" }
161 #}
162 #
163 #
164 #setup_xfail "mips-*-*"
165 #send "ptype v_signed_char\n"
166 #gdb_expect {
167 # -re "type = signed char.*$gdb_prompt $" { pass "ptype signed char" }
168 # -re ".*$gdb_prompt $" { fail "ptype signed char" }
169 # timeout { fail "(timeout) ptype signed char" }
170 #}
171 #
172 #
173 #send "ptype v_unsigned_char\n"
174 #gdb_expect {
175 # -re "type = unsigned char.*$gdb_prompt $" { pass "ptype unsigned char" }
176 # -re ".*$gdb_prompt $" { fail "ptype unsigned char" }
177 # timeout { fail "(timeout) ptype unsigned char" }
178 #}
179
180 gdb_test "ptype v_short" "type = short(| int).*" "ptype short"
181
182 #send "ptype v_signed_short\n"
183 #gdb_expect {
184 # -re "type = short.*$gdb_prompt $" { pass "ptype signed short" }
185 # -re ".*$gdb_prompt $" { fail "ptype signed short" }
186 # timeout { fail "(timeout) ptype signed short" }
187 #}
188 #
189 #
190 #send "ptype v_unsigned_short\n"
191 #gdb_expect {
192 # -re "type = unsigned short.*$gdb_prompt $" { pass "ptype unsigned short" }
193 # -re ".*$gdb_prompt $" { fail "ptype unsigned short" }
194 # timeout { fail "(timeout) ptype unsigned short" }
195 #}
196
197
198 gdb_test "ptype v_int" "type = int.*" "ptype int"
199
200 #send "ptype v_signed_int\n"
201 #gdb_expect {
202 # -re "type = int.*$gdb_prompt $" { pass "ptype signed int" }
203 # -re ".*$gdb_prompt $" { fail "ptype signed int" }
204 # timeout { fail "(timeout) ptype signed int" }
205 #}
206 #
207 #
208 #send "ptype v_unsigned_int\n"
209 #gdb_expect {
210 # -re "type = unsigned int.*$gdb_prompt $" { pass "ptype unsigned int" }
211 # -re ".*$gdb_prompt $" { fail "ptype unsigned int" }
212 # timeout { fail "(timeout) ptype unsigned int" }
213 #}
214 #
215 #
216 #send "ptype v_long\n"
217 #gdb_expect {
218 # -re "type = long.*$gdb_prompt $" { pass "ptype long" }
219 # -re ".*$gdb_prompt $" { fail "ptype long" }
220 # timeout { fail "(timeout) ptype long" }
221 #}
222 #
223 #
224 #send "ptype v_signed_long\n"
225 #gdb_expect {
226 # -re "type = long.*$gdb_prompt $" { pass "ptype signed long" }
227 # -re ".*$gdb_prompt $" { fail "ptype signed long" }
228 # timeout { fail "(timeout) ptype signed long" }
229 #}
230 #
231 #
232 #send "ptype v_unsigned_long\n"
233 #gdb_expect {
234 # -re "type = unsigned long.*$gdb_prompt $" { pass "ptype unsigned long" }
235 # -re ".*$gdb_prompt $" { fail "ptype unsigned long" }
236 # timeout { fail "(timeout) ptype unsigned long" }
237 #}
238 #
239 #
240 #send "ptype v_float\n"
241 #gdb_expect {
242 # -re "type = float.*$gdb_prompt $" { pass "ptype float" }
243 # -re ".*$gdb_prompt $" { fail "ptype float" }
244 # timeout { fail "(timeout) ptype float" }
245 #}
246 #
247 #
248 #send "ptype v_double\n"
249 #gdb_expect {
250 # -re "type = double.*$gdb_prompt $" { pass "ptype double" }
251 # -re ".*$gdb_prompt $" { fail "ptype double" }
252 # timeout { fail "(timeout) ptype double" }
253 #}
254
255
256 #
257 # test ptype command with arrays
258 #
259 #setup_xfail "mips-sgi-*"
260 #send "ptype v_char_array\n"
261 #gdb_expect {
262 # -re "type = char .2..*$gdb_prompt $" { pass "ptype char array" }
263 # -re ".*$gdb_prompt $" { fail "ptype char array" }
264 # timeout { fail "(timeout) ptype char array" }
265 #}
266 #
267 #
268 #setup_xfail "mips-*-*"
269 #send "ptype v_signed_char_array\n"
270 #gdb_expect {
271 # -re "type = (|signed )char .2..*$gdb_prompt $" { pass "ptype signed char array" }
272 # -re ".*$gdb_prompt $" { fail "ptype signed char array" }
273 # timeout { fail "(timeout) ptype signed char array" }
274 #}
275 #
276 #
277 #send "ptype v_unsigned_char_array\n"
278 #gdb_expect {
279 # -re "type = unsigned char .2..*$gdb_prompt $" { pass "ptype unsigned char array" }
280 # -re ".*$gdb_prompt $" { fail "ptype unsigned char array" }
281 # timeout { fail "(timeout) ptype unsigned char array" }
282 #}
283 #
284 #
285 #
286 #send "ptype v_int_array\n"
287 #gdb_expect {
288 # -re "type = int .2..*$gdb_prompt $" { pass "ptype int array" }
289 # -re ".*$gdb_prompt $" { fail "ptype int array" }
290 # timeout { fail "(timeout) ptype int array" }
291 #}
292 #
293 #
294 #send "ptype v_signed_int_array\n"
295 #gdb_expect {
296 # -re "type = int .2..*$gdb_prompt $" { pass "ptype signed int array" }
297 # -re ".*$gdb_prompt $" { fail "ptype signed int array" }
298 # timeout { fail "(timeout) ptype signed int array" }
299 #}
300 #
301 #
302 #send "ptype v_unsigned_int_array\n"
303 #gdb_expect {
304 # -re "type = unsigned int .2..*$gdb_prompt $" { pass "ptype unsigned int array" }
305 # -re ".*$gdb_prompt $" { fail "ptype unsigned int array" }
306 # timeout { fail "(timeout) ptype unsigned int array" }
307 #}
308 #
309 #
310 #send "ptype v_long_array\n"
311 #gdb_expect {
312 # -re "type = (long|int|long int) .2..*$gdb_prompt $" {
313 # pass "ptype long array" }
314 # -re ".*$gdb_prompt $" { fail "ptype long array" }
315 # timeout { fail "(timeout) ptype long array" }
316 #}
317 #
318 #
319 #send "ptype v_signed_long_array\n"
320 #gdb_expect {
321 # -re "type = (long|int|long int) .2..*$gdb_prompt $" {
322 # pass "ptype signed long array" }
323 # -re ".*$gdb_prompt $" { fail "ptype signed long array" }
324 # timeout { fail "(timeout) ptype signed long array" }
325 #}
326 #
327 #
328 #send "ptype v_unsigned_long_array\n"
329 #gdb_expect {
330 # -re "type = unsigned long .2..*$gdb_prompt $" { pass "ptype unsigned long array" }
331 # -re ".*$gdb_prompt $" { fail "ptype unsigned long array" }
332 # timeout { fail "(timeout) ptype unsigned long array" }
333 #}
334 #
335 #
336 #send "ptype v_float_array\n"
337 #gdb_expect {
338 # -re "type = float .2..*$gdb_prompt $" { pass "ptype float array" }
339 # -re ".*$gdb_prompt $" { fail "ptype float array" }
340 # timeout { fail "(timeout) ptype float array" }
341 #}
342 #
343 #
344 #send "ptype v_double_array\n"
345 #gdb_expect {
346 # -re "type = double .2..*$gdb_prompt $" { pass "ptype double array" }
347 # -re ".*$gdb_prompt $" { fail "ptype double array" }
348 # timeout { fail "(timeout) ptype double array" }
349 #}
350 #
351
352 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" }
353 if {$hp_aCC_compiler} {setup_xfail "hppa*-*-*"}
354 gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
355
356 gdb_test "ptype pv_char_array" "type = (|unsigned )char \\(\\*\\)\\\[0?\\\]"
357
358 #
359 ##
360 ## test ptype command with pointers
361 ##
362 #setup_xfail "mips-sgi-*"
363 #send "ptype v_char_pointer\n"
364 #gdb_expect {
365 # -re "type = char \*.*$gdb_prompt $" { pass "ptype char pointer" }
366 # -re ".*$gdb_prompt $" { fail "ptype char pointer" }
367 # timeout { fail "(timeout) ptype char pointer" }
368 #}
369 #
370 #
371 #setup_xfail "mips-*-*"
372 #send "ptype v_signed_char_pointer\n"
373 #gdb_expect {
374 # -re "type = (|signed )char \*.*$gdb_prompt $"
375 # { pass "ptype signed char pointer" }
376 # -re ".*$gdb_prompt $" { fail "ptype signed char pointer" }
377 # timeout { fail "(timeout) ptype signed char pointer" }
378 #}
379 #
380 #
381 #send "ptype v_unsigned_char_pointer\n"
382 #gdb_expect {
383 # -re "type = unsigned char \*.*$gdb_prompt $" { pass "ptype unsigned char pointer" }
384 # -re ".*$gdb_prompt $" { fail "ptype unsigned char pointer" }
385 # timeout { fail "(timeout) ptype unsigned char pointer" }
386 #}
387 #
388 #
389 #send "ptype v_short_pointer\n"
390 #gdb_expect {
391 # -re "type = (short|short int) \*.*$gdb_prompt $" { pass "ptype short pointer" }
392 # -re ".*$gdb_prompt $" { fail "ptype short pointer" }
393 # timeout { fail "(timeout) ptype short pointer" }
394 #}
395 #
396 #
397 #send "ptype v_signed_short_pointer\n"
398 #gdb_expect {
399 # -re "type = short \*.*$gdb_prompt $" { pass "ptype signed short pointer" }
400 # -re ".*$gdb_prompt $" { fail "ptype signed short pointer" }
401 # timeout { fail "(timeout) ptype signed short pointer" }
402 #}
403 #
404 #
405 #send "ptype v_unsigned_short_pointer\n"
406 #gdb_expect {
407 # -re "type = unsigned short \*.*$gdb_prompt $" { pass "ptype unsigned short pointer" }
408 # -re ".*$gdb_prompt $" { fail "ptype unsigned short pointer" }
409 # timeout { fail "(timeout) ptype unsigned short pointer" }
410 #}
411 #
412 #
413 #send "ptype v_int_pointer\n"
414 #gdb_expect {
415 # -re "type = int \*.*$gdb_prompt $" { pass "ptype int pointer" }
416 # -re ".*$gdb_prompt $" { fail "ptype int pointer" }
417 # timeout { fail "(timeout) ptype int pointer" }
418 #}
419 #
420 #
421 #send "ptype v_signed_int_pointer\n"
422 #gdb_expect {
423 # -re "type = int \*.*$gdb_prompt $" { pass "ptype signed int pointer" }
424 # -re ".*$gdb_prompt $" { fail "ptype signed int pointer" }
425 # timeout { fail "(timeout) ptype signed int pointer" }
426 #}
427 #
428 #
429 #send "ptype v_unsigned_int_pointer\n"
430 #gdb_expect {
431 # -re "type = unsigned int \*.*$gdb_prompt $" { pass "ptype unsigned int pointer" }
432 # -re ".*$gdb_prompt $" { fail "ptype unsigned int pointer" }
433 # timeout { fail "(timeout) ptype unsigned int pointer" }
434 #}
435 #
436 #
437 #send "ptype v_long_pointer\n"
438 #gdb_expect {
439 # -re "type = long \*.*$gdb_prompt $" { pass "ptype long pointer" }
440 # -re ".*$gdb_prompt $" { fail "ptype long pointer" }
441 # timeout { fail "(timeout) ptype long pointer" }
442 #}
443 #
444 #
445 #send "ptype v_signed_long_pointer\n"
446 #gdb_expect {
447 # -re "type = long \*.*$gdb_prompt $" { pass "ptype signed long pointer" }
448 # -re ".*$gdb_prompt $" { fail "ptype signed long pointer" }
449 # timeout { fail "(timeout) ptype signed long pointer" }
450 #}
451 #
452 #
453 #send "ptype v_unsigned_long_pointer\n"
454 #gdb_expect {
455 # -re "type = unsigned long \*.*$gdb_prompt $" { pass "ptype unsigned long pointer" }
456 # -re ".*$gdb_prompt $" { fail "ptype unsigned long pointer" }
457 # timeout { fail "(timeout) ptype unsigned long pointer" }
458 #}
459 #
460 #
461 #send "ptype v_float_pointer\n"
462 #gdb_expect {
463 # -re "type = float \*.*$gdb_prompt $" { pass "ptype float pointer" }
464 # -re ".*$gdb_prompt $" { fail "ptype float pointer" }
465 # timeout { fail "(timeout) ptype float pointer" }
466 #}
467 #
468 #
469 #send "ptype v_double_pointer\n"
470 #gdb_expect {
471 # -re "type = double \*.*$gdb_prompt $" { pass "ptype double pointer" }
472 # -re ".*$gdb_prompt $" { fail "ptype double pointer" }
473 # timeout { fail "(timeout) ptype double pointer" }
474 #}
475
476 #
477 # test ptype command with nested structure and union
478 #
479 if {$hp_aCC_compiler} {
480 set outer "outer_struct::"
481 set struct ""
482 set union ""
483 } else {
484 set outer ""
485 set struct "struct"
486 set union "union"
487 }
488 gdb_test "ptype struct outer_struct" "type = struct outer_struct \{.*\[\r\n\]+\
489 .*int outer_int;.*\[\r\n\]+\
490 .*(struct|) ${outer}inner_struct inner_struct_instance;.*\[\r\n\]+\
491 .*(union|) ${outer}inner_union inner_union_instance;.*\[\r\n\]+\
492 .*(long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype outer structure"
493
494 gdb_test "ptype ${struct} ${outer}inner_struct" "type = struct ${outer}inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype inner structure"
495
496 gdb_test "ptype ${union} ${outer}inner_union" "type = union ${outer}inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype inner union"
497
498 gdb_test "ptype nested_su" "type = struct outer_struct \{.*\[\r\n\] int outer_int;.*\[\r\n\] (struct |)${outer}inner_struct inner_struct_instance;.*\[\r\n\] (union |)${outer}inner_union inner_union_instance;.*\[\r\n\] (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype nested structure"
499
500 gdb_test "ptype nested_su.outer_int" "type = int.*" "ptype outer int"
501
502 gdb_test "ptype nested_su.inner_struct_instance" "type = struct ${outer}inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype nested structure #2"
503
504 gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype inner int"
505
506 gdb_test "ptype nested_su.inner_union_instance" "type = union ${outer}inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union"
507
508 # Print the type description of variable the_highest, and verify that
509 # the type description for the fields whose type is anonymous are
510 # correctly printed (at nesting level 1 and 2).
511
512 gdb_test "ptype the_highest" \
513 "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" \
514 "ptype the_highest"
515
516 # Print the type descrption for one of the fields of variable the_highest.
517 # The purpose is to verify that the type of a field that was printed above
518 # as "struct {...}" is now printed in a more descriptive way (because the
519 # nesting level is now one level less).
520
521 gdb_test "ptype the_highest.anonymous_level_1" \
522 "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \
523 "ptype the_highest"
524
525 get_debug_format
526
527 # Print the type of the identifier ID, and check the response:
528 # - Expect to see PROTOTYPED as the type. PROTOTYPED is not a regular
529 # expression; it's a literal string.
530 # - If we instead see the unprototyped type PLAIN, and we're using STABS
531 # generated by GCC, that's an xfail; as of 9 Feb 2002, GCC never emits
532 # prototyped function types in STABS. Like PROTOTYPED, PLAIN is a
533 # literal string, not a regular expression.
534 # - If we see OVERPROTOTYPED, it's an xfail for RealView; RealView
535 # does not distinguish prototyped and unprototyped functions, and
536 # GDB defaults to prototyped.
537 # - Otherwise, it's a failure.
538 proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" } } {
539 global gdb_prompt
540 global gcc_compiled
541
542 # Turn the arguments, which are literal strings, into
543 # regular expressions by quoting any special characters they contain.
544 foreach var { prototyped plain overprototyped } {
545 eval "set val \$$var"
546 regsub -all "\[\]\[*()\]" $val "\\\\&" val
547 regsub -all "short int" $val "short( int)?" val
548 regsub -all "long int" $val "long( int)?" val
549 eval "set $var \$val"
550 }
551
552 gdb_test_multiple "ptype $id" "ptype $id" {
553 -re "type = $prototyped\[\r\n\]+$gdb_prompt $" {
554 pass "ptype $id"
555 }
556 -re "type = $plain\[\r\n\]+$gdb_prompt $" {
557 if {$gcc_compiled} { setup_xfail_format "stabs" }
558 fail "ptype $id (compiler doesn't emit prototyped types)"
559 }
560 -re "type = $overprototyped\[\r\n\]+$gdb_prompt $" {
561 if { [test_compiler_info "armcc-*"] } {
562 setup_xfail "*-*-*"
563 }
564 fail "ptype $id (compiler doesn't emit unprototyped types)"
565 }
566 }
567 }
568
569 ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \
570 "int (*)()"
571 ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()" \
572 "double (*)(void)"
573 ptype_maybe_prototyped "new_fptr" "double (*)(void)" "double (*)()"
574 ptype_maybe_prototyped "fptr" "int (*)(int, float)" "int (*)()"
575 ptype_maybe_prototyped "fptr2" "int *(*)(int (*)(int, float), float)" \
576 "int *(*)()"
577 ptype_maybe_prototyped "xptr" "int (*)(int (*)(), int (*)(void), int)" \
578 "int (*)()" \
579 "int (*)(int (*)(void), int (*)(void), int)"
580 ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \
581 "int (*(*)())()"
582 ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \
583 "int (*(*(*)())())()"
584
585 # Test printing type of typedefs in different scopes, with same name
586 # but different type.
587
588 gdb_test "list intfoo" ".*"
589 gdb_test "ptype foo" "type = int" "ptype foo typedef after first list of intfoo"
590 gdb_test "list charfoo" ".*"
591 gdb_test "ptype foo" "type = char" "ptype foo typedef after first list of charfoo"
592 gdb_test "list intfoo" ".*"
593 gdb_test "ptype foo" "type = int" "ptype foo typedef after second list of intfoo"
594 gdb_test "list charfoo" ".*"
595 gdb_test "ptype foo" "type = char" "ptype foo typedef after second list of charfoo"
596
597 # Test printing type of string constants and array constants, but
598 # requires a running process. These call malloc, and can take a long
599 # time to execute over a slow serial link, so increase the timeout.
600
601 # UDI can't do this (PR 2416). XFAIL is not suitable, because attempting
602 # the operation causes a slow painful death rather than a nice simple failure.
603
604 if [runto_main] then {
605
606 if [target_info exists gdb,cannot_call_functions] {
607 setup_xfail "*-*-*" 2416
608 fail "This target can not call functions"
609 continue
610 }
611
612 # We need to up this because this can be really slow on some boards.
613 # (malloc() is called as part of the test).
614 set prev_timeout $timeout
615 set timeout 60
616
617 gdb_test "ptype \"abc\"" "type = char \\\[4\\\]"
618 gdb_test "ptype {'a','b','c'}" "type = char \\\[3\\\]"
619 gdb_test "ptype {0,1,2}" "type = int \\\[3\\\]"
620 gdb_test "ptype {(long)0,(long)1,(long)2}" "type = long \\\[3\\\]"
621 gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]"
622 gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]"
623 gdb_test "ptype {4,5,6}\[2\]" "type = int"
624 gdb_test "ptype *&{4,5,6}\[1\]" "Attempt to take address of value not located in memory."
625
626 set timeout $prev_timeout
627
628 # Test ptype of user register
629 gdb_test "ptype \$pc" "void \\(\\*\\)\\(\\)" "ptype \$pc"
630 }
This page took 0.048187 seconds and 5 git commands to generate.