1 # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003
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 gdb_test "print g_B.a" ".* = 3" "print g_B.a"
84 gdb_test "print g_B.b" ".* = 5" "print g_B.b"
86 gdb_test "print g_B.x" ".* = 6" "print g_B.x"
88 # Print all members of g_C using fully qualified form.
90 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
92 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
94 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
96 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
98 # Print members of g_C using nonambiguous compact form.
100 gdb_test "print g_C.a" ".* = 7" "print g_C.a"
102 gdb_test "print g_C.c" ".* = 9" "print g_C.c"
104 gdb_test "print g_C.x" ".* = 10" "print g_C.x"
108 # Single inheritance, print type definitions.
111 proc test_ptype_si {} {
115 global hp_aCC_compiler
117 # Print class A as a type.
121 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
122 pass "ptype A (FIXME)"
124 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
126 fail "ptype A (FIXME)"
128 -re ".*$gdb_prompt $" { fail "ptype A" }
129 timeout { fail "ptype A (timeout)" ; return }
132 # Print class A as an explicit class.
134 send_gdb "ptype class A\n"
136 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
137 pass "ptype class A (FIXME)"
139 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
140 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
141 fail "ptype class A (FIXME)"
143 -re ".*$gdb_prompt $" { fail "ptype class A" }
144 timeout { fail "ptype class A (timeout)" ; return }
147 # Print type of an object of type A.
149 send_gdb "ptype g_A\n"
151 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
152 pass "ptype g_A (FIXME)"
154 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
155 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
156 fail "ptype g_A (FIXME)"
158 -re ".*$gdb_prompt $" { fail "ptype g_A" }
159 timeout { fail "ptype g_A (timeout)" ; return }
162 # Print class B as a type.
164 gdb_test "ptype B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype B"
166 # Print class B as an explicit class.
168 gdb_test "ptype class B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype class B"
170 # Print type of an object of type B.
172 gdb_test "ptype g_B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype g_B"
174 # Print class C as a type.
176 gdb_test "ptype C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype C"
178 # Print class C as an explicit class.
180 gdb_test "ptype class C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype class C"
182 # Print type of an object of type g_C.
184 gdb_test "ptype g_C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype g_C"
186 # gcc cygnus-2.3.3 (Q1) has this bug, but it was fixed as of
187 # cygnus-2.3.3-930417. PR 2819.
188 send_gdb "ptype tagless_struct\n"
190 -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(\\);${ws}\}$nl$gdb_prompt $" {
191 pass "ptype tagless struct"
193 -re "type = class \{${ws}public:${ws}int one;${ws}int two;;${ws}\}$nl$gdb_prompt $" {
194 pass "ptype tagless struct"
196 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
197 pass "ptype tagless struct (obsolete gcc or gdb)"
199 -re ".*$gdb_prompt $" {
200 fail "ptype tagless struct"
203 fail "ptype tagless struct (timeout)"
207 send_gdb "ptype v_tagless\n"
209 -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(\\);${ws}\}$nl$gdb_prompt $" {
210 pass "ptype variable of type tagless struct"
212 -re "type = class \{${ws}public:${ws}int one;${ws}int two;;${ws}\}$nl$gdb_prompt $" {
213 pass "ptype tagless struct"
215 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
216 pass "ptype variable of type tagless struct (obsolete gcc or gdb)"
218 -re ".*$gdb_prompt $" {
219 fail "ptype variable of type tagless struct"
222 fail "ptype variable of type tagless struct (timeout)"
228 # Single inheritance, print complete classes.
231 proc test_print_si_classes {} {
232 # Print all members of g_A.
234 gdb_test "print g_A" ".* = \{a = 1, x = 2\}" "print g_A"
236 # Print all members of g_B.
238 gdb_test "print g_B" ".* = \{\<(class |)A\> = \{a = 3, x = 4\}, b = 5, x = 6\}" "print g_B"
240 # Print all members of g_C.
242 gdb_test "print g_C" ".* = \{\<(class |)A\> = \{a = 7, x = 8\}, c = 9, x = 10\}" "print g_C"
246 # Single inheritance, print anonymous unions.
247 # GDB versions prior to 4.14 entered an infinite loop when printing
248 # the type of a class containing an anonymous union, and they were also
249 # incapable of printing the member of an anonymous union.
250 # We test the printing of the member first, and perform the other tests
251 # only if the test succeeds, to avoid the infinite loop.
254 proc test_print_anon_union {} {
259 gdb_test "print g_anon_union.a" ".* = 2" "print anonymous union member"
260 send_gdb "print g_anon_union\n"
262 -re ".* = \{one = 1, ( = |)\{a = 2, b = 2\}\}$nl$gdb_prompt $" {
263 pass "print variable of type anonymous union"
265 -re ".* = .*\{one = 1, ( = |)\{a = 2, b = .*\}\}$nl$gdb_prompt $" {
266 pass "print variable of type anonymous union (obsolete gcc or gdb)"
268 -re ".*$nl$gdb_prompt $" {
269 fail "print variable of type anonymous union"
272 fail "print variableof type anonymous union (timeout)"
275 send_gdb "ptype g_anon_union\n"
277 -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 $" {
278 pass "print type of anonymous union"
280 -re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}int a;${ws}long int b;${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 $" {
281 pass "print type of anonymous union"
283 -re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}int a;${ws}long int b;${ws}\};${ws}\}$nl$gdb_prompt $" {
284 pass "print type of anonymous union"
286 -re "type = (struct|class).*\{.*int one;.*union \{.*int a;.*(long|long int|int) b;.*\};.*\}$nl$gdb_prompt $" {
287 pass "print type of anonymous union (obsolete gcc or gdb)"
289 -re ".*$nl$gdb_prompt $" {
290 fail "print type of anonymous union"
293 fail "print type of anonymous union (timeout)"
299 # Multiple inheritance, print individual members.
302 proc test_print_mi_members {} {
305 global hp_aCC_compiler
307 # Print all members of g_A.
309 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
311 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
313 # Print all members of g_B.
315 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
317 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
319 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
321 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
323 # Print all members of g_C.
325 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
327 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
329 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
331 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
333 # Print all members of g_D.
335 # The following is ambiguous, and gdb should detect this.
336 # For now, accept gdb's behavior as an expected failure if it
337 # simply prints either member correctly.
339 send_gdb "print g_D.A::a\n"
341 -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 15$nl$gdb_prompt $" {
342 pass "print g_D.A::a"
344 -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 11$nl$gdb_prompt $" {
345 pass "print g_D.A::a (using B)"
347 -re ".* = 15$nl$gdb_prompt $" {
348 kfail "gdb/68" "print g_D.A::a"
350 -re ".* = 11$nl$gdb_prompt $" {
351 kfail "gdb/68" "print g_D.A::a"
353 -re ".*$gdb_prompt $" { fail "print g_D.A::a" }
354 timeout { fail "print g_D.A::a (timeout)" ; return }
357 # The following is ambiguous, and gdb should detect this.
358 # For now, accept gdb's behavior as an expected failure if it
359 # simply prints either member correctly.
361 send_gdb "print g_D.A::x\n"
363 -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 16$nl$gdb_prompt $" {
364 pass "print g_D.A::x"
366 -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 12$nl$gdb_prompt $" {
367 pass "print g_D.A::x (using B)"
369 -re ".* = 16$nl$gdb_prompt $" {
370 kfail "gdb/68" "print g_D.A::x"
372 -re ".* = 12$nl$gdb_prompt $" {
373 kfail "gdb/68" "print g_D.A::x"
375 -re ".*$gdb_prompt $" { fail "print g_D.A::x" }
376 timeout { fail "print g_D.A::x (timeout)" ; return }
379 gdb_test "print g_D.B::b" ".* = 13" "print g_D.B::b"
381 gdb_test "print g_D.B::x" ".* = 14" "print g_D.B::x"
383 gdb_test "print g_D.C::c" ".* = 17" "print g_D.C::c"
385 gdb_test "print g_D.C::x" ".* = 18" "print g_D.C::x"
387 gdb_test "print g_D.D::d" ".* = 19" "print g_D.D::d"
389 gdb_test "print g_D.D::x" ".* = 20" "print g_D.D::x"
391 # Print all members of g_E.
393 # The following is ambiguous, and gdb should detect this.
394 # For now, accept gdb's behavior as an expected failure if it
395 # simply prints either member correctly.
397 send_gdb "print g_E.A::a\n"
399 -re ".* = 21$nl$gdb_prompt $" {
400 kfail "gdb/68" "print g_E.A::a"
402 -re ".* = 25$nl$gdb_prompt $" {
403 kfail "gdb/68" "print g_E.A::a"
405 -re ".*$gdb_prompt $" { fail "print g_E.A::a" }
406 timeout { fail "print g_E.A::a (timeout)" ; return }
409 # The following is ambiguous, and gdb should detect this.
410 # For now, accept gdb's behavior as an expected failure if it
411 # simply prints either member correctly.
413 send_gdb "print g_E.A::x\n"
415 -re "warning: A ambiguous; using E::D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 26$nl$gdb_prompt $" {
416 pass "print g_E.A::x"
418 -re "warning: A ambiguous; using E::D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 22$nl$gdb_prompt $" {
419 pass "print g_E.A::x (using B)"
421 -re ".* = 26$nl$gdb_prompt $" {
422 kfail "gdb/68" "print g_E.A::x"
424 -re ".* = 22$nl$gdb_prompt $" {
425 kfail "gdb/68" "print g_E.A::x"
427 -re ".*$gdb_prompt $" { fail "print g_E.A::x" }
428 timeout { fail "print g_E.A::x (timeout)" ; return }
431 gdb_test "print g_E.B::b" ".* = 23" "print g_E.B::b"
433 gdb_test "print g_E.B::x" ".* = 24" "print g_E.B::x"
435 gdb_test "print g_E.C::c" ".* = 27" "print g_E.C::c"
437 gdb_test "print g_E.C::x" ".* = 28" "print g_E.C::x"
439 gdb_test "print g_E.D::d" ".* = 29" "print g_E.D::d"
441 gdb_test "print g_E.D::x" ".* = 30" "print g_E.D::x"
443 gdb_test "print g_E.E::e" ".* = 31" "print g_E.E::e"
445 gdb_test "print g_E.E::x" ".* = 32" "print g_E.E::x"
449 # Multiple inheritance, print type definitions.
452 proc test_ptype_mi {} {
455 gdb_test "ptype D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype D"
457 gdb_test "ptype class D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype class D"
459 gdb_test "ptype g_D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype g_D"
461 gdb_test "ptype E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype E"
463 gdb_test "ptype class E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype class E"
465 gdb_test "ptype g_E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype g_E"
469 # Multiple inheritance, print complete classes.
472 proc test_print_mi_classes {} {
473 # Print all members of g_D.
475 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"
477 # Print all members of g_E.
479 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"
483 # Single virtual inheritance, print individual members.
486 proc test_print_svi_members {} {
491 # Print all members of g_vA.
493 gdb_test "print g_vA.vA::va" ".* = 1" "print g_vA.vA::va"
495 gdb_test "print g_vA.vA::vx" ".* = 2" "print g_vA.vA::vx"
497 # Print members of g_vA using compact form.
499 gdb_test "print g_vA.va" ".* = 1" "print g_vA.va"
501 gdb_test "print g_vA.vx" ".* = 2" "print g_vA.vx"
503 # Print all members of g_vB.
505 send_gdb "print g_vB.vA::va\n"
507 -re ".* = 3$nl$gdb_prompt $" { pass "print g_vB.vA::va" }
508 -re ".*virtual baseclass botch.*$gdb_prompt $" {
509 # Does not happen with gcc cygnus-2.4.5-930828
510 fail "print g_vB.vA::va (known bug with gcc cygnus-2.4.5-930417)"
511 # Many of the rest of these tests have the same problem.
514 -re ".*$gdb_prompt $" { fail "print g_vB.vA::va" }
515 timeout { fail "print g_vB.vA::va (timeout)" ; return }
518 gdb_test "print g_vB.vA::vx" ".* = 4" "print g_vB.vA::vx"
520 gdb_test "print g_vB.vB::vb" ".* = 5" "print g_vB.vB::vb"
522 gdb_test "print g_vB.vB::vx" ".* = 6" "print g_vB.vB::vx"
524 # Print members of g_vB using compact form.
526 gdb_test "print g_vB.va" ".* = 3" "print g_vB.va"
528 gdb_test "print g_vB.vb" ".* = 5" "print g_vB.vb"
530 gdb_test "print g_vB.vx" ".* = 6" "print g_vB.vx"
532 # Print all members of g_vC.
534 gdb_test "print g_vC.vA::va" ".* = 7" "print g_vC.vA::va"
536 gdb_test "print g_vC.vA::vx" ".* = 8" "print g_vC.vA::vx"
538 gdb_test "print g_vC.vC::vc" ".* = 9" "print g_vC.vC::vc"
540 gdb_test "print g_vC.vC::vx" ".* = 10" "print g_vC.vC::vx"
542 # Print members of g_vC using compact form.
544 gdb_test "print g_vC.va" ".* = 7" "print g_vC.va"
546 gdb_test "print g_vC.vc" ".* = 9" "print g_vC.vc"
548 gdb_test "print g_vC.vx" ".* = 10" "print g_vC.vx"
552 # Single virtual inheritance, print type definitions.
555 proc test_ptype_vi {} {
561 # This class does not use any C++-specific features, so it's fine for
562 # it to print as "struct".
563 send_gdb "ptype vA\n"
565 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
568 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
571 -re ".*$gdb_prompt $" { fail "ptype vA" }
572 timeout { fail "ptype vA (timeout)" ; return }
575 # This class does not use any C++-specific features, so it's fine for
576 # it to print as "struct".
577 send_gdb "ptype class vA\n"
579 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
580 pass "ptype class vA"
582 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
583 pass "ptype class vA"
585 -re ".*$gdb_prompt $" { fail "ptype class vA" }
586 timeout { fail "ptype class vA (timeout)" ; return }
589 # This class does not use any C++-specific features, so it's fine for
590 # it to print as "struct".
591 send_gdb "ptype g_vA\n"
593 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
596 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
599 -re ".*$gdb_prompt $" { fail "ptype g_vA" }
600 timeout { fail "ptype g_vA (timeout)" ; return }
603 send_gdb "ptype vB\n"
605 -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 $" {
608 -re "ptype vB${nl}type = class vB : public virtual vA \{$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" {
609 pass "ptype vB (aCC)"
611 -re ".*$gdb_prompt $" { fail "ptype vB" }
612 timeout { fail "ptype vB (timeout)" }
615 send_gdb "ptype class vB\n"
617 -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 $" {
618 pass "ptype class vB"
620 -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
621 pass "ptype class vB (aCC)"
623 -re ".*$gdb_prompt $" { fail "ptype class vB" }
624 timeout { fail "ptype class vB (timeout)" }
627 send_gdb "ptype g_vB\n"
629 -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 $" {
632 -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
633 pass "ptype g_vB (aCC)"
635 -re ".*$gdb_prompt $" { fail "ptype g_vB" }
636 timeout { fail "ptype g_vB (timeout)" }
639 send_gdb "ptype vC\n"
641 -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 $" {
644 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
645 pass "ptype vC (aCC)"
647 -re ".*$gdb_prompt $" { fail "ptype vC" }
648 timeout { fail "ptype vC (timeout)" }
651 send_gdb "ptype class vC\n"
653 -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 $" {
654 pass "ptype class vC"
656 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
657 pass "ptype class vC (aCC)"
659 -re ".*$gdb_prompt $" { fail "ptype class vC" }
660 timeout { fail "ptype class vC (timeout)" }
663 send_gdb "ptype g_vC\n"
665 -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 $" {
668 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
669 pass "ptype g_vC (aCC)"
671 -re ".*$gdb_prompt $" { fail "ptype g_vC" }
672 timeout { fail "ptype g_vC (timeout)" }
677 # Single virtual inheritance, print complete classes.
680 proc test_print_svi_classes {} {
687 # Print all members of g_vA.
689 gdb_test "print g_vA" ".* = \{va = 1, vx = 2\}" "print g_vA"
691 # Print all members of g_vB.
693 send_gdb "print g_vB\n"
695 -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, Virtual table at $hex\}$nl$gdb_prompt $" {
696 pass "print g_vB (aCC)"
698 -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, __vfp = $hex\}$nl$gdb_prompt $" {
699 pass "print g_vB (aCC)"
701 -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, ${vbptr}vA = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
704 -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, _vptr.vB = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
705 pass "print g_vB (FIXME v3 vtbl ptr)"
707 -re ".*invalid address 0x0.*$gdb_prompt $" {
708 # Does not happen with gcc cygnus-2.4.5-930828
709 fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)"
710 # Many of the rest of these tests have the same problem.
713 -re ".*$gdb_prompt $" { fail "print g_vB" }
714 timeout { fail "print g_vB (timeout)" ; return }
717 # Print all members of g_vC.
719 send_gdb "print g_vC\n"
721 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, Virtual table at $hex\}$nl$gdb_prompt $" {
722 pass "print g_vC (aCC)"
724 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, __vfp = $hex\}$nl$gdb_prompt $" {
725 pass "print g_vC (aCC)"
727 -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, ${vbptr}vA = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
730 -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, _vptr.vC = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
731 pass "print g_vC (FIXME v3 vtbl ptr)"
733 -re ".*$gdb_prompt $" { fail "print g_vC" }
734 timeout { fail "print g_vC (timeout)" }
739 # Multiple virtual inheritance, print individual members.
742 proc test_print_mvi_members {} {
747 # Print all members of g_vD.
749 send_gdb "print g_vD.vA::va\n"
751 -re ".* = 19$nl$gdb_prompt $" { pass "print g_vD.vA::va" }
752 -re ".*virtual baseclass botch.*$gdb_prompt $" {
753 # Does not happen with gcc cygnus-2.4.5-930828
754 fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)"
755 # Many of the rest of these tests have the same problem.
758 -re ".*$gdb_prompt $" { fail "print g_vD.vA::va" }
759 timeout { fail "print g_vD.vA::va (timeout)" ; return }
762 gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx"
764 gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb"
766 gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx"
768 gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc"
770 gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx"
772 gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd"
774 gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx"
776 # Print all members of g_vE.
778 gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va"
780 gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx"
782 gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb"
784 gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx"
786 gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc"
788 gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx"
790 gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd"
792 gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx"
794 gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve"
796 gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx"
800 # Multiple virtual inheritance, print type definitions.
803 proc test_ptype_mvi {} {
809 send_gdb "ptype vD\n"
811 -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 $" {
814 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
817 -re ".*$gdb_prompt $" { fail "ptype vD" }
818 timeout { fail "(timeout) ptype vD" }
821 send_gdb "ptype class vD\n"
823 -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 $" {
824 pass "ptype class vD"
826 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
827 pass "ptype class vD"
829 -re ".*$gdb_prompt $" { fail "ptype class vD" }
830 timeout { fail "(timeout) ptype class vD" }
833 send_gdb "ptype g_vD\n"
835 -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 $" {
838 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
841 -re ".*$gdb_prompt $" { fail "ptype g_vD" }
842 timeout { fail "(timeout) ptype g_vD" }
845 send_gdb "ptype vE\n"
847 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
850 -re ".*class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
853 -re ".*$gdb_prompt $" { fail "ptype vE" }
854 timeout { fail "(timeout) ptype vE" }
857 send_gdb "ptype class vE\n"
859 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
860 pass "ptype class vE"
862 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
863 pass "ptype class vE"
865 -re ".*$gdb_prompt $" { fail "ptype class vE" }
866 timeout { fail "(timeout) ptype class vE" }
869 send_gdb "ptype g_vE\n"
871 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
874 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
877 -re ".*$gdb_prompt $" { fail "ptype g_vE" }
878 timeout { fail "(timeout) ptype g_vE" }
883 # Multiple virtual inheritance, print complete classes.
886 proc test_print_mvi_classes {} {
893 # Print all members of g_vD.
895 send_gdb "print g_vD\n"
897 -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 $" {
898 pass "print g_vD (aCC)"
900 -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 $" {
901 pass "print g_vD (aCC)"
903 -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 $" {
906 -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 $" {
907 pass "print g_vD (FIXME v3 vtbl ptr)"
909 -re ".*invalid address 0x0.*$gdb_prompt $" {
910 # Does not happen with gcc cygnus-2.4.5-930828
911 fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)"
912 # Many of the rest of these tests have the same problem.
915 -re ".*$gdb_prompt $" { fail "print g_vD" }
916 timeout { fail "print g_vD (timeout)" ; return }
919 # Print all members of g_vE.
921 send_gdb "print g_vE\n"
923 -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 $" {
924 pass "print g_vE (aCC)"
926 -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 $" {
927 pass "print g_vE (aCC)"
929 -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 $" {
932 -re ".* = \{\<vD\> = \{\<vB\> = \{\<vA\> = \{va = 0, vx = 0\}, _vptr.vB = $hex *(\<VTT for vD\>)?, vb = 0, vx = 0\}, \<vC\> = \{_vptr.vC = $hex *(\<VTT for vD\>)?, vc = 0, vx = 0\}, _vptr.vD = $hex, vd = 0, vx = 0\}, _vptr.vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
933 pass "print g_vE (FIXME v3 vtbl ptr)"
935 -re ".*$gdb_prompt $" { fail "print g_vE" }
936 timeout { fail "print g_vE (timeout)" }
951 # Start with a fresh gdb.
955 gdb_reinitialize_dir $srcdir/$subdir
958 gdb_test "set language c++" ""
959 gdb_test "set width 0" ""
961 # Get the debug format for the compiled test case.
963 if { ![ runto_main] } {
974 gdb_stop_suppressing_tests;
976 if { ![ runto 'inheritance2' ] } {
980 test_print_si_members
981 test_print_si_classes
982 test_print_mi_members
983 test_print_mi_classes
984 test_print_anon_union
986 gdb_stop_suppressing_tests;
988 if { ![ runto 'inheritance4' ] } {
992 test_print_svi_members
993 test_print_svi_classes
994 test_print_mvi_members
995 test_print_mvi_classes