]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/ptype.exp
Major revision to testsuites for cross-testing and DOS testing support.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / ptype.exp
1 # Copyright (C) 1988, 1990, 1991, 1992, 1994 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Rob Savoye. (rob@cygnus.com)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 #
27 # test running programs
28 #
29 set prms_id 0
30 set bug_id 0
31
32 set testfile "ptype"
33 set srcfile ${testfile}.c
34 set binfile ${objdir}/${subdir}/${testfile}
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36 perror "Couldn't compile ${srcfile}"
37 return -1
38 }
39
40 # Create and source the file that provides information about the compiler
41 # used to compile the test case.
42 if [get_compiler_info ${binfile}] {
43 return -1;
44 }
45
46 gdb_exit
47 gdb_start
48 gdb_reinitialize_dir $srcdir/$subdir
49 gdb_load ${binfile}
50
51 # Test ptype of unnamed enumeration members before any action causes
52 # the partial symbol table to be expanded to full symbols. This fails
53 # with stabs compilers which fail to use a nameless stab (such as
54 # pre-2.4.5 versions of gcc and most non-gcc compilers).
55
56 send_gdb "ptype red1\n"
57 expect {
58 -re "type = enum primary1_tag \{red1, green1, blue1\}.*$prompt $"\
59 {
60 # The workaround is in effect. As this is a compiler, not GDB,
61 # bug, we'll make it a PASS but perhaps it should be an XFAIL.
62 pass "ptype unnamed enumeration member (worked around)"
63 }
64 -re "type = enum \{red1, green1, blue1\}.*$prompt $"\
65 { pass "ptype unnamed enumeration member" }
66 -re ".*$prompt $" { fail "ptype unnamed enumeration member" }
67 timeout { fail "(timeout) ptype unnamed enumeration member" }
68 }
69
70 #
71 # test ptype command with structures
72 #
73 # Here and elsewhere, we accept
74 # "long", "long int", or "int" for long variables (whatis.exp already
75 # has an XFAIL for "int" (Sun cc bug), so no need to fail it here).
76 send_gdb "ptype struct t_struct\n"
77 expect {
78 -re "type = struct t_struct \{.*
79 (unsigned |)char v_char_member;.*
80 (short|short int) v_short_member;.*
81 int v_int_member;.*
82 (long|long int|int) v_long_member;.*
83 float v_float_member;.*
84 double v_double_member;.*
85 \}.*$prompt $" { pass "ptype structure" }
86 -re ".*$prompt $" { fail "ptype structure" }
87 timeout { fail "(timeout) ptype structure" }
88 }
89
90 # Test the equivalence between '.' and '->' for struct member references.
91
92 if [gdb_test "ptype v_struct1.v_float_member" "type = float"]<0 then {
93 gdb_exit
94 gdb_start
95 return -1
96 }
97 if [gdb_test "ptype v_struct1->v_float_member" "type = float"]<0 then {
98 gdb_exit
99 gdb_start
100 return -1
101 }
102 if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then {
103 gdb_exit
104 gdb_start
105 return -1
106 }
107 if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then {
108 gdb_exit
109 gdb_start
110 return -1
111 }
112
113
114 send_gdb "ptype struct link\n"
115 expect {
116 -re "type = struct link \{.*
117 struct link \[*\]next;.*
118 struct link \[*(\]+linkfunc\[)(\]+(struct link \[*\], int\[)\]|);.*
119 struct t_struct stuff.1..2..3.;.*
120 \}.*$prompt $" { pass "ptype linked list structure" }
121 -re ".*$prompt $" {
122
123 # IBM's xlc puts out bogus stabs--the stuff field is type 42,
124 # which isn't defined.
125
126 fail "ptype linked list structure (compiler bug in IBM's xlc)"
127 }
128 timeout { fail "(timeout) ptype linked list structure" }
129 }
130
131
132 #
133 # test ptype command with unions
134 #
135 send_gdb "ptype union t_union\n"
136 expect {
137 -re "type = union t_union \{.*
138 (unsigned |)char v_char_member;.*
139 (short|short int) v_short_member;.*
140 int v_int_member;.*
141 (long|long int|int) v_long_member;.*
142 float v_float_member;.*
143 double v_double_member;.*
144 \}.*$prompt $" { pass "ptype union" }
145 -re ".*$prompt $" { fail "ptype union" }
146 timeout { fail "(timeout) ptype union" }
147 }
148
149
150 send_gdb "ptype union tu_link\n"
151 expect {
152 -re "type = union tu_link .*
153 struct link \[*\]next;.*
154 struct link \[(\*\]+linkfunc\[)(\]+(struct link \[*\], int\[)\]|);.*
155 struct t_struct stuff.1..2..3.;.*
156 \}.*$prompt $" { pass "ptype linked list union" }
157 -re ".*$prompt $" {
158
159 # IBM's xlc puts out bogus stabs--the stuff field is type 42,
160 # which isn't defined.
161
162 fail "ptype linked list union (compiler bug in IBM's xlc)"
163 }
164 timeout { fail "(timeout) ptype linked list union" }
165 }
166
167
168 #
169 # test ptype command with enums
170 #
171
172 send_gdb "ptype primary\n"
173 expect {
174 -re "type = enum .red, green, blue.*$prompt $" { pass "ptype unnamed enumeration" }
175 -re ".*$prompt $" { fail "ptype unnamed enumeration" }
176 timeout { fail "(timeout) ptype unnamed enumeration" }
177 }
178
179
180 send_gdb "ptype enum colors\n"
181 expect {
182 -re "type = enum colors \{yellow, purple, pink\}.*$prompt $"\
183 { pass "ptype named enumeration" }
184 -re ".*$prompt $" { fail "ptype named enumeration" }
185 timeout { fail "(timeout) ptype named enumeration" }
186 }
187
188
189 #
190 # test ptype command with enums as typedef
191 #
192 send_gdb "ptype boolean\n"
193 expect {
194 -re "type = enum \{FALSE, TRUE\}.*$prompt $" { pass "ptype unnamed typedef'd enumeration" }
195 -re ".*$prompt $" { fail "ptype unnamed typedef'd enumeration" }
196 timeout { fail "(timeout) ptype unnamed typedef'd enumeration" }
197 }
198
199 # And check that whatis shows the name, not "enum {...}".
200
201 # The problem with xlc is that the stabs look like
202 # :t51=eFALSE:0,TRUE:1,;
203 # boolean:t55=51
204 # v_boolean:G51
205 # GDB's behavior is correct; the type which the variable is defined
206 # as (51) doesn't have a name. Only 55 has a name.
207
208 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" }
209 gdb_test "whatis v_boolean" "type = boolean" \
210 "whatis unnamed typedef'd enum (compiler bug in IBM's xlc)"
211
212 # Same thing with struct and union.
213 gdb_test "ptype t_struct3" "type = struct \{.*
214 *double v_double_member;.*
215 *int v_int_member;.*\}" "printing typedef'd struct"
216
217 gdb_test "ptype t_union3" "type = union \{.*
218 *double v_double_member;.*
219 *int v_int_member;.*\}" "printing typedef'd union"
220
221 send_gdb "ptype enum bvals\n"
222 expect {
223 -re "type = enum bvals \{false, true\}.*$prompt $" { pass "ptype named typedef'd enumf'd enum" }
224 -re ".*$prompt $" { fail "ptype named typedef'd enumeration" }
225 timeout { fail "(timeout) ptype named typedef'd enumeration" }
226 }
227
228
229 #
230 # test ptype command with out-of-order enum values
231 #
232 send_gdb "ptype enum misordered\n"
233 expect {
234 -re "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*$prompt $"\
235 { pass "ptype misordered enumeration" }
236 -re ".*$prompt $" { fail "ptype misordered enumeration" }
237 timeout { fail "(timeout) ptype misordered enumeration" }
238 }
239
240
241 #
242 # test ptype command with a named enum's value
243 #
244 send_gdb "ptype three\n"
245 expect {
246 -re "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*$prompt $"\
247 { pass "ptype named enumeration member" }
248 -re ".*$prompt $" { fail "ptype named enumeration member" }
249 timeout { fail "(timeout) ptype named enumeration member" }
250 }
251
252
253 send_gdb "ptype red\n"
254 expect {
255 -re "type = enum \{red, green, blue\}.*$prompt $"\
256 { pass "ptype unnamed enumeration member" }
257 -re ".*$prompt $" { fail "ptype unnamed enumeration member" }
258 timeout { fail "(timeout) ptype unnamed enumeration member" }
259 }
260
261
262 #
263 # test ptype command with basic C types
264 #
265 # I've commented most of this out because it duplicates tests in whatis.exp.
266 # I've just left in a token test or 2 which is designed to test that ptype
267 # acts like whatis for basic types. If it is thought to be necessary to
268 # test both whatis and ptype for all the types, the tests should be
269 # merged into whatis.exp, or else maintenance will be a royal pain -kingdon
270 #setup_xfail "i960-*-*" 1821
271 #setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*"
272 #send "ptype v_char\n"
273 #expect {
274 # -re "type = char.*$prompt $" { pass "ptype char" }
275 # -re ".*$prompt $" { fail "ptype char" }
276 # timeout { fail "(timeout) ptype char" }
277 #}
278 #
279 #
280 #setup_xfail "mips-*-*" "a29k-*-*"
281 #send "ptype v_signed_char\n"
282 #expect {
283 # -re "type = signed char.*$prompt $" { pass "ptype signed char" }
284 # -re ".*$prompt $" { fail "ptype signed char" }
285 # timeout { fail "(timeout) ptype signed char" }
286 #}
287 #
288 #
289 #send "ptype v_unsigned_char\n"
290 #expect {
291 # -re "type = unsigned char.*$prompt $" { pass "ptype unsigned char" }
292 # -re ".*$prompt $" { fail "ptype unsigned char" }
293 # timeout { fail "(timeout) ptype unsigned char" }
294 #}
295
296
297 send_gdb "ptype v_short\n"
298 expect {
299 -re "type = short(| int).*$prompt $" { pass "ptype short" }
300 -re ".*$prompt $" { fail "ptype short" }
301 timeout { fail "(timeout) ptype short" }
302 }
303
304
305 #send "ptype v_signed_short\n"
306 #expect {
307 # -re "type = short.*$prompt $" { pass "ptype signed short" }
308 # -re ".*$prompt $" { fail "ptype signed short" }
309 # timeout { fail "(timeout) ptype signed short" }
310 #}
311 #
312 #
313 #send "ptype v_unsigned_short\n"
314 #expect {
315 # -re "type = unsigned short.*$prompt $" { pass "ptype unsigned short" }
316 # -re ".*$prompt $" { fail "ptype unsigned short" }
317 # timeout { fail "(timeout) ptype unsigned short" }
318 #}
319
320
321 send_gdb "ptype v_int\n"
322 expect {
323 -re "type = int.*$prompt $" { pass "ptype int" }
324 -re ".*$prompt $" { fail "ptype int" }
325 timeout { fail "(timeout) ptype int" }
326 }
327
328
329 #send "ptype v_signed_int\n"
330 #expect {
331 # -re "type = int.*$prompt $" { pass "ptype signed int" }
332 # -re ".*$prompt $" { fail "ptype signed int" }
333 # timeout { fail "(timeout) ptype signed int" }
334 #}
335 #
336 #
337 #send "ptype v_unsigned_int\n"
338 #expect {
339 # -re "type = unsigned int.*$prompt $" { pass "ptype unsigned int" }
340 # -re ".*$prompt $" { fail "ptype unsigned int" }
341 # timeout { fail "(timeout) ptype unsigned int" }
342 #}
343 #
344 #
345 #send "ptype v_long\n"
346 #expect {
347 # -re "type = long.*$prompt $" { pass "ptype long" }
348 # -re ".*$prompt $" { fail "ptype long" }
349 # timeout { fail "(timeout) ptype long" }
350 #}
351 #
352 #
353 #send "ptype v_signed_long\n"
354 #expect {
355 # -re "type = long.*$prompt $" { pass "ptype signed long" }
356 # -re ".*$prompt $" { fail "ptype signed long" }
357 # timeout { fail "(timeout) ptype signed long" }
358 #}
359 #
360 #
361 #send "ptype v_unsigned_long\n"
362 #expect {
363 # -re "type = unsigned long.*$prompt $" { pass "ptype unsigned long" }
364 # -re ".*$prompt $" { fail "ptype unsigned long" }
365 # timeout { fail "(timeout) ptype unsigned long" }
366 #}
367 #
368 #
369 #send "ptype v_float\n"
370 #expect {
371 # -re "type = float.*$prompt $" { pass "ptype float" }
372 # -re ".*$prompt $" { fail "ptype float" }
373 # timeout { fail "(timeout) ptype float" }
374 #}
375 #
376 #
377 #send "ptype v_double\n"
378 #expect {
379 # -re "type = double.*$prompt $" { pass "ptype double" }
380 # -re ".*$prompt $" { fail "ptype double" }
381 # timeout { fail "(timeout) ptype double" }
382 #}
383
384
385 #
386 # test ptype command with arrays
387 #
388 #setup_xfail "i960-*-*" 1821
389 #setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*"
390 #send "ptype v_char_array\n"
391 #expect {
392 # -re "type = char .2..*$prompt $" { pass "ptype char array" }
393 # -re ".*$prompt $" { fail "ptype char array" }
394 # timeout { fail "(timeout) ptype char array" }
395 #}
396 #
397 #
398 #setup_xfail "mips-*-*" "a29k-*-*"
399 #send "ptype v_signed_char_array\n"
400 #expect {
401 # -re "type = (|signed )char .2..*$prompt $" { pass "ptype signed char array" }
402 # -re ".*$prompt $" { fail "ptype signed char array" }
403 # timeout { fail "(timeout) ptype signed char array" }
404 #}
405 #
406 #
407 #send "ptype v_unsigned_char_array\n"
408 #expect {
409 # -re "type = unsigned char .2..*$prompt $" { pass "ptype unsigned char array" }
410 # -re ".*$prompt $" { fail "ptype unsigned char array" }
411 # timeout { fail "(timeout) ptype unsigned char array" }
412 #}
413 #
414 #
415 #
416 #send "ptype v_int_array\n"
417 #expect {
418 # -re "type = int .2..*$prompt $" { pass "ptype int array" }
419 # -re ".*$prompt $" { fail "ptype int array" }
420 # timeout { fail "(timeout) ptype int array" }
421 #}
422 #
423 #
424 #send "ptype v_signed_int_array\n"
425 #expect {
426 # -re "type = int .2..*$prompt $" { pass "ptype signed int array" }
427 # -re ".*$prompt $" { fail "ptype signed int array" }
428 # timeout { fail "(timeout) ptype signed int array" }
429 #}
430 #
431 #
432 #send "ptype v_unsigned_int_array\n"
433 #expect {
434 # -re "type = unsigned int .2..*$prompt $" { pass "ptype unsigned int array" }
435 # -re ".*$prompt $" { fail "ptype unsigned int array" }
436 # timeout { fail "(timeout) ptype unsigned int array" }
437 #}
438 #
439 #
440 #send "ptype v_long_array\n"
441 #expect {
442 # -re "type = (long|int|long int) .2..*$prompt $" {
443 # pass "ptype long array" }
444 # -re ".*$prompt $" { fail "ptype long array" }
445 # timeout { fail "(timeout) ptype long array" }
446 #}
447 #
448 #
449 #send "ptype v_signed_long_array\n"
450 #expect {
451 # -re "type = (long|int|long int) .2..*$prompt $" {
452 # pass "ptype signed long array" }
453 # -re ".*$prompt $" { fail "ptype signed long array" }
454 # timeout { fail "(timeout) ptype signed long array" }
455 #}
456 #
457 #
458 #send "ptype v_unsigned_long_array\n"
459 #expect {
460 # -re "type = unsigned long .2..*$prompt $" { pass "ptype unsigned long array" }
461 # -re ".*$prompt $" { fail "ptype unsigned long array" }
462 # timeout { fail "(timeout) ptype unsigned long array" }
463 #}
464 #
465 #
466 #send "ptype v_float_array\n"
467 #expect {
468 # -re "type = float .2..*$prompt $" { pass "ptype float array" }
469 # -re ".*$prompt $" { fail "ptype float array" }
470 # timeout { fail "(timeout) ptype float array" }
471 #}
472 #
473 #
474 #send "ptype v_double_array\n"
475 #expect {
476 # -re "type = double .2..*$prompt $" { pass "ptype double array" }
477 # -re ".*$prompt $" { fail "ptype double array" }
478 # timeout { fail "(timeout) ptype double array" }
479 #}
480 #
481
482 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" }
483 gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]"
484
485 #
486 ##
487 ## test ptype command with pointers
488 ##
489 #setup_xfail "i960-*-*" 1821
490 #setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*"
491 #send "ptype v_char_pointer\n"
492 #expect {
493 # -re "type = char \*.*$prompt $" { pass "ptype char pointer" }
494 # -re ".*$prompt $" { fail "ptype char pointer" }
495 # timeout { fail "(timeout) ptype char pointer" }
496 #}
497 #
498 #
499 #setup_xfail "mips-*-*" "a29k-*-*"
500 #send "ptype v_signed_char_pointer\n"
501 #expect {
502 # -re "type = (|signed )char \*.*$prompt $"
503 # { pass "ptype signed char pointer" }
504 # -re ".*$prompt $" { fail "ptype signed char pointer" }
505 # timeout { fail "(timeout) ptype signed char pointer" }
506 #}
507 #
508 #
509 #send "ptype v_unsigned_char_pointer\n"
510 #expect {
511 # -re "type = unsigned char \*.*$prompt $" { pass "ptype unsigned char pointer" }
512 # -re ".*$prompt $" { fail "ptype unsigned char pointer" }
513 # timeout { fail "(timeout) ptype unsigned char pointer" }
514 #}
515 #
516 #
517 #send "ptype v_short_pointer\n"
518 #expect {
519 # -re "type = (short|short int) \*.*$prompt $" { pass "ptype short pointer" }
520 # -re ".*$prompt $" { fail "ptype short pointer" }
521 # timeout { fail "(timeout) ptype short pointer" }
522 #}
523 #
524 #
525 #send "ptype v_signed_short_pointer\n"
526 #expect {
527 # -re "type = short \*.*$prompt $" { pass "ptype signed short pointer" }
528 # -re ".*$prompt $" { fail "ptype signed short pointer" }
529 # timeout { fail "(timeout) ptype signed short pointer" }
530 #}
531 #
532 #
533 #send "ptype v_unsigned_short_pointer\n"
534 #expect {
535 # -re "type = unsigned short \*.*$prompt $" { pass "ptype unsigned short pointer" }
536 # -re ".*$prompt $" { fail "ptype unsigned short pointer" }
537 # timeout { fail "(timeout) ptype unsigned short pointer" }
538 #}
539 #
540 #
541 #send "ptype v_int_pointer\n"
542 #expect {
543 # -re "type = int \*.*$prompt $" { pass "ptype int pointer" }
544 # -re ".*$prompt $" { fail "ptype int pointer" }
545 # timeout { fail "(timeout) ptype int pointer" }
546 #}
547 #
548 #
549 #send "ptype v_signed_int_pointer\n"
550 #expect {
551 # -re "type = int \*.*$prompt $" { pass "ptype signed int pointer" }
552 # -re ".*$prompt $" { fail "ptype signed int pointer" }
553 # timeout { fail "(timeout) ptype signed int pointer" }
554 #}
555 #
556 #
557 #send "ptype v_unsigned_int_pointer\n"
558 #expect {
559 # -re "type = unsigned int \*.*$prompt $" { pass "ptype unsigned int pointer" }
560 # -re ".*$prompt $" { fail "ptype unsigned int pointer" }
561 # timeout { fail "(timeout) ptype unsigned int pointer" }
562 #}
563 #
564 #
565 #send "ptype v_long_pointer\n"
566 #expect {
567 # -re "type = long \*.*$prompt $" { pass "ptype long pointer" }
568 # -re ".*$prompt $" { fail "ptype long pointer" }
569 # timeout { fail "(timeout) ptype long pointer" }
570 #}
571 #
572 #
573 #send "ptype v_signed_long_pointer\n"
574 #expect {
575 # -re "type = long \*.*$prompt $" { pass "ptype signed long pointer" }
576 # -re ".*$prompt $" { fail "ptype signed long pointer" }
577 # timeout { fail "(timeout) ptype signed long pointer" }
578 #}
579 #
580 #
581 #send "ptype v_unsigned_long_pointer\n"
582 #expect {
583 # -re "type = unsigned long \*.*$prompt $" { pass "ptype unsigned long pointer" }
584 # -re ".*$prompt $" { fail "ptype unsigned long pointer" }
585 # timeout { fail "(timeout) ptype unsigned long pointer" }
586 #}
587 #
588 #
589 #send "ptype v_float_pointer\n"
590 #expect {
591 # -re "type = float \*.*$prompt $" { pass "ptype float pointer" }
592 # -re ".*$prompt $" { fail "ptype float pointer" }
593 # timeout { fail "(timeout) ptype float pointer" }
594 #}
595 #
596 #
597 #send "ptype v_double_pointer\n"
598 #expect {
599 # -re "type = double \*.*$prompt $" { pass "ptype double pointer" }
600 # -re ".*$prompt $" { fail "ptype double pointer" }
601 # timeout { fail "(timeout) ptype double pointer" }
602 #}
603
604 #
605 # test ptype command with nested structure and union
606 #
607 send_gdb "ptype struct outer_struct\n"
608 expect {
609 -re "type = struct outer_struct \{.*
610 int outer_int;.*
611 struct inner_struct inner_struct_instance;.*
612 union inner_union inner_union_instance;.*
613 (long|long int|int) outer_long;.*
614 \}.*$prompt $" { pass "ptype outer structure" }
615 -re ".*$prompt $" { fail "ptype outer structure" }
616 timeout { fail "(timeout) ptype outer structure" }
617 }
618
619
620 send_gdb "ptype struct inner_struct\n"
621 expect {
622 -re "type = struct inner_struct \{.*
623 int inner_int;.*
624 (long|long int|int) inner_long;.*
625 \}.*$prompt $" { pass "ptype inner structure" }
626 -re ".*$prompt $" { fail "ptype inner structure" }
627 timeout { fail "(timeout) ptype inner structure" }
628 }
629
630
631 send_gdb "ptype union inner_union\n"
632 expect {
633 -re "type = union inner_union \{.*
634 int inner_union_int;.*
635 (long|long int|int) inner_union_long;.*
636 \}.*$prompt $" { pass "ptype inner union" }
637 -re ".*$prompt $" { fail "ptype inner union" }
638 timeout { fail "(timeout) ptype inner union" }
639 }
640
641
642 send_gdb "ptype nested_su\n"
643 expect {
644 -re "type = struct outer_struct \{.*
645 int outer_int;.*
646 struct inner_struct inner_struct_instance;.*
647 union inner_union inner_union_instance;.*
648 (long|long int|int) outer_long;.*
649 \}.*$prompt $" { pass "ptype nested structure" }
650 -re ".*$prompt $" { fail "ptype nested structure" }
651 timeout { fail "(timeout) ptype nested structure" }
652 }
653
654
655 send_gdb "ptype nested_su.outer_int\n"
656 expect {
657 -re "type = int.*$prompt $" { pass "ptype outer int" }
658 -re ".*$prompt $" { fail "ptype outer int" }
659 timeout { fail "(timeout) ptype outer int" }
660 }
661
662
663 send_gdb "ptype nested_su.inner_struct_instance\n"
664 expect {
665 -re "type = struct inner_struct \{.*
666 int inner_int;.*
667 (long|long int|int) inner_long;.*
668 \}.*$prompt $" { pass "ptype nested structure" }
669 -re ".*$prompt $" { fail "ptype nested structure" }
670 timeout { fail "(timeout) ptype nested structure" }
671 }
672
673
674 send_gdb "ptype nested_su.inner_struct_instance.inner_int\n"
675 expect {
676 -re "type = int.*$prompt $" { pass "ptype inner int" }
677 -re ".*$prompt $" { fail "ptype inner int" }
678 timeout { fail "(timeout) ptype inner int" }
679 }
680
681
682 send_gdb "ptype nested_su.inner_union_instance\n"
683 expect {
684 -re "type = union inner_union \{.*
685 int inner_union_int;.*
686 (long|long int|int) inner_union_long;.*
687 \}.*$prompt $" { pass "ptype nested union" }
688 -re ".*$prompt $" { fail "ptype nested union" }
689 timeout { fail "(timeout) ptype nested union" }
690 }
691
692 # Test printing type of string constants and array constants, but
693 # requires a running process. These call malloc, and can take a long
694 # time to execute over a slow serial link, so increase the timeout.
695
696 # UDI can't do this (PR 2416). XFAIL is not suitable, because attempting
697 # the operation causes a slow painful death rather than a nice simple failure.
698
699 if ![istarget "*-*-udi*"] then {
700 if [runto_main] then {
701 setup_xfail "a29k-*-udi" 2416
702 gdb_test "ptype \"abc\"" "type = char \\\[4\\\]"
703 setup_xfail "a29k-*-udi" 2416
704 gdb_test "ptype {'a','b','c'}" "type = char \\\[3\\\]"
705 setup_xfail "a29k-*-udi" 2416
706 gdb_test "ptype {0,1,2}" "type = int \\\[3\\\]"
707 setup_xfail "a29k-*-udi" 2416
708 gdb_test "ptype {(long)0,(long)1,(long)2}" "type = long \\\[3\\\]"
709 setup_xfail "a29k-*-udi" 2416
710 gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]"
711 setup_xfail "a29k-*-udi" 2416
712 gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]"
713 setup_xfail "a29k-*-udi" 2416
714 gdb_test "ptype {4,5,6}\[2\]" "type = int"
715 setup_xfail "a29k-*-udi" 2416
716 gdb_test "ptype *&{4,5,6}\[1\]" "type = int"
717 }
718 }