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 ".* = \{\<vA\> = \{va = 3, vx = 4\}, _vptr.vB = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
735 pass "print g_vB (FIXME v3 vtbl ptr)"
737 -re ".*invalid address 0x0.*$gdb_prompt $" {
738 # Does not happen with gcc cygnus-2.4.5-930828
739 fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)"
740 # Many of the rest of these tests have the same problem.
743 -re ".*$gdb_prompt $" { fail "print g_vB" }
744 timeout { fail "print g_vB (timeout)" ; return }
747 # Print all members of g_vC.
749 setup_xfail_format "DWARF 1"
750 send_gdb "print g_vC\n"
752 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, Virtual table at $hex\}$nl$gdb_prompt $" {
753 pass "print g_vC (aCC)"
755 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, __vfp = $hex\}$nl$gdb_prompt $" {
756 pass "print g_vC (aCC)"
758 -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, ${vbptr}vA = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
761 -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, _vptr.vC = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
762 pass "print g_vC (FIXME v3 vtbl ptr)"
764 -re ".*$gdb_prompt $" { fail "print g_vC" }
765 timeout { fail "print g_vC (timeout)" }
770 # Multiple virtual inheritance, print individual members.
773 proc test_print_mvi_members {} {
778 # Print all members of g_vD.
780 setup_xfail_format "DWARF 1"
781 send_gdb "print g_vD.vA::va\n"
783 -re ".* = 19$nl$gdb_prompt $" { pass "print g_vD.vA::va" }
784 -re ".*virtual baseclass botch.*$gdb_prompt $" {
785 # Does not happen with gcc cygnus-2.4.5-930828
786 fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)"
787 # Many of the rest of these tests have the same problem.
790 -re ".*$gdb_prompt $" { fail "print g_vD.vA::va" }
791 timeout { fail "print g_vD.vA::va (timeout)" ; return }
794 setup_xfail_format "DWARF 1"
795 gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx"
797 setup_xfail_format "DWARF 1"
798 gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb"
800 setup_xfail_format "DWARF 1"
801 gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx"
803 setup_xfail_format "DWARF 1"
804 gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc"
806 setup_xfail_format "DWARF 1"
807 gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx"
809 gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd"
811 gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx"
813 # Print all members of g_vE.
815 setup_xfail_format "DWARF 1"
816 gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va"
818 setup_xfail_format "DWARF 1"
819 gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx"
821 setup_xfail_format "DWARF 1"
822 gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb"
824 setup_xfail_format "DWARF 1"
825 gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx"
827 setup_xfail_format "DWARF 1"
828 gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc"
830 setup_xfail_format "DWARF 1"
831 gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx"
833 setup_xfail_format "DWARF 1"
834 gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd"
836 gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx"
838 gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve"
840 gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx"
844 # Multiple virtual inheritance, print type definitions.
847 proc test_ptype_mvi {} {
853 setup_xfail_format "DWARF 1"
854 send_gdb "ptype vD\n"
856 -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 $" {
859 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
862 -re ".*$gdb_prompt $" { fail "ptype vD" }
863 timeout { fail "(timeout) ptype vD" }
866 setup_xfail_format "DWARF 1"
867 send_gdb "ptype class vD\n"
869 -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 $" {
870 pass "ptype class vD"
872 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
873 pass "ptype class vD"
875 -re ".*$gdb_prompt $" { fail "ptype class vD" }
876 timeout { fail "(timeout) ptype class vD" }
879 setup_xfail_format "DWARF 1"
880 send_gdb "ptype g_vD\n"
882 -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 $" {
885 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
888 -re ".*$gdb_prompt $" { fail "ptype g_vD" }
889 timeout { fail "(timeout) ptype g_vD" }
892 setup_xfail_format "DWARF 1"
893 send_gdb "ptype vE\n"
895 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
898 -re ".*class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
901 -re ".*$gdb_prompt $" { fail "ptype vE" }
902 timeout { fail "(timeout) ptype vE" }
905 setup_xfail_format "DWARF 1"
906 send_gdb "ptype class vE\n"
908 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
909 pass "ptype class vE"
911 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
912 pass "ptype class vE"
914 -re ".*$gdb_prompt $" { fail "ptype class vE" }
915 timeout { fail "(timeout) ptype class vE" }
918 setup_xfail_format "DWARF 1"
919 send_gdb "ptype g_vE\n"
921 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
924 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
927 -re ".*$gdb_prompt $" { fail "ptype g_vE" }
928 timeout { fail "(timeout) ptype g_vE" }
933 # Multiple virtual inheritance, print complete classes.
936 proc test_print_mvi_classes {} {
943 # Print all members of g_vD.
945 setup_xfail_format "DWARF 1"
946 send_gdb "print g_vD\n"
948 -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 $" {
949 pass "print g_vD (aCC)"
951 -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 $" {
952 pass "print g_vD (aCC)"
954 -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 $" {
957 -re ".* = \{\<vB\> = \{\<vA\> = \{va = 19, vx = 20\}, _vptr.vB = $hex, vb = 21, vx = 22\}, \<vC\> = \{_vptr.vC = $hex, vc = 23, vx = 24\}, _vptr.vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
958 pass "print g_vD (FIXME v3 vtbl ptr)"
960 -re ".*invalid address 0x0.*$gdb_prompt $" {
961 # Does not happen with gcc cygnus-2.4.5-930828
962 fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)"
963 # Many of the rest of these tests have the same problem.
966 -re ".*$gdb_prompt $" { fail "print g_vD" }
967 timeout { fail "print g_vD (timeout)" ; return }
970 # Print all members of g_vE.
972 setup_xfail_format "DWARF 1"
973 send_gdb "print g_vE\n"
975 -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 $" {
976 pass "print g_vE (aCC)"
978 -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 $" {
979 pass "print g_vE (aCC)"
981 -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 $" {
984 -re ".* = \{\<vD\> = \{\<vB\> = \{\<vA\> = \{va = 0, vx = 0\}, _vptr.vB = $hex, vb = 0, vx = 0\}, \<vC\> = \{_vptr.vC = $hex, vc = 0, vx = 0\}, _vptr.vD = $hex, vd = 0, vx = 0\}, _vptr.vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
985 pass "print g_vE (FIXME v3 vtbl ptr)"
987 -re ".*$gdb_prompt $" { fail "print g_vE" }
988 timeout { fail "print g_vE (timeout)" }
1003 # Start with a fresh gdb.
1007 gdb_reinitialize_dir $srcdir/$subdir
1010 gdb_test "set language c++" ""
1011 gdb_test "set width 0" ""
1013 # Get the debug format for the compiled test case.
1015 if { ![ runto_main] } {
1026 gdb_stop_suppressing_tests;
1028 if { ![ runto 'inheritance2' ] } {
1032 test_print_si_members
1033 test_print_si_classes
1034 test_print_mi_members
1035 test_print_mi_classes
1036 test_print_anon_union
1038 gdb_stop_suppressing_tests;
1040 if { ![ runto 'inheritance4' ] } {
1044 test_print_svi_members
1045 test_print_svi_classes
1046 test_print_mvi_members
1047 test_print_mvi_classes