Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.cp / inherit.exp
blobe90c0c68e1a8593b00a3b87d6e9984c5a0c33b23
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.
8 #
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)
21 set ws "\[\r\n\t \]+"
22 set nl "\[\r\n\]+"
23 set vhn "\\$\[0-9\]+"
25 if $tracelevel then {
26 strace $tracelevel
29 if { [skip_cplus_tests] } { continue }
31 load_lib "cp-support.exp"
33 set testfile "inherit"
34 set srcfile misc.cc
35 set binfile ${objdir}/${subdir}/${testfile}
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
38 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
41 # Single inheritance, print type definitions.
43 proc test_ptype_si { } {
44 global gdb_prompt
45 global ws
46 global nl
48 # A simple class.
50 cp_test_ptype_class \
51 "ptype A" "ptype A (FIXME)" "class" "A" \
53 { field public "int a;" }
54 { field public "int x;" }
56 cp_test_ptype_class "ptype class A" "ptype class A (FIXME)" "class" "A" ibid
57 cp_test_ptype_class "ptype g_A" "ptype g_A (FIXME)" "class" "A" ibid
59 # A derived class.
61 cp_test_ptype_class \
62 "ptype B" "" "class" "B" \
64 { base "public A" }
65 { field public "int b;" }
66 { field public "int x;" }
68 cp_test_ptype_class "ptype class B" "" "class" "B" ibid
69 cp_test_ptype_class "ptype g_B" "" "class" "B" ibid
71 # Another derived class.
73 cp_test_ptype_class \
74 "ptype C" "" "class" "C" \
76 { base "public A" }
77 { field public "int c;" }
78 { field public "int x;" }
80 cp_test_ptype_class "ptype class C" "" "class" "C" ibid
81 cp_test_ptype_class "ptype g_C" "" "class" "C" ibid
83 # A structure with no tag.
84 # TODO: move this mess into a separate file, and re-specify
85 # which results are PASS, KFAIL, XFAIL, and FAIL.
87 set re_tag "tagless_struct"
88 set XX_tag "\\._1"
89 set re_class "(class $re_tag \{${ws}public:|class \{${ws}public:|struct $re_tag \{|struct \{)"
90 set XX_class "(class $XX_tag \{${ws}public:|struct $XX_tag \{)"
91 set re_fields "int one;${ws}int two;"
92 set re_synth_gcc_23 "$re_tag & operator=\\($re_tag const ?&\\);${ws}$re_tag\\($re_tag const ?&\\);${ws}$re_tag\\((void|)\\);"
93 set XX_synth_gcc_23 "($re_tag|$XX_tag) & operator=\\($XX_tag const ?&\\);${ws}$XX_tag\\($XX_tag const ?&\\);${ws}$XX_tag\\((void|)\\);"
95 set name "ptype tagless struct"
96 gdb_test_multiple "ptype tagless_struct" $name {
97 -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
98 # gcc 2.95.3 -gdwarf-2
99 pass "$name"
101 -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
102 # gcc 2.95.3 -gstabs+
103 pass "$name"
105 -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
106 # gcc 3.3.4 -gdwarf-2
107 # gcc 3.4.1 -gdwarf-2
108 # gcc HEAD 2004-07-31 -gdwarf-2
109 # gcc HEAD 2004-07-31 -gstabs+
110 pass "$name"
112 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
113 # gcc 3.3.4 -gstabs+
114 # gcc 3.4.1 -gstabs+
115 pass "$name"
119 set name "ptype variable of type tagless struct"
120 gdb_test_multiple "ptype v_tagless" $name {
121 -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
122 # gcc 2.95.3 -gdwarf-2
123 pass "$name"
125 -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
126 # gcc 2.95.3 -gstabs+
127 pass "$name"
129 -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
130 # gcc 3.3.4 -gdwarf-2
131 # gcc 3.4.1 -gdwarf-2
132 # gcc HEAD 2004-07-31 -gdwarf-2
133 # gcc HEAD 2004-07-31 -gstabs+
134 pass "$name"
136 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
137 # gcc 3.3.4 -gstabs+
138 # gcc 3.4.1 -gstabs+
139 pass "$name"
144 # Multiple inheritance, print type definitions.
146 proc test_ptype_mi { } {
148 # A class with two bases.
150 cp_test_ptype_class \
151 "ptype D" "" "class" "D" \
153 { base "public B" }
154 { base "public C" }
155 { field public "int d;" }
156 { field public "int x;" }
158 cp_test_ptype_class "ptype class D" "" "class" "D" ibid
159 cp_test_ptype_class "ptype g_D" "" "class" "D" ibid
161 # A class derived from the previous class.
163 cp_test_ptype_class \
164 "ptype E" "" "class" "E" \
166 { base "public D" }
167 { field public "int e;" }
168 { field public "int x;" }
170 cp_test_ptype_class "ptype class E" "" "class" "E" ibid
171 cp_test_ptype_class "ptype g_E" "" "class" "E" ibid
174 # Single virtual inheritance, print type definitions.
176 proc test_ptype_vi { } {
178 # class vA
180 cp_test_ptype_class \
181 "ptype vA" "" "class" "vA" \
183 { field public "int va;" }
184 { field public "int vx;" }
186 cp_test_ptype_class "ptype class vA" "" "class" "vA" ibid
187 cp_test_ptype_class "ptype g_vA" "" "class" "vA" ibid
189 # class vB
191 cp_test_ptype_class \
192 "ptype vB" "" "class" "vB" \
194 { base "public virtual vA" }
195 { vbase "vA" }
196 { field public "int vb;" }
197 { field public "int vx;" }
199 cp_test_ptype_class "ptype class vB" "" "class" "vB" ibid
200 cp_test_ptype_class "ptype g_vB" "" "class" "vB" ibid
202 # class vC
204 cp_test_ptype_class \
205 "ptype vC" "" "class" "vC" \
207 { base "public virtual vA" }
208 { vbase "vA" }
209 { field public "int vc;" }
210 { field public "int vx;" }
212 cp_test_ptype_class "ptype class vC" "" "class" "vC" ibid
213 cp_test_ptype_class "ptype g_vC" "" "class" "vC" ibid
217 # Multiple virtual inheritance, print type definitions.
219 proc test_ptype_mvi { } {
221 # class vD
223 cp_test_ptype_class \
224 "ptype vD" "" "class" "vD" \
226 { base "public virtual vB" }
227 { base "public virtual vC" }
228 { vbase "vC" }
229 { vbase "vB" }
230 { field public "int vd;" }
231 { field public "int vx;" }
233 cp_test_ptype_class "ptype class vD" "" "class" "vD" ibid
234 cp_test_ptype_class "ptype g_vD" "" "class" "vD" ibid
236 # class vE
238 cp_test_ptype_class \
239 "ptype vE" "" "class" "vE" \
241 { base "public virtual vD" }
242 { vbase "vD" }
243 { field public "int ve;" }
244 { field public "int vx;" }
246 cp_test_ptype_class "ptype class vE" "" "class" "vE" ibid
247 cp_test_ptype_class "ptype g_vE" "" "class" "vE" ibid
251 # Single inheritance, print individual members.
253 proc test_print_si_members { } {
254 global vhn
256 # Print all members of g_A using fully qualified form.
257 gdb_test "print g_A.A::a" "$vhn = 1"
258 gdb_test "print g_A.A::x" "$vhn = 2"
260 # Print members of g_A using nonambiguous compact form.
261 gdb_test "print g_A.a" "$vhn = 1"
262 gdb_test "print g_A.x" "$vhn = 2"
264 # Print all members of g_B using fully qualified form.
265 gdb_test "print g_B.A::a" "$vhn = 3"
266 gdb_test "print g_B.A::x" "$vhn = 4"
267 gdb_test "print g_B.B::b" "$vhn = 5"
268 gdb_test "print g_B.B::x" "$vhn = 6"
270 # Print members of g_B using nonambiguous compact form.
271 gdb_test "print g_B.a" "$vhn = 3"
272 gdb_test "print g_B.b" "$vhn = 5"
273 gdb_test "print g_B.x" "$vhn = 6"
275 # Print all members of g_C using fully qualified form.
276 gdb_test "print g_C.A::a" "$vhn = 7"
277 gdb_test "print g_C.A::x" "$vhn = 8"
278 gdb_test "print g_C.C::c" "$vhn = 9"
279 gdb_test "print g_C.C::x" "$vhn = 10"
281 # Print members of g_C using nonambiguous compact form.
282 gdb_test "print g_C.a" "$vhn = 7"
283 gdb_test "print g_C.c" "$vhn = 9"
284 gdb_test "print g_C.x" "$vhn = 10"
287 # Single inheritance, print complete classes.
289 proc test_print_si_classes { } {
290 global vhn
292 # Print all members of g_A, g_B, g_C.
293 gdb_test "print g_A" "$vhn = \{a = 1, x = 2\}"
294 gdb_test "print g_B" "$vhn = \{<(class A|A)> = \{a = 3, x = 4\}, b = 5, x = 6\}"
295 gdb_test "print g_C" "$vhn = \{<(class A|A)> = \{a = 7, x = 8\}, c = 9, x = 10\}"
298 # Multiple inheritance, print individual members.
300 proc test_print_mi_members {} {
301 global gdb_prompt
302 global nl
303 global vhn
305 # Print all members of g_A.
306 gdb_test "print g_A.A::a" "$vhn = 1"
307 gdb_test "print g_A.A::x" "$vhn = 2"
309 # Print all members of g_B.
310 gdb_test "print g_B.A::a" "$vhn = 3"
311 gdb_test "print g_B.A::x" "$vhn = 4"
312 gdb_test "print g_B.B::b" "$vhn = 5"
313 gdb_test "print g_B.B::x" "$vhn = 6"
315 # Print all members of g_C.
316 gdb_test "print g_C.A::a" "$vhn = 7"
317 gdb_test "print g_C.A::x" "$vhn = 8"
318 gdb_test "print g_C.C::c" "$vhn = 9"
319 gdb_test "print g_C.C::x" "$vhn = 10"
321 # Print all members of g_D.
323 # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb
324 # should detect these. There are no ways to PASS these tests
325 # because I don't know what the gdb message will be. -- chastain
326 # 2004-01-27.
328 set name "print g_D.A::a"
329 gdb_test_multiple "print g_D.A::a" $name {
330 -re "$vhn = (15|11)$nl$gdb_prompt $" {
331 kfail "gdb/68" "print g_D.A::a"
335 set name "print g_D.A::x"
336 gdb_test_multiple "print g_D.A::x" $name {
337 -re "$vhn = (16|12)$nl$gdb_prompt $" {
338 kfail "gdb/68" "print g_D.A::x"
342 gdb_test "print g_D.B::b" "$vhn = 13"
343 gdb_test "print g_D.B::x" "$vhn = 14"
344 gdb_test "print g_D.C::c" "$vhn = 17"
345 gdb_test "print g_D.C::x" "$vhn = 18"
346 gdb_test "print g_D.D::d" "$vhn = 19"
347 gdb_test "print g_D.D::x" "$vhn = 20"
349 # Print all members of g_E.
350 # g_E.A::a and g_E.A::x are ambiguous.
352 set name "print g_E.A::a"
353 gdb_test_multiple "print g_E.A::a" $name {
354 -re "$vhn = (21|25)$nl$gdb_prompt $" {
355 kfail "gdb/68" "print g_E.A::a"
359 set name "print g_E.A::x"
360 gdb_test_multiple "print g_E.A::x" $name {
361 -re "$vhn = (26|22)$nl$gdb_prompt $" {
362 kfail "gdb/68" "print g_E.A::x"
366 gdb_test "print g_E.B::b" "$vhn = 23"
367 gdb_test "print g_E.B::x" "$vhn = 24"
368 gdb_test "print g_E.C::c" "$vhn = 27"
369 gdb_test "print g_E.C::x" "$vhn = 28"
370 gdb_test "print g_E.D::d" "$vhn = 29"
371 gdb_test "print g_E.D::x" "$vhn = 30"
372 gdb_test "print g_E.E::e" "$vhn = 31"
373 gdb_test "print g_E.E::x" "$vhn = 32"
376 # Multiple inheritance, print individual member types.
378 proc test_print_mi_member_types {} {
379 global gdb_prompt
380 global nl
381 global vhn
383 # Print the types of some members of g_D without qualifying them.
384 gdb_test "ptype g_D.b" "type = int"
385 gdb_test "ptype g_D.c" "type = int"
386 gdb_test "ptype g_D.d" "type = int"
388 # Print the types of qualified members; none of these tests pass today.
390 # Print all members of g_A.
391 setup_kfail "gdb/2092" "*-*-*"
392 gdb_test "ptype g_A.A::a" "type = int"
393 setup_kfail "gdb/2092" "*-*-*"
394 gdb_test "ptype g_A.A::x" "type = int"
396 # Print all members of g_B.
397 setup_kfail "gdb/2092" "*-*-*"
398 gdb_test "ptype g_B.A::a" "type = int"
399 setup_kfail "gdb/2092" "*-*-*"
400 gdb_test "ptype g_B.A::x" "type = int"
401 setup_kfail "gdb/2092" "*-*-*"
402 gdb_test "ptype g_B.B::b" "type = int"
403 setup_kfail "gdb/2092" "*-*-*"
404 gdb_test "ptype g_B.B::x" "type = int"
406 # Print all members of g_C.
407 setup_kfail "gdb/2092" "*-*-*"
408 gdb_test "ptype g_C.A::a" "type = int"
409 setup_kfail "gdb/2092" "*-*-*"
410 gdb_test "ptype g_C.A::x" "type = int"
411 setup_kfail "gdb/2092" "*-*-*"
412 gdb_test "ptype g_C.C::c" "type = int"
413 setup_kfail "gdb/2092" "*-*-*"
414 gdb_test "ptype g_C.C::x" "type = int"
416 # Print all members of g_D.
418 # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb
419 # should detect these. There are no ways to PASS these tests
420 # because I don't know what the gdb message will be. -- chastain
421 # 2004-01-27.
423 set name "ptype g_D.A::a"
424 gdb_test_multiple "ptype g_D.A::a" $name {
425 -re "Attempt to take address of non-lval$nl$gdb_prompt $" {
426 kfail "gdb/2092" "$name"
428 -re "type = int$nl$gdb_prompt $" {
429 kfail "gdb/68" "ptype g_D.A::a"
433 set name "ptype g_D.A::x"
434 gdb_test_multiple "ptype g_D.A::x" $name {
435 -re "Attempt to take address of non-lval$nl$gdb_prompt $" {
436 kfail "gdb/2092" "$name"
438 -re "type = int$nl$gdb_prompt $" {
439 kfail "gdb/68" "ptype g_D.A::x"
443 setup_kfail "gdb/2092" "*-*-*"
444 gdb_test "ptype g_D.B::b" "type = int"
445 setup_kfail "gdb/2092" "*-*-*"
446 gdb_test "ptype g_D.B::x" "type = int"
447 setup_kfail "gdb/2092" "*-*-*"
448 gdb_test "ptype g_D.C::c" "type = int"
449 setup_kfail "gdb/2092" "*-*-*"
450 gdb_test "ptype g_D.C::x" "type = int"
451 setup_kfail "gdb/2092" "*-*-*"
452 gdb_test "ptype g_D.D::d" "type = int"
453 setup_kfail "gdb/2092" "*-*-*"
454 gdb_test "ptype g_D.D::x" "type = int"
456 # Print all members of g_E.
457 # g_E.A::a and g_E.A::x are ambiguous.
459 set name "ptype g_E.A::a"
460 gdb_test_multiple "ptype g_E.A::a" $name {
461 -re "Attempt to take address of non-lval$nl$gdb_prompt $" {
462 kfail "gdb/2092" "$name"
464 -re "type = int$nl$gdb_prompt $" {
465 kfail "gdb/68" "ptype g_E.A::a"
469 set name "ptype g_E.A::x"
470 gdb_test_multiple "ptype g_E.A::x" $name {
471 -re "Attempt to take address of non-lval$nl$gdb_prompt $" {
472 kfail "gdb/2092" "$name"
474 -re "type = int$nl$gdb_prompt $" {
475 kfail "gdb/68" "ptype g_E.A::x"
479 setup_kfail "gdb/2092" "*-*-*"
480 gdb_test "ptype g_E.B::b" "type = int"
481 setup_kfail "gdb/2092" "*-*-*"
482 gdb_test "ptype g_E.B::x" "type = int"
483 setup_kfail "gdb/2092" "*-*-*"
484 gdb_test "ptype g_E.C::c" "type = int"
485 setup_kfail "gdb/2092" "*-*-*"
486 gdb_test "ptype g_E.C::x" "type = int"
487 setup_kfail "gdb/2092" "*-*-*"
488 gdb_test "ptype g_E.D::d" "type = int"
489 setup_kfail "gdb/2092" "*-*-*"
490 gdb_test "ptype g_E.D::x" "type = int"
491 setup_kfail "gdb/2092" "*-*-*"
492 gdb_test "ptype g_E.E::e" "type = int"
493 setup_kfail "gdb/2092" "*-*-*"
494 gdb_test "ptype g_E.E::x" "type = int"
497 # Multiple inheritance, print complete classes.
499 proc test_print_mi_classes { } {
500 global vhn
502 # Print all members of g_D.
503 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\}"
505 # Print all members of g_E.
506 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\}"
509 # Single inheritance, print anonymous unions.
510 # GDB versions prior to 4.14 entered an infinite loop when printing
511 # the type of a class containing an anonymous union, and they were also
512 # incapable of printing the member of an anonymous union.
513 # We test the printing of the member first, and perform the other tests
514 # only if the test succeeds, to avoid the infinite loop.
516 # GDB HEAD 2004-01-27 with hp aCC A.03.45 crashes on the first test.
517 # -- chastain 2004-01-27
519 proc test_print_anon_union {} {
520 global gdb_prompt
521 global ws
522 global nl
523 global vhn
525 gdb_test "print g_anon_union.a" "$vhn = 2" "print anonymous union member"
527 set name "print variable of type anonymous union"
528 gdb_test_multiple "print g_anon_union" $name {
529 -re "$vhn = \{one = 1, \{a = 2, b = 2\}\}$nl$gdb_prompt $" {
530 pass $name
534 # The nested union prints as a multi-line field, but the class body
535 # scanner is inherently line-oriented. This is ugly but it works.
537 cp_test_ptype_class \
538 "ptype g_anon_union" "print type of anonymous union" \
539 "class" "class_with_anon_union" \
541 { field public "int one;" }
542 { field public "union \{" }
543 { field public "int a;" }
544 { field public "long int b;" }
545 { field public "\};" }
551 # Single virtual inheritance, print individual members.
553 proc test_print_svi_members { } {
554 global vhn
556 # Print all members of g_vA.
557 gdb_test "print g_vA.vA::va" "$vhn = 1"
558 gdb_test "print g_vA.vA::vx" "$vhn = 2"
560 # Print members of g_vA using compact form.
561 gdb_test "print g_vA.va" "$vhn = 1"
562 gdb_test "print g_vA.vx" "$vhn = 2"
564 # Print all members of g_vB.
565 gdb_test "print g_vB.vA::va" "$vhn = 3"
566 gdb_test "print g_vB.vA::vx" "$vhn = 4"
567 gdb_test "print g_vB.vB::vb" "$vhn = 5"
568 gdb_test "print g_vB.vB::vx" "$vhn = 6"
570 # Print members of g_vB using compact form.
571 gdb_test "print g_vB.va" "$vhn = 3"
572 gdb_test "print g_vB.vb" "$vhn = 5"
573 gdb_test "print g_vB.vx" "$vhn = 6"
575 # Print all members of g_vC.
576 gdb_test "print g_vC.vA::va" "$vhn = 7"
577 gdb_test "print g_vC.vA::vx" "$vhn = 8"
578 gdb_test "print g_vC.vC::vc" "$vhn = 9"
579 gdb_test "print g_vC.vC::vx" "$vhn = 10"
581 # Print members of g_vC using compact form.
582 gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va"
583 gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc"
584 gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx"
587 # Single virtual inheritance, print complete classes.
589 proc test_print_svi_classes { } {
590 global gdb_prompt
591 global hex
592 global nl
593 global vhn
595 # Print all members of g_vA.
596 gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}"
598 # Print all members of g_vB.
599 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
600 set re_vbptr_3 "_vptr.vB"
602 set name "print g_vB"
603 gdb_test_multiple "print g_vB" $name {
604 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
605 # gcc 2.95.3 -gdwarf-2
606 # gcc 2.95.3 -gstabs+
607 pass $name
609 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
610 # gcc 3.3.4 -gdwarf-2
611 # gcc 3.4.1 -gdwarf-2
612 # gcc 3.4.1 -gstabs+
613 # gcc HEAD 2004-07-31 -gdwarf-2
614 pass "$name (FIXME v3 vtbl ptr)"
616 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
617 # gcc 3.3.4 -gstabs+
618 pass $name
620 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <typeinfo for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
621 # gcc HEAD 2004-07-31 -gstabs+
622 pass $name
626 # Print all members of g_vC.
627 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
628 set re_vbptr_3 "_vptr.vC"
630 set name "print g_vC"
631 gdb_test_multiple "print g_vC" $name {
632 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
633 # gcc 2.95.3 -gdwarf-2
634 # gcc 2.95.3 -gstabs+
635 pass $name
637 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
638 # gcc 3.3.4 -gdwarf-2
639 # gcc 3.4.1 -gdwarf-2
640 # gcc 3.4.1 -gstabs+
641 # gcc HEAD 2004-07-31 -gdwarf-2
642 pass "$name (FIXME v3 vtbl ptr)"
644 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
645 # gcc 3.3.4 -gstabs+
646 pass $name
648 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <typeinfo for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
649 # gcc HEAD 2004-07-31 -gstabs+
650 pass $name
655 # Multiple virtual inheritance, print individual members.
657 proc test_print_mvi_members { } {
658 global vhn
660 # Print all members of g_vD.
661 gdb_test "print g_vD.vA::va" "$vhn = 19"
662 gdb_test "print g_vD.vA::vx" "$vhn = 20"
663 gdb_test "print g_vD.vB::vb" "$vhn = 21"
664 gdb_test "print g_vD.vB::vx" "$vhn = 22"
665 gdb_test "print g_vD.vC::vc" "$vhn = 23"
666 gdb_test "print g_vD.vC::vx" "$vhn = 24"
667 gdb_test "print g_vD.vD::vd" "$vhn = 25"
668 gdb_test "print g_vD.vD::vx" "$vhn = 26"
670 # Print all members of g_vE.
671 gdb_test "print g_vE.vA::va" "$vhn = 0"
672 gdb_test "print g_vE.vA::vx" "$vhn = 0"
673 gdb_test "print g_vE.vB::vb" "$vhn = 0"
674 gdb_test "print g_vE.vB::vx" "$vhn = 0"
675 gdb_test "print g_vE.vC::vc" "$vhn = 0"
676 gdb_test "print g_vE.vC::vx" "$vhn = 0"
677 gdb_test "print g_vE.vD::vd" "$vhn = 0"
678 gdb_test "print g_vE.vD::vx" "$vhn = 0"
679 gdb_test "print g_vE.vE::ve" "$vhn = 27"
680 gdb_test "print g_vE.vE::vx" "$vhn = 28"
683 # Multiple virtual inheritance, print complete classes.
685 proc test_print_mvi_classes { } {
686 global gdb_prompt
687 global hex
688 global ws
689 global nl
690 global vhn
692 # Virtual base pointers for everybody.
694 set re_vbptr_2_vA "(_vb.2vA|_vb.vA)"
695 set re_vbptr_2_vB "(_vb.2vB|_vb.vB)"
696 set re_vbptr_2_vC "(_vb.2vC|_vb.vC)"
697 set re_vbptr_2_vD "(_vb.2vD|_vb.vD)"
698 set re_vbptr_3_vA "_vptr.vA"
699 set re_vbptr_3_vB "_vptr.vB"
700 set re_vbptr_3_vC "_vptr.vC"
701 set re_vbptr_3_vD "_vptr.vD"
702 set re_vbptr_3_vE "_vptr.vE"
704 # Print all members of g_vD.
706 set name "print g_vD"
707 gdb_test_multiple "print g_vD" $name {
708 -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 $" {
709 # gcc 2.95.3 -gdwarf-2
710 # gcc 2.95.3 -gstabs+
711 pass $name
713 -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 $" {
714 # gcc 3.3.2 -gdwarf-2
715 # gcc HEAD 2004-01-21 -gdwarf-2
716 # gcc HEAD 2004-01-21 -gstabs+
717 pass "$name (FIXME v3 vtbl ptr)"
719 -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 $" {
720 # gcc 3.3.2 -gstabs+
721 pass "$name"
725 # Print all members of g_vE.
727 set name "print g_vE"
728 gdb_test_multiple "print g_vE" $name {
729 -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 $" {
730 # gcc 2.95.3 -gdwarf-2
731 # gcc 2.95.3 -gstabs+
732 pass $name
734 -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 $" {
735 # gcc 3.3.4 -gdwarf-2
736 # gcc 3.3.4 -gstabs+
737 # gcc 3.4.1 -gdwarf-2
738 # gcc 3.4.1 -gstabs+
739 # gcc HEAD 2004-07-31 -gdwarf-2
740 pass "$name (FIXME v3 vtbl ptr)"
742 -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 $" {
743 # gcc 3.2.7-rh -gstabs+
744 pass $name
746 -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 $" {
747 # gcc HEAD 2004-07-31 -gstabs+
748 pass $name
753 proc do_tests { } {
754 global prms_id
755 global bug_id
756 global subdir
757 global objdir
758 global srcdir
759 global binfile
761 set prms_id 0
762 set bug_id 0
764 # Start with a fresh gdb.
766 gdb_exit
767 gdb_start
768 gdb_reinitialize_dir $srcdir/$subdir
769 gdb_load $binfile
771 gdb_test "set language c++" ""
772 gdb_test "set width 0" ""
774 if { ![runto_main] } then {
775 perror "couldn't run to main"
776 return
779 test_ptype_si
780 test_ptype_mi
781 test_ptype_vi
782 test_ptype_mvi
784 if { ![runto 'inheritance2'] } then {
785 perror "couldn't run to inheritance2"
786 return
789 test_print_si_members
790 test_print_si_classes
791 test_print_mi_members
792 test_print_mi_member_types
793 test_print_mi_classes
794 test_print_anon_union
796 if { ![runto 'inheritance4'] } {
797 perror "couldn't run to inheritance4"
798 return
801 test_print_svi_members
802 test_print_svi_classes
803 test_print_mvi_members
804 test_print_mvi_classes
807 do_tests