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 { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
47 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
51 # Single inheritance, print individual members.
54 proc test_print_si_members {} {
55 # Print all members of g_A using fully qualified form.
57 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
59 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
61 # Print members of g_A using nonambiguous compact form.
63 gdb_test "print g_A.a" ".* = 1" "print g_A.a"
65 gdb_test "print g_A.x" ".* = 2" "print g_A.x"
67 # Print all members of g_B using fully qualified form.
69 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
71 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
73 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
75 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
77 # Print members of g_B using nonambiguous compact form.
79 setup_xfail_format "DWARF 1"
80 gdb_test "print g_B.a" ".* = 3" "print g_B.a"
82 gdb_test "print g_B.b" ".* = 5" "print g_B.b"
84 gdb_test "print g_B.x" ".* = 6" "print g_B.x"
86 # Print all members of g_C using fully qualified form.
88 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
90 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
92 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
94 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
96 # Print members of g_C using nonambiguous compact form.
98 setup_xfail_format "DWARF 1"
99 gdb_test "print g_C.a" ".* = 7" "print g_C.a"
101 gdb_test "print g_C.c" ".* = 9" "print g_C.c"
103 gdb_test "print g_C.x" ".* = 10" "print g_C.x"
107 # Single inheritance, print type definitions.
110 proc test_ptype_si {} {
114 global hp_aCC_compiler
116 # Print class A as a type.
120 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
121 pass "ptype A (FIXME)"
123 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
125 fail "ptype A (FIXME)"
127 -re ".*$gdb_prompt $" { fail "ptype A" }
128 timeout { fail "ptype A (timeout)" ; return }
131 # Print class A as an explicit class.
133 send_gdb "ptype class A\n"
135 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
136 pass "ptype class A (FIXME)"
138 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
139 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
140 fail "ptype class A (FIXME)"
142 -re ".*$gdb_prompt $" { fail "ptype class A" }
143 timeout { fail "ptype class A (timeout)" ; return }
146 # Print type of an object of type A.
148 send_gdb "ptype g_A\n"
150 -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
151 pass "ptype g_A (FIXME)"
153 -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
154 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
155 fail "ptype g_A (FIXME)"
157 -re ".*$gdb_prompt $" { fail "ptype g_A" }
158 timeout { fail "ptype g_A (timeout)" ; return }
161 # Print class B as a type.
163 setup_xfail_format "DWARF 1"
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 setup_xfail_format "DWARF 1"
169 gdb_test "ptype class B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype class B"
171 # Print type of an object of type B.
173 setup_xfail_format "DWARF 1"
174 gdb_test "ptype g_B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype g_B"
176 # Print class C as a type.
178 setup_xfail_format "DWARF 1"
179 gdb_test "ptype C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype C"
181 # Print class C as an explicit class.
183 setup_xfail_format "DWARF 1"
184 gdb_test "ptype class C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype class C"
186 # Print type of an object of type g_C.
188 setup_xfail_format "DWARF 1"
189 gdb_test "ptype g_C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype g_C"
191 # gcc cygnus-2.3.3 (Q1) has this bug, but it was fixed as of
192 # cygnus-2.3.3-930417. PR 2819.
193 send_gdb "ptype tagless_struct\n"
195 -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 $" {
196 pass "ptype tagless struct"
198 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
199 pass "ptype tagless struct (obsolete gcc or gdb)"
201 -re ".*$gdb_prompt $" {
202 fail "ptype tagless struct"
205 fail "ptype tagless struct (timeout)"
209 send_gdb "ptype v_tagless\n"
211 -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 $" {
212 pass "ptype variable of type tagless struct"
214 -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
215 pass "ptype variable of type tagless struct (obsolete gcc or gdb)"
217 -re ".*$gdb_prompt $" {
218 fail "ptype variable of type tagless struct"
221 fail "ptype variable of type tagless struct (timeout)"
227 # Single inheritance, print complete classes.
230 proc test_print_si_classes {} {
231 # Print all members of g_A.
233 gdb_test "print g_A" ".* = \{a = 1, x = 2\}" "print g_A"
235 # Print all members of g_B.
237 setup_xfail_format "DWARF 1"
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 setup_xfail_format "DWARF 1"
243 gdb_test "print g_C" ".* = \{\<(class |)A\> = \{a = 7, x = 8\}, c = 9, x = 10\}" "print g_C"
247 # Single inheritance, print anonymous unions.
248 # GDB versions prior to 4.14 entered an infinite loop when printing
249 # the type of a class containing an anonymous union, and they were also
250 # incapable of printing the member of an anonymous union.
251 # We test the printing of the member first, and perform the other tests
252 # only if the test succeeds, to avoid the infinite loop.
255 proc test_print_anon_union {} {
260 setup_xfail_format "DWARF 1"
261 gdb_test "print g_anon_union.a" ".* = 2" "print anonymous union member"
262 setup_xfail_format "DWARF 1"
263 send_gdb "print g_anon_union\n"
265 -re ".* = \{one = 1, ( = |)\{a = 2, b = 2\}\}$nl$gdb_prompt $" {
266 pass "print variable of type anonymous union"
268 -re ".* = .*\{one = 1, ( = |)\{a = 2, b = .*\}\}$nl$gdb_prompt $" {
269 pass "print variable of type anonymous union (obsolete gcc or gdb)"
271 -re ".*$nl$gdb_prompt $" {
272 fail "print variable of type anonymous union"
275 fail "print variableof type anonymous union (timeout)"
278 setup_xfail_format "DWARF 1"
279 send_gdb "ptype g_anon_union\n"
281 -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 $" {
282 pass "print type of anonymous union"
284 -re "type = (struct|class).*\{.*int one;.*union \{.*int a;.*(long|long int|int) b;.*\};.*\}$nl$gdb_prompt $" {
285 pass "print type of anonymous union (obsolete gcc or gdb)"
287 -re ".*$nl$gdb_prompt $" {
288 fail "print type of anonymous union"
291 fail "print type of anonymous union (timeout)"
297 # Multiple inheritance, print individual members.
300 proc test_print_mi_members {} {
303 global hp_aCC_compiler
305 # Print all members of g_A.
307 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
309 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
311 # Print all members of g_B.
313 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
315 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
317 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
319 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
321 # Print all members of g_C.
323 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
325 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
327 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
329 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
331 # Print all members of g_D.
333 # The following is ambiguous, and gdb should detect this.
334 # For now, accept gdb's behavior as an expected failure if it
335 # simply prints either member correctly.
337 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
338 send_gdb "print g_D.A::a\n"
340 -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 15$nl$gdb_prompt $" {
341 pass "print g_D.A::a"
343 -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 11$nl$gdb_prompt $" {
344 pass "print g_D.A::a (using B)"
346 -re ".* = 15$nl$gdb_prompt $" {
347 fail "print g_D.A::a (FIXME)"
349 -re ".* = 11$nl$gdb_prompt $" {
350 fail "print g_D.A::a (FIXME)"
352 -re ".*$gdb_prompt $" { fail "print g_D.A::a" }
353 timeout { fail "print g_D.A::a (timeout)" ; return }
356 # The following is ambiguous, and gdb should detect this.
357 # For now, accept gdb's behavior as an expected failure if it
358 # simply prints either member correctly.
360 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
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 fail "print g_D.A::x (FIXME)"
372 -re ".* = 12$nl$gdb_prompt $" {
373 fail "print g_D.A::x (FIXME)"
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 setup_xfail_format "DWARF 1"
384 gdb_test "print g_D.C::c" ".* = 17" "print g_D.C::c"
386 setup_xfail_format "DWARF 1"
387 gdb_test "print g_D.C::x" ".* = 18" "print g_D.C::x"
389 gdb_test "print g_D.D::d" ".* = 19" "print g_D.D::d"
391 gdb_test "print g_D.D::x" ".* = 20" "print g_D.D::x"
393 # Print all members of g_E.
395 # The following is ambiguous, and gdb should detect this.
396 # For now, accept gdb's behavior as an expected failure if it
397 # simply prints either member correctly.
400 send_gdb "print g_E.A::a\n"
402 -re ".* = 21$nl$gdb_prompt $" {
403 fail "print g_E.A::a (FIXME)"
405 -re ".* = 25$nl$gdb_prompt $" {
406 fail "print g_E.A::a (FIXME)"
408 -re ".*$gdb_prompt $" { fail "print g_E.A::a" }
409 timeout { fail "print g_E.A::a (timeout)" ; return }
412 # The following is ambiguous, and gdb should detect this.
413 # For now, accept gdb's behavior as an expected failure if it
414 # simply prints either member correctly.
416 if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
417 send_gdb "print g_E.A::x\n"
419 -re "warning: A ambiguous; using E::D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 26$nl$gdb_prompt $" {
420 pass "print g_E.A::x"
422 -re "warning: A ambiguous; using E::D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 22$nl$gdb_prompt $" {
423 pass "print g_E.A::x (using B)"
425 -re ".* = 26$nl$gdb_prompt $" {
426 fail "print g_E.A::x (FIXME)"
428 -re ".* = 22$nl$gdb_prompt $" {
429 fail "print g_E.A::x (FIXME)"
431 -re ".*$gdb_prompt $" { fail "print g_E.A::x" }
432 timeout { fail "print g_E.A::x (timeout)" ; return }
435 gdb_test "print g_E.B::b" ".* = 23" "print g_E.B::b"
437 gdb_test "print g_E.B::x" ".* = 24" "print g_E.B::x"
439 setup_xfail_format "DWARF 1"
440 gdb_test "print g_E.C::c" ".* = 27" "print g_E.C::c"
442 setup_xfail_format "DWARF 1"
443 gdb_test "print g_E.C::x" ".* = 28" "print g_E.C::x"
445 gdb_test "print g_E.D::d" ".* = 29" "print g_E.D::d"
447 gdb_test "print g_E.D::x" ".* = 30" "print g_E.D::x"
449 gdb_test "print g_E.E::e" ".* = 31" "print g_E.E::e"
451 gdb_test "print g_E.E::x" ".* = 32" "print g_E.E::x"
455 # Multiple inheritance, print type definitions.
458 proc test_ptype_mi {} {
461 setup_xfail_format "DWARF 1"
462 gdb_test "ptype D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype D"
464 setup_xfail_format "DWARF 1"
465 gdb_test "ptype class D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype class D"
467 setup_xfail_format "DWARF 1"
468 gdb_test "ptype g_D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype g_D"
470 setup_xfail_format "DWARF 1"
471 gdb_test "ptype E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype E"
473 setup_xfail_format "DWARF 1"
474 gdb_test "ptype class E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype class E"
476 setup_xfail_format "DWARF 1"
477 gdb_test "ptype g_E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype g_E"
481 # Multiple inheritance, print complete classes.
484 proc test_print_mi_classes {} {
485 # Print all members of g_D.
487 setup_xfail_format "DWARF 1"
488 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"
490 # Print all members of g_E.
492 setup_xfail_format "DWARF 1"
493 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"
497 # Single virtual inheritance, print individual members.
500 proc test_print_svi_members {} {
505 # Print all members of g_vA.
507 gdb_test "print g_vA.vA::va" ".* = 1" "print g_vA.vA::va"
509 gdb_test "print g_vA.vA::vx" ".* = 2" "print g_vA.vA::vx"
511 # Print members of g_vA using compact form.
513 gdb_test "print g_vA.va" ".* = 1" "print g_vA.va"
515 gdb_test "print g_vA.vx" ".* = 2" "print g_vA.vx"
517 # Print all members of g_vB.
519 setup_xfail_format "DWARF 1"
520 send_gdb "print g_vB.vA::va\n"
522 -re ".* = 3$nl$gdb_prompt $" { pass "print g_vB.vA::va" }
523 -re ".*virtual baseclass botch.*$gdb_prompt $" {
524 # Does not happen with gcc cygnus-2.4.5-930828
525 fail "print g_vB.vA::va (known bug with gcc cygnus-2.4.5-930417)"
526 # Many of the rest of these tests have the same problem.
529 -re ".*$gdb_prompt $" { fail "print g_vB.vA::va" }
530 timeout { fail "print g_vB.vA::va (timeout)" ; return }
533 setup_xfail_format "DWARF 1"
534 gdb_test "print g_vB.vA::vx" ".* = 4" "print g_vB.vA::vx"
536 gdb_test "print g_vB.vB::vb" ".* = 5" "print g_vB.vB::vb"
538 gdb_test "print g_vB.vB::vx" ".* = 6" "print g_vB.vB::vx"
540 # Print members of g_vB using compact form.
542 setup_xfail_format "DWARF 1"
543 gdb_test "print g_vB.va" ".* = 3" "print g_vB.va"
545 gdb_test "print g_vB.vb" ".* = 5" "print g_vB.vb"
547 gdb_test "print g_vB.vx" ".* = 6" "print g_vB.vx"
549 # Print all members of g_vC.
551 setup_xfail_format "DWARF 1"
552 gdb_test "print g_vC.vA::va" ".* = 7" "print g_vC.vA::va"
554 setup_xfail_format "DWARF 1"
555 gdb_test "print g_vC.vA::vx" ".* = 8" "print g_vC.vA::vx"
557 gdb_test "print g_vC.vC::vc" ".* = 9" "print g_vC.vC::vc"
559 gdb_test "print g_vC.vC::vx" ".* = 10" "print g_vC.vC::vx"
561 # Print members of g_vC using compact form.
563 setup_xfail_format "DWARF 1"
564 gdb_test "print g_vC.va" ".* = 7" "print g_vC.va"
566 gdb_test "print g_vC.vc" ".* = 9" "print g_vC.vc"
568 gdb_test "print g_vC.vx" ".* = 10" "print g_vC.vx"
572 # Single virtual inheritance, print type definitions.
575 proc test_ptype_vi {} {
580 # This class does not use any C++-specific features, so it's fine for
581 # it to print as "struct".
582 send_gdb "ptype vA\n"
584 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
587 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
590 -re ".*$gdb_prompt $" { fail "ptype vA" }
591 timeout { fail "ptype vA (timeout)" ; return }
594 # This class does not use any C++-specific features, so it's fine for
595 # it to print as "struct".
596 send_gdb "ptype class vA\n"
598 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
599 pass "ptype class vA"
601 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
602 pass "ptype class vA"
604 -re ".*$gdb_prompt $" { fail "ptype class vA" }
605 timeout { fail "ptype class vA (timeout)" ; return }
608 # This class does not use any C++-specific features, so it's fine for
609 # it to print as "struct".
610 send_gdb "ptype g_vA\n"
612 -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
615 -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
618 -re ".*$gdb_prompt $" { fail "ptype g_vA" }
619 timeout { fail "ptype g_vA (timeout)" ; return }
622 setup_xfail_format "DWARF 1"
623 send_gdb "ptype vB\n"
625 -re "ptype vB${nl}type = class vB : public virtual vA \{$nl private:${ws}vA \[*\]+_vb\[\\\$\.\]+vA;$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" {
628 -re "ptype vB${nl}type = class vB : public virtual vA \{$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" {
629 pass "ptype vB (aCC)"
631 -re ".*$gdb_prompt $" { fail "ptype vB" }
632 timeout { fail "ptype vB (timeout)" }
635 setup_xfail_format "DWARF 1"
636 send_gdb "ptype class vB\n"
638 -re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
639 pass "ptype class vB"
641 -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
642 pass "ptype class vB (aCC)"
644 -re ".*$gdb_prompt $" { fail "ptype class vB" }
645 timeout { fail "ptype class vB (timeout)" }
648 setup_xfail_format "DWARF 1"
649 send_gdb "ptype g_vB\n"
651 -re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
654 -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
655 pass "ptype g_vB (aCC)"
657 -re ".*$gdb_prompt $" { fail "ptype g_vB" }
658 timeout { fail "ptype g_vB (timeout)" }
661 setup_xfail_format "DWARF 1"
662 send_gdb "ptype vC\n"
664 -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
667 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
668 pass "ptype vC (aCC)"
670 -re ".*$gdb_prompt $" { fail "ptype vC" }
671 timeout { fail "ptype vC (timeout)" }
674 setup_xfail_format "DWARF 1"
675 send_gdb "ptype class vC\n"
677 -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
678 pass "ptype class vC"
680 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
681 pass "ptype class vC (aCC)"
683 -re ".*$gdb_prompt $" { fail "ptype class vC" }
684 timeout { fail "ptype class vC (timeout)" }
687 setup_xfail_format "DWARF 1"
688 send_gdb "ptype g_vC\n"
690 -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \[*\]+_vb\[\\\$\.\]vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
693 -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
694 pass "ptype g_vC (aCC)"
696 -re ".*$gdb_prompt $" { fail "ptype g_vC" }
697 timeout { fail "ptype g_vC (timeout)" }
702 # Single virtual inheritance, print complete classes.
705 proc test_print_svi_classes {} {
711 # Print all members of g_vA.
713 gdb_test "print g_vA" ".* = \{va = 1, vx = 2\}" "print g_vA"
715 # Print all members of g_vB.
717 setup_xfail_format "DWARF 1"
718 send_gdb "print g_vB\n"
720 -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, Virtual table at $hex\}$nl$gdb_prompt $" {
721 pass "print g_vB (aCC)"
723 -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, __vfp = $hex\}$nl$gdb_prompt $" {
724 pass "print g_vB (aCC)"
726 -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, _vb\[\\\$\.\]vA = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
729 -re ".*invalid address 0x0.*$gdb_prompt $" {
730 # Does not happen with gcc cygnus-2.4.5-930828
731 fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)"
732 # Many of the rest of these tests have the same problem.
735 -re ".*$gdb_prompt $" { fail "print g_vB" }
736 timeout { fail "print g_vB (timeout)" ; return }
739 # Print all members of g_vC.
741 setup_xfail_format "DWARF 1"
742 send_gdb "print g_vC\n"
744 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, Virtual table at $hex\}$nl$gdb_prompt $" {
745 pass "print g_vC (aCC)"
747 -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, __vfp = $hex\}$nl$gdb_prompt $" {
748 pass "print g_vC (aCC)"
750 -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, _vb\[\\\$\.\]vA = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
753 -re ".*$gdb_prompt $" { fail "print g_vC" }
754 timeout { fail "print g_vC (timeout)" }
759 # Multiple virtual inheritance, print individual members.
762 proc test_print_mvi_members {} {
767 # Print all members of g_vD.
769 setup_xfail_format "DWARF 1"
770 send_gdb "print g_vD.vA::va\n"
772 -re ".* = 19$nl$gdb_prompt $" { pass "print g_vD.vA::va" }
773 -re ".*virtual baseclass botch.*$gdb_prompt $" {
774 # Does not happen with gcc cygnus-2.4.5-930828
775 fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)"
776 # Many of the rest of these tests have the same problem.
779 -re ".*$gdb_prompt $" { fail "print g_vD.vA::va" }
780 timeout { fail "print g_vD.vA::va (timeout)" ; return }
783 setup_xfail_format "DWARF 1"
784 gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx"
786 setup_xfail_format "DWARF 1"
787 gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb"
789 setup_xfail_format "DWARF 1"
790 gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx"
792 setup_xfail_format "DWARF 1"
793 gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc"
795 setup_xfail_format "DWARF 1"
796 gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx"
798 gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd"
800 gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx"
802 # Print all members of g_vE.
804 setup_xfail_format "DWARF 1"
805 gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va"
807 setup_xfail_format "DWARF 1"
808 gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx"
810 setup_xfail_format "DWARF 1"
811 gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb"
813 setup_xfail_format "DWARF 1"
814 gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx"
816 setup_xfail_format "DWARF 1"
817 gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc"
819 setup_xfail_format "DWARF 1"
820 gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx"
822 setup_xfail_format "DWARF 1"
823 gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd"
825 gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx"
827 gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve"
829 gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx"
833 # Multiple virtual inheritance, print type definitions.
836 proc test_ptype_mvi {} {
841 setup_xfail_format "DWARF 1"
842 send_gdb "ptype vD\n"
844 -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \[*\]+_vb\[\\\$\.\]vC;${ws}vB \[*\]+_vb\[\\\$\.\]vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
847 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
850 -re ".*$gdb_prompt $" { fail "ptype vD" }
851 timeout { fail "(timeout) ptype vD" }
854 setup_xfail_format "DWARF 1"
855 send_gdb "ptype class vD\n"
857 -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \[*\]+_vb\[\\\$\.\]vC;${ws}vB \[*\]+_vb\[\\\$\.\]vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
858 pass "ptype class vD"
860 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
861 pass "ptype class vD"
863 -re ".*$gdb_prompt $" { fail "ptype class vD" }
864 timeout { fail "(timeout) ptype class vD" }
867 setup_xfail_format "DWARF 1"
868 send_gdb "ptype g_vD\n"
870 -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \[*\]+_vb\[\\\$\.\]vC;${ws}vB \[*\]+_vb\[\\\$\.\]vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
873 -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
876 -re ".*$gdb_prompt $" { fail "ptype g_vD" }
877 timeout { fail "(timeout) ptype g_vD" }
880 setup_xfail_format "DWARF 1"
881 send_gdb "ptype vE\n"
883 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \[*\]+_vb\[\\\$\.\]vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
886 -re ".*class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
889 -re ".*$gdb_prompt $" { fail "ptype vE" }
890 timeout { fail "(timeout) ptype vE" }
893 setup_xfail_format "DWARF 1"
894 send_gdb "ptype class vE\n"
896 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \[*\]+_vb\[\\\$\.\]vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
897 pass "ptype class vE"
899 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
900 pass "ptype class vE"
902 -re ".*$gdb_prompt $" { fail "ptype class vE" }
903 timeout { fail "(timeout) ptype class vE" }
906 setup_xfail_format "DWARF 1"
907 send_gdb "ptype g_vE\n"
909 -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \[*\]+_vb\[\\\$\.\]vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
912 -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
915 -re ".*$gdb_prompt $" { fail "ptype g_vE" }
916 timeout { fail "(timeout) ptype g_vE" }
921 # Multiple virtual inheritance, print complete classes.
924 proc test_print_mvi_classes {} {
930 # Print all members of g_vD.
932 setup_xfail_format "DWARF 1"
933 send_gdb "print g_vD\n"
935 -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 $" {
936 pass "print g_vD (aCC)"
938 -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 $" {
939 pass "print g_vD (aCC)"
941 -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 $" {
944 -re ".*invalid address 0x0.*$gdb_prompt $" {
945 # Does not happen with gcc cygnus-2.4.5-930828
946 fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)"
947 # Many of the rest of these tests have the same problem.
950 -re ".*$gdb_prompt $" { fail "print g_vD" }
951 timeout { fail "print g_vD (timeout)" ; return }
954 # Print all members of g_vE.
956 setup_xfail_format "DWARF 1"
957 send_gdb "print g_vE\n"
959 -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 $" {
960 pass "print g_vE (aCC)"
962 -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 $" {
963 pass "print g_vE (aCC)"
965 -re ".* = \{\<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\}$nl$gdb_prompt $" {
968 -re ".*$gdb_prompt $" { fail "print g_vE" }
969 timeout { fail "print g_vE (timeout)" }
984 # Start with a fresh gdb.
988 gdb_reinitialize_dir $srcdir/$subdir
991 gdb_test "set language c++" ""
992 gdb_test "set width 0" ""
994 # Get the debug format for the compiled test case.
996 if { ![ runto_main] } {
1007 gdb_stop_suppressing_tests;
1009 if { ![ runto 'inheritance2(void)' ] } {
1013 test_print_si_members
1014 test_print_si_classes
1015 test_print_mi_members
1016 test_print_mi_classes
1017 test_print_anon_union
1019 gdb_stop_suppressing_tests;
1021 if { ![ runto 'inheritance4(void)' ] } {
1025 test_print_svi_members
1026 test_print_svi_classes
1027 test_print_mvi_members
1028 test_print_mvi_classes