]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.cp/inherit.exp
* cp-valprint.c (cp_print_value_fields): Use
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / inherit.exp
1 # Copyright 1992-1999, 2001-2004, 2006-2012 Free Software Foundation,
2 # 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 3 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, see <http://www.gnu.org/licenses/>.
16
17 # This file was written by Fred Fish. (fnf@cygnus.com)
18 # And rewritten by Michael Chastain. (mec.gnu@mindspring.com)
19
20 set ws "\[\r\n\t \]+"
21 set nl "\[\r\n\]+"
22 set vhn "\\$\[0-9\]+"
23
24 if { [skip_cplus_tests] } { continue }
25
26 load_lib "cp-support.exp"
27
28 set testfile "inherit"
29 set srcfile misc.cc
30 set binfile ${objdir}/${subdir}/${testfile}
31
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
33 untested inherit.exp
34 return -1
35 }
36
37 # Single inheritance, print type definitions.
38
39 proc test_ptype_si { } {
40 global gdb_prompt
41 global ws
42 global nl
43
44 # A simple class.
45
46 cp_test_ptype_class \
47 "ptype A" "ptype A (FIXME)" "class" "A" \
48 {
49 { field public "int a;" }
50 { field public "int x;" }
51 }
52 cp_test_ptype_class "ptype class A" "ptype class A (FIXME)" "class" "A" ibid
53 cp_test_ptype_class "ptype g_A" "ptype g_A (FIXME)" "class" "A" ibid
54
55 # A derived class.
56
57 cp_test_ptype_class \
58 "ptype B" "" "class" "B" \
59 {
60 { base "public A" }
61 { field public "int b;" }
62 { field public "int x;" }
63 }
64 cp_test_ptype_class "ptype class B" "" "class" "B" ibid
65 cp_test_ptype_class "ptype g_B" "" "class" "B" ibid
66
67 # Another derived class.
68
69 cp_test_ptype_class \
70 "ptype C" "" "class" "C" \
71 {
72 { base "public A" }
73 { field public "int c;" }
74 { field public "int x;" }
75 }
76 cp_test_ptype_class "ptype class C" "" "class" "C" ibid
77 cp_test_ptype_class "ptype g_C" "" "class" "C" ibid
78
79 # A structure with no tag.
80 # TODO: move this mess into a separate file, and re-specify
81 # which results are PASS, KFAIL, XFAIL, and FAIL.
82
83 set re_tag "tagless_struct"
84 set XX_tag "\\._1"
85 set re_class "(class $re_tag \{${ws}public:|class \{${ws}public:|struct $re_tag \{|struct \{)"
86 set XX_class "(class $XX_tag \{${ws}public:|struct $XX_tag \{)"
87 set re_fields "int one;${ws}int two;"
88 set re_synth_gcc_23 "$re_tag & operator=\\($re_tag const ?&\\);${ws}$re_tag\\($re_tag const ?&\\);${ws}$re_tag\\((void|)\\);"
89 set XX_synth_gcc_23 "($re_tag|$XX_tag) & operator=\\($XX_tag const ?&\\);${ws}$XX_tag\\($XX_tag const ?&\\);${ws}$XX_tag\\((void|)\\);"
90
91 set name "ptype tagless struct"
92 gdb_test_multiple "ptype tagless_struct" $name {
93 -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
94 # gcc 2.95.3 -gdwarf-2
95 pass "$name"
96 }
97 -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
98 # gcc 2.95.3 -gstabs+
99 pass "$name"
100 }
101 -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
102 # gcc 3.3.4 -gdwarf-2
103 # gcc 3.4.1 -gdwarf-2
104 # gcc HEAD 2004-07-31 -gdwarf-2
105 # gcc HEAD 2004-07-31 -gstabs+
106 pass "$name"
107 }
108 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
109 # gcc 3.3.4 -gstabs+
110 # gcc 3.4.1 -gstabs+
111 pass "$name"
112 }
113 -re "No symbol \"tagless_struct\" in current context.$nl$gdb_prompt $" {
114 # Several GCC 4.x versions provide neither a DW_TAG_typedef DIE
115 # nor use the typedef name as struct tag name.
116 xfail "$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 = \[0-9\]+\}\}$nl$gdb_prompt $" {
495 pass $name
496 }
497 }
498
499 set name "print type of anonymous union"
500 set re_tag "class_with_anon_union"
501 set re_class "(class $re_tag \{${ws}public:|struct $re_tag \{)"
502 set re_fields "int one;${ws}union \{${ws}int a;${ws}long( int)? b;${ws}\};"
503 gdb_test_multiple "ptype g_anon_union" $name {
504 -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
505 pass $name
506 }
507 }
508 }
509
510
511 # Single virtual inheritance, print individual members.
512
513 proc test_print_svi_members { } {
514 global vhn
515
516 # Print all members of g_vA.
517 gdb_test "print g_vA.vA::va" "$vhn = 1"
518 gdb_test "print g_vA.vA::vx" "$vhn = 2"
519
520 # Print members of g_vA using compact form.
521 gdb_test "print g_vA.va" "$vhn = 1"
522 gdb_test "print g_vA.vx" "$vhn = 2"
523
524 # Print all members of g_vB.
525 gdb_test "print g_vB.vA::va" "$vhn = 3"
526 gdb_test "print g_vB.vA::vx" "$vhn = 4"
527 gdb_test "print g_vB.vB::vb" "$vhn = 5"
528 gdb_test "print g_vB.vB::vx" "$vhn = 6"
529
530 # Print members of g_vB using compact form.
531 gdb_test "print g_vB.va" "$vhn = 3"
532 gdb_test "print g_vB.vb" "$vhn = 5"
533 gdb_test "print g_vB.vx" "$vhn = 6"
534
535 # Print all members of g_vC.
536 gdb_test "print g_vC.vA::va" "$vhn = 7"
537 gdb_test "print g_vC.vA::vx" "$vhn = 8"
538 gdb_test "print g_vC.vC::vc" "$vhn = 9"
539 gdb_test "print g_vC.vC::vx" "$vhn = 10"
540
541 # Print members of g_vC using compact form.
542 gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va"
543 gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc"
544 gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx"
545 }
546
547 # Single virtual inheritance, print complete classes.
548
549 proc test_print_svi_classes { } {
550 global gdb_prompt
551 global hex
552 global nl
553 global vhn
554
555 # Print all members of g_vA.
556 gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}"
557
558 # Print all members of g_vB.
559 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
560 set re_vbptr_3 "_vptr.vB"
561
562 set name "print g_vB"
563 gdb_test_multiple "print g_vB" $name {
564 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
565 # gcc 2.95.3 -gdwarf-2
566 # gcc 2.95.3 -gstabs+
567 pass $name
568 }
569 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
570 # gcc 3.3.4 -gdwarf-2
571 # gcc 3.4.1 -gdwarf-2
572 # gcc 3.4.1 -gstabs+
573 # gcc HEAD 2004-07-31 -gdwarf-2
574 pass "$name (FIXME v3 vtbl ptr)"
575 }
576 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
577 # gcc 3.3.4 -gstabs+
578 pass $name
579 }
580 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <typeinfo for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
581 # gcc HEAD 2004-07-31 -gstabs+
582 pass $name
583 }
584 }
585
586 # Print all members of g_vC.
587 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
588 set re_vbptr_3 "_vptr.vC"
589
590 set name "print g_vC"
591 gdb_test_multiple "print g_vC" $name {
592 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
593 # gcc 2.95.3 -gdwarf-2
594 # gcc 2.95.3 -gstabs+
595 pass $name
596 }
597 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
598 # gcc 3.3.4 -gdwarf-2
599 # gcc 3.4.1 -gdwarf-2
600 # gcc 3.4.1 -gstabs+
601 # gcc HEAD 2004-07-31 -gdwarf-2
602 pass "$name (FIXME v3 vtbl ptr)"
603 }
604 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
605 # gcc 3.3.4 -gstabs+
606 pass $name
607 }
608 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <typeinfo for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
609 # gcc HEAD 2004-07-31 -gstabs+
610 pass $name
611 }
612 }
613 }
614
615 # Multiple virtual inheritance, print individual members.
616
617 proc test_print_mvi_members { } {
618 global vhn
619
620 # Print all members of g_vD.
621 gdb_test "print g_vD.vA::va" "$vhn = 19"
622 gdb_test "print g_vD.vA::vx" "$vhn = 20"
623 gdb_test "print g_vD.vB::vb" "$vhn = 21"
624 gdb_test "print g_vD.vB::vx" "$vhn = 22"
625 gdb_test "print g_vD.vC::vc" "$vhn = 23"
626 gdb_test "print g_vD.vC::vx" "$vhn = 24"
627 gdb_test "print g_vD.vD::vd" "$vhn = 25"
628 gdb_test "print g_vD.vD::vx" "$vhn = 26"
629
630 # Print all members of g_vE.
631 gdb_test "print g_vE.vA::va" "$vhn = 0"
632 gdb_test "print g_vE.vA::vx" "$vhn = 0"
633 gdb_test "print g_vE.vB::vb" "$vhn = 0"
634 gdb_test "print g_vE.vB::vx" "$vhn = 0"
635 gdb_test "print g_vE.vC::vc" "$vhn = 0"
636 gdb_test "print g_vE.vC::vx" "$vhn = 0"
637 gdb_test "print g_vE.vD::vd" "$vhn = 0"
638 gdb_test "print g_vE.vD::vx" "$vhn = 0"
639 gdb_test "print g_vE.vE::ve" "$vhn = 27"
640 gdb_test "print g_vE.vE::vx" "$vhn = 28"
641 }
642
643 # Multiple virtual inheritance, print complete classes.
644
645 proc test_print_mvi_classes { } {
646 global gdb_prompt
647 global hex
648 global ws
649 global nl
650 global vhn
651
652 # Virtual base pointers for everybody.
653
654 set re_vbptr_2_vA "(_vb.2vA|_vb.vA)"
655 set re_vbptr_2_vB "(_vb.2vB|_vb.vB)"
656 set re_vbptr_2_vC "(_vb.2vC|_vb.vC)"
657 set re_vbptr_2_vD "(_vb.2vD|_vb.vD)"
658 set re_vbptr_3_vA "_vptr.vA"
659 set re_vbptr_3_vB "_vptr.vB"
660 set re_vbptr_3_vC "_vptr.vC"
661 set re_vbptr_3_vD "_vptr.vD"
662 set re_vbptr_3_vE "_vptr.vE"
663
664 # Print all members of g_vD.
665
666 set name "print g_vD"
667 gdb_test_multiple "print g_vD" $name {
668 -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 $" {
669 # gcc 2.95.3 -gdwarf-2
670 # gcc 2.95.3 -gstabs+
671 pass $name
672 }
673 -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = ${hex}( <vtable for vD.*>)?, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <vtable for vC.*>)?, vc = 23, vx = 24\}, $re_vbptr_3_vD = ${hex}( <vtable for vD.*>)?, vd = 25, vx = 26\}$nl$gdb_prompt $" {
674 # gcc 3.3.2 -gdwarf-2
675 # gcc HEAD 2004-01-21 -gdwarf-2
676 # gcc HEAD 2004-01-21 -gstabs+
677 pass "$name (FIXME v3 vtbl ptr)"
678 }
679 -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 $" {
680 # gcc 3.3.2 -gstabs+
681 pass "$name"
682 }
683 }
684
685 # Print all members of g_vE.
686
687 set name "print g_vE"
688 gdb_test_multiple "print g_vE" $name {
689 -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 $" {
690 # gcc 2.95.3 -gdwarf-2
691 # gcc 2.95.3 -gstabs+
692 pass $name
693 }
694 -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = ${hex}( <vtable for vE.*>)?, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <vtable for vE.*>)?, vc = 0, vx = 0\}, $re_vbptr_3_vD = ${hex}( <vtable for vE.*>)?, vd = 0, vx = 0\}, $re_vbptr_3_vE = ${hex}( <vtable for vE.*>)?, ve = 27, vx = 28\}$nl$gdb_prompt $" {
695 # gcc 3.3.4 -gdwarf-2
696 # gcc 3.3.4 -gstabs+
697 # gcc 3.4.1 -gdwarf-2
698 # gcc 3.4.1 -gstabs+
699 # gcc HEAD 2004-07-31 -gdwarf-2
700 pass "$name (FIXME v3 vtbl ptr)"
701 }
702 -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 $" {
703 # gcc 3.2.7-rh -gstabs+
704 pass $name
705 }
706 -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 $" {
707 # gcc HEAD 2004-07-31 -gstabs+
708 pass $name
709 }
710 }
711 }
712
713 proc do_tests { } {
714 global subdir
715 global objdir
716 global srcdir
717 global binfile
718
719
720 # Start with a fresh gdb.
721
722 gdb_exit
723 gdb_start
724 gdb_reinitialize_dir $srcdir/$subdir
725 gdb_load $binfile
726
727 gdb_test_no_output "set width 0"
728
729 if { ![runto_main] } then {
730 perror "couldn't run to main"
731 return
732 }
733
734 gdb_test_no_output "set language c++"
735 test_ptype_si
736 test_ptype_mi
737 test_ptype_vi
738 test_ptype_mvi
739
740 if { ![runto 'inheritance2'] } then {
741 perror "couldn't run to inheritance2"
742 return
743 }
744
745 test_print_si_members
746 test_print_si_classes
747 test_print_mi_members
748 test_print_mi_member_types
749 test_print_mi_classes
750 test_print_anon_union
751
752 if { ![runto 'inheritance4'] } {
753 perror "couldn't run to inheritance4"
754 return
755 }
756
757 test_print_svi_members
758 test_print_svi_classes
759 test_print_mvi_members
760 test_print_mvi_classes
761 }
762
763 do_tests