1 # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001
2 # Free Software Foundation, Inc.
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 2 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
21 # This file was written by Fred Fish. (fnf@cygnus.com)
26 # The format of a g++ virtual base pointer.
27 set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?"
33 if { [skip_cplus_tests] } { continue }
35 # Note - create separate "inherit" executable from misc.cc
37 set testfile "inherit"
39 set binfile ${objdir}/${subdir}/${testfile}
42 # Create and source the file that provides information about the compiler
43 # used to compile the test case.
45 if [get_compiler_info ${binfile} "c++"] {
49 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
50 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
54 # Single inheritance, print individual members.
57 proc test_print_si_members {} {
58 # Print all members of g_A using fully qualified form.
60 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
62 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
64 # Print members of g_A using nonambiguous compact form.
66 gdb_test "print g_A.a" ".* = 1" "print g_A.a"
68 gdb_test "print g_A.x" ".* = 2" "print g_A.x"
70 # Print all members of g_B using fully qualified form.
72 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
74 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
76 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
78 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
80 # Print members of g_B using nonambiguous compact form.
82 setup_xfail_format "DWARF 1"
83 gdb_test "print g_B.a" ".* = 3" "print g_B.a"
85 gdb_test "print g_B.b" ".* = 5" "print g_B.b"
87 gdb_test "print g_B.x" ".* = 6" "print g_B.x"
89 # Print all members of g_C using fully qualified form.
91 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
93 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
95 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
97 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
99 # Print members of g_C using nonambiguous compact form.
101 setup_xfail_format "DWARF 1"
102 gdb_test "print g_C.a" ".* = 7" "print g_C.a"
104 gdb_test "print g_C.c" ".* = 9" "print g_C.c"
106 gdb_test "print g_C.x" ".* = 10" "print g_C.x"
110 # Single inheritance, print type definitions.
113 proc test_ptype_si {} {
117 global hp_aCC_compiler
119 # Print class A as a type.
123 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
124 pass "ptype A (FIXME)"
126 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
128 fail "ptype A (FIXME)"
130 -re ".*$gdb_prompt $" { fail "ptype A" }
131 timeout { fail "ptype A (timeout)" ; return }
134 # Print class A as an explicit class.
136 send_gdb "ptype class A\n"
138 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
139 pass "ptype class A (FIXME)"
141 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
142 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
143 fail "ptype class A (FIXME)"
145 -re ".*$gdb_prompt $" { fail "ptype class A" }
146 timeout { fail "ptype class A (timeout)" ; return }
149 # Print type of an object of type A.
151 send_gdb "ptype g_A\n"
153 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
154 pass "ptype g_A (FIXME)"
156 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
157 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
158 fail "ptype g_A (FIXME)"
160 -re ".*$gdb_prompt $" { fail "ptype g_A" }
161 timeout { fail "ptype g_A (timeout)" ; return }
164 # Print class B as a type.
166 setup_xfail_format "DWARF 1"
167 gdb_test "ptype B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype B"
169 # Print class B as an explicit class.
171 setup_xfail_format "DWARF 1"
172 gdb_test "ptype class B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype class B"
174 # Print type of an object of type B.
176 setup_xfail_format "DWARF 1"
177 gdb_test "ptype g_B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype g_B"
179 # Print class C as a type.
181 setup_xfail_format "DWARF 1"
182 gdb_test "ptype C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype C"
184 # Print class C as an explicit class.
186 setup_xfail_format "DWARF 1"
187 gdb_test "ptype class C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype class C"
189 # Print type of an object of type g_C.
191 setup_xfail_format "DWARF 1"
192 gdb_test "ptype g_C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype g_C"
194 # gcc cygnus-2.3.3 (Q1) has this bug, but it was fixed as of
195 # cygnus-2.3.3-930417. PR 2819.
196 send_gdb "ptype tagless_struct\n"
198 -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct &\\);${ws}\\\$_1 \\(tagless_struct &\\);${ws}\\\$_1 \\(\\);${ws}\}$nl$gdb_prompt $" {
199 pass "ptype tagless struct"
201 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
202 pass "ptype tagless struct (obsolete gcc or gdb)"
204 -re ".*$gdb_prompt $" {
205 fail "ptype tagless struct"
208 fail "ptype tagless struct (timeout)"
212 send_gdb "ptype v_tagless\n"
214 -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct &\\);${ws}\\\$_1 \\(tagless_struct &\\);${ws}\\\$_1 \\(\\);${ws}\}$nl$gdb_prompt $" {
215 pass "ptype variable of type tagless struct"
217 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
218 pass "ptype variable of type tagless struct (obsolete gcc or gdb)"
220 -re ".*$gdb_prompt $" {
221 fail "ptype variable of type tagless struct"
224 fail "ptype variable of type tagless struct (timeout)"
230 # Single inheritance, print complete classes.
233 proc test_print_si_classes {} {
234 # Print all members of g_A.
236 gdb_test "print g_A" ".* = \{a = 1, x = 2\}" "print g_A"
238 # Print all members of g_B.
240 setup_xfail_format "DWARF 1"
241 gdb_test "print g_B" ".* = \{\<(class |)A\> = \{a = 3, x = 4\}, b = 5, x = 6\}" "print g_B"
243 # Print all members of g_C.
245 setup_xfail_format "DWARF 1"
246 gdb_test "print g_C" ".* = \{\<(class |)A\> = \{a = 7, x = 8\}, c = 9, x = 10\}" "print g_C"
250 # Single inheritance, print anonymous unions.
251 # GDB versions prior to 4.14 entered an infinite loop when printing
252 # the type of a class containing an anonymous union, and they were also
253 # incapable of printing the member of an anonymous union.
254 # We test the printing of the member first, and perform the other tests
255 # only if the test succeeds, to avoid the infinite loop.
258 proc test_print_anon_union {} {
263 setup_xfail_format "DWARF 1"
264 gdb_test "print g_anon_union.a" ".* = 2" "print anonymous union member"
265 setup_xfail_format "DWARF 1"
266 send_gdb "print g_anon_union\n"
268 -re ".* = \{one = 1, ( = |)\{a = 2, b = 2\}\}$nl$gdb_prompt $" {
269 pass "print variable of type anonymous union"
271 -re ".* = .*\{one = 1, ( = |)\{a = 2, b = .*\}\}$nl$gdb_prompt $" {
272 pass "print variable of type anonymous union (obsolete gcc or gdb)"
274 -re ".*$nl$gdb_prompt $" {
275 fail "print variable of type anonymous union"
278 fail "print variableof type anonymous union (timeout)"
281 setup_xfail_format "DWARF 1"
282 send_gdb "ptype g_anon_union\n"
284 -re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}public:${ws}int a;${ws}long int b;${ws}union \{\.\.\.\} & operator=\\(union \{\.\.\.\} &\\);${ws}\\\$_0 \\(union \{\.\.\.\} &\\);${ws}\\\$_0 \\(\\);${ws}\};${ws}class_with_anon_union & operator=\\(class_with_anon_union const &\\);${ws}class_with_anon_union\\(class_with_anon_union const &\\);${ws}class_with_anon_union\\(void\\);${ws}\}$nl$gdb_prompt $" {
285 pass "print type of anonymous union"
287 -re "type = (struct|class).*\{.*int one;.*union \{.*int a;.*(long|long int|int) b;.*\};.*\}$nl$gdb_prompt $" {
288 pass "print type of anonymous union (obsolete gcc or gdb)"
290 -re ".*$nl$gdb_prompt $" {
291 fail "print type of anonymous union"
294 fail "print type of anonymous union (timeout)"
300 # Multiple inheritance, print individual members.
303 proc test_print_mi_members {} {
306 global hp_aCC_compiler
308 # Print all members of g_A.
310 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
312 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
314 # Print all members of g_B.
316 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
318 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
320 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
322 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
324 # Print all members of g_C.
326 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
328 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
330 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
332 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
334 # Print all members of g_D.
336 # The following is ambiguous, and gdb should detect this.
337 # For now, accept gdb's behavior as an expected failure if it
338 # simply prints either member correctly.
340 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
341 send_gdb "print g_D.A::a\n"
343 -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 15$nl$gdb_prompt $" {
344 pass "print g_D.A::a"
346 -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 11$nl$gdb_prompt $" {
347 pass "print g_D.A::a (using B)"
349 -re ".* = 15$nl$gdb_prompt $" {
350 fail "print g_D.A::a (FIXME)"
352 -re ".* = 11$nl$gdb_prompt $" {
353 fail "print g_D.A::a (FIXME)"
355 -re ".*$gdb_prompt $" { fail "print g_D.A::a" }
356 timeout { fail "print g_D.A::a (timeout)" ; return }
359 # The following is ambiguous, and gdb should detect this.
360 # For now, accept gdb's behavior as an expected failure if it
361 # simply prints either member correctly.
363 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
364 send_gdb "print g_D.A::x\n"
366 -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 16$nl$gdb_prompt $" {
367 pass "print g_D.A::x"
369 -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 12$nl$gdb_prompt $" {
370 pass "print g_D.A::x (using B)"
372 -re ".* = 16$nl$gdb_prompt $" {
373 fail "print g_D.A::x (FIXME)"
375 -re ".* = 12$nl$gdb_prompt $" {
376 fail "print g_D.A::x (FIXME)"
378 -re ".*$gdb_prompt $" { fail "print g_D.A::x" }
379 timeout { fail "print g_D.A::x (timeout)" ; return }
382 gdb_test "print g_D.B::b" ".* = 13" "print g_D.B::b"
384 gdb_test "print g_D.B::x" ".* = 14" "print g_D.B::x"
386 setup_xfail_format "DWARF 1"
387 gdb_test "print g_D.C::c" ".* = 17" "print g_D.C::c"
389 setup_xfail_format "DWARF 1"
390 gdb_test "print g_D.C::x" ".* = 18" "print g_D.C::x"
392 gdb_test "print g_D.D::d" ".* = 19" "print g_D.D::d"
394 gdb_test "print g_D.D::x" ".* = 20" "print g_D.D::x"
396 # Print all members of g_E.
398 # The following is ambiguous, and gdb should detect this.
399 # For now, accept gdb's behavior as an expected failure if it
400 # simply prints either member correctly.
403 send_gdb "print g_E.A::a\n"
405 -re ".* = 21$nl$gdb_prompt $" {
406 fail "print g_E.A::a (FIXME)"
408 -re ".* = 25$nl$gdb_prompt $" {
409 fail "print g_E.A::a (FIXME)"
411 -re ".*$gdb_prompt $" { fail "print g_E.A::a" }
412 timeout { fail "print g_E.A::a (timeout)" ; return }
415 # The following is ambiguous, and gdb should detect this.
416 # For now, accept gdb's behavior as an expected failure if it
417 # simply prints either member correctly.
419 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
420 send_gdb "print g_E.A::x\n"
422 -re "warning: A ambiguous; using E::D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 26$nl$gdb_prompt $" {
423 pass "print g_E.A::x"
425 -re "warning: A ambiguous; using E::D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 22$nl$gdb_prompt $" {
426 pass "print g_E.A::x (using B)"
428 -re ".* = 26$nl$gdb_prompt $" {
429 fail "print g_E.A::x (FIXME)"
431 -re ".* = 22$nl$gdb_prompt $" {
432 fail "print g_E.A::x (FIXME)"
434 -re ".*$gdb_prompt $" { fail "print g_E.A::x" }
435 timeout { fail "print g_E.A::x (timeout)" ; return }
438 gdb_test "print g_E.B::b" ".* = 23" "print g_E.B::b"
440 gdb_test "print g_E.B::x" ".* = 24" "print g_E.B::x"
442 setup_xfail_format "DWARF 1"
443 gdb_test "print g_E.C::c" ".* = 27" "print g_E.C::c"
445 setup_xfail_format "DWARF 1"
446 gdb_test "print g_E.C::x" ".* = 28" "print g_E.C::x"
448 gdb_test "print g_E.D::d" ".* = 29" "print g_E.D::d"
450 gdb_test "print g_E.D::x" ".* = 30" "print g_E.D::x"
452 gdb_test "print g_E.E::e" ".* = 31" "print g_E.E::e"
454 gdb_test "print g_E.E::x" ".* = 32" "print g_E.E::x"
458 # Multiple inheritance, print type definitions.
461 proc test_ptype_mi {} {
464 setup_xfail_format "DWARF 1"
465 gdb_test "ptype D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype D"
467 setup_xfail_format "DWARF 1"
468 gdb_test "ptype class D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype class D"
470 setup_xfail_format "DWARF 1"
471 gdb_test "ptype g_D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype g_D"
473 setup_xfail_format "DWARF 1"
474 gdb_test "ptype E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype E"
476 setup_xfail_format "DWARF 1"
477 gdb_test "ptype class E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype class E"
479 setup_xfail_format "DWARF 1"
480 gdb_test "ptype g_E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype g_E"
484 # Multiple inheritance, print complete classes.
487 proc test_print_mi_classes {} {
488 # Print all members of g_D.
490 setup_xfail_format "DWARF 1"
491 gdb_test "print g_D" ".* = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 11, x = 12\}, b = 13, x = 14\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 15, x = 16\}, c = 17, x = 18\}, d = 19, x = 20\}" "print g_D"
493 # Print all members of g_E.
495 setup_xfail_format "DWARF 1"
496 gdb_test "print g_E" ".* = \{\<(class |)D\> = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 21, x = 22\}, b = 23, x = 24\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 25, x = 26\}, c = 27, x = 28\}, d = 29, x = 30\}, e = 31, x = 32\}" "print g_E"
500 # Single virtual inheritance, print individual members.
503 proc test_print_svi_members {} {
508 # Print all members of g_vA.
510 gdb_test "print g_vA.vA::va" ".* = 1" "print g_vA.vA::va"
512 gdb_test "print g_vA.vA::vx" ".* = 2" "print g_vA.vA::vx"
514 # Print members of g_vA using compact form.
516 gdb_test "print g_vA.va" ".* = 1" "print g_vA.va"
518 gdb_test "print g_vA.vx" ".* = 2" "print g_vA.vx"
520 # Print all members of g_vB.
522 setup_xfail_format "DWARF 1"
523 send_gdb "print g_vB.vA::va\n"
525 -re ".* = 3$nl$gdb_prompt $" { pass "print g_vB.vA::va" }
526 -re ".*virtual baseclass botch.*$gdb_prompt $" {
527 # Does not happen with gcc cygnus-2.4.5-930828
528 fail "print g_vB.vA::va (known bug with gcc cygnus-2.4.5-930417)"
529 # Many of the rest of these tests have the same problem.
532 -re ".*$gdb_prompt $" { fail "print g_vB.vA::va" }
533 timeout { fail "print g_vB.vA::va (timeout)" ; return }
536 setup_xfail_format "DWARF 1"
537 gdb_test "print g_vB.vA::vx" ".* = 4" "print g_vB.vA::vx"
539 gdb_test "print g_vB.vB::vb" ".* = 5" "print g_vB.vB::vb"
541 gdb_test "print g_vB.vB::vx" ".* = 6" "print g_vB.vB::vx"
543 # Print members of g_vB using compact form.
545 setup_xfail_format "DWARF 1"
546 gdb_test "print g_vB.va" ".* = 3" "print g_vB.va"
548 gdb_test "print g_vB.vb" ".* = 5" "print g_vB.vb"
550 gdb_test "print g_vB.vx" ".* = 6" "print g_vB.vx"
552 # Print all members of g_vC.
554 setup_xfail_format "DWARF 1"
555 gdb_test "print g_vC.vA::va" ".* = 7" "print g_vC.vA::va"
557 setup_xfail_format "DWARF 1"
558 gdb_test "print g_vC.vA::vx" ".* = 8" "print g_vC.vA::vx"
560 gdb_test "print g_vC.vC::vc" ".* = 9" "print g_vC.vC::vc"
562 gdb_test "print g_vC.vC::vx" ".* = 10" "print g_vC.vC::vx"
564 # Print members of g_vC using compact form.
566 setup_xfail_format "DWARF 1"
567 gdb_test "print g_vC.va" ".* = 7" "print g_vC.va"
569 gdb_test "print g_vC.vc" ".* = 9" "print g_vC.vc"
571 gdb_test "print g_vC.vx" ".* = 10" "print g_vC.vx"
575 # Single virtual inheritance, print type definitions.
578 proc test_ptype_vi {} {
584 # This class does not use any C++-specific features, so it's fine for
585 # it to print as "struct".
586 send_gdb "ptype vA\n"
588 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
591 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
594 -re ".*$gdb_prompt $" { fail "ptype vA" }
595 timeout { fail "ptype vA (timeout)" ; return }
598 # This class does not use any C++-specific features, so it's fine for
599 # it to print as "struct".
600 send_gdb "ptype class vA\n"
602 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
603 pass "ptype class vA"
605 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
606 pass "ptype class vA"
608 -re ".*$gdb_prompt $" { fail "ptype class vA" }
609 timeout { fail "ptype class vA (timeout)" ; return }
612 # This class does not use any C++-specific features, so it's fine for
613 # it to print as "struct".
614 send_gdb "ptype g_vA\n"
616 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
619 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
622 -re ".*$gdb_prompt $" { fail "ptype g_vA" }
623 timeout { fail "ptype g_vA (timeout)" ; return }
626 setup_xfail_format "DWARF 1"
627 send_gdb "ptype vB\n"
629 -re "ptype vB${nl}type = class vB : public virtual vA \{$nl private:${ws}vA \\*${vbptr}vA;$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" {
632 -re "ptype vB${nl}type = class vB : public virtual vA \{$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" {
633 pass "ptype vB (aCC)"
635 -re ".*$gdb_prompt $" { fail "ptype vB" }
636 timeout { fail "ptype vB (timeout)" }
639 setup_xfail_format "DWARF 1"
640 send_gdb "ptype class vB\n"
642 -re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
643 pass "ptype class vB"
645 -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
646 pass "ptype class vB (aCC)"
648 -re ".*$gdb_prompt $" { fail "ptype class vB" }
649 timeout { fail "ptype class vB (timeout)" }
652 setup_xfail_format "DWARF 1"
653 send_gdb "ptype g_vB\n"
655 -re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
658 -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
659 pass "ptype g_vB (aCC)"
661 -re ".*$gdb_prompt $" { fail "ptype g_vB" }
662 timeout { fail "ptype g_vB (timeout)" }
665 setup_xfail_format "DWARF 1"
666 send_gdb "ptype vC\n"
668 -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
671 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
672 pass "ptype vC (aCC)"
674 -re ".*$gdb_prompt $" { fail "ptype vC" }
675 timeout { fail "ptype vC (timeout)" }
678 setup_xfail_format "DWARF 1"
679 send_gdb "ptype class vC\n"
681 -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
682 pass "ptype class vC"
684 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
685 pass "ptype class vC (aCC)"
687 -re ".*$gdb_prompt $" { fail "ptype class vC" }
688 timeout { fail "ptype class vC (timeout)" }
691 setup_xfail_format "DWARF 1"
692 send_gdb "ptype g_vC\n"
694 -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
697 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
698 pass "ptype g_vC (aCC)"
700 -re ".*$gdb_prompt $" { fail "ptype g_vC" }
701 timeout { fail "ptype g_vC (timeout)" }
706 # Single virtual inheritance, print complete classes.
709 proc test_print_svi_classes {} {
716 # Print all members of g_vA.
718 gdb_test "print g_vA" ".* = \{va = 1, vx = 2\}" "print g_vA"
720 # Print all members of g_vB.
722 setup_xfail_format "DWARF 1"
723 send_gdb "print g_vB\n"
725 -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, Virtual table at $hex\}$nl$gdb_prompt $" {
726 pass "print g_vB (aCC)"
728 -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, __vfp = $hex\}$nl$gdb_prompt $" {
729 pass "print g_vB (aCC)"
731 -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, ${vbptr}vA = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
734 -re ".*invalid address 0x0.*$gdb_prompt $" {
735 # Does not happen with gcc cygnus-2.4.5-930828
736 fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)"
737 # Many of the rest of these tests have the same problem.
740 -re ".*$gdb_prompt $" { fail "print g_vB" }
741 timeout { fail "print g_vB (timeout)" ; return }
744 # Print all members of g_vC.
746 setup_xfail_format "DWARF 1"
747 send_gdb "print g_vC\n"
749 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, Virtual table at $hex\}$nl$gdb_prompt $" {
750 pass "print g_vC (aCC)"
752 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, __vfp = $hex\}$nl$gdb_prompt $" {
753 pass "print g_vC (aCC)"
755 -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, ${vbptr}vA = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
758 -re ".*$gdb_prompt $" { fail "print g_vC" }
759 timeout { fail "print g_vC (timeout)" }
764 # Multiple virtual inheritance, print individual members.
767 proc test_print_mvi_members {} {
772 # Print all members of g_vD.
774 setup_xfail_format "DWARF 1"
775 send_gdb "print g_vD.vA::va\n"
777 -re ".* = 19$nl$gdb_prompt $" { pass "print g_vD.vA::va" }
778 -re ".*virtual baseclass botch.*$gdb_prompt $" {
779 # Does not happen with gcc cygnus-2.4.5-930828
780 fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)"
781 # Many of the rest of these tests have the same problem.
784 -re ".*$gdb_prompt $" { fail "print g_vD.vA::va" }
785 timeout { fail "print g_vD.vA::va (timeout)" ; return }
788 setup_xfail_format "DWARF 1"
789 gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx"
791 setup_xfail_format "DWARF 1"
792 gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb"
794 setup_xfail_format "DWARF 1"
795 gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx"
797 setup_xfail_format "DWARF 1"
798 gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc"
800 setup_xfail_format "DWARF 1"
801 gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx"
803 gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd"
805 gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx"
807 # Print all members of g_vE.
809 setup_xfail_format "DWARF 1"
810 gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va"
812 setup_xfail_format "DWARF 1"
813 gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx"
815 setup_xfail_format "DWARF 1"
816 gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb"
818 setup_xfail_format "DWARF 1"
819 gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx"
821 setup_xfail_format "DWARF 1"
822 gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc"
824 setup_xfail_format "DWARF 1"
825 gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx"
827 setup_xfail_format "DWARF 1"
828 gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd"
830 gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx"
832 gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve"
834 gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx"
838 # Multiple virtual inheritance, print type definitions.
841 proc test_ptype_mvi {} {
847 setup_xfail_format "DWARF 1"
848 send_gdb "ptype vD\n"
850 -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
853 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
856 -re ".*$gdb_prompt $" { fail "ptype vD" }
857 timeout { fail "(timeout) ptype vD" }
860 setup_xfail_format "DWARF 1"
861 send_gdb "ptype class vD\n"
863 -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
864 pass "ptype class vD"
866 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
867 pass "ptype class vD"
869 -re ".*$gdb_prompt $" { fail "ptype class vD" }
870 timeout { fail "(timeout) ptype class vD" }
873 setup_xfail_format "DWARF 1"
874 send_gdb "ptype g_vD\n"
876 -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
879 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
882 -re ".*$gdb_prompt $" { fail "ptype g_vD" }
883 timeout { fail "(timeout) ptype g_vD" }
886 setup_xfail_format "DWARF 1"
887 send_gdb "ptype vE\n"
889 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
892 -re ".*class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
895 -re ".*$gdb_prompt $" { fail "ptype vE" }
896 timeout { fail "(timeout) ptype vE" }
899 setup_xfail_format "DWARF 1"
900 send_gdb "ptype class vE\n"
902 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
903 pass "ptype class vE"
905 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
906 pass "ptype class vE"
908 -re ".*$gdb_prompt $" { fail "ptype class vE" }
909 timeout { fail "(timeout) ptype class vE" }
912 setup_xfail_format "DWARF 1"
913 send_gdb "ptype g_vE\n"
915 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
918 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
921 -re ".*$gdb_prompt $" { fail "ptype g_vE" }
922 timeout { fail "(timeout) ptype g_vE" }
927 # Multiple virtual inheritance, print complete classes.
930 proc test_print_mvi_classes {} {
937 # Print all members of g_vD.
939 setup_xfail_format "DWARF 1"
940 send_gdb "print g_vD\n"
942 -re ".* = \{\<class vB\> = \{\<class vA\> = \{va = 19, vx = 20\}, vb = 21, vx = 22, Virtual table at $hex\}, \<class vC\> = \{vc = 23, vx = 24, Virtual table at $hex\}, vd = 25, vx = 26, Virtual table at $hex\}$nl$gdb_prompt $" {
943 pass "print g_vD (aCC)"
945 -re ".* = \{\<class vB\> = \{\<class vA\> = \{va = 19, vx = 20\}, vb = 21, vx = 22, __vfp = $hex\}, \<class vC\> = \{vc = 23, vx = 24, __vfp = $hex\}, vd = 25, vx = 26, __vfp = $hex\}$nl$gdb_prompt $" {
946 pass "print g_vD (aCC)"
948 -re ".* = \{\<vB\> = \{\<vA\> = \{va = 19, vx = 20\}, ${vbptr}vA = $hex, vb = 21, vx = 22\}, \<vC\> = \{${vbptr}vA = $hex, vc = 23, vx = 24\}, ${vbptr}vC = $hex, ${vbptr}vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
951 -re ".*invalid address 0x0.*$gdb_prompt $" {
952 # Does not happen with gcc cygnus-2.4.5-930828
953 fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)"
954 # Many of the rest of these tests have the same problem.
957 -re ".*$gdb_prompt $" { fail "print g_vD" }
958 timeout { fail "print g_vD (timeout)" ; return }
961 # Print all members of g_vE.
963 setup_xfail_format "DWARF 1"
964 send_gdb "print g_vE\n"
966 -re ".* = \{\<class vD\> = \{\<class vB\> = \{\<class vA\> = \{va = 0, vx = 0\}, vb = 0, vx = 0, Virtual table at $hex\}, \<class vC\> = \{vc = 0, vx = 0, Virtual table at $hex\}, vd = 0, vx = 0, Virtual table at $hex\}, ve = 27, vx = 28, Virtual table at $hex\}$nl$gdb_prompt $" {
967 pass "print g_vE (aCC)"
969 -re ".* = \{\<class vD\> = \{\<class vB\> = \{\<class vA\> = \{va = 0, vx = 0\}, vb = 0, vx = 0, __vfp = $hex\}, \<class vC\> = \{vc = 0, vx = 0, __vfp = $hex\}, vd = 0, vx = 0, __vfp = $hex\}, ve = 27, vx = 28, __vfp = $hex\}$nl$gdb_prompt $" {
970 pass "print g_vE (aCC)"
972 -re ".* = \{\<vD\> = \{\<vB\> = \{\<vA\> = \{va = 0, vx = 0\}, ${vbptr}vA = $hex, vb = 0, vx = 0\}, \<vC\> = \{${vbptr}vA = $hex, vc = 0, vx = 0\}, ${vbptr}vC = $hex, ${vbptr}vB = $hex, vd = 0, vx = 0\}, ${vbptr}vD = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
975 -re ".*$gdb_prompt $" { fail "print g_vE" }
976 timeout { fail "print g_vE (timeout)" }
991 # Start with a fresh gdb.
995 gdb_reinitialize_dir $srcdir/$subdir
998 gdb_test "set language c++" ""
999 gdb_test "set width 0" ""
1001 # Get the debug format for the compiled test case.
1003 if { ![ runto_main] } {
1014 gdb_stop_suppressing_tests;
1016 if { ![ runto 'inheritance2' ] } {
1020 test_print_si_members
1021 test_print_si_classes
1022 test_print_mi_members
1023 test_print_mi_classes
1024 test_print_anon_union
1026 gdb_stop_suppressing_tests;
1028 if { ![ runto 'inheritance4' ] } {
1032 test_print_svi_members
1033 test_print_svi_classes
1034 test_print_mvi_members
1035 test_print_mvi_classes