]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.cp/inherit.exp
* NEWS: Mention pointer to member improvements.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / inherit.exp
1 # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
2 # 2004, 2006 Free Software Foundation, Inc.
3
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.
13 #
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.
17
18 # This file was written by Fred Fish. (fnf@cygnus.com)
19 # And rewritten by Michael Chastain. (mec.gnu@mindspring.com)
20
21 set ws "\[\r\n\t \]+"
22 set nl "\[\r\n\]+"
23 set vhn "\\$\[0-9\]+"
24
25 if $tracelevel then {
26 strace $tracelevel
27 }
28
29 if { [skip_cplus_tests] } { continue }
30
31 load_lib "cp-support.exp"
32
33 set testfile "inherit"
34 set srcfile misc.cc
35 set binfile ${objdir}/${subdir}/${testfile}
36
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
38 untested inherit.exp
39 return -1
40 }
41
42 # Single inheritance, print type definitions.
43
44 proc test_ptype_si { } {
45 global gdb_prompt
46 global ws
47 global nl
48
49 # A simple class.
50
51 cp_test_ptype_class \
52 "ptype A" "ptype A (FIXME)" "class" "A" \
53 {
54 { field public "int a;" }
55 { field public "int x;" }
56 }
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
59
60 # A derived class.
61
62 cp_test_ptype_class \
63 "ptype B" "" "class" "B" \
64 {
65 { base "public A" }
66 { field public "int b;" }
67 { field public "int x;" }
68 }
69 cp_test_ptype_class "ptype class B" "" "class" "B" ibid
70 cp_test_ptype_class "ptype g_B" "" "class" "B" ibid
71
72 # Another derived class.
73
74 cp_test_ptype_class \
75 "ptype C" "" "class" "C" \
76 {
77 { base "public A" }
78 { field public "int c;" }
79 { field public "int x;" }
80 }
81 cp_test_ptype_class "ptype class C" "" "class" "C" ibid
82 cp_test_ptype_class "ptype g_C" "" "class" "C" ibid
83
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.
87
88 set re_tag "tagless_struct"
89 set XX_tag "\\._1"
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|)\\);"
95
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
100 pass "$name"
101 }
102 -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
103 # gcc 2.95.3 -gstabs+
104 pass "$name"
105 }
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+
111 pass "$name"
112 }
113 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
114 # gcc 3.3.4 -gstabs+
115 # gcc 3.4.1 -gstabs+
116 pass "$name"
117 }
118 }
119
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
124 pass "$name"
125 }
126 -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
127 # gcc 2.95.3 -gstabs+
128 pass "$name"
129 }
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+
135 pass "$name"
136 }
137 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
138 # gcc 3.3.4 -gstabs+
139 # gcc 3.4.1 -gstabs+
140 pass "$name"
141 }
142 }
143 }
144
145 # Multiple inheritance, print type definitions.
146
147 proc test_ptype_mi { } {
148
149 # A class with two bases.
150
151 cp_test_ptype_class \
152 "ptype D" "" "class" "D" \
153 {
154 { base "public B" }
155 { base "public C" }
156 { field public "int d;" }
157 { field public "int x;" }
158 }
159 cp_test_ptype_class "ptype class D" "" "class" "D" ibid
160 cp_test_ptype_class "ptype g_D" "" "class" "D" ibid
161
162 # A class derived from the previous class.
163
164 cp_test_ptype_class \
165 "ptype E" "" "class" "E" \
166 {
167 { base "public D" }
168 { field public "int e;" }
169 { field public "int x;" }
170 }
171 cp_test_ptype_class "ptype class E" "" "class" "E" ibid
172 cp_test_ptype_class "ptype g_E" "" "class" "E" ibid
173 }
174
175 # Single virtual inheritance, print type definitions.
176
177 proc test_ptype_vi { } {
178
179 # class vA
180
181 cp_test_ptype_class \
182 "ptype vA" "" "class" "vA" \
183 {
184 { field public "int va;" }
185 { field public "int vx;" }
186 }
187 cp_test_ptype_class "ptype class vA" "" "class" "vA" ibid
188 cp_test_ptype_class "ptype g_vA" "" "class" "vA" ibid
189
190 # class vB
191
192 cp_test_ptype_class \
193 "ptype vB" "" "class" "vB" \
194 {
195 { base "public virtual vA" }
196 { vbase "vA" }
197 { field public "int vb;" }
198 { field public "int vx;" }
199 }
200 cp_test_ptype_class "ptype class vB" "" "class" "vB" ibid
201 cp_test_ptype_class "ptype g_vB" "" "class" "vB" ibid
202
203 # class vC
204
205 cp_test_ptype_class \
206 "ptype vC" "" "class" "vC" \
207 {
208 { base "public virtual vA" }
209 { vbase "vA" }
210 { field public "int vc;" }
211 { field public "int vx;" }
212 }
213 cp_test_ptype_class "ptype class vC" "" "class" "vC" ibid
214 cp_test_ptype_class "ptype g_vC" "" "class" "vC" ibid
215
216 }
217
218 # Multiple virtual inheritance, print type definitions.
219
220 proc test_ptype_mvi { } {
221
222 # class vD
223
224 cp_test_ptype_class \
225 "ptype vD" "" "class" "vD" \
226 {
227 { base "public virtual vB" }
228 { base "public virtual vC" }
229 { vbase "vC" }
230 { vbase "vB" }
231 { field public "int vd;" }
232 { field public "int vx;" }
233 }
234 cp_test_ptype_class "ptype class vD" "" "class" "vD" ibid
235 cp_test_ptype_class "ptype g_vD" "" "class" "vD" ibid
236
237 # class vE
238
239 cp_test_ptype_class \
240 "ptype vE" "" "class" "vE" \
241 {
242 { base "public virtual vD" }
243 { vbase "vD" }
244 { field public "int ve;" }
245 { field public "int vx;" }
246 }
247 cp_test_ptype_class "ptype class vE" "" "class" "vE" ibid
248 cp_test_ptype_class "ptype g_vE" "" "class" "vE" ibid
249
250 }
251
252 # Single inheritance, print individual members.
253
254 proc test_print_si_members { } {
255 global vhn
256
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"
260
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"
264
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"
270
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"
275
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"
281
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"
286 }
287
288 # Single inheritance, print complete classes.
289
290 proc test_print_si_classes { } {
291 global vhn
292
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\}"
297 }
298
299 # Multiple inheritance, print individual members.
300
301 proc test_print_mi_members {} {
302 global gdb_prompt
303 global nl
304 global vhn
305
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"
309
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"
315
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"
321
322 # Print all members of g_D.
323 #
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
327 # 2004-01-27.
328
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"
333 }
334 }
335
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"
340 }
341 }
342
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"
349
350 # Print all members of g_E.
351 # g_E.A::a and g_E.A::x are ambiguous.
352
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"
357 }
358 }
359
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"
364 }
365 }
366
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"
375 }
376
377 # Multiple inheritance, print individual member types.
378
379 proc test_print_mi_member_types {} {
380 global gdb_prompt
381 global nl
382 global vhn
383
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"
388
389 # Print the types of qualified members; none of these tests pass today.
390
391 # Print all members of g_A.
392 gdb_test "ptype g_A.A::a" "type = int"
393 gdb_test "ptype g_A.A::x" "type = int"
394
395 # Print all members of g_B.
396 gdb_test "ptype g_B.A::a" "type = int"
397 gdb_test "ptype g_B.A::x" "type = int"
398 gdb_test "ptype g_B.B::b" "type = int"
399 gdb_test "ptype g_B.B::x" "type = int"
400
401 # Print all members of g_C.
402 gdb_test "ptype g_C.A::a" "type = int"
403 gdb_test "ptype g_C.A::x" "type = int"
404 gdb_test "ptype g_C.C::c" "type = int"
405 gdb_test "ptype g_C.C::x" "type = int"
406
407 # Print all members of g_D.
408 #
409 # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb
410 # should detect these. There are no ways to PASS these tests
411 # because I don't know what the gdb message will be. -- chastain
412 # 2004-01-27.
413
414 set name "ptype g_D.A::a"
415 gdb_test_multiple "ptype g_D.A::a" $name {
416 -re "type = int$nl$gdb_prompt $" {
417 kfail "gdb/68" "ptype g_D.A::a"
418 }
419 }
420
421 set name "ptype g_D.A::x"
422 gdb_test_multiple "ptype g_D.A::x" $name {
423 -re "type = int$nl$gdb_prompt $" {
424 kfail "gdb/68" "ptype g_D.A::x"
425 }
426 }
427
428 gdb_test "ptype g_D.B::b" "type = int"
429 gdb_test "ptype g_D.B::x" "type = int"
430 gdb_test "ptype g_D.C::c" "type = int"
431 gdb_test "ptype g_D.C::x" "type = int"
432 gdb_test "ptype g_D.D::d" "type = int"
433 gdb_test "ptype g_D.D::x" "type = int"
434
435 # Print all members of g_E.
436 # g_E.A::a and g_E.A::x are ambiguous.
437
438 set name "ptype g_E.A::a"
439 gdb_test_multiple "ptype g_E.A::a" $name {
440 -re "type = int$nl$gdb_prompt $" {
441 kfail "gdb/68" "ptype g_E.A::a"
442 }
443 }
444
445 set name "ptype g_E.A::x"
446 gdb_test_multiple "ptype g_E.A::x" $name {
447 -re "type = int$nl$gdb_prompt $" {
448 kfail "gdb/68" "ptype g_E.A::x"
449 }
450 }
451
452 gdb_test "ptype g_E.B::b" "type = int"
453 gdb_test "ptype g_E.B::x" "type = int"
454 gdb_test "ptype g_E.C::c" "type = int"
455 gdb_test "ptype g_E.C::x" "type = int"
456 gdb_test "ptype g_E.D::d" "type = int"
457 gdb_test "ptype g_E.D::x" "type = int"
458 gdb_test "ptype g_E.E::e" "type = int"
459 gdb_test "ptype g_E.E::x" "type = int"
460 }
461
462 # Multiple inheritance, print complete classes.
463
464 proc test_print_mi_classes { } {
465 global vhn
466
467 # Print all members of g_D.
468 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\}"
469
470 # Print all members of g_E.
471 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\}"
472 }
473
474 # Single inheritance, print anonymous unions.
475 # GDB versions prior to 4.14 entered an infinite loop when printing
476 # the type of a class containing an anonymous union, and they were also
477 # incapable of printing the member of an anonymous union.
478 # We test the printing of the member first, and perform the other tests
479 # only if the test succeeds, to avoid the infinite loop.
480 #
481 # GDB HEAD 2004-01-27 with hp aCC A.03.45 crashes on the first test.
482 # -- chastain 2004-01-27
483
484 proc test_print_anon_union {} {
485 global gdb_prompt
486 global ws
487 global nl
488 global vhn
489
490 gdb_test "print g_anon_union.a" "$vhn = 2" "print anonymous union member"
491
492 set name "print variable of type anonymous union"
493 gdb_test_multiple "print g_anon_union" $name {
494 -re "$vhn = \{one = 1, \{a = 2, b = 2\}\}$nl$gdb_prompt $" {
495 pass $name
496 }
497 }
498
499 # The nested union prints as a multi-line field, but the class body
500 # scanner is inherently line-oriented. This is ugly but it works.
501
502 cp_test_ptype_class \
503 "ptype g_anon_union" "print type of anonymous union" \
504 "class" "class_with_anon_union" \
505 {
506 { field public "int one;" }
507 { field public "union \{" }
508 { field public "int a;" }
509 { field public "long int b;" }
510 { field public "\};" }
511 }
512
513 }
514
515
516 # Single virtual inheritance, print individual members.
517
518 proc test_print_svi_members { } {
519 global vhn
520
521 # Print all members of g_vA.
522 gdb_test "print g_vA.vA::va" "$vhn = 1"
523 gdb_test "print g_vA.vA::vx" "$vhn = 2"
524
525 # Print members of g_vA using compact form.
526 gdb_test "print g_vA.va" "$vhn = 1"
527 gdb_test "print g_vA.vx" "$vhn = 2"
528
529 # Print all members of g_vB.
530 gdb_test "print g_vB.vA::va" "$vhn = 3"
531 gdb_test "print g_vB.vA::vx" "$vhn = 4"
532 gdb_test "print g_vB.vB::vb" "$vhn = 5"
533 gdb_test "print g_vB.vB::vx" "$vhn = 6"
534
535 # Print members of g_vB using compact form.
536 gdb_test "print g_vB.va" "$vhn = 3"
537 gdb_test "print g_vB.vb" "$vhn = 5"
538 gdb_test "print g_vB.vx" "$vhn = 6"
539
540 # Print all members of g_vC.
541 gdb_test "print g_vC.vA::va" "$vhn = 7"
542 gdb_test "print g_vC.vA::vx" "$vhn = 8"
543 gdb_test "print g_vC.vC::vc" "$vhn = 9"
544 gdb_test "print g_vC.vC::vx" "$vhn = 10"
545
546 # Print members of g_vC using compact form.
547 gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va"
548 gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc"
549 gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx"
550 }
551
552 # Single virtual inheritance, print complete classes.
553
554 proc test_print_svi_classes { } {
555 global gdb_prompt
556 global hex
557 global nl
558 global vhn
559
560 # Print all members of g_vA.
561 gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}"
562
563 # Print all members of g_vB.
564 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
565 set re_vbptr_3 "_vptr.vB"
566
567 set name "print g_vB"
568 gdb_test_multiple "print g_vB" $name {
569 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
570 # gcc 2.95.3 -gdwarf-2
571 # gcc 2.95.3 -gstabs+
572 pass $name
573 }
574 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
575 # gcc 3.3.4 -gdwarf-2
576 # gcc 3.4.1 -gdwarf-2
577 # gcc 3.4.1 -gstabs+
578 # gcc HEAD 2004-07-31 -gdwarf-2
579 pass "$name (FIXME v3 vtbl ptr)"
580 }
581 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
582 # gcc 3.3.4 -gstabs+
583 pass $name
584 }
585 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <typeinfo for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
586 # gcc HEAD 2004-07-31 -gstabs+
587 pass $name
588 }
589 }
590
591 # Print all members of g_vC.
592 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
593 set re_vbptr_3 "_vptr.vC"
594
595 set name "print g_vC"
596 gdb_test_multiple "print g_vC" $name {
597 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
598 # gcc 2.95.3 -gdwarf-2
599 # gcc 2.95.3 -gstabs+
600 pass $name
601 }
602 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
603 # gcc 3.3.4 -gdwarf-2
604 # gcc 3.4.1 -gdwarf-2
605 # gcc 3.4.1 -gstabs+
606 # gcc HEAD 2004-07-31 -gdwarf-2
607 pass "$name (FIXME v3 vtbl ptr)"
608 }
609 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
610 # gcc 3.3.4 -gstabs+
611 pass $name
612 }
613 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <typeinfo for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
614 # gcc HEAD 2004-07-31 -gstabs+
615 pass $name
616 }
617 }
618 }
619
620 # Multiple virtual inheritance, print individual members.
621
622 proc test_print_mvi_members { } {
623 global vhn
624
625 # Print all members of g_vD.
626 gdb_test "print g_vD.vA::va" "$vhn = 19"
627 gdb_test "print g_vD.vA::vx" "$vhn = 20"
628 gdb_test "print g_vD.vB::vb" "$vhn = 21"
629 gdb_test "print g_vD.vB::vx" "$vhn = 22"
630 gdb_test "print g_vD.vC::vc" "$vhn = 23"
631 gdb_test "print g_vD.vC::vx" "$vhn = 24"
632 gdb_test "print g_vD.vD::vd" "$vhn = 25"
633 gdb_test "print g_vD.vD::vx" "$vhn = 26"
634
635 # Print all members of g_vE.
636 gdb_test "print g_vE.vA::va" "$vhn = 0"
637 gdb_test "print g_vE.vA::vx" "$vhn = 0"
638 gdb_test "print g_vE.vB::vb" "$vhn = 0"
639 gdb_test "print g_vE.vB::vx" "$vhn = 0"
640 gdb_test "print g_vE.vC::vc" "$vhn = 0"
641 gdb_test "print g_vE.vC::vx" "$vhn = 0"
642 gdb_test "print g_vE.vD::vd" "$vhn = 0"
643 gdb_test "print g_vE.vD::vx" "$vhn = 0"
644 gdb_test "print g_vE.vE::ve" "$vhn = 27"
645 gdb_test "print g_vE.vE::vx" "$vhn = 28"
646 }
647
648 # Multiple virtual inheritance, print complete classes.
649
650 proc test_print_mvi_classes { } {
651 global gdb_prompt
652 global hex
653 global ws
654 global nl
655 global vhn
656
657 # Virtual base pointers for everybody.
658
659 set re_vbptr_2_vA "(_vb.2vA|_vb.vA)"
660 set re_vbptr_2_vB "(_vb.2vB|_vb.vB)"
661 set re_vbptr_2_vC "(_vb.2vC|_vb.vC)"
662 set re_vbptr_2_vD "(_vb.2vD|_vb.vD)"
663 set re_vbptr_3_vA "_vptr.vA"
664 set re_vbptr_3_vB "_vptr.vB"
665 set re_vbptr_3_vC "_vptr.vC"
666 set re_vbptr_3_vD "_vptr.vD"
667 set re_vbptr_3_vE "_vptr.vE"
668
669 # Print all members of g_vD.
670
671 set name "print g_vD"
672 gdb_test_multiple "print g_vD" $name {
673 -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 $" {
674 # gcc 2.95.3 -gdwarf-2
675 # gcc 2.95.3 -gstabs+
676 pass $name
677 }
678 -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 $" {
679 # gcc 3.3.2 -gdwarf-2
680 # gcc HEAD 2004-01-21 -gdwarf-2
681 # gcc HEAD 2004-01-21 -gstabs+
682 pass "$name (FIXME v3 vtbl ptr)"
683 }
684 -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 $" {
685 # gcc 3.3.2 -gstabs+
686 pass "$name"
687 }
688 }
689
690 # Print all members of g_vE.
691
692 set name "print g_vE"
693 gdb_test_multiple "print g_vE" $name {
694 -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 $" {
695 # gcc 2.95.3 -gdwarf-2
696 # gcc 2.95.3 -gstabs+
697 pass $name
698 }
699 -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 $" {
700 # gcc 3.3.4 -gdwarf-2
701 # gcc 3.3.4 -gstabs+
702 # gcc 3.4.1 -gdwarf-2
703 # gcc 3.4.1 -gstabs+
704 # gcc HEAD 2004-07-31 -gdwarf-2
705 pass "$name (FIXME v3 vtbl ptr)"
706 }
707 -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 $" {
708 # gcc 3.2.7-rh -gstabs+
709 pass $name
710 }
711 -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 $" {
712 # gcc HEAD 2004-07-31 -gstabs+
713 pass $name
714 }
715 }
716 }
717
718 proc do_tests { } {
719 global prms_id
720 global bug_id
721 global subdir
722 global objdir
723 global srcdir
724 global binfile
725
726 set prms_id 0
727 set bug_id 0
728
729 # Start with a fresh gdb.
730
731 gdb_exit
732 gdb_start
733 gdb_reinitialize_dir $srcdir/$subdir
734 gdb_load $binfile
735
736 gdb_test "set language c++" ""
737 gdb_test "set width 0" ""
738
739 if { ![runto_main] } then {
740 perror "couldn't run to main"
741 return
742 }
743
744 test_ptype_si
745 test_ptype_mi
746 test_ptype_vi
747 test_ptype_mvi
748
749 if { ![runto 'inheritance2'] } then {
750 perror "couldn't run to inheritance2"
751 return
752 }
753
754 test_print_si_members
755 test_print_si_classes
756 test_print_mi_members
757 test_print_mi_member_types
758 test_print_mi_classes
759 test_print_anon_union
760
761 if { ![runto 'inheritance4'] } {
762 perror "couldn't run to inheritance4"
763 return
764 }
765
766 test_print_svi_members
767 test_print_svi_classes
768 test_print_mvi_members
769 test_print_mvi_classes
770 }
771
772 do_tests