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)
28 # Check to see if we have an executable to test. If not, then either we
29 # haven't tried to compile one, or the compilation failed for some reason.
30 # In either case, just notify the user and skip the tests in this file.
31 # Note - create separate "inherit" executable from misc.cc
33 set testfile "inherit-hp"
34 set srcfile misc-hp.cc
35 set binfile ${objdir}/${subdir}/${testfile}
37 if [get_compiler_info ${binfile} "c++"] {
42 if {[skip_hp_tests $gcc_compiled]} then { continue }
45 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
46 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
50 # Single inheritance, print individual members.
53 proc test_print_si_members {} {
54 # Print all members of g_A using fully qualified form.
56 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
58 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
60 # Print members of g_A using nonambiguous compact form.
62 gdb_test "print g_A.a" ".* = 1" "print g_A.a"
64 gdb_test "print g_A.x" ".* = 2" "print g_A.x"
66 # Print all members of g_B using fully qualified form.
68 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
70 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
72 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
74 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
76 # Print members of g_B using nonambiguous compact form.
78 setup_xfail_format "DWARF 1"
79 gdb_test "print g_B.a" ".* = 3" "print g_B.a"
81 gdb_test "print g_B.b" ".* = 5" "print g_B.b"
83 gdb_test "print g_B.x" ".* = 6" "print g_B.x"
85 # Print all members of g_C using fully qualified form.
87 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
89 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
91 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
93 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
95 # Print members of g_C using nonambiguous compact form.
97 setup_xfail_format "DWARF 1"
98 gdb_test "print g_C.a" ".* = 7" "print g_C.a"
100 gdb_test "print g_C.c" ".* = 9" "print g_C.c"
102 gdb_test "print g_C.x" ".* = 10" "print g_C.x"
106 # Single inheritance, print type definitions.
109 proc test_ptype_si {} {
113 # Print class A as a type.
117 -re "type = class A \{\r\n.*\[ \]*int a;\r\n\[ \]*int x;\r\n.*\[ \]*\}\r\n$gdb_prompt $" {
118 pass "ptype A (FIXME)"
120 -re "type = struct A \{\r\n\[ \]*int a;\r\n\[ \]*int x;\r\n\[ \]*\}\r\n$gdb_prompt $" {
122 fail "ptype A (FIXME)"
124 -re ".*$gdb_prompt $" { fail "ptype A" }
125 timeout { fail "ptype A (timeout)" ; return }
128 # Print class A as an explicit class.
130 send_gdb "ptype class A\n"
132 -re "type = class A \{\r\n.*\[ \]*int a;\r\n\[ \]*int x;\r\n.*\[ \]*\}\r\n$gdb_prompt $" {
133 pass "ptype class A (FIXME)"
135 -re "type = struct A \{\r\n\[ \]*int a;\r\n\[ \]*int x;\r\n\[ \]*\}\r\n$gdb_prompt $" {
137 fail "ptype class A (FIXME)"
139 -re ".*$gdb_prompt $" { fail "ptype class A" }
140 timeout { fail "ptype class A (timeout)" ; return }
143 # Print type of an object of type A.
145 send_gdb "ptype g_A\n"
147 -re "type = class A \{\r\n.*\[ \]*int a;\r\n\[ \]*int x;\r\n.*\[ \]*\}\r\n$gdb_prompt $" {
148 pass "ptype g_A (FIXME)"
150 -re "type = struct A \{\r\n\[ \]*int a;\r\n\[ \]*int x;\r\n\[ \]*\}\r\n$gdb_prompt $" {
152 fail "ptype g_A (FIXME)"
154 -re ".*$gdb_prompt $" { fail "ptype g_A" }
155 timeout { fail "ptype g_A (timeout)" ; return }
158 # Print class B as a type.
160 setup_xfail_format "DWARF 1"
161 gdb_test "ptype B" "type = class B : public A \{\r\n\[ \]*public:\r\n\[ \]*int b;\r\n\[ \]*int x;\r\n.*\}" "ptype B"
163 # Print class B as an explicit class.
165 setup_xfail_format "DWARF 1"
166 gdb_test "ptype class B" "type = class B : public A \{\r\n\[ \]*public:\r\n\[ \]*int b;\r\n\[ \]*int x;\r\n.*\}" "ptype class B"
168 # Print type of an object of type B.
170 setup_xfail_format "DWARF 1"
171 gdb_test "ptype g_B" "type = class B : public A \{\r\n\[ \]*public:\r\n\[ \]*int b;\r\n\[ \]*int x;\r\n.*\}" "ptype g_B"
173 # Print class C as a type.
175 setup_xfail_format "DWARF 1"
176 gdb_test "ptype C" "type = class C : public A \{\r\n\[ \]*public:\r\n\[ \]*int c;\r\n\[ \]*int x;\r\n.*\}" "ptype C"
178 # Print class C as an explicit class.
180 setup_xfail_format "DWARF 1"
181 gdb_test "ptype class C" "type = class C : public A \{\r\n\[ \]*public:\r\n\[ \]*int c;\r\n\[ \]*int x;\r\n.*\}" "ptype class C"
183 # Print type of an object of type g_C.
185 setup_xfail_format "DWARF 1"
186 gdb_test "ptype g_C" "type = class C : public A \{\r\n\[ \]*public:\r\n\[ \]*int c;\r\n\[ \]*int x;\r\n.*\}" "ptype g_C"
188 # gcc cygnus-2.3.3 (Q1) has this bug, but it was fixed as of
189 # cygnus-2.3.3-930417. PR 2819.
190 send_gdb "ptype tagless_struct\n"
192 -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct &\\);${ws}\\\$_1 \\(tagless_struct &\\);${ws}\\\$_1 \\(\\);${ws}\}\r\n$gdb_prompt $" {
193 pass "ptype tagless struct"
195 -re "type = (struct|class).*\{.*int one;.*int two;.*\}\r\n$gdb_prompt $" {
196 pass "ptype tagless struct (obsolete gcc or gdb)"
198 -re ".*$gdb_prompt $" {
199 fail "ptype tagless struct"
202 fail "ptype tagless struct (timeout)"
206 send_gdb "ptype v_tagless\n"
208 -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct &\\);${ws}\\\$_1 \\(tagless_struct &\\);${ws}\\\$_1 \\(\\);${ws}\}\r\n$gdb_prompt $" {
209 pass "ptype variable of type tagless struct"
211 -re "type = (struct|class).*\{.*int one;.*int two;.*\}\r\n$gdb_prompt $" {
212 pass "ptype variable of type tagless struct (obsolete gcc or gdb)"
214 -re ".*$gdb_prompt $" {
215 fail "ptype variable of type tagless struct"
218 fail "ptype variable of type tagless struct (timeout)"
224 # Single inheritance, print complete classes.
227 proc test_print_si_classes {} {
228 # Print all members of g_A.
230 gdb_test "print g_A" ".* = \{a = 1, x = 2\}" "print g_A"
232 # Print all members of g_B.
234 setup_xfail_format "DWARF 1"
235 gdb_test "print g_B" ".* = \{\<class A\> = \{a = 3, x = 4\}, b = 5, x = 6\}" "print g_B"
237 # Print all members of g_C.
239 setup_xfail_format "DWARF 1"
240 gdb_test "print g_C" ".* = \{\<class A\> = \{a = 7, x = 8\}, c = 9, x = 10\}" "print g_C"
244 # Single inheritance, print anonymous unions.
245 # GDB versions prior to 4.14 entered an infinite loop when printing
246 # the type of a class containing an anonymous union, and they were also
247 # incapable of printing the member of an anonymous union.
248 # We test the printing of the member first, and perform the other tests
249 # only if the test succeeds, to avoid the infinite loop.
252 proc test_print_anon_union {} {
256 setup_xfail_format "DWARF 1"
257 gdb_test "print g_anon_union.a" ".* = 2" "print anonymous union member"
258 setup_xfail_format "DWARF 1"
259 send_gdb "print g_anon_union\n"
261 -re ".* = \{one = 1, \{a = 2, b = 2\}\}\r\n$gdb_prompt $" {
262 pass "print variable of type anonymous union"
264 -re ".* = .*\{one = 1, = \{a = 2, b = .*\}\}\r\n$gdb_prompt $" {
265 pass "print variable of type anonymous union (obsolete gcc or gdb)"
267 -re ".*\r\n$gdb_prompt $" {
268 fail "print variable of type anonymous union"
271 fail "print variableof type anonymous union (timeout)"
274 setup_xfail_format "DWARF 1"
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}\}\r\n$gdb_prompt $" {
278 pass "print type of anonymous union"
280 -re "type = (struct|class).*\{.*int one;.*union \{.*int a;.*(long|long int|int) b;.*\};.*\}\r\n$gdb_prompt $" {
281 pass "print type of anonymous union (obsolete gcc or gdb)"
283 -re ".*\r\n$gdb_prompt $" {
284 fail "print type of anonymous union"
287 fail "print type of anonymous union (timeout)"
293 # Multiple inheritance, print individual members.
296 proc test_print_mi_members {} {
299 # Print all members of g_A.
301 gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
303 gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
305 # Print all members of g_B.
307 gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
309 gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
311 gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
313 gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
315 # Print all members of g_C.
317 gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
319 gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
321 gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
323 gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
325 # Print all members of g_D.
327 # The following is ambiguous, and gdb should detect this.
328 # For now, accept gdb's behavior as an expected failure if it
329 # simply prints either member correctly.
331 # setup_xfail "*-*-*"
332 send_gdb "print g_D.A::a\n"
334 -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.\r\n\\$\[0-9\]* = 11\r\n$gdb_prompt $" {
335 pass "print g_D.A::a"
337 -re ".* = 15\r\n$gdb_prompt $" {
338 fail "print g_D.A::a (did GDB's algorithm change?)"
340 -re ".* = 11\r\n$gdb_prompt $" {
341 fail "print g_D.A::a (ambiguity not reported)"
343 -re ".*$gdb_prompt $" { fail "print g_D.A::a" }
344 timeout { fail "print g_D.A::a (timeout)" ; return }
347 # The following is ambiguous, and gdb should detect this.
348 # For now, accept gdb's behavior as an expected failure if it
349 # simply prints either member correctly.
351 # setup_xfail "*-*-*"
352 send_gdb "print g_D.A::x\n"
354 -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.\r\n\\$\[0-9\]* = 12\r\n$gdb_prompt $" {
355 pass "print g_D.A::x"
357 -re ".* = 16\r\n$gdb_prompt $" {
358 fail "print g_D.A::x (did GDB's algorithm change?)"
360 -re ".* = 12\r\n$gdb_prompt $" {
361 fail "print g_D.A::x (ambiguity not reported)"
363 -re ".*$gdb_prompt $" { fail "print g_D.A::x" }
364 timeout { fail "print g_D.A::x (timeout)" ; return }
367 gdb_test "print g_D.B::b" ".* = 13" "print g_D.B::b"
369 gdb_test "print g_D.B::x" ".* = 14" "print g_D.B::x"
371 setup_xfail_format "DWARF 1"
372 gdb_test "print g_D.C::c" ".* = 17" "print g_D.C::c"
374 setup_xfail_format "DWARF 1"
375 gdb_test "print g_D.C::x" ".* = 18" "print g_D.C::x"
377 gdb_test "print g_D.D::d" ".* = 19" "print g_D.D::d"
379 gdb_test "print g_D.D::x" ".* = 20" "print g_D.D::x"
381 # Print all members of g_E.
383 # The following is ambiguous, and gdb should detect this.
384 # For now, accept gdb's behavior as an expected failure if it
385 # simply prints either member correctly.
388 send_gdb "print g_E.A::a\n"
390 -re "warning: A ambiguous; using E::D::B::A. Use a cast to disambiguate.\r\n\\$\[0-9\]* = 21\r\n$gdb_prompt $" {
391 pass "print g_E.A::a"
393 -re ".* = 25\r\n$gdb_prompt $" {
394 fail "print g_E.A::a (did GDB's algorithm change?)"
396 -re ".* = 21\r\n$gdb_prompt $" {
397 fail "print g_E.A::a (ambiguity not reported)"
399 -re ".*$gdb_prompt $" { fail "print g_E.A::a" }
400 timeout { fail "print g_E.A::a (timeout)" ; return }
403 # The following is ambiguous, and gdb should detect this.
404 # For now, accept gdb's behavior as an expected failure if it
405 # simply prints either member correctly.
407 # setup_xfail "*-*-*"
408 send_gdb "print g_E.A::x\n"
410 -re "warning: A ambiguous; using E::D::B::A. Use a cast to disambiguate.\r\n\\$\[0-9\]* = 22\r\n$gdb_prompt $" {
411 pass "print g_E.A::x"
413 -re ".* = 26\r\n$gdb_prompt $" {
414 fail "print g_E.A::x (did GDB's algorithm change?)"
416 -re ".* = 22\r\n$gdb_prompt $" {
417 fail "print g_E.A::x (ambiguity not reported)"
419 -re ".*$gdb_prompt $" { fail "print g_E.A::x" }
420 timeout { fail "print g_E.A::x (timeout)" ; return }
423 gdb_test "print g_E.B::b" ".* = 23" "print g_E.B::b"
425 gdb_test "print g_E.B::x" ".* = 24" "print g_E.B::x"
427 setup_xfail_format "DWARF 1"
428 gdb_test "print g_E.C::c" ".* = 27" "print g_E.C::c"
430 setup_xfail_format "DWARF 1"
431 gdb_test "print g_E.C::x" ".* = 28" "print g_E.C::x"
433 gdb_test "print g_E.D::d" ".* = 29" "print g_E.D::d"
435 gdb_test "print g_E.D::x" ".* = 30" "print g_E.D::x"
437 gdb_test "print g_E.E::e" ".* = 31" "print g_E.E::e"
439 gdb_test "print g_E.E::x" ".* = 32" "print g_E.E::x"
443 # Multiple inheritance, print type definitions.
446 proc test_ptype_mi {} {
447 setup_xfail_format "DWARF 1"
448 gdb_test "ptype D" "type = class D : public B, public C \{\r\n\[ \]*public:\r\n\[ \]*int d;\r\n\[ \]*int x;\r\n.*\}" "ptype D"
450 setup_xfail_format "DWARF 1"
451 gdb_test "ptype class D" "type = class D : public B, public C \{\r\n\[ \]*public:\r\n\[ \]*int d;\r\n\[ \]*int x;\r\n.*\}" "ptype class D"
453 setup_xfail_format "DWARF 1"
454 gdb_test "ptype g_D" "type = class D : public B, public C \{\r\n\[ \]*public:\r\n\[ \]*int d;\r\n\[ \]*int x;\r\n.*\}" "ptype g_D"
456 setup_xfail_format "DWARF 1"
457 gdb_test "ptype E" "type = class E : public D \{\r\n\[ \]*public:\r\n\[ \]*int e;\r\n\[ \]*int x;\r\n.*\}" "ptype E"
459 setup_xfail_format "DWARF 1"
460 gdb_test "ptype class E" "type = class E : public D \{\r\n\[ \]*public:\r\n\[ \]*int e;\r\n\[ \]*int x;\r\n.*\}" "ptype class E"
462 setup_xfail_format "DWARF 1"
463 gdb_test "ptype g_E" "type = class E : public D \{\r\n\[ \]*public:\r\n\[ \]*int e;\r\n\[ \]*int x;\r\n.*\}" "ptype g_E"
467 # Multiple inheritance, print complete classes.
470 proc test_print_mi_classes {} {
471 # Print all members of g_D.
473 setup_xfail_format "DWARF 1"
474 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"
476 # Print all members of g_E.
478 setup_xfail_format "DWARF 1"
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 {} {
490 # Print all members of g_vA.
492 gdb_test "print g_vA.vA::va" ".* = 1" "print g_vA.vA::va"
494 gdb_test "print g_vA.vA::vx" ".* = 2" "print g_vA.vA::vx"
496 # Print members of g_vA using compact form.
498 gdb_test "print g_vA.va" ".* = 1" "print g_vA.va"
500 gdb_test "print g_vA.vx" ".* = 2" "print g_vA.vx"
502 # Print all members of g_vB.
504 setup_xfail_format "DWARF 1"
505 send_gdb "print g_vB.vA::va\n"
507 -re ".* = 3\r\n$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 setup_xfail_format "DWARF 1"
519 gdb_test "print g_vB.vA::vx" ".* = 4" "print g_vB.vA::vx"
521 gdb_test "print g_vB.vB::vb" ".* = 5" "print g_vB.vB::vb"
523 gdb_test "print g_vB.vB::vx" ".* = 6" "print g_vB.vB::vx"
525 # Print members of g_vB using compact form.
527 setup_xfail_format "DWARF 1"
528 gdb_test "print g_vB.va" ".* = 3" "print g_vB.va"
530 gdb_test "print g_vB.vb" ".* = 5" "print g_vB.vb"
532 gdb_test "print g_vB.vx" ".* = 6" "print g_vB.vx"
534 # Print all members of g_vC.
536 setup_xfail_format "DWARF 1"
537 gdb_test "print g_vC.vA::va" ".* = 7" "print g_vC.vA::va"
539 setup_xfail_format "DWARF 1"
540 gdb_test "print g_vC.vA::vx" ".* = 8" "print g_vC.vA::vx"
542 gdb_test "print g_vC.vC::vc" ".* = 9" "print g_vC.vC::vc"
544 gdb_test "print g_vC.vC::vx" ".* = 10" "print g_vC.vC::vx"
546 # Print members of g_vC using compact form.
548 setup_xfail_format "DWARF 1"
549 gdb_test "print g_vC.va" ".* = 7" "print g_vC.va"
551 gdb_test "print g_vC.vc" ".* = 9" "print g_vC.vc"
553 gdb_test "print g_vC.vx" ".* = 10" "print g_vC.vx"
557 # Single virtual inheritance, print type definitions.
560 proc test_ptype_vi {} {
563 # This class does not use any C++-specific features, so it's fine for
564 # it to print as "struct".
565 send_gdb "ptype vA\n"
567 -re "type = class vA \{\[\r\n\]+\[ \]*public:\[\r\n\]+\[ \]*int va;\[\r\n\]+\[ \]*int vx;\[\r\n\]+.*\}\[\r\n\]+$gdb_prompt $" {
570 -re "type = struct vA \{\[\r\n\]+\[ \]*int va;\[\r\n\]+\[ \]*int vx;\[\r\n\]+\}\[\r\n\]+$gdb_prompt $" {
573 -re ".*$gdb_prompt $" { fail "ptype vA" }
574 timeout { fail "ptype vA (timeout)" ; return }
577 # This class does not use any C++-specific features, so it's fine for
578 # it to print as "struct".
579 send_gdb "ptype class vA\n"
581 -re "type = class vA \{\[\r\n\]+\[ \]*public:\[\r\n\]+\[ \]*int va;\[\r\n\]+\[ \]*int vx;\[\r\n\]+.*\}\[\r\n\]+$gdb_prompt $" {
582 pass "ptype class vA"
584 -re "type = struct vA \{\[\r\n\]+\[ \]*int va;\[\r\n\]+\[ \]*int vx;\[\r\n\]+\}\[\r\n\]+$gdb_prompt $" {
585 pass "ptype class vA"
587 -re ".*$gdb_prompt $" { fail "ptype class vA" }
588 timeout { fail "ptype class vA (timeout)" ; return }
591 # This class does not use any C++-specific features, so it's fine for
592 # it to print as "struct".
593 send_gdb "ptype g_vA\n"
595 -re "type = class vA \{\[\r\n\]+\[ \]*public:\[\r\n\]+\[ \]*int va;\[\r\n\]+\[ \]*int vx;\[\r\n\]+.*\}\[\r\n\]+$gdb_prompt $" {
598 -re "type = struct vA \{\[\r\n\]+\[ \]*int va;\[\r\n\]+\[ \]*int vx;\[\r\n\]+\}\[\r\n\]+$gdb_prompt $" {
601 -re ".*$gdb_prompt $" { fail "ptype g_vA" }
602 timeout { fail "ptype g_vA (timeout)" ; return }
605 setup_xfail_format "DWARF 1"
606 gdb_test "ptype vB" "ptype vB\[\r\n\]+type = class vB : public virtual vA \{\[\r\n\]+ public:\r\n\[ \]+int vb;\r\n\[ \]+int vx;\r\n.*\}" "ptype vB (aCC)"
608 setup_xfail_format "DWARF 1"
609 gdb_test "ptype class vB" "type = class vB : public virtual vA \{\r\n\[ \]*public:\r\n\[ \]*int vb;\r\n\[ \]*int vx;\r\n.*\}" "ptype class vB (aCC)"
611 setup_xfail_format "DWARF 1"
612 gdb_test "ptype g_vB" "type = class vB : public virtual vA \{\r\n\[ \]*public:\r\n\[ \]*int vb;\r\n\[ \]*int vx;\r\n.*\}" "ptype g_vB (aCC)"
614 setup_xfail_format "DWARF 1"
615 gdb_test "ptype vC" "type = class vC : public virtual vA \{\r\n\[ \]*public:\r\n\[ \]*int vc;\r\n\[ \]*int vx;\r\n.*\}" "ptype vC (aCC)"
617 setup_xfail_format "DWARF 1"
618 gdb_test "ptype class vC" "type = class vC : public virtual vA \{\r\n\[ \]*public:\r\n\[ \]*int vc;\r\n\[ \]*int vx;\r\n.*\}" "ptype class vC (aCC)"
620 setup_xfail_format "DWARF 1"
621 gdb_test "ptype g_vC" "type = class vC : public virtual vA \{\r\n\[ \]*public:\r\n\[ \]*int vc;\r\n\[ \]*int vx;\r\n.*\}" "ptype g_vC (aCC)"
625 # Single virtual inheritance, print complete classes.
628 proc test_print_svi_classes {} {
633 # Print all members of g_vA.
635 gdb_test "print g_vA" ".* = \{va = 1, vx = 2\}" "print g_vA"
637 # Print all members of g_vB.
639 setup_xfail_format "DWARF 1"
640 send_gdb "print g_vB\n"
642 -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, Virtual table at $hex\}\r\n$gdb_prompt $" {
645 -re ".*invalid address 0x0.*$gdb_prompt $" {
646 # Does not happen with gcc cygnus-2.4.5-930828
647 fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)"
648 # Many of the rest of these tests have the same problem.
651 -re ".*$gdb_prompt $" { fail "print g_vB" }
652 timeout { fail "print g_vB (timeout)" ; return }
655 # Print all members of g_vC.
657 setup_xfail_format "DWARF 1"
658 gdb_test "print g_vC" ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, Virtual table at $hex\}" "print g_vC"
662 # Multiple virtual inheritance, print individual members.
665 proc test_print_mvi_members {} {
669 # Print all members of g_vD.
671 setup_xfail_format "DWARF 1"
672 send_gdb "print g_vD.vA::va\n"
674 -re ".* = 19\r\n$gdb_prompt $" { pass "print g_vD.vA::va" }
675 -re ".*virtual baseclass botch.*$gdb_prompt $" {
676 # Does not happen with gcc cygnus-2.4.5-930828
677 fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)"
678 # Many of the rest of these tests have the same problem.
681 -re ".*$gdb_prompt $" { fail "print g_vD.vA::va" }
682 timeout { fail "print g_vD.vA::va (timeout)" ; return }
685 setup_xfail_format "DWARF 1"
686 gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx"
688 setup_xfail_format "DWARF 1"
689 gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb"
691 setup_xfail_format "DWARF 1"
692 gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx"
694 setup_xfail_format "DWARF 1"
695 gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc"
697 setup_xfail_format "DWARF 1"
698 gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx"
700 gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd"
702 gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx"
704 # Print all members of g_vE.
706 setup_xfail_format "DWARF 1"
707 gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va"
709 setup_xfail_format "DWARF 1"
710 gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx"
712 setup_xfail_format "DWARF 1"
713 gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb"
715 setup_xfail_format "DWARF 1"
716 gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx"
718 setup_xfail_format "DWARF 1"
719 gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc"
721 setup_xfail_format "DWARF 1"
722 gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx"
724 setup_xfail_format "DWARF 1"
725 gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd"
727 gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx"
729 gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve"
731 gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx"
735 # Multiple virtual inheritance, print type definitions.
738 proc test_ptype_mvi {} {
739 setup_xfail_format "DWARF 1"
740 gdb_test "ptype vD" "type = class vD : public virtual vB, public virtual vC \{\r\n\[ \]*public:\r\n\[ \]*int vd;\r\n\[ \]*int vx;\r\n.*\}" "ptype vD (aCC)"
742 setup_xfail_format "DWARF 1"
743 gdb_test "ptype class vD" "type = class vD : public virtual vB, public virtual vC \{\r\n\[ \]*public:\r\n\[ \]*int vd;\r\n\[ \]*int vx;\r\n.*\}" "ptype class vD (aCC)"
745 setup_xfail_format "DWARF 1"
746 gdb_test "ptype g_vD" "type = class vD : public virtual vB, public virtual vC \{\r\n\[ \]*public:\r\n\[ \]*int vd;\r\n\[ \]*int vx;\r\n.*\}" "ptype g_vD (aCC)"
748 setup_xfail_format "DWARF 1"
749 gdb_test "ptype vE" "type = class vE : public virtual vD \{\r\n\[ \]*public:\r\n\[ \]*int ve;\r\n\[ \]*int vx;\r\n.*\}" "ptype vE (aCC)"
751 setup_xfail_format "DWARF 1"
752 gdb_test "ptype class vE" "type = class vE : public virtual vD \{\r\n\[ \]*public:\r\n\[ \]*int ve;\r\n\[ \]*int vx;\r\n.*\}" "ptype class vE (aCC)"
754 setup_xfail_format "DWARF 1"
755 gdb_test "ptype g_vE" "type = class vE : public virtual vD \{\r\n\[ \]*public:\r\n\[ \]*int ve;\r\n\[ \]*int vx;\r\n.*\}" "ptype g_vE (aCC)"
759 # Multiple virtual inheritance, print complete classes.
762 proc test_print_mvi_classes {} {
767 # Print all members of g_vD.
769 setup_xfail_format "DWARF 1"
770 send_gdb "print g_vD\n"
772 -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\}\r\n$gdb_prompt $" {
775 -re ".*invalid address 0x0.*$gdb_prompt $" {
776 # Does not happen with gcc cygnus-2.4.5-930828
777 fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)"
778 # Many of the rest of these tests have the same problem.
781 -re ".*$gdb_prompt $" { fail "print g_vD" }
782 timeout { fail "print g_vD (timeout)" ; return }
785 # Print all members of g_vE.
787 setup_xfail_format "DWARF 1"
788 gdb_test "print g_vE" ".* = \{\<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\}" "print g_vE"
802 # Start with a fresh gdb.
806 gdb_reinitialize_dir $srcdir/$subdir
809 gdb_test "set language c++" ""
810 gdb_test "set width 0" ""
812 # Get the debug format for the compiled test case.
814 if { ![ runto_main] } {
825 gdb_stop_suppressing_tests;
827 if { ![ runto 'inheritance2(void)' ] } {
831 test_print_si_members
832 test_print_si_classes
833 test_print_mi_members
834 test_print_mi_classes
835 test_print_anon_union
837 gdb_stop_suppressing_tests;
839 if { ![ runto 'inheritance4(void)' ] } {
843 test_print_svi_members
844 test_print_svi_classes
845 test_print_mvi_members
846 test_print_mvi_classes