2006-03-01 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / inherit.exp
CommitLineData
ebac27b4
MC
1# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
2# 2004 Free Software Foundation, Inc.
c906108c
SS
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
c906108c 18# This file was written by Fred Fish. (fnf@cygnus.com)
ebac27b4 19# And rewritten by Michael Chastain. (mec.gnu@mindspring.com)
c906108c 20
ebac27b4
MC
21set ws "\[\r\n\t \]+"
22set nl "\[\r\n\]+"
23set vhn "\\$\[0-9\]+"
c2d11a7d 24
c906108c 25if $tracelevel then {
ebac27b4 26 strace $tracelevel
c906108c
SS
27}
28
d4f3574e
SS
29if { [skip_cplus_tests] } { continue }
30
25808999
MC
31load_lib "cp-support.exp"
32
c906108c
SS
33set testfile "inherit"
34set srcfile misc.cc
35set binfile ${objdir}/${subdir}/${testfile}
36
c906108c
SS
37if { [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."
39}
40
c906108c 41# Single inheritance, print type definitions.
c906108c 42
ebac27b4 43proc test_ptype_si { } {
c906108c
SS
44 global gdb_prompt
45 global ws
46 global nl
47
25808999 48 # A simple class.
c906108c 49
25808999
MC
50 cp_test_ptype_class \
51 "ptype A" "ptype A (FIXME)" "class" "A" \
52 {
53 { field public "int a;" }
54 { field public "int x;" }
ebac27b4 55 }
25808999
MC
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
c906108c 58
25808999 59 # A derived class.
c906108c 60
25808999
MC
61 cp_test_ptype_class \
62 "ptype B" "" "class" "B" \
63 {
64 { base "public A" }
65 { field public "int b;" }
66 { field public "int x;" }
ebac27b4 67 }
25808999
MC
68 cp_test_ptype_class "ptype class B" "" "class" "B" ibid
69 cp_test_ptype_class "ptype g_B" "" "class" "B" ibid
c906108c 70
25808999 71 # Another derived class.
c906108c 72
25808999
MC
73 cp_test_ptype_class \
74 "ptype C" "" "class" "C" \
75 {
76 { base "public A" }
77 { field public "int c;" }
78 { field public "int x;" }
ebac27b4 79 }
25808999
MC
80 cp_test_ptype_class "ptype class C" "" "class" "C" ibid
81 cp_test_ptype_class "ptype g_C" "" "class" "C" ibid
c906108c 82
25808999
MC
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.
ebac27b4
MC
86
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|)\\);"
94
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
9366563b 99 pass "$name"
c906108c 100 }
ebac27b4
MC
101 -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
102 # gcc 2.95.3 -gstabs+
9366563b 103 pass "$name"
c906108c 104 }
ebac27b4 105 -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
9366563b
MC
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"
c906108c 111 }
ebac27b4 112 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
9366563b
MC
113 # gcc 3.3.4 -gstabs+
114 # gcc 3.4.1 -gstabs+
ebac27b4 115 pass "$name"
c906108c
SS
116 }
117 }
118
ebac27b4
MC
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
9366563b 123 pass "$name"
3e36a0f4 124 }
ebac27b4
MC
125 -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
126 # gcc 2.95.3 -gstabs+
9366563b 127 pass "$name"
c906108c 128 }
ebac27b4 129 -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
9366563b
MC
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"
c906108c 135 }
ebac27b4 136 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
9366563b
MC
137 # gcc 3.3.4 -gstabs+
138 # gcc 3.4.1 -gstabs+
ebac27b4 139 pass "$name"
c906108c
SS
140 }
141 }
142}
143
ebac27b4 144# Multiple inheritance, print type definitions.
c906108c 145
ebac27b4 146proc test_ptype_mi { } {
ebac27b4 147
25808999 148 # A class with two bases.
ebac27b4 149
25808999
MC
150 cp_test_ptype_class \
151 "ptype D" "" "class" "D" \
152 {
153 { base "public B" }
154 { base "public C" }
155 { field public "int d;" }
156 { field public "int x;" }
c906108c 157 }
25808999
MC
158 cp_test_ptype_class "ptype class D" "" "class" "D" ibid
159 cp_test_ptype_class "ptype g_D" "" "class" "D" ibid
ebac27b4 160
25808999 161 # A class derived from the previous class.
ebac27b4 162
25808999
MC
163 cp_test_ptype_class \
164 "ptype E" "" "class" "E" \
165 {
166 { base "public D" }
167 { field public "int e;" }
168 { field public "int x;" }
3e36a0f4 169 }
25808999
MC
170 cp_test_ptype_class "ptype class E" "" "class" "E" ibid
171 cp_test_ptype_class "ptype g_E" "" "class" "E" ibid
c906108c
SS
172}
173
ebac27b4 174# Single virtual inheritance, print type definitions.
c906108c 175
ebac27b4 176proc test_ptype_vi { } {
c906108c 177
25808999 178 # class vA
c906108c 179
25808999
MC
180 cp_test_ptype_class \
181 "ptype vA" "" "class" "vA" \
182 {
183 { field public "int va;" }
184 { field public "int vx;" }
ebac27b4 185 }
25808999
MC
186 cp_test_ptype_class "ptype class vA" "" "class" "vA" ibid
187 cp_test_ptype_class "ptype g_vA" "" "class" "vA" ibid
c906108c 188
25808999 189 # class vB
c906108c 190
25808999
MC
191 cp_test_ptype_class \
192 "ptype vB" "" "class" "vB" \
193 {
194 { base "public virtual vA" }
195 { vbase "vA" }
196 { field public "int vb;" }
197 { field public "int vx;" }
ebac27b4 198 }
25808999
MC
199 cp_test_ptype_class "ptype class vB" "" "class" "vB" ibid
200 cp_test_ptype_class "ptype g_vB" "" "class" "vB" ibid
c906108c 201
25808999 202 # class vC
c906108c 203
25808999
MC
204 cp_test_ptype_class \
205 "ptype vC" "" "class" "vC" \
206 {
207 { base "public virtual vA" }
208 { vbase "vA" }
209 { field public "int vc;" }
210 { field public "int vx;" }
ebac27b4 211 }
25808999
MC
212 cp_test_ptype_class "ptype class vC" "" "class" "vC" ibid
213 cp_test_ptype_class "ptype g_vC" "" "class" "vC" ibid
c906108c 214
ebac27b4 215}
c906108c 216
ebac27b4 217# Multiple virtual inheritance, print type definitions.
c906108c 218
ebac27b4 219proc test_ptype_mvi { } {
c906108c 220
25808999 221 # class vD
c906108c 222
25808999
MC
223 cp_test_ptype_class \
224 "ptype vD" "" "class" "vD" \
225 {
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;" }
ebac27b4 232 }
25808999
MC
233 cp_test_ptype_class "ptype class vD" "" "class" "vD" ibid
234 cp_test_ptype_class "ptype g_vD" "" "class" "vD" ibid
c906108c 235
25808999 236 # class vE
c906108c 237
25808999
MC
238 cp_test_ptype_class \
239 "ptype vE" "" "class" "vE" \
240 {
241 { base "public virtual vD" }
242 { vbase "vD" }
243 { field public "int ve;" }
244 { field public "int vx;" }
ebac27b4 245 }
25808999
MC
246 cp_test_ptype_class "ptype class vE" "" "class" "vE" ibid
247 cp_test_ptype_class "ptype g_vE" "" "class" "vE" ibid
c906108c 248
c906108c
SS
249}
250
ebac27b4 251# Single inheritance, print individual members.
c906108c 252
ebac27b4
MC
253proc test_print_si_members { } {
254 global vhn
c906108c 255
ebac27b4
MC
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"
c906108c 259
ebac27b4
MC
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"
c906108c 263
ebac27b4
MC
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"
c906108c 269
ebac27b4
MC
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"
c906108c 274
ebac27b4
MC
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"
c906108c 280
ebac27b4
MC
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"
c906108c
SS
285}
286
ebac27b4 287# Single inheritance, print complete classes.
c906108c 288
ebac27b4
MC
289proc test_print_si_classes { } {
290 global vhn
c906108c 291
ebac27b4
MC
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\}"
c906108c
SS
296}
297
ebac27b4 298# Multiple inheritance, print individual members.
c906108c 299
ebac27b4 300proc test_print_mi_members {} {
c906108c 301 global gdb_prompt
c906108c 302 global nl
ebac27b4 303 global vhn
c906108c 304
ebac27b4
MC
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"
c906108c 308
ebac27b4
MC
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"
c906108c 314
ebac27b4
MC
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"
c906108c 320
ebac27b4
MC
321 # Print all members of g_D.
322 #
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.
327
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"
c906108c 332 }
c906108c
SS
333 }
334
ebac27b4
MC
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"
339 }
340 }
c906108c 341
ebac27b4
MC
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"
c906108c 348
ebac27b4
MC
349 # Print all members of g_E.
350 # g_E.A::a and g_E.A::x are ambiguous.
c906108c 351
ebac27b4
MC
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"
356 }
357 }
c906108c 358
ebac27b4
MC
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"
363 }
364 }
c906108c 365
ebac27b4
MC
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"
374}
c906108c 375
ebac27b4 376# Multiple inheritance, print complete classes.
c906108c 377
ebac27b4
MC
378proc test_print_mi_classes { } {
379 global vhn
c906108c 380
ebac27b4
MC
381 # Print all members of g_D.
382 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\}"
c906108c 383
ebac27b4
MC
384 # Print all members of g_E.
385 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\}"
c906108c
SS
386}
387
ebac27b4
MC
388# Single inheritance, print anonymous unions.
389# GDB versions prior to 4.14 entered an infinite loop when printing
390# the type of a class containing an anonymous union, and they were also
391# incapable of printing the member of an anonymous union.
392# We test the printing of the member first, and perform the other tests
393# only if the test succeeds, to avoid the infinite loop.
c906108c 394#
ebac27b4
MC
395# GDB HEAD 2004-01-27 with hp aCC A.03.45 crashes on the first test.
396# -- chastain 2004-01-27
c906108c 397
ebac27b4 398proc test_print_anon_union {} {
c906108c 399 global gdb_prompt
a0b3c4fd 400 global ws
c906108c 401 global nl
ebac27b4 402 global vhn
c906108c 403
ebac27b4 404 gdb_test "print g_anon_union.a" "$vhn = 2" "print anonymous union member"
c906108c 405
ebac27b4
MC
406 set name "print variable of type anonymous union"
407 gdb_test_multiple "print g_anon_union" $name {
408 -re "$vhn = \{one = 1, \{a = 2, b = 2\}\}$nl$gdb_prompt $" {
409 pass $name
c906108c 410 }
c906108c
SS
411 }
412
25808999
MC
413 # The nested union prints as a multi-line field, but the class body
414 # scanner is inherently line-oriented. This is ugly but it works.
c906108c 415
25808999
MC
416 cp_test_ptype_class \
417 "ptype g_anon_union" "print type of anonymous union" \
418 "class" "class_with_anon_union" \
419 {
420 { field public "int one;" }
421 { field public "union \{" }
422 { field public "int a;" }
423 { field public "long int b;" }
424 { field public "\};" }
a0b3c4fd 425 }
25808999 426
ebac27b4 427}
c906108c 428
c906108c 429
ebac27b4 430# Single virtual inheritance, print individual members.
c906108c 431
ebac27b4
MC
432proc test_print_svi_members { } {
433 global vhn
c906108c 434
ebac27b4
MC
435 # Print all members of g_vA.
436 gdb_test "print g_vA.vA::va" "$vhn = 1"
437 gdb_test "print g_vA.vA::vx" "$vhn = 2"
c906108c 438
ebac27b4
MC
439 # Print members of g_vA using compact form.
440 gdb_test "print g_vA.va" "$vhn = 1"
441 gdb_test "print g_vA.vx" "$vhn = 2"
442
443 # Print all members of g_vB.
444 gdb_test "print g_vB.vA::va" "$vhn = 3"
445 gdb_test "print g_vB.vA::vx" "$vhn = 4"
446 gdb_test "print g_vB.vB::vb" "$vhn = 5"
447 gdb_test "print g_vB.vB::vx" "$vhn = 6"
448
449 # Print members of g_vB using compact form.
450 gdb_test "print g_vB.va" "$vhn = 3"
451 gdb_test "print g_vB.vb" "$vhn = 5"
452 gdb_test "print g_vB.vx" "$vhn = 6"
453
454 # Print all members of g_vC.
455 gdb_test "print g_vC.vA::va" "$vhn = 7"
456 gdb_test "print g_vC.vA::vx" "$vhn = 8"
457 gdb_test "print g_vC.vC::vc" "$vhn = 9"
458 gdb_test "print g_vC.vC::vx" "$vhn = 10"
459
460 # Print members of g_vC using compact form.
461 gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va"
462 gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc"
463 gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx"
c906108c
SS
464}
465
c906108c 466# Single virtual inheritance, print complete classes.
c906108c 467
ebac27b4 468proc test_print_svi_classes { } {
c906108c
SS
469 global gdb_prompt
470 global hex
c906108c 471 global nl
ebac27b4 472 global vhn
c906108c
SS
473
474 # Print all members of g_vA.
ebac27b4 475 gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}"
c906108c
SS
476
477 # Print all members of g_vB.
ebac27b4
MC
478 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
479 set re_vbptr_3 "_vptr.vB"
480
481 set name "print g_vB"
482 gdb_test_multiple "print g_vB" $name {
483 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
484 # gcc 2.95.3 -gdwarf-2
485 # gcc 2.95.3 -gstabs+
486 pass $name
487 }
488 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
9366563b
MC
489 # gcc 3.3.4 -gdwarf-2
490 # gcc 3.4.1 -gdwarf-2
491 # gcc 3.4.1 -gstabs+
492 # gcc HEAD 2004-07-31 -gdwarf-2
ebac27b4
MC
493 pass "$name (FIXME v3 vtbl ptr)"
494 }
495 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
9366563b
MC
496 # gcc 3.3.4 -gstabs+
497 pass $name
498 }
499 -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <typeinfo for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
500 # gcc HEAD 2004-07-31 -gstabs+
ebac27b4 501 pass $name
5178b9d6 502 }
c906108c
SS
503 }
504
505 # Print all members of g_vC.
ebac27b4
MC
506 set re_vbptr_2 "(_vb.2vA|_vb.vA)"
507 set re_vbptr_3 "_vptr.vC"
508
509 set name "print g_vC"
510 gdb_test_multiple "print g_vC" $name {
511 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
512 # gcc 2.95.3 -gdwarf-2
513 # gcc 2.95.3 -gstabs+
514 pass $name
515 }
516 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
9366563b
MC
517 # gcc 3.3.4 -gdwarf-2
518 # gcc 3.4.1 -gdwarf-2
519 # gcc 3.4.1 -gstabs+
520 # gcc HEAD 2004-07-31 -gdwarf-2
ebac27b4
MC
521 pass "$name (FIXME v3 vtbl ptr)"
522 }
523 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
9366563b
MC
524 # gcc 3.3.4 -gstabs+
525 pass $name
526 }
527 -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <typeinfo for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
528 # gcc HEAD 2004-07-31 -gstabs+
ebac27b4 529 pass $name
a0b3c4fd 530 }
a0b3c4fd 531 }
c906108c
SS
532}
533
c906108c 534# Multiple virtual inheritance, print individual members.
c906108c 535
ebac27b4
MC
536proc test_print_mvi_members { } {
537 global vhn
c906108c
SS
538
539 # Print all members of g_vD.
ebac27b4
MC
540 gdb_test "print g_vD.vA::va" "$vhn = 19"
541 gdb_test "print g_vD.vA::vx" "$vhn = 20"
542 gdb_test "print g_vD.vB::vb" "$vhn = 21"
543 gdb_test "print g_vD.vB::vx" "$vhn = 22"
544 gdb_test "print g_vD.vC::vc" "$vhn = 23"
545 gdb_test "print g_vD.vC::vx" "$vhn = 24"
546 gdb_test "print g_vD.vD::vd" "$vhn = 25"
547 gdb_test "print g_vD.vD::vx" "$vhn = 26"
c906108c
SS
548
549 # Print all members of g_vE.
ebac27b4
MC
550 gdb_test "print g_vE.vA::va" "$vhn = 0"
551 gdb_test "print g_vE.vA::vx" "$vhn = 0"
552 gdb_test "print g_vE.vB::vb" "$vhn = 0"
553 gdb_test "print g_vE.vB::vx" "$vhn = 0"
554 gdb_test "print g_vE.vC::vc" "$vhn = 0"
555 gdb_test "print g_vE.vC::vx" "$vhn = 0"
556 gdb_test "print g_vE.vD::vd" "$vhn = 0"
557 gdb_test "print g_vE.vD::vx" "$vhn = 0"
558 gdb_test "print g_vE.vE::ve" "$vhn = 27"
559 gdb_test "print g_vE.vE::vx" "$vhn = 28"
c906108c
SS
560}
561
ebac27b4 562# Multiple virtual inheritance, print complete classes.
c906108c 563
ebac27b4 564proc test_print_mvi_classes { } {
a0b3c4fd 565 global gdb_prompt
ebac27b4 566 global hex
a0b3c4fd 567 global ws
c906108c 568 global nl
ebac27b4 569 global vhn
c906108c 570
ebac27b4 571 # Virtual base pointers for everybody.
c906108c 572
ebac27b4
MC
573 set re_vbptr_2_vA "(_vb.2vA|_vb.vA)"
574 set re_vbptr_2_vB "(_vb.2vB|_vb.vB)"
575 set re_vbptr_2_vC "(_vb.2vC|_vb.vC)"
576 set re_vbptr_2_vD "(_vb.2vD|_vb.vD)"
577 set re_vbptr_3_vA "_vptr.vA"
578 set re_vbptr_3_vB "_vptr.vB"
579 set re_vbptr_3_vC "_vptr.vC"
580 set re_vbptr_3_vD "_vptr.vD"
581 set re_vbptr_3_vE "_vptr.vE"
c906108c
SS
582
583 # Print all members of g_vD.
584
ebac27b4
MC
585 set name "print g_vD"
586 gdb_test_multiple "print g_vD" $name {
587 -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 $" {
588 # gcc 2.95.3 -gdwarf-2
589 # gcc 2.95.3 -gstabs+
590 pass $name
c906108c 591 }
ebac27b4
MC
592 -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 $" {
593 # gcc 3.3.2 -gdwarf-2
594 # gcc HEAD 2004-01-21 -gdwarf-2
595 # gcc HEAD 2004-01-21 -gstabs+
596 pass "$name (FIXME v3 vtbl ptr)"
5178b9d6 597 }
ebac27b4
MC
598 -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 $" {
599 # gcc 3.3.2 -gstabs+
600 pass "$name"
3c6cb4a1 601 }
c906108c
SS
602 }
603
604 # Print all members of g_vE.
605
ebac27b4
MC
606 set name "print g_vE"
607 gdb_test_multiple "print g_vE" $name {
608 -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 $" {
609 # gcc 2.95.3 -gdwarf-2
610 # gcc 2.95.3 -gstabs+
611 pass $name
a0b3c4fd 612 }
ebac27b4 613 -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 $" {
9366563b
MC
614 # gcc 3.3.4 -gdwarf-2
615 # gcc 3.3.4 -gstabs+
616 # gcc 3.4.1 -gdwarf-2
617 # gcc 3.4.1 -gstabs+
618 # gcc HEAD 2004-07-31 -gdwarf-2
ebac27b4 619 pass "$name (FIXME v3 vtbl ptr)"
5178b9d6 620 }
ec4646ef
MC
621 -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 $" {
622 # gcc 3.2.7-rh -gstabs+
9366563b
MC
623 pass $name
624 }
625 -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 $" {
626 # gcc HEAD 2004-07-31 -gstabs+
627 pass $name
ec4646ef 628 }
a0b3c4fd 629 }
c906108c
SS
630}
631
ebac27b4 632proc do_tests { } {
c906108c
SS
633 global prms_id
634 global bug_id
635 global subdir
636 global objdir
637 global srcdir
638 global binfile
639
640 set prms_id 0
641 set bug_id 0
642
643 # Start with a fresh gdb.
644
645 gdb_exit
646 gdb_start
647 gdb_reinitialize_dir $srcdir/$subdir
648 gdb_load $binfile
649
650 gdb_test "set language c++" ""
651 gdb_test "set width 0" ""
652
ebac27b4
MC
653 if { ![runto_main] } then {
654 perror "couldn't run to main"
655 return
c906108c
SS
656 }
657
658 test_ptype_si
659 test_ptype_mi
660 test_ptype_vi
661 test_ptype_mvi
662
ebac27b4
MC
663 if { ![runto 'inheritance2'] } then {
664 perror "couldn't run to inheritance2"
665 return
c906108c
SS
666 }
667
668 test_print_si_members
669 test_print_si_classes
670 test_print_mi_members
671 test_print_mi_classes
672 test_print_anon_union
673
ebac27b4
MC
674 if { ![runto 'inheritance4'] } {
675 perror "couldn't run to inheritance4"
676 return
c906108c
SS
677 }
678
679 test_print_svi_members
680 test_print_svi_classes
681 test_print_mvi_members
682 test_print_mvi_classes
683}
684
685do_tests
This page took 0.638475 seconds and 4 git commands to generate.