1 # Copyright (C) 1992, 1993, 1994, 1997 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)
29 # Check to see if we have an executable to test. If not, then either we
30 # haven't tried to compile one, or the compilation failed for some reason.
31 # In either case, just notify the user and skip the tests in this file.
32 # Note - create separate "inherit" executable from misc.cc
34 set testfile "inherit"
36 set binfile ${objdir}/${subdir}/${testfile}
39 # Create and source the file that provides information about the compiler
40 # used to compile the test case.
42 if [get_compiler_info ${binfile} "c++"] {
46 # if we are on HPUX and we are not compiled with gcc, then skip these tests.
48 if [istarget hppa*-*-hpux*] {
55 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
56 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
60 # Single inheritance, print individual members.
63 proc test_print_si_members {} {
64 # Print all members of g_A using fully qualified form.
66 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
68 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
70 # Print members of g_A using nonambiguous compact form.
72 gdb_test "print g_A.a" ".* = 1" "print g_A.a"
74 gdb_test "print g_A.x" ".* = 2" "print g_A.x"
76 # Print all members of g_B using fully qualified form.
78 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
80 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
82 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
84 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
86 # Print members of g_B using nonambiguous compact form.
88 setup_xfail_format "DWARF 1"
89 gdb_test "print g_B.a" ".* = 3" "print g_B.a"
91 gdb_test "print g_B.b" ".* = 5" "print g_B.b"
93 gdb_test "print g_B.x" ".* = 6" "print g_B.x"
95 # Print all members of g_C using fully qualified form.
97 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
99 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
101 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
103 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
105 # Print members of g_C using nonambiguous compact form.
107 setup_xfail_format "DWARF 1"
108 gdb_test "print g_C.a" ".* = 7" "print g_C.a"
110 gdb_test "print g_C.c" ".* = 9" "print g_C.c"
112 gdb_test "print g_C.x" ".* = 10" "print g_C.x"
116 # Single inheritance, print type definitions.
119 proc test_ptype_si {} {
124 # Print class A as a type.
128 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
129 pass "ptype A (FIXME)"
131 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
133 fail "ptype A (FIXME)"
135 -re ".*$gdb_prompt $" { fail "ptype A" }
136 timeout { fail "ptype A (timeout)" ; return }
139 # Print class A as an explicit class.
141 send_gdb "ptype class A\n"
143 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
144 pass "ptype class A (FIXME)"
146 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
148 fail "ptype class A (FIXME)"
150 -re ".*$gdb_prompt $" { fail "ptype class A" }
151 timeout { fail "ptype class A (timeout)" ; return }
154 # Print type of an object of type A.
156 send_gdb "ptype g_A\n"
158 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
159 pass "ptype g_A (FIXME)"
161 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
163 fail "ptype g_A (FIXME)"
165 -re ".*$gdb_prompt $" { fail "ptype g_A" }
166 timeout { fail "ptype g_A (timeout)" ; return }
169 # Print class B as a type.
171 setup_xfail_format "DWARF 1"
172 gdb_test "ptype B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype B"
174 # Print class B as an explicit class.
176 setup_xfail_format "DWARF 1"
177 gdb_test "ptype class B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype class B"
179 # Print type of an object of type B.
181 setup_xfail_format "DWARF 1"
182 gdb_test "ptype g_B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype g_B"
184 # Print class C as a type.
186 setup_xfail_format "DWARF 1"
187 gdb_test "ptype C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype C"
189 # Print class C as an explicit class.
191 setup_xfail_format "DWARF 1"
192 gdb_test "ptype class C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype class C"
194 # Print type of an object of type g_C.
196 setup_xfail_format "DWARF 1"
197 gdb_test "ptype g_C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype g_C"
199 # gcc cygnus-2.3.3 (Q1) has this bug, but it was fixed as of
200 # cygnus-2.3.3-930417. PR 2819.
201 send_gdb "ptype tagless_struct\n"
203 -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 $" {
204 pass "ptype tagless struct"
206 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
207 pass "ptype tagless struct (obsolete gcc or gdb)"
209 -re ".*$gdb_prompt $" {
210 fail "ptype tagless struct"
213 fail "ptype tagless struct (timeout)"
217 send_gdb "ptype v_tagless\n"
219 -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 $" {
220 pass "ptype variable of type tagless struct"
222 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
223 pass "ptype variable of type tagless struct (obsolete gcc or gdb)"
225 -re ".*$gdb_prompt $" {
226 fail "ptype variable of type tagless struct"
229 fail "ptype variable of type tagless struct (timeout)"
235 # Single inheritance, print complete classes.
238 proc test_print_si_classes {} {
239 # Print all members of g_A.
241 gdb_test "print g_A" ".* = \{a = 1, x = 2\}" "print g_A"
243 # Print all members of g_B.
245 setup_xfail_format "DWARF 1"
246 gdb_test "print g_B" ".* = \{\<A\> = \{a = 3, x = 4\}, b = 5, x = 6\}" "print g_B"
248 # Print all members of g_C.
250 setup_xfail_format "DWARF 1"
251 gdb_test "print g_C" ".* = \{\<A\> = \{a = 7, x = 8\}, c = 9, x = 10\}" "print g_C"
255 # Single inheritance, print anonymous unions.
256 # GDB versions prior to 4.14 entered an infinite loop when printing
257 # the type of a class containing an anonymous union, and they were also
258 # incapable of printing the member of an anonymous union.
259 # We test the printing of the member first, and perform the other tests
260 # only if the test succeeds, to avoid the infinite loop.
263 proc test_print_anon_union {} {
268 setup_xfail_format "DWARF 1"
269 gdb_test "print g_anon_union.a" ".* = 2" "print anonymous union member"
270 setup_xfail_format "DWARF 1"
271 send_gdb "print g_anon_union\n"
273 -re ".* = \{one = 1, = \{a = 2, b = 2\}\}$nl$gdb_prompt $" {
274 pass "print variable of type anonymous union"
276 -re ".* = .*\{one = 1, = \{a = 2, b = .*\}\}$nl$gdb_prompt $" {
277 pass "print variable of type anonymous union (obsolete gcc or gdb)"
279 -re ".*$nl$gdb_prompt $" {
280 fail "print variable of type anonymous union"
283 fail "print variableof type anonymous union (timeout)"
286 setup_xfail_format "DWARF 1"
287 send_gdb "ptype g_anon_union\n"
289 -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 $" {
290 pass "print type of anonymous union"
292 -re "type = (struct|class).*\{.*int one;.*union \{.*int a;.*(long|long int|int) b;.*\};.*\}$nl$gdb_prompt $" {
293 pass "print type of anonymous union (obsolete gcc or gdb)"
295 -re ".*$nl$gdb_prompt $" {
296 fail "print type of anonymous union"
299 fail "print type of anonymous union (timeout)"
305 # Multiple inheritance, print individual members.
308 proc test_print_mi_members {} {
312 # Print all members of g_A.
314 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
316 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
318 # Print all members of g_B.
320 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
322 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
324 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
326 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
328 # Print all members of g_C.
330 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
332 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
334 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
336 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
338 # Print all members of g_D.
340 # The following is ambiguous, and gdb should detect this.
341 # For now, accept gdb's behavior as an expected failure if it
342 # simply prints either member correctly.
345 send_gdb "print g_D.A::a\n"
347 -re ".* = 11$nl$gdb_prompt $" {
348 fail "print g_D.A::a (FIXME)"
350 -re ".* = 15$nl$gdb_prompt $" {
351 fail "print g_D.A::a (FIXME)"
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.
362 send_gdb "print g_D.A::x\n"
364 -re ".* = 12$nl$gdb_prompt $" {
365 fail "print g_D.A::x (FIXME)"
367 -re ".* = 16$nl$gdb_prompt $" {
368 fail "print g_D.A::x (FIXME)"
370 -re ".*$gdb_prompt $" { fail "print g_D.A::x" }
371 timeout { fail "print g_D.A::x (timeout)" ; return }
374 gdb_test "print g_D.B::b" ".* = 13" "print g_D.B::b"
376 gdb_test "print g_D.B::x" ".* = 14" "print g_D.B::x"
378 setup_xfail_format "DWARF 1"
379 gdb_test "print g_D.C::c" ".* = 17" "print g_D.C::c"
381 setup_xfail_format "DWARF 1"
382 gdb_test "print g_D.C::x" ".* = 18" "print g_D.C::x"
384 gdb_test "print g_D.D::d" ".* = 19" "print g_D.D::d"
386 gdb_test "print g_D.D::x" ".* = 20" "print g_D.D::x"
388 # Print all members of g_E.
390 # The following is ambiguous, and gdb should detect this.
391 # For now, accept gdb's behavior as an expected failure if it
392 # simply prints either member correctly.
395 send_gdb "print g_E.A::a\n"
397 -re ".* = 21$nl$gdb_prompt $" {
398 fail "print g_E.A::a (FIXME)"
400 -re ".* = 25$nl$gdb_prompt $" {
401 fail "print g_E.A::a (FIXME)"
403 -re ".*$gdb_prompt $" { fail "print g_E.A::a" }
404 timeout { fail "print g_E.A::a (timeout)" ; return }
407 # The following is ambiguous, and gdb should detect this.
408 # For now, accept gdb's behavior as an expected failure if it
409 # simply prints either member correctly.
412 send_gdb "print g_E.A::x\n"
414 -re ".* = 22$nl$gdb_prompt $" {
415 fail "print g_E.A::x (FIXME)"
417 -re ".* = 26$nl$gdb_prompt $" {
418 fail "print g_E.A::x (FIXME)"
420 -re ".*$gdb_prompt $" { fail "print g_E.A::x" }
421 timeout { fail "print g_E.A::x (timeout)" ; return }
424 gdb_test "print g_E.B::b" ".* = 23" "print g_E.B::b"
426 gdb_test "print g_E.B::x" ".* = 24" "print g_E.B::x"
428 setup_xfail_format "DWARF 1"
429 gdb_test "print g_E.C::c" ".* = 27" "print g_E.C::c"
431 setup_xfail_format "DWARF 1"
432 gdb_test "print g_E.C::x" ".* = 28" "print g_E.C::x"
434 gdb_test "print g_E.D::d" ".* = 29" "print g_E.D::d"
436 gdb_test "print g_E.D::x" ".* = 30" "print g_E.D::x"
438 gdb_test "print g_E.E::e" ".* = 31" "print g_E.E::e"
440 gdb_test "print g_E.E::x" ".* = 32" "print g_E.E::x"
444 # Multiple inheritance, print type definitions.
447 proc test_ptype_mi {} {
450 setup_xfail_format "DWARF 1"
451 gdb_test "ptype D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype D"
453 setup_xfail_format "DWARF 1"
454 gdb_test "ptype class D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype class D"
456 setup_xfail_format "DWARF 1"
457 gdb_test "ptype g_D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype g_D"
459 setup_xfail_format "DWARF 1"
460 gdb_test "ptype E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype E"
462 setup_xfail_format "DWARF 1"
463 gdb_test "ptype class E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype class E"
465 setup_xfail_format "DWARF 1"
466 gdb_test "ptype g_E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype g_E"
470 # Multiple inheritance, print complete classes.
473 proc test_print_mi_classes {} {
474 # Print all members of g_D.
476 setup_xfail_format "DWARF 1"
477 gdb_test "print g_D" ".* = \{\<B\> = \{\<A\> = \{a = 11, x = 12\}, b = 13, x = 14\}, \<C\> = \{\<A\> = \{a = 15, x = 16\}, c = 17, x = 18\}, d = 19, x = 20\}" "print g_D"
479 # Print all members of g_E.
481 setup_xfail_format "DWARF 1"
482 gdb_test "print g_E" ".* = \{\<D\> = \{\<B\> = \{\<A\> = \{a = 21, x = 22\}, b = 23, x = 24\}, \<C\> = \{\<A\> = \{a = 25, x = 26\}, c = 27, x = 28\}, d = 29, x = 30\}, e = 31, x = 32\}" "print g_E"
486 # Single virtual inheritance, print individual members.
489 proc test_print_svi_members {} {
494 # Print all members of g_vA.
496 gdb_test "print g_vA.vA::va" ".* = 1" "print g_vA.vA::va"
498 gdb_test "print g_vA.vA::vx" ".* = 2" "print g_vA.vA::vx"
500 # Print members of g_vA using compact form.
502 gdb_test "print g_vA.va" ".* = 1" "print g_vA.va"
504 gdb_test "print g_vA.vx" ".* = 2" "print g_vA.vx"
506 # Print all members of g_vB.
508 setup_xfail_format "DWARF 1"
509 send_gdb "print g_vB.vA::va\n"
511 -re ".* = 3$nl$gdb_prompt $" { pass "print g_vB.vA::va" }
512 -re ".*virtual baseclass botch.*$gdb_prompt $" {
513 # Does not happen with gcc cygnus-2.4.5-930828
514 fail "print g_vB.vA::va (known bug with gcc cygnus-2.4.5-930417)"
515 # Many of the rest of these tests have the same problem.
518 -re ".*$gdb_prompt $" { fail "print g_vB.vA::va" }
519 timeout { fail "print g_vB.vA::va (timeout)" ; return }
522 setup_xfail_format "DWARF 1"
523 gdb_test "print g_vB.vA::vx" ".* = 4" "print g_vB.vA::vx"
525 gdb_test "print g_vB.vB::vb" ".* = 5" "print g_vB.vB::vb"
527 gdb_test "print g_vB.vB::vx" ".* = 6" "print g_vB.vB::vx"
529 # Print members of g_vB using compact form.
531 setup_xfail_format "DWARF 1"
532 gdb_test "print g_vB.va" ".* = 3" "print g_vB.va"
534 gdb_test "print g_vB.vb" ".* = 5" "print g_vB.vb"
536 gdb_test "print g_vB.vx" ".* = 6" "print g_vB.vx"
538 # Print all members of g_vC.
540 setup_xfail_format "DWARF 1"
541 gdb_test "print g_vC.vA::va" ".* = 7" "print g_vC.vA::va"
543 setup_xfail_format "DWARF 1"
544 gdb_test "print g_vC.vA::vx" ".* = 8" "print g_vC.vA::vx"
546 gdb_test "print g_vC.vC::vc" ".* = 9" "print g_vC.vC::vc"
548 gdb_test "print g_vC.vC::vx" ".* = 10" "print g_vC.vC::vx"
550 # Print members of g_vC using compact form.
552 setup_xfail_format "DWARF 1"
553 gdb_test "print g_vC.va" ".* = 7" "print g_vC.va"
555 gdb_test "print g_vC.vc" ".* = 9" "print g_vC.vc"
557 gdb_test "print g_vC.vx" ".* = 10" "print g_vC.vx"
561 # Single virtual inheritance, print type definitions.
564 proc test_ptype_vi {} {
568 # This class does not use any C++-specific features, so it's fine for
569 # it to print as "struct".
570 send_gdb "ptype vA\n"
572 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
575 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
578 -re ".*$gdb_prompt $" { fail "ptype vA" }
579 timeout { fail "ptype vA (timeout)" ; return }
582 # This class does not use any C++-specific features, so it's fine for
583 # it to print as "struct".
584 send_gdb "ptype class vA\n"
586 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
587 pass "ptype class vA"
589 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
590 pass "ptype class vA"
592 -re ".*$gdb_prompt $" { fail "ptype class vA" }
593 timeout { fail "ptype class vA (timeout)" ; return }
596 # This class does not use any C++-specific features, so it's fine for
597 # it to print as "struct".
598 send_gdb "ptype g_vA\n"
600 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
603 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
606 -re ".*$gdb_prompt $" { fail "ptype g_vA" }
607 timeout { fail "ptype g_vA (timeout)" ; return }
610 setup_xfail_format "DWARF 1"
611 gdb_test "ptype vB" "ptype vB\[\r\n\]+type = class vB : public virtual vA \{$nl private:$nl\[ \]+vA \[*\]+_vb\[\\\$\.\]+vA;$nl public:$nl\[ \]+int vb;$nl\[ \]+int vx;$nl.*\}" "ptype vB"
613 setup_xfail_format "DWARF 1"
614 gdb_test "ptype class vB" "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}" "ptype class vB"
616 setup_xfail_format "DWARF 1"
617 gdb_test "ptype g_vB" "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}" "ptype g_vB"
619 setup_xfail_format "DWARF 1"
620 gdb_test "ptype vC" "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}" "ptype vC"
622 setup_xfail_format "DWARF 1"
623 gdb_test "ptype class vC" "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}" "ptype class vC"
625 setup_xfail_format "DWARF 1"
626 gdb_test "ptype g_vC" "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}" "ptype g_vC"
630 # Single virtual inheritance, print complete classes.
633 proc test_print_svi_classes {} {
639 # Print all members of g_vA.
641 gdb_test "print g_vA" ".* = \{va = 1, vx = 2\}" "print g_vA"
643 # Print all members of g_vB.
645 setup_xfail_format "DWARF 1"
646 send_gdb "print g_vB\n"
648 -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, _vb\[\\\$\.\]vA = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
651 -re ".*invalid address 0x0.*$gdb_prompt $" {
652 # Does not happen with gcc cygnus-2.4.5-930828
653 fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)"
654 # Many of the rest of these tests have the same problem.
657 -re ".*$gdb_prompt $" { fail "print g_vB" }
658 timeout { fail "print g_vB (timeout)" ; return }
661 # Print all members of g_vC.
663 setup_xfail_format "DWARF 1"
664 gdb_test "print g_vC" ".* = \{\<vA\> = \{va = 7, vx = 8\}, _vb\[\\\$\.\]vA = $hex, vc = 9, vx = 10\}" "print g_vC"
668 # Multiple virtual inheritance, print individual members.
671 proc test_print_mvi_members {} {
676 # Print all members of g_vD.
678 setup_xfail_format "DWARF 1"
679 send_gdb "print g_vD.vA::va\n"
681 -re ".* = 19$nl$gdb_prompt $" { pass "print g_vD.vA::va" }
682 -re ".*virtual baseclass botch.*$gdb_prompt $" {
683 # Does not happen with gcc cygnus-2.4.5-930828
684 fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)"
685 # Many of the rest of these tests have the same problem.
688 -re ".*$gdb_prompt $" { fail "print g_vD.vA::va" }
689 timeout { fail "print g_vD.vA::va (timeout)" ; return }
692 setup_xfail_format "DWARF 1"
693 gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx"
695 setup_xfail_format "DWARF 1"
696 gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb"
698 setup_xfail_format "DWARF 1"
699 gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx"
701 setup_xfail_format "DWARF 1"
702 gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc"
704 setup_xfail_format "DWARF 1"
705 gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx"
707 gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd"
709 gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx"
711 # Print all members of g_vE.
713 setup_xfail_format "DWARF 1"
714 gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va"
716 setup_xfail_format "DWARF 1"
717 gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx"
719 setup_xfail_format "DWARF 1"
720 gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb"
722 setup_xfail_format "DWARF 1"
723 gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx"
725 setup_xfail_format "DWARF 1"
726 gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc"
728 setup_xfail_format "DWARF 1"
729 gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx"
731 setup_xfail_format "DWARF 1"
732 gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd"
734 gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx"
736 gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve"
738 gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx"
742 # Multiple virtual inheritance, print type definitions.
745 proc test_ptype_mvi {} {
748 setup_xfail_format "DWARF 1"
749 gdb_test "ptype vD" "type = class vD : public virtual vB, public virtual vC \{$nl\[ \]*private:$nl\[ \]*vC \[*\]+_vb\[\\\$\.\]vC;$nl\[ \]*vB \[*\]+_vb\[\\\$\.\]vB;$nl\[ \]*public:$nl\[ \]*int vd;$nl\[ \]*int vx;$nl.*\}" "ptype vD"
751 setup_xfail_format "DWARF 1"
752 gdb_test "ptype class vD" "type = class vD : public virtual vB, public virtual vC \{$nl\[ \]*private:$nl\[ \]*vC \[*\]+_vb\[\\\$\.\]vC;$nl\[ \]*vB \[*\]+_vb\[\\\$\.\]vB;$nl\[ \]*public:$nl\[ \]*int vd;$nl\[ \]*int vx;$nl.*\}" "ptype class vD"
754 setup_xfail_format "DWARF 1"
755 gdb_test "ptype g_vD" "type = class vD : public virtual vB, public virtual vC \{$nl\[ \]*private:$nl\[ \]*vC \[*\]+_vb\[\\\$\.\]vC;$nl\[ \]*vB \[*\]+_vb\[\\\$\.\]vB;$nl\[ \]*public:$nl\[ \]*int vd;$nl\[ \]*int vx;$nl.*\}" "ptype g_vD"
757 setup_xfail_format "DWARF 1"
758 gdb_test "ptype vE" "type = class vE : public virtual vD \{$nl\[ \]*private:$nl\[ \]*vD \[*\]+_vb\[\\\$\.\]vD;$nl\[ \]*public:$nl\[ \]*int ve;$nl\[ \]*int vx;$nl.*\}" "ptype vE"
760 setup_xfail_format "DWARF 1"
761 gdb_test "ptype class vE" "type = class vE : public virtual vD \{$nl\[ \]*private:$nl\[ \]*vD \[*\]+_vb\[\\\$\.\]vD;$nl\[ \]*public:$nl\[ \]*int ve;$nl\[ \]*int vx;$nl.*\}" "ptype class vE"
763 setup_xfail_format "DWARF 1"
764 gdb_test "ptype g_vE" "type = class vE : public virtual vD \{$nl\[ \]*private:$nl\[ \]*vD \[*\]+_vb\[\\\$\.\]vD;$nl\[ \]*public:$nl\[ \]*int ve;$nl\[ \]*int vx;$nl.*\}" "ptype g_vE"
768 # Multiple virtual inheritance, print complete classes.
771 proc test_print_mvi_classes {} {
777 # Print all members of g_vD.
779 setup_xfail_format "DWARF 1"
780 send_gdb "print g_vD\n"
782 -re ".* = \{\<vB\> = \{\<vA\> = \{va = 19, vx = 20\}, _vb\[\\\$\.\]vA = $hex, vb = 21, vx = 22\}, \<vC\> = \{_vb\[\\\$\.\]vA = $hex, vc = 23, vx = 24\}, _vb\[\\\$\.\]vC = $hex, _vb\[\\\$\.\]vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
785 -re ".*invalid address 0x0.*$gdb_prompt $" {
786 # Does not happen with gcc cygnus-2.4.5-930828
787 fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)"
788 # Many of the rest of these tests have the same problem.
791 -re ".*$gdb_prompt $" { fail "print g_vD" }
792 timeout { fail "print g_vD (timeout)" ; return }
795 # Print all members of g_vE.
797 setup_xfail_format "DWARF 1"
798 gdb_test "print g_vE" ".* = \{\<vD\> = \{\<vB\> = \{\<vA\> = \{va = 0, vx = 0\}, _vb\[\\\$\.\]vA = $hex, vb = 0, vx = 0\}, \<vC\> = \{_vb\[\\\$\.\]vA = $hex, vc = 0, vx = 0\}, _vb\[\\\$\.\]vC = $hex, _vb\[\\\$\.\]vB = $hex, vd = 0, vx = 0\}, _vb\[\\\$\.\]vD = $hex, ve = 27, vx = 28\}" "print g_vE"
812 # Start with a fresh gdb.
816 gdb_reinitialize_dir $srcdir/$subdir
819 gdb_test "set language c++" ""
820 gdb_test "set width 0" ""
822 # Get the debug format for the compiled test case.
824 if { ![ runto_main] } {
835 gdb_stop_suppressing_tests;
837 if { ![ runto 'inheritance2(void)' ] } {
841 test_print_si_members
842 test_print_si_classes
843 test_print_mi_members
844 test_print_mi_classes
845 test_print_anon_union
847 gdb_stop_suppressing_tests;
849 if { ![ runto 'inheritance4(void)' ] } {
853 test_print_svi_members
854 test_print_svi_classes
855 test_print_mvi_members
856 test_print_mvi_classes