1 # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
2 # 2004, 2006 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # This file was written by Fred Fish. (fnf@cygnus.com)
19 # And rewritten by Michael Chastain. (mec.gnu@mindspring.com)
29 if { [skip_cplus_tests] } { continue }
31 load_lib "cp-support.exp"
33 set testfile "inherit"
35 set binfile ${objdir}/${subdir}/${testfile}
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
42 # Single inheritance, print type definitions.
44 proc test_ptype_si { } {
52 "ptype A" "ptype A (FIXME)" "class" "A" \
54 { field public "int a;" }
55 { field public "int x;" }
57 cp_test_ptype_class "ptype class A" "ptype class A (FIXME)" "class" "A" ibid
58 cp_test_ptype_class "ptype g_A" "ptype g_A (FIXME)" "class" "A" ibid
63 "ptype B" "" "class" "B" \
66 { field public "int b;" }
67 { field public "int x;" }
69 cp_test_ptype_class "ptype class B" "" "class" "B" ibid
70 cp_test_ptype_class "ptype g_B" "" "class" "B" ibid
72 # Another derived class.
75 "ptype C" "" "class" "C" \
78 { field public "int c;" }
79 { field public "int x;" }
81 cp_test_ptype_class "ptype class C" "" "class" "C" ibid
82 cp_test_ptype_class "ptype g_C" "" "class" "C" ibid
84 # A structure with no tag.
85 # TODO: move this mess into a separate file, and re-specify
86 # which results are PASS, KFAIL, XFAIL, and FAIL.
88 set re_tag "tagless_struct"
90 set re_class "(class $re_tag \{${ws}public:|class \{${ws}public:|struct $re_tag \{|struct \{)"
91 set XX_class "(class $XX_tag \{${ws}public:|struct $XX_tag \{)"
92 set re_fields "int one;${ws}int two;"
93 set re_synth_gcc_23 "$re_tag & operator=\\($re_tag const ?&\\);${ws}$re_tag\\($re_tag const ?&\\);${ws}$re_tag\\((void|)\\);"
94 set XX_synth_gcc_23 "($re_tag|$XX_tag) & operator=\\($XX_tag const ?&\\);${ws}$XX_tag\\($XX_tag const ?&\\);${ws}$XX_tag\\((void|)\\);"
96 set name "ptype tagless struct"
97 gdb_test_multiple "ptype tagless_struct" $name {
98 -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
99 # gcc 2.95.3 -gdwarf-2
102 -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
103 # gcc 2.95.3 -gstabs+
106 -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
107 # gcc 3.3.4 -gdwarf-2
108 # gcc 3.4.1 -gdwarf-2
109 # gcc HEAD 2004-07-31 -gdwarf-2
110 # gcc HEAD 2004-07-31 -gstabs+
113 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
120 set name "ptype variable of type tagless struct"
121 gdb_test_multiple "ptype v_tagless" $name {
122 -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
123 # gcc 2.95.3 -gdwarf-2
126 -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
127 # gcc 2.95.3 -gstabs+
130 -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
131 # gcc 3.3.4 -gdwarf-2
132 # gcc 3.4.1 -gdwarf-2
133 # gcc HEAD 2004-07-31 -gdwarf-2
134 # gcc HEAD 2004-07-31 -gstabs+
137 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
145 # Multiple inheritance, print type definitions.
147 proc test_ptype_mi { } {
149 # A class with two bases.
151 cp_test_ptype_class \
152 "ptype D" "" "class" "D" \
156 { field public "int d;" }
157 { field public "int x;" }
159 cp_test_ptype_class "ptype class D" "" "class" "D" ibid
160 cp_test_ptype_class "ptype g_D" "" "class" "D" ibid
162 # A class derived from the previous class.
164 cp_test_ptype_class \
165 "ptype E" "" "class" "E" \
168 { field public "int e;" }
169 { field public "int x;" }
171 cp_test_ptype_class "ptype class E" "" "class" "E" ibid
172 cp_test_ptype_class "ptype g_E" "" "class" "E" ibid
175 # Single virtual inheritance, print type definitions.
177 proc test_ptype_vi { } {
181 cp_test_ptype_class \
182 "ptype vA" "" "class" "vA" \
184 { field public "int va;" }
185 { field public "int vx;" }
187 cp_test_ptype_class "ptype class vA" "" "class" "vA" ibid
188 cp_test_ptype_class "ptype g_vA" "" "class" "vA" ibid
192 cp_test_ptype_class \
193 "ptype vB" "" "class" "vB" \
195 { base "public virtual vA" }
197 { field public "int vb;" }
198 { field public "int vx;" }
200 cp_test_ptype_class "ptype class vB" "" "class" "vB" ibid
201 cp_test_ptype_class "ptype g_vB" "" "class" "vB" ibid
205 cp_test_ptype_class \
206 "ptype vC" "" "class" "vC" \
208 { base "public virtual vA" }
210 { field public "int vc;" }
211 { field public "int vx;" }
213 cp_test_ptype_class "ptype class vC" "" "class" "vC" ibid
214 cp_test_ptype_class "ptype g_vC" "" "class" "vC" ibid
218 # Multiple virtual inheritance, print type definitions.
220 proc test_ptype_mvi { } {
224 cp_test_ptype_class \
225 "ptype vD" "" "class" "vD" \
227 { base "public virtual vB" }
228 { base "public virtual vC" }
231 { field public "int vd;" }
232 { field public "int vx;" }
234 cp_test_ptype_class "ptype class vD" "" "class" "vD" ibid
235 cp_test_ptype_class "ptype g_vD" "" "class" "vD" ibid
239 cp_test_ptype_class \
240 "ptype vE" "" "class" "vE" \
242 { base "public virtual vD" }
244 { field public "int ve;" }
245 { field public "int vx;" }
247 cp_test_ptype_class "ptype class vE" "" "class" "vE" ibid
248 cp_test_ptype_class "ptype g_vE" "" "class" "vE" ibid
252 # Single inheritance, print individual members.
254 proc test_print_si_members { } {
257 # Print all members of g_A using fully qualified form.
258 gdb_test "print g_A.A::a" "$vhn = 1"
259 gdb_test "print g_A.A::x" "$vhn = 2"
261 # Print members of g_A using nonambiguous compact form.
262 gdb_test "print g_A.a" "$vhn = 1"
263 gdb_test "print g_A.x" "$vhn = 2"
265 # Print all members of g_B using fully qualified form.
266 gdb_test "print g_B.A::a" "$vhn = 3"
267 gdb_test "print g_B.A::x" "$vhn = 4"
268 gdb_test "print g_B.B::b" "$vhn = 5"
269 gdb_test "print g_B.B::x" "$vhn = 6"
271 # Print members of g_B using nonambiguous compact form.
272 gdb_test "print g_B.a" "$vhn = 3"
273 gdb_test "print g_B.b" "$vhn = 5"
274 gdb_test "print g_B.x" "$vhn = 6"
276 # Print all members of g_C using fully qualified form.
277 gdb_test "print g_C.A::a" "$vhn = 7"
278 gdb_test "print g_C.A::x" "$vhn = 8"
279 gdb_test "print g_C.C::c" "$vhn = 9"
280 gdb_test "print g_C.C::x" "$vhn = 10"
282 # Print members of g_C using nonambiguous compact form.
283 gdb_test "print g_C.a" "$vhn = 7"
284 gdb_test "print g_C.c" "$vhn = 9"
285 gdb_test "print g_C.x" "$vhn = 10"
288 # Single inheritance, print complete classes.
290 proc test_print_si_classes { } {
293 # Print all members of g_A, g_B, g_C.
294 gdb_test "print g_A" "$vhn = \{a = 1, x = 2\}"
295 gdb_test "print g_B" "$vhn = \{<(class A|A)> = \{a = 3, x = 4\}, b = 5, x = 6\}"
296 gdb_test "print g_C" "$vhn = \{<(class A|A)> = \{a = 7, x = 8\}, c = 9, x = 10\}"
299 # Multiple inheritance, print individual members.
301 proc test_print_mi_members {} {
306 # Print all members of g_A.
307 gdb_test "print g_A.A::a" "$vhn = 1"
308 gdb_test "print g_A.A::x" "$vhn = 2"
310 # Print all members of g_B.
311 gdb_test "print g_B.A::a" "$vhn = 3"
312 gdb_test "print g_B.A::x" "$vhn = 4"
313 gdb_test "print g_B.B::b" "$vhn = 5"
314 gdb_test "print g_B.B::x" "$vhn = 6"
316 # Print all members of g_C.
317 gdb_test "print g_C.A::a" "$vhn = 7"
318 gdb_test "print g_C.A::x" "$vhn = 8"
319 gdb_test "print g_C.C::c" "$vhn = 9"
320 gdb_test "print g_C.C::x" "$vhn = 10"
322 # Print all members of g_D.
324 # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb
325 # should detect these. There are no ways to PASS these tests
326 # because I don't know what the gdb message will be. -- chastain
329 set name "print g_D.A::a"
330 gdb_test_multiple "print g_D.A::a" $name {
331 -re "$vhn = (15|11)$nl$gdb_prompt $" {
332 kfail "gdb/68" "print g_D.A::a"
336 set name "print g_D.A::x"
337 gdb_test_multiple "print g_D.A::x" $name {
338 -re "$vhn = (16|12)$nl$gdb_prompt $" {
339 kfail "gdb/68" "print g_D.A::x"
343 gdb_test "print g_D.B::b" "$vhn = 13"
344 gdb_test "print g_D.B::x" "$vhn = 14"
345 gdb_test "print g_D.C::c" "$vhn = 17"
346 gdb_test "print g_D.C::x" "$vhn = 18"
347 gdb_test "print g_D.D::d" "$vhn = 19"
348 gdb_test "print g_D.D::x" "$vhn = 20"
350 # Print all members of g_E.
351 # g_E.A::a and g_E.A::x are ambiguous.
353 set name "print g_E.A::a"
354 gdb_test_multiple "print g_E.A::a" $name {
355 -re "$vhn = (21|25)$nl$gdb_prompt $" {
356 kfail "gdb/68" "print g_E.A::a"
360 set name "print g_E.A::x"
361 gdb_test_multiple "print g_E.A::x" $name {
362 -re "$vhn = (26|22)$nl$gdb_prompt $" {
363 kfail "gdb/68" "print g_E.A::x"
367 gdb_test "print g_E.B::b" "$vhn = 23"
368 gdb_test "print g_E.B::x" "$vhn = 24"
369 gdb_test "print g_E.C::c" "$vhn = 27"
370 gdb_test "print g_E.C::x" "$vhn = 28"
371 gdb_test "print g_E.D::d" "$vhn = 29"
372 gdb_test "print g_E.D::x" "$vhn = 30"
373 gdb_test "print g_E.E::e" "$vhn = 31"
374 gdb_test "print g_E.E::x" "$vhn = 32"
377 # Multiple inheritance, print individual member types.
379 proc test_print_mi_member_types {} {
384 # Print the types of some members of g_D without qualifying them.
385 gdb_test "ptype g_D.b" "type = int"
386 gdb_test "ptype g_D.c" "type = int"
387 gdb_test "ptype g_D.d" "type = int"
389 # Print the types of qualified members; none of these tests pass today.
391 # Print all members of g_A.
392 setup_kfail "gdb/2092" "*-*-*"
393 gdb_test "ptype g_A.A::a" "type = int"
394 setup_kfail "gdb/2092" "*-*-*"
395 gdb_test "ptype g_A.A::x" "type = int"
397 # Print all members of g_B.
398 setup_kfail "gdb/2092" "*-*-*"
399 gdb_test "ptype g_B.A::a" "type = int"
400 setup_kfail "gdb/2092" "*-*-*"
401 gdb_test "ptype g_B.A::x" "type = int"
402 setup_kfail "gdb/2092" "*-*-*"
403 gdb_test "ptype g_B.B::b" "type = int"
404 setup_kfail "gdb/2092" "*-*-*"
405 gdb_test "ptype g_B.B::x" "type = int"
407 # Print all members of g_C.
408 setup_kfail "gdb/2092" "*-*-*"
409 gdb_test "ptype g_C.A::a" "type = int"
410 setup_kfail "gdb/2092" "*-*-*"
411 gdb_test "ptype g_C.A::x" "type = int"
412 setup_kfail "gdb/2092" "*-*-*"
413 gdb_test "ptype g_C.C::c" "type = int"
414 setup_kfail "gdb/2092" "*-*-*"
415 gdb_test "ptype g_C.C::x" "type = int"
417 # Print all members of g_D.
419 # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb
420 # should detect these. There are no ways to PASS these tests
421 # because I don't know what the gdb message will be. -- chastain
424 set name "ptype g_D.A::a"
425 gdb_test_multiple "ptype g_D.A::a" $name {
426 -re "Attempt to take address of non-lval$nl$gdb_prompt $" {
427 kfail "gdb/2092" "$name"
429 -re "type = int$nl$gdb_prompt $" {
430 kfail "gdb/68" "ptype g_D.A::a"
434 set name "ptype g_D.A::x"
435 gdb_test_multiple "ptype g_D.A::x" $name {
436 -re "Attempt to take address of non-lval$nl$gdb_prompt $" {
437 kfail "gdb/2092" "$name"
439 -re "type = int$nl$gdb_prompt $" {
440 kfail "gdb/68" "ptype g_D.A::x"
444 setup_kfail "gdb/2092" "*-*-*"
445 gdb_test "ptype g_D.B::b" "type = int"
446 setup_kfail "gdb/2092" "*-*-*"
447 gdb_test "ptype g_D.B::x" "type = int"
448 setup_kfail "gdb/2092" "*-*-*"
449 gdb_test "ptype g_D.C::c" "type = int"
450 setup_kfail "gdb/2092" "*-*-*"
451 gdb_test "ptype g_D.C::x" "type = int"
452 setup_kfail "gdb/2092" "*-*-*"
453 gdb_test "ptype g_D.D::d" "type = int"
454 setup_kfail "gdb/2092" "*-*-*"
455 gdb_test "ptype g_D.D::x" "type = int"
457 # Print all members of g_E.
458 # g_E.A::a and g_E.A::x are ambiguous.
460 set name "ptype g_E.A::a"
461 gdb_test_multiple "ptype g_E.A::a" $name {
462 -re "Attempt to take address of non-lval$nl$gdb_prompt $" {
463 kfail "gdb/2092" "$name"
465 -re "type = int$nl$gdb_prompt $" {
466 kfail "gdb/68" "ptype g_E.A::a"
470 set name "ptype g_E.A::x"
471 gdb_test_multiple "ptype g_E.A::x" $name {
472 -re "Attempt to take address of non-lval$nl$gdb_prompt $" {
473 kfail "gdb/2092" "$name"
475 -re "type = int$nl$gdb_prompt $" {
476 kfail "gdb/68" "ptype g_E.A::x"
480 setup_kfail "gdb/2092" "*-*-*"
481 gdb_test "ptype g_E.B::b" "type = int"
482 setup_kfail "gdb/2092" "*-*-*"
483 gdb_test "ptype g_E.B::x" "type = int"
484 setup_kfail "gdb/2092" "*-*-*"
485 gdb_test "ptype g_E.C::c" "type = int"
486 setup_kfail "gdb/2092" "*-*-*"
487 gdb_test "ptype g_E.C::x" "type = int"
488 setup_kfail "gdb/2092" "*-*-*"
489 gdb_test "ptype g_E.D::d" "type = int"
490 setup_kfail "gdb/2092" "*-*-*"
491 gdb_test "ptype g_E.D::x" "type = int"
492 setup_kfail "gdb/2092" "*-*-*"
493 gdb_test "ptype g_E.E::e" "type = int"
494 setup_kfail "gdb/2092" "*-*-*"
495 gdb_test "ptype g_E.E::x" "type = int"
498 # Multiple inheritance, print complete classes.
500 proc test_print_mi_classes { } {
503 # Print all members of g_D.
504 gdb_test "print g_D" "$vhn = \{\<(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\}"
506 # Print all members of g_E.
507 gdb_test "print g_E" "$vhn = \{\<(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\}"
510 # Single inheritance, print anonymous unions.
511 # GDB versions prior to 4.14 entered an infinite loop when printing
512 # the type of a class containing an anonymous union, and they were also
513 # incapable of printing the member of an anonymous union.
514 # We test the printing of the member first, and perform the other tests
515 # only if the test succeeds, to avoid the infinite loop.
517 # GDB HEAD 2004-01-27 with hp aCC A.03.45 crashes on the first test.
518 # -- chastain 2004-01-27
520 proc test_print_anon_union {} {
526 gdb_test "print g_anon_union.a" "$vhn = 2" "print anonymous union member"
528 set name "print variable of type anonymous union"
529 gdb_test_multiple "print g_anon_union" $name {
530 -re "$vhn = \{one = 1, \{a = 2, b = 2\}\}$nl$gdb_prompt $" {
535 # The nested union prints as a multi-line field, but the class body
536 # scanner is inherently line-oriented. This is ugly but it works.
538 cp_test_ptype_class \
539 "ptype g_anon_union" "print type of anonymous union" \
540 "class" "class_with_anon_union" \
542 { field public "int one;" }
543 { field public "union \{" }
544 { field public "int a;" }
545 { field public "long int b;" }
546 { field public "\};" }
552 # Single virtual inheritance, print individual members.
554 proc test_print_svi_members { } {
557 # Print all members of g_vA.
558 gdb_test "print g_vA.vA::va" "$vhn = 1"
559 gdb_test "print g_vA.vA::vx" "$vhn = 2"
561 # Print members of g_vA using compact form.
562 gdb_test "print g_vA.va" "$vhn = 1"
563 gdb_test "print g_vA.vx" "$vhn = 2"
565 # Print all members of g_vB.
566 gdb_test "print g_vB.vA::va" "$vhn = 3"
567 gdb_test "print g_vB.vA::vx" "$vhn = 4"
568 gdb_test "print g_vB.vB::vb" "$vhn = 5"
569 gdb_test "print g_vB.vB::vx" "$vhn = 6"
571 # Print members of g_vB using compact form.
572 gdb_test "print g_vB.va" "$vhn = 3"
573 gdb_test "print g_vB.vb" "$vhn = 5"
574 gdb_test "print g_vB.vx" "$vhn = 6"
576 # Print all members of g_vC.
577 gdb_test "print g_vC.vA::va" "$vhn = 7"
578 gdb_test "print g_vC.vA::vx" "$vhn = 8"
579 gdb_test "print g_vC.vC::vc" "$vhn = 9"
580 gdb_test "print g_vC.vC::vx" "$vhn = 10"
582 # Print members of g_vC using compact form.
583 gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va"
584 gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc"
585 gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx"
588 # Single virtual inheritance, print complete classes.
590 proc test_print_svi_classes { } {
596 # Print all members of g_vA.
597 gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}"
599 # Print all members of g_vB.
600 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
601 set re_vbptr_3 "_vptr.vB"
603 set name "print g_vB"
604 gdb_test_multiple "print g_vB" $name {
605 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
606 # gcc 2.95.3 -gdwarf-2
607 # gcc 2.95.3 -gstabs+
610 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
611 # gcc 3.3.4 -gdwarf-2
612 # gcc 3.4.1 -gdwarf-2
614 # gcc HEAD 2004-07-31 -gdwarf-2
615 pass "$name (FIXME v3 vtbl ptr)"
617 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
621 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <typeinfo for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
622 # gcc HEAD 2004-07-31 -gstabs+
627 # Print all members of g_vC.
628 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
629 set re_vbptr_3 "_vptr.vC"
631 set name "print g_vC"
632 gdb_test_multiple "print g_vC" $name {
633 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
634 # gcc 2.95.3 -gdwarf-2
635 # gcc 2.95.3 -gstabs+
638 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
639 # gcc 3.3.4 -gdwarf-2
640 # gcc 3.4.1 -gdwarf-2
642 # gcc HEAD 2004-07-31 -gdwarf-2
643 pass "$name (FIXME v3 vtbl ptr)"
645 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
649 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <typeinfo for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
650 # gcc HEAD 2004-07-31 -gstabs+
656 # Multiple virtual inheritance, print individual members.
658 proc test_print_mvi_members { } {
661 # Print all members of g_vD.
662 gdb_test "print g_vD.vA::va" "$vhn = 19"
663 gdb_test "print g_vD.vA::vx" "$vhn = 20"
664 gdb_test "print g_vD.vB::vb" "$vhn = 21"
665 gdb_test "print g_vD.vB::vx" "$vhn = 22"
666 gdb_test "print g_vD.vC::vc" "$vhn = 23"
667 gdb_test "print g_vD.vC::vx" "$vhn = 24"
668 gdb_test "print g_vD.vD::vd" "$vhn = 25"
669 gdb_test "print g_vD.vD::vx" "$vhn = 26"
671 # Print all members of g_vE.
672 gdb_test "print g_vE.vA::va" "$vhn = 0"
673 gdb_test "print g_vE.vA::vx" "$vhn = 0"
674 gdb_test "print g_vE.vB::vb" "$vhn = 0"
675 gdb_test "print g_vE.vB::vx" "$vhn = 0"
676 gdb_test "print g_vE.vC::vc" "$vhn = 0"
677 gdb_test "print g_vE.vC::vx" "$vhn = 0"
678 gdb_test "print g_vE.vD::vd" "$vhn = 0"
679 gdb_test "print g_vE.vD::vx" "$vhn = 0"
680 gdb_test "print g_vE.vE::ve" "$vhn = 27"
681 gdb_test "print g_vE.vE::vx" "$vhn = 28"
684 # Multiple virtual inheritance, print complete classes.
686 proc test_print_mvi_classes { } {
693 # Virtual base pointers for everybody.
695 set re_vbptr_2_vA "(_vb.2vA|_vb.vA)"
696 set re_vbptr_2_vB "(_vb.2vB|_vb.vB)"
697 set re_vbptr_2_vC "(_vb.2vC|_vb.vC)"
698 set re_vbptr_2_vD "(_vb.2vD|_vb.vD)"
699 set re_vbptr_3_vA "_vptr.vA"
700 set re_vbptr_3_vB "_vptr.vB"
701 set re_vbptr_3_vC "_vptr.vC"
702 set re_vbptr_3_vD "_vptr.vD"
703 set re_vbptr_3_vE "_vptr.vE"
705 # Print all members of g_vD.
707 set name "print g_vD"
708 gdb_test_multiple "print g_vD" $name {
709 -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_2_vA = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_2_vA = $hex, vc = 23, vx = 24\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
710 # gcc 2.95.3 -gdwarf-2
711 # gcc 2.95.3 -gstabs+
714 -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = $hex, vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
715 # gcc 3.3.2 -gdwarf-2
716 # gcc HEAD 2004-01-21 -gdwarf-2
717 # gcc HEAD 2004-01-21 -gstabs+
718 pass "$name (FIXME v3 vtbl ptr)"
720 -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = $hex <VTT for vD>, vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
726 # Print all members of g_vE.
728 set name "print g_vE"
729 gdb_test_multiple "print g_vE" $name {
730 -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_2_vA = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_2_vA = $hex, vc = 0, vx = 0\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 0, vx = 0\}, $re_vbptr_2_vD = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
731 # gcc 2.95.3 -gdwarf-2
732 # gcc 2.95.3 -gstabs+
735 -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
736 # gcc 3.3.4 -gdwarf-2
738 # gcc 3.4.1 -gdwarf-2
740 # gcc HEAD 2004-07-31 -gdwarf-2
741 pass "$name (FIXME v3 vtbl ptr)"
743 -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex <VTT for vD>, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
744 # gcc 3.2.7-rh -gstabs+
747 -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex <typeinfo for vE>, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
748 # gcc HEAD 2004-07-31 -gstabs+
765 # Start with a fresh gdb.
769 gdb_reinitialize_dir $srcdir/$subdir
772 gdb_test "set language c++" ""
773 gdb_test "set width 0" ""
775 if { ![runto_main] } then {
776 perror "couldn't run to main"
785 if { ![runto 'inheritance2'] } then {
786 perror "couldn't run to inheritance2"
790 test_print_si_members
791 test_print_si_classes
792 test_print_mi_members
793 test_print_mi_member_types
794 test_print_mi_classes
795 test_print_anon_union
797 if { ![runto 'inheritance4'] } {
798 perror "couldn't run to inheritance4"
802 test_print_svi_members
803 test_print_svi_classes
804 test_print_mvi_members
805 test_print_mvi_classes