1 # Copyright (C) 1992, 1993, 1994, 1997, 1999 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Fred Fish. (fnf@cygnus.com)
25 # The format of a g++ virtual base pointer.
26 set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?"
32 if { [skip_cplus_tests] } { continue }
34 # Note - create separate "inherit" executable from misc.cc
36 set testfile "inherit"
38 set binfile ${objdir}/${subdir}/${testfile}
41 # Create and source the file that provides information about the compiler
42 # used to compile the test case.
44 if [get_compiler_info ${binfile} "c++"] {
48 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
49 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
53 # Single inheritance, print individual members.
56 proc test_print_si_members {} {
57 # Print all members of g_A using fully qualified form.
59 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
61 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
63 # Print members of g_A using nonambiguous compact form.
65 gdb_test "print g_A.a" ".* = 1" "print g_A.a"
67 gdb_test "print g_A.x" ".* = 2" "print g_A.x"
69 # Print all members of g_B using fully qualified form.
71 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
73 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
75 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
77 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
79 # Print members of g_B using nonambiguous compact form.
81 setup_xfail_format "DWARF 1"
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 setup_xfail_format "DWARF 1"
101 gdb_test "print g_C.a" ".* = 7" "print g_C.a"
103 gdb_test "print g_C.c" ".* = 9" "print g_C.c"
105 gdb_test "print g_C.x" ".* = 10" "print g_C.x"
109 # Single inheritance, print type definitions.
112 proc test_ptype_si {} {
116 global hp_aCC_compiler
118 # Print class A as a type.
122 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
123 pass "ptype A (FIXME)"
125 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
127 fail "ptype A (FIXME)"
129 -re ".*$gdb_prompt $" { fail "ptype A" }
130 timeout { fail "ptype A (timeout)" ; return }
133 # Print class A as an explicit class.
135 send_gdb "ptype class A\n"
137 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
138 pass "ptype class A (FIXME)"
140 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
141 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
142 fail "ptype class A (FIXME)"
144 -re ".*$gdb_prompt $" { fail "ptype class A" }
145 timeout { fail "ptype class A (timeout)" ; return }
148 # Print type of an object of type A.
150 send_gdb "ptype g_A\n"
152 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
153 pass "ptype g_A (FIXME)"
155 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
156 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
157 fail "ptype g_A (FIXME)"
159 -re ".*$gdb_prompt $" { fail "ptype g_A" }
160 timeout { fail "ptype g_A (timeout)" ; return }
163 # Print class B as a type.
165 setup_xfail_format "DWARF 1"
166 gdb_test "ptype B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype B"
168 # Print class B as an explicit class.
170 setup_xfail_format "DWARF 1"
171 gdb_test "ptype class B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype class B"
173 # Print type of an object of type B.
175 setup_xfail_format "DWARF 1"
176 gdb_test "ptype g_B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype g_B"
178 # Print class C as a type.
180 setup_xfail_format "DWARF 1"
181 gdb_test "ptype C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype C"
183 # Print class C as an explicit class.
185 setup_xfail_format "DWARF 1"
186 gdb_test "ptype class C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype class C"
188 # Print type of an object of type g_C.
190 setup_xfail_format "DWARF 1"
191 gdb_test "ptype g_C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype g_C"
193 # gcc cygnus-2.3.3 (Q1) has this bug, but it was fixed as of
194 # cygnus-2.3.3-930417. PR 2819.
195 send_gdb "ptype tagless_struct\n"
197 -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 $" {
198 pass "ptype tagless struct"
200 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
201 pass "ptype tagless struct (obsolete gcc or gdb)"
203 -re ".*$gdb_prompt $" {
204 fail "ptype tagless struct"
207 fail "ptype tagless struct (timeout)"
211 send_gdb "ptype v_tagless\n"
213 -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 $" {
214 pass "ptype variable of type tagless struct"
216 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
217 pass "ptype variable of type tagless struct (obsolete gcc or gdb)"
219 -re ".*$gdb_prompt $" {
220 fail "ptype variable of type tagless struct"
223 fail "ptype variable of type tagless struct (timeout)"
229 # Single inheritance, print complete classes.
232 proc test_print_si_classes {} {
233 # Print all members of g_A.
235 gdb_test "print g_A" ".* = \{a = 1, x = 2\}" "print g_A"
237 # Print all members of g_B.
239 setup_xfail_format "DWARF 1"
240 gdb_test "print g_B" ".* = \{\<(class |)A\> = \{a = 3, x = 4\}, b = 5, x = 6\}" "print g_B"
242 # Print all members of g_C.
244 setup_xfail_format "DWARF 1"
245 gdb_test "print g_C" ".* = \{\<(class |)A\> = \{a = 7, x = 8\}, c = 9, x = 10\}" "print g_C"
249 # Single inheritance, print anonymous unions.
250 # GDB versions prior to 4.14 entered an infinite loop when printing
251 # the type of a class containing an anonymous union, and they were also
252 # incapable of printing the member of an anonymous union.
253 # We test the printing of the member first, and perform the other tests
254 # only if the test succeeds, to avoid the infinite loop.
257 proc test_print_anon_union {} {
262 setup_xfail_format "DWARF 1"
263 gdb_test "print g_anon_union.a" ".* = 2" "print anonymous union member"
264 setup_xfail_format "DWARF 1"
265 send_gdb "print g_anon_union\n"
267 -re ".* = \{one = 1, ( = |)\{a = 2, b = 2\}\}$nl$gdb_prompt $" {
268 pass "print variable of type anonymous union"
270 -re ".* = .*\{one = 1, ( = |)\{a = 2, b = .*\}\}$nl$gdb_prompt $" {
271 pass "print variable of type anonymous union (obsolete gcc or gdb)"
273 -re ".*$nl$gdb_prompt $" {
274 fail "print variable of type anonymous union"
277 fail "print variableof type anonymous union (timeout)"
280 setup_xfail_format "DWARF 1"
281 send_gdb "ptype g_anon_union\n"
283 -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 $" {
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 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
340 send_gdb "print g_D.A::a\n"
342 -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 15$nl$gdb_prompt $" {
343 pass "print g_D.A::a"
345 -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 11$nl$gdb_prompt $" {
346 pass "print g_D.A::a (using B)"
348 -re ".* = 15$nl$gdb_prompt $" {
349 fail "print g_D.A::a (FIXME)"
351 -re ".* = 11$nl$gdb_prompt $" {
352 fail "print g_D.A::a (FIXME)"
354 -re ".*$gdb_prompt $" { fail "print g_D.A::a" }
355 timeout { fail "print g_D.A::a (timeout)" ; return }
358 # The following is ambiguous, and gdb should detect this.
359 # For now, accept gdb's behavior as an expected failure if it
360 # simply prints either member correctly.
362 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
363 send_gdb "print g_D.A::x\n"
365 -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 16$nl$gdb_prompt $" {
366 pass "print g_D.A::x"
368 -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 12$nl$gdb_prompt $" {
369 pass "print g_D.A::x (using B)"
371 -re ".* = 16$nl$gdb_prompt $" {
372 fail "print g_D.A::x (FIXME)"
374 -re ".* = 12$nl$gdb_prompt $" {
375 fail "print g_D.A::x (FIXME)"
377 -re ".*$gdb_prompt $" { fail "print g_D.A::x" }
378 timeout { fail "print g_D.A::x (timeout)" ; return }
381 gdb_test "print g_D.B::b" ".* = 13" "print g_D.B::b"
383 gdb_test "print g_D.B::x" ".* = 14" "print g_D.B::x"
385 setup_xfail_format "DWARF 1"
386 gdb_test "print g_D.C::c" ".* = 17" "print g_D.C::c"
388 setup_xfail_format "DWARF 1"
389 gdb_test "print g_D.C::x" ".* = 18" "print g_D.C::x"
391 gdb_test "print g_D.D::d" ".* = 19" "print g_D.D::d"
393 gdb_test "print g_D.D::x" ".* = 20" "print g_D.D::x"
395 # Print all members of g_E.
397 # The following is ambiguous, and gdb should detect this.
398 # For now, accept gdb's behavior as an expected failure if it
399 # simply prints either member correctly.
402 send_gdb "print g_E.A::a\n"
404 -re ".* = 21$nl$gdb_prompt $" {
405 fail "print g_E.A::a (FIXME)"
407 -re ".* = 25$nl$gdb_prompt $" {
408 fail "print g_E.A::a (FIXME)"
410 -re ".*$gdb_prompt $" { fail "print g_E.A::a" }
411 timeout { fail "print g_E.A::a (timeout)" ; return }
414 # The following is ambiguous, and gdb should detect this.
415 # For now, accept gdb's behavior as an expected failure if it
416 # simply prints either member correctly.
418 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
419 send_gdb "print g_E.A::x\n"
421 -re "warning: A ambiguous; using E::D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 26$nl$gdb_prompt $" {
422 pass "print g_E.A::x"
424 -re "warning: A ambiguous; using E::D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 22$nl$gdb_prompt $" {
425 pass "print g_E.A::x (using B)"
427 -re ".* = 26$nl$gdb_prompt $" {
428 fail "print g_E.A::x (FIXME)"
430 -re ".* = 22$nl$gdb_prompt $" {
431 fail "print g_E.A::x (FIXME)"
433 -re ".*$gdb_prompt $" { fail "print g_E.A::x" }
434 timeout { fail "print g_E.A::x (timeout)" ; return }
437 gdb_test "print g_E.B::b" ".* = 23" "print g_E.B::b"
439 gdb_test "print g_E.B::x" ".* = 24" "print g_E.B::x"
441 setup_xfail_format "DWARF 1"
442 gdb_test "print g_E.C::c" ".* = 27" "print g_E.C::c"
444 setup_xfail_format "DWARF 1"
445 gdb_test "print g_E.C::x" ".* = 28" "print g_E.C::x"
447 gdb_test "print g_E.D::d" ".* = 29" "print g_E.D::d"
449 gdb_test "print g_E.D::x" ".* = 30" "print g_E.D::x"
451 gdb_test "print g_E.E::e" ".* = 31" "print g_E.E::e"
453 gdb_test "print g_E.E::x" ".* = 32" "print g_E.E::x"
457 # Multiple inheritance, print type definitions.
460 proc test_ptype_mi {} {
463 setup_xfail_format "DWARF 1"
464 gdb_test "ptype D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype D"
466 setup_xfail_format "DWARF 1"
467 gdb_test "ptype class D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype class D"
469 setup_xfail_format "DWARF 1"
470 gdb_test "ptype g_D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype g_D"
472 setup_xfail_format "DWARF 1"
473 gdb_test "ptype E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype E"
475 setup_xfail_format "DWARF 1"
476 gdb_test "ptype class E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype class E"
478 setup_xfail_format "DWARF 1"
479 gdb_test "ptype g_E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype g_E"
483 # Multiple inheritance, print complete classes.
486 proc test_print_mi_classes {} {
487 # Print all members of g_D.
489 setup_xfail_format "DWARF 1"
490 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"
492 # Print all members of g_E.
494 setup_xfail_format "DWARF 1"
495 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"
499 # Single virtual inheritance, print individual members.
502 proc test_print_svi_members {} {
507 # Print all members of g_vA.
509 gdb_test "print g_vA.vA::va" ".* = 1" "print g_vA.vA::va"
511 gdb_test "print g_vA.vA::vx" ".* = 2" "print g_vA.vA::vx"
513 # Print members of g_vA using compact form.
515 gdb_test "print g_vA.va" ".* = 1" "print g_vA.va"
517 gdb_test "print g_vA.vx" ".* = 2" "print g_vA.vx"
519 # Print all members of g_vB.
521 setup_xfail_format "DWARF 1"
522 send_gdb "print g_vB.vA::va\n"
524 -re ".* = 3$nl$gdb_prompt $" { pass "print g_vB.vA::va" }
525 -re ".*virtual baseclass botch.*$gdb_prompt $" {
526 # Does not happen with gcc cygnus-2.4.5-930828
527 fail "print g_vB.vA::va (known bug with gcc cygnus-2.4.5-930417)"
528 # Many of the rest of these tests have the same problem.
531 -re ".*$gdb_prompt $" { fail "print g_vB.vA::va" }
532 timeout { fail "print g_vB.vA::va (timeout)" ; return }
535 setup_xfail_format "DWARF 1"
536 gdb_test "print g_vB.vA::vx" ".* = 4" "print g_vB.vA::vx"
538 gdb_test "print g_vB.vB::vb" ".* = 5" "print g_vB.vB::vb"
540 gdb_test "print g_vB.vB::vx" ".* = 6" "print g_vB.vB::vx"
542 # Print members of g_vB using compact form.
544 setup_xfail_format "DWARF 1"
545 gdb_test "print g_vB.va" ".* = 3" "print g_vB.va"
547 gdb_test "print g_vB.vb" ".* = 5" "print g_vB.vb"
549 gdb_test "print g_vB.vx" ".* = 6" "print g_vB.vx"
551 # Print all members of g_vC.
553 setup_xfail_format "DWARF 1"
554 gdb_test "print g_vC.vA::va" ".* = 7" "print g_vC.vA::va"
556 setup_xfail_format "DWARF 1"
557 gdb_test "print g_vC.vA::vx" ".* = 8" "print g_vC.vA::vx"
559 gdb_test "print g_vC.vC::vc" ".* = 9" "print g_vC.vC::vc"
561 gdb_test "print g_vC.vC::vx" ".* = 10" "print g_vC.vC::vx"
563 # Print members of g_vC using compact form.
565 setup_xfail_format "DWARF 1"
566 gdb_test "print g_vC.va" ".* = 7" "print g_vC.va"
568 gdb_test "print g_vC.vc" ".* = 9" "print g_vC.vc"
570 gdb_test "print g_vC.vx" ".* = 10" "print g_vC.vx"
574 # Single virtual inheritance, print type definitions.
577 proc test_ptype_vi {} {
583 # This class does not use any C++-specific features, so it's fine for
584 # it to print as "struct".
585 send_gdb "ptype vA\n"
587 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
590 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
593 -re ".*$gdb_prompt $" { fail "ptype vA" }
594 timeout { fail "ptype vA (timeout)" ; return }
597 # This class does not use any C++-specific features, so it's fine for
598 # it to print as "struct".
599 send_gdb "ptype class vA\n"
601 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
602 pass "ptype class vA"
604 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
605 pass "ptype class vA"
607 -re ".*$gdb_prompt $" { fail "ptype class vA" }
608 timeout { fail "ptype class vA (timeout)" ; return }
611 # This class does not use any C++-specific features, so it's fine for
612 # it to print as "struct".
613 send_gdb "ptype g_vA\n"
615 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
618 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
621 -re ".*$gdb_prompt $" { fail "ptype g_vA" }
622 timeout { fail "ptype g_vA (timeout)" ; return }
625 setup_xfail_format "DWARF 1"
626 send_gdb "ptype vB\n"
628 -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 $" {
631 -re "ptype vB${nl}type = class vB : public virtual vA \{$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" {
632 pass "ptype vB (aCC)"
634 -re ".*$gdb_prompt $" { fail "ptype vB" }
635 timeout { fail "ptype vB (timeout)" }
638 setup_xfail_format "DWARF 1"
639 send_gdb "ptype class vB\n"
641 -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 $" {
642 pass "ptype class vB"
644 -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
645 pass "ptype class vB (aCC)"
647 -re ".*$gdb_prompt $" { fail "ptype class vB" }
648 timeout { fail "ptype class vB (timeout)" }
651 setup_xfail_format "DWARF 1"
652 send_gdb "ptype g_vB\n"
654 -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 $" {
657 -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
658 pass "ptype g_vB (aCC)"
660 -re ".*$gdb_prompt $" { fail "ptype g_vB" }
661 timeout { fail "ptype g_vB (timeout)" }
664 setup_xfail_format "DWARF 1"
665 send_gdb "ptype vC\n"
667 -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 $" {
670 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
671 pass "ptype vC (aCC)"
673 -re ".*$gdb_prompt $" { fail "ptype vC" }
674 timeout { fail "ptype vC (timeout)" }
677 setup_xfail_format "DWARF 1"
678 send_gdb "ptype class vC\n"
680 -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 $" {
681 pass "ptype class vC"
683 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
684 pass "ptype class vC (aCC)"
686 -re ".*$gdb_prompt $" { fail "ptype class vC" }
687 timeout { fail "ptype class vC (timeout)" }
690 setup_xfail_format "DWARF 1"
691 send_gdb "ptype g_vC\n"
693 -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 $" {
696 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
697 pass "ptype g_vC (aCC)"
699 -re ".*$gdb_prompt $" { fail "ptype g_vC" }
700 timeout { fail "ptype g_vC (timeout)" }
705 # Single virtual inheritance, print complete classes.
708 proc test_print_svi_classes {} {
715 # Print all members of g_vA.
717 gdb_test "print g_vA" ".* = \{va = 1, vx = 2\}" "print g_vA"
719 # Print all members of g_vB.
721 setup_xfail_format "DWARF 1"
722 send_gdb "print g_vB\n"
724 -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, Virtual table at $hex\}$nl$gdb_prompt $" {
725 pass "print g_vB (aCC)"
727 -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, __vfp = $hex\}$nl$gdb_prompt $" {
728 pass "print g_vB (aCC)"
730 -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, ${vbptr}vA = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
733 -re ".*invalid address 0x0.*$gdb_prompt $" {
734 # Does not happen with gcc cygnus-2.4.5-930828
735 fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)"
736 # Many of the rest of these tests have the same problem.
739 -re ".*$gdb_prompt $" { fail "print g_vB" }
740 timeout { fail "print g_vB (timeout)" ; return }
743 # Print all members of g_vC.
745 setup_xfail_format "DWARF 1"
746 send_gdb "print g_vC\n"
748 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, Virtual table at $hex\}$nl$gdb_prompt $" {
749 pass "print g_vC (aCC)"
751 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, __vfp = $hex\}$nl$gdb_prompt $" {
752 pass "print g_vC (aCC)"
754 -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, ${vbptr}vA = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
757 -re ".*$gdb_prompt $" { fail "print g_vC" }
758 timeout { fail "print g_vC (timeout)" }
763 # Multiple virtual inheritance, print individual members.
766 proc test_print_mvi_members {} {
771 # Print all members of g_vD.
773 setup_xfail_format "DWARF 1"
774 send_gdb "print g_vD.vA::va\n"
776 -re ".* = 19$nl$gdb_prompt $" { pass "print g_vD.vA::va" }
777 -re ".*virtual baseclass botch.*$gdb_prompt $" {
778 # Does not happen with gcc cygnus-2.4.5-930828
779 fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)"
780 # Many of the rest of these tests have the same problem.
783 -re ".*$gdb_prompt $" { fail "print g_vD.vA::va" }
784 timeout { fail "print g_vD.vA::va (timeout)" ; return }
787 setup_xfail_format "DWARF 1"
788 gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx"
790 setup_xfail_format "DWARF 1"
791 gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb"
793 setup_xfail_format "DWARF 1"
794 gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx"
796 setup_xfail_format "DWARF 1"
797 gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc"
799 setup_xfail_format "DWARF 1"
800 gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx"
802 gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd"
804 gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx"
806 # Print all members of g_vE.
808 setup_xfail_format "DWARF 1"
809 gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va"
811 setup_xfail_format "DWARF 1"
812 gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx"
814 setup_xfail_format "DWARF 1"
815 gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb"
817 setup_xfail_format "DWARF 1"
818 gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx"
820 setup_xfail_format "DWARF 1"
821 gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc"
823 setup_xfail_format "DWARF 1"
824 gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx"
826 setup_xfail_format "DWARF 1"
827 gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd"
829 gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx"
831 gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve"
833 gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx"
837 # Multiple virtual inheritance, print type definitions.
840 proc test_ptype_mvi {} {
846 setup_xfail_format "DWARF 1"
847 send_gdb "ptype vD\n"
849 -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 $" {
852 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
855 -re ".*$gdb_prompt $" { fail "ptype vD" }
856 timeout { fail "(timeout) ptype vD" }
859 setup_xfail_format "DWARF 1"
860 send_gdb "ptype class vD\n"
862 -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 $" {
863 pass "ptype class vD"
865 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
866 pass "ptype class vD"
868 -re ".*$gdb_prompt $" { fail "ptype class vD" }
869 timeout { fail "(timeout) ptype class vD" }
872 setup_xfail_format "DWARF 1"
873 send_gdb "ptype g_vD\n"
875 -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 $" {
878 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
881 -re ".*$gdb_prompt $" { fail "ptype g_vD" }
882 timeout { fail "(timeout) ptype g_vD" }
885 setup_xfail_format "DWARF 1"
886 send_gdb "ptype vE\n"
888 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
891 -re ".*class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
894 -re ".*$gdb_prompt $" { fail "ptype vE" }
895 timeout { fail "(timeout) ptype vE" }
898 setup_xfail_format "DWARF 1"
899 send_gdb "ptype class vE\n"
901 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
902 pass "ptype class vE"
904 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
905 pass "ptype class vE"
907 -re ".*$gdb_prompt $" { fail "ptype class vE" }
908 timeout { fail "(timeout) ptype class vE" }
911 setup_xfail_format "DWARF 1"
912 send_gdb "ptype g_vE\n"
914 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
917 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
920 -re ".*$gdb_prompt $" { fail "ptype g_vE" }
921 timeout { fail "(timeout) ptype g_vE" }
926 # Multiple virtual inheritance, print complete classes.
929 proc test_print_mvi_classes {} {
936 # Print all members of g_vD.
938 setup_xfail_format "DWARF 1"
939 send_gdb "print g_vD\n"
941 -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 $" {
942 pass "print g_vD (aCC)"
944 -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 $" {
945 pass "print g_vD (aCC)"
947 -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 $" {
950 -re ".*invalid address 0x0.*$gdb_prompt $" {
951 # Does not happen with gcc cygnus-2.4.5-930828
952 fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)"
953 # Many of the rest of these tests have the same problem.
956 -re ".*$gdb_prompt $" { fail "print g_vD" }
957 timeout { fail "print g_vD (timeout)" ; return }
960 # Print all members of g_vE.
962 setup_xfail_format "DWARF 1"
963 send_gdb "print g_vE\n"
965 -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 $" {
966 pass "print g_vE (aCC)"
968 -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 $" {
969 pass "print g_vE (aCC)"
971 -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 $" {
974 -re ".*$gdb_prompt $" { fail "print g_vE" }
975 timeout { fail "print g_vE (timeout)" }
990 # Start with a fresh gdb.
994 gdb_reinitialize_dir $srcdir/$subdir
997 gdb_test "set language c++" ""
998 gdb_test "set width 0" ""
1000 # Get the debug format for the compiled test case.
1002 if { ![ runto_main] } {
1013 gdb_stop_suppressing_tests;
1015 if { ![ runto 'inheritance2(void)' ] } {
1019 test_print_si_members
1020 test_print_si_classes
1021 test_print_mi_members
1022 test_print_mi_classes
1023 test_print_anon_union
1025 gdb_stop_suppressing_tests;
1027 if { ![ runto 'inheritance4(void)' ] } {
1031 test_print_svi_members
1032 test_print_svi_classes
1033 test_print_mvi_members
1034 test_print_mvi_classes