1 |
578 |
markom |
# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001
|
2 |
|
|
# 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 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
19 |
|
|
# bug-gdb@prep.ai.mit.edu
|
20 |
|
|
|
21 |
|
|
# This file was written by Fred Fish. (fnf@cygnus.com)
|
22 |
|
|
|
23 |
|
|
set ws "\[\r\n\t \]+"
|
24 |
|
|
set nl "\[\r\n\]+"
|
25 |
|
|
|
26 |
|
|
# The format of a g++ virtual base pointer.
|
27 |
|
|
set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?"
|
28 |
|
|
|
29 |
|
|
if $tracelevel then {
|
30 |
|
|
strace $tracelevel
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
if { [skip_cplus_tests] } { continue }
|
34 |
|
|
|
35 |
|
|
# Note - create separate "inherit" executable from misc.cc
|
36 |
|
|
|
37 |
|
|
set testfile "inherit"
|
38 |
|
|
set srcfile misc.cc
|
39 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
# Create and source the file that provides information about the compiler
|
43 |
|
|
# used to compile the test case.
|
44 |
|
|
|
45 |
|
|
if [get_compiler_info ${binfile} "c++"] {
|
46 |
|
|
return -1
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
|
50 |
|
|
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
#
|
54 |
|
|
# Single inheritance, print individual members.
|
55 |
|
|
#
|
56 |
|
|
|
57 |
|
|
proc test_print_si_members {} {
|
58 |
|
|
# Print all members of g_A using fully qualified form.
|
59 |
|
|
|
60 |
|
|
gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
|
61 |
|
|
|
62 |
|
|
gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
|
63 |
|
|
|
64 |
|
|
# Print members of g_A using nonambiguous compact form.
|
65 |
|
|
|
66 |
|
|
gdb_test "print g_A.a" ".* = 1" "print g_A.a"
|
67 |
|
|
|
68 |
|
|
gdb_test "print g_A.x" ".* = 2" "print g_A.x"
|
69 |
|
|
|
70 |
|
|
# Print all members of g_B using fully qualified form.
|
71 |
|
|
|
72 |
|
|
gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
|
73 |
|
|
|
74 |
|
|
gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
|
75 |
|
|
|
76 |
|
|
gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
|
77 |
|
|
|
78 |
|
|
gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
|
79 |
|
|
|
80 |
|
|
# Print members of g_B using nonambiguous compact form.
|
81 |
|
|
|
82 |
|
|
setup_xfail_format "DWARF 1"
|
83 |
|
|
gdb_test "print g_B.a" ".* = 3" "print g_B.a"
|
84 |
|
|
|
85 |
|
|
gdb_test "print g_B.b" ".* = 5" "print g_B.b"
|
86 |
|
|
|
87 |
|
|
gdb_test "print g_B.x" ".* = 6" "print g_B.x"
|
88 |
|
|
|
89 |
|
|
# Print all members of g_C using fully qualified form.
|
90 |
|
|
|
91 |
|
|
gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
|
92 |
|
|
|
93 |
|
|
gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
|
94 |
|
|
|
95 |
|
|
gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
|
96 |
|
|
|
97 |
|
|
gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
|
98 |
|
|
|
99 |
|
|
# Print members of g_C using nonambiguous compact form.
|
100 |
|
|
|
101 |
|
|
setup_xfail_format "DWARF 1"
|
102 |
|
|
gdb_test "print g_C.a" ".* = 7" "print g_C.a"
|
103 |
|
|
|
104 |
|
|
gdb_test "print g_C.c" ".* = 9" "print g_C.c"
|
105 |
|
|
|
106 |
|
|
gdb_test "print g_C.x" ".* = 10" "print g_C.x"
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
#
|
110 |
|
|
# Single inheritance, print type definitions.
|
111 |
|
|
#
|
112 |
|
|
|
113 |
|
|
proc test_ptype_si {} {
|
114 |
|
|
global gdb_prompt
|
115 |
|
|
global ws
|
116 |
|
|
global nl
|
117 |
|
|
global hp_aCC_compiler
|
118 |
|
|
|
119 |
|
|
# Print class A as a type.
|
120 |
|
|
|
121 |
|
|
send_gdb "ptype A\n"
|
122 |
|
|
gdb_expect {
|
123 |
|
|
-re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
|
124 |
|
|
pass "ptype A (FIXME)"
|
125 |
|
|
}
|
126 |
|
|
-re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
|
127 |
|
|
setup_xfail "*-*-*"
|
128 |
|
|
fail "ptype A (FIXME)"
|
129 |
|
|
}
|
130 |
|
|
-re ".*$gdb_prompt $" { fail "ptype A" }
|
131 |
|
|
timeout { fail "ptype A (timeout)" ; return }
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
# Print class A as an explicit class.
|
135 |
|
|
|
136 |
|
|
send_gdb "ptype class A\n"
|
137 |
|
|
gdb_expect {
|
138 |
|
|
-re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
|
139 |
|
|
pass "ptype class A (FIXME)"
|
140 |
|
|
}
|
141 |
|
|
-re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
|
142 |
|
|
if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
|
143 |
|
|
fail "ptype class A (FIXME)"
|
144 |
|
|
}
|
145 |
|
|
-re ".*$gdb_prompt $" { fail "ptype class A" }
|
146 |
|
|
timeout { fail "ptype class A (timeout)" ; return }
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
# Print type of an object of type A.
|
150 |
|
|
|
151 |
|
|
send_gdb "ptype g_A\n"
|
152 |
|
|
gdb_expect {
|
153 |
|
|
-re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" {
|
154 |
|
|
pass "ptype g_A (FIXME)"
|
155 |
|
|
}
|
156 |
|
|
-re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" {
|
157 |
|
|
if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
|
158 |
|
|
fail "ptype g_A (FIXME)"
|
159 |
|
|
}
|
160 |
|
|
-re ".*$gdb_prompt $" { fail "ptype g_A" }
|
161 |
|
|
timeout { fail "ptype g_A (timeout)" ; return }
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
# Print class B as a type.
|
165 |
|
|
|
166 |
|
|
setup_xfail_format "DWARF 1"
|
167 |
|
|
gdb_test "ptype B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype B"
|
168 |
|
|
|
169 |
|
|
# Print class B as an explicit class.
|
170 |
|
|
|
171 |
|
|
setup_xfail_format "DWARF 1"
|
172 |
|
|
gdb_test "ptype class B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype class B"
|
173 |
|
|
|
174 |
|
|
# Print type of an object of type B.
|
175 |
|
|
|
176 |
|
|
setup_xfail_format "DWARF 1"
|
177 |
|
|
gdb_test "ptype g_B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype g_B"
|
178 |
|
|
|
179 |
|
|
# Print class C as a type.
|
180 |
|
|
|
181 |
|
|
setup_xfail_format "DWARF 1"
|
182 |
|
|
gdb_test "ptype C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype C"
|
183 |
|
|
|
184 |
|
|
# Print class C as an explicit class.
|
185 |
|
|
|
186 |
|
|
setup_xfail_format "DWARF 1"
|
187 |
|
|
gdb_test "ptype class C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype class C"
|
188 |
|
|
|
189 |
|
|
# Print type of an object of type g_C.
|
190 |
|
|
|
191 |
|
|
setup_xfail_format "DWARF 1"
|
192 |
|
|
gdb_test "ptype g_C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype g_C"
|
193 |
|
|
|
194 |
|
|
# gcc cygnus-2.3.3 (Q1) has this bug, but it was fixed as of
|
195 |
|
|
# cygnus-2.3.3-930417. PR 2819.
|
196 |
|
|
send_gdb "ptype tagless_struct\n"
|
197 |
|
|
gdb_expect {
|
198 |
|
|
-re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct &\\);${ws}\\\$_1 \\(tagless_struct &\\);${ws}\\\$_1 \\(\\);${ws}\}$nl$gdb_prompt $" {
|
199 |
|
|
pass "ptype tagless struct"
|
200 |
|
|
}
|
201 |
|
|
-re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
|
202 |
|
|
pass "ptype tagless struct (obsolete gcc or gdb)"
|
203 |
|
|
}
|
204 |
|
|
-re ".*$gdb_prompt $" {
|
205 |
|
|
fail "ptype tagless struct"
|
206 |
|
|
}
|
207 |
|
|
timeout {
|
208 |
|
|
fail "ptype tagless struct (timeout)"
|
209 |
|
|
}
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
send_gdb "ptype v_tagless\n"
|
213 |
|
|
gdb_expect {
|
214 |
|
|
-re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct &\\);${ws}\\\$_1 \\(tagless_struct &\\);${ws}\\\$_1 \\(\\);${ws}\}$nl$gdb_prompt $" {
|
215 |
|
|
pass "ptype variable of type tagless struct"
|
216 |
|
|
}
|
217 |
|
|
-re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" {
|
218 |
|
|
pass "ptype variable of type tagless struct (obsolete gcc or gdb)"
|
219 |
|
|
}
|
220 |
|
|
-re ".*$gdb_prompt $" {
|
221 |
|
|
fail "ptype variable of type tagless struct"
|
222 |
|
|
}
|
223 |
|
|
timeout {
|
224 |
|
|
fail "ptype variable of type tagless struct (timeout)"
|
225 |
|
|
}
|
226 |
|
|
}
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
#
|
230 |
|
|
# Single inheritance, print complete classes.
|
231 |
|
|
#
|
232 |
|
|
|
233 |
|
|
proc test_print_si_classes {} {
|
234 |
|
|
# Print all members of g_A.
|
235 |
|
|
|
236 |
|
|
gdb_test "print g_A" ".* = \{a = 1, x = 2\}" "print g_A"
|
237 |
|
|
|
238 |
|
|
# Print all members of g_B.
|
239 |
|
|
|
240 |
|
|
setup_xfail_format "DWARF 1"
|
241 |
|
|
gdb_test "print g_B" ".* = \{\<(class |)A\> = \{a = 3, x = 4\}, b = 5, x = 6\}" "print g_B"
|
242 |
|
|
|
243 |
|
|
# Print all members of g_C.
|
244 |
|
|
|
245 |
|
|
setup_xfail_format "DWARF 1"
|
246 |
|
|
gdb_test "print g_C" ".* = \{\<(class |)A\> = \{a = 7, x = 8\}, c = 9, x = 10\}" "print g_C"
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
#
|
250 |
|
|
# Single inheritance, print anonymous unions.
|
251 |
|
|
# GDB versions prior to 4.14 entered an infinite loop when printing
|
252 |
|
|
# the type of a class containing an anonymous union, and they were also
|
253 |
|
|
# incapable of printing the member of an anonymous union.
|
254 |
|
|
# We test the printing of the member first, and perform the other tests
|
255 |
|
|
# only if the test succeeds, to avoid the infinite loop.
|
256 |
|
|
#
|
257 |
|
|
|
258 |
|
|
proc test_print_anon_union {} {
|
259 |
|
|
global gdb_prompt
|
260 |
|
|
global ws
|
261 |
|
|
global nl
|
262 |
|
|
|
263 |
|
|
setup_xfail_format "DWARF 1"
|
264 |
|
|
gdb_test "print g_anon_union.a" ".* = 2" "print anonymous union member"
|
265 |
|
|
setup_xfail_format "DWARF 1"
|
266 |
|
|
send_gdb "print g_anon_union\n"
|
267 |
|
|
gdb_expect {
|
268 |
|
|
-re ".* = \{one = 1, ( = |)\{a = 2, b = 2\}\}$nl$gdb_prompt $" {
|
269 |
|
|
pass "print variable of type anonymous union"
|
270 |
|
|
}
|
271 |
|
|
-re ".* = .*\{one = 1, ( = |)\{a = 2, b = .*\}\}$nl$gdb_prompt $" {
|
272 |
|
|
pass "print variable of type anonymous union (obsolete gcc or gdb)"
|
273 |
|
|
}
|
274 |
|
|
-re ".*$nl$gdb_prompt $" {
|
275 |
|
|
fail "print variable of type anonymous union"
|
276 |
|
|
}
|
277 |
|
|
timeout {
|
278 |
|
|
fail "print variableof type anonymous union (timeout)"
|
279 |
|
|
}
|
280 |
|
|
}
|
281 |
|
|
setup_xfail_format "DWARF 1"
|
282 |
|
|
send_gdb "ptype g_anon_union\n"
|
283 |
|
|
gdb_expect {
|
284 |
|
|
-re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}public:${ws}int a;${ws}long int b;${ws}union \{\.\.\.\} & operator=\\(union \{\.\.\.\} &\\);${ws}\\\$_0 \\(union \{\.\.\.\} &\\);${ws}\\\$_0 \\(\\);${ws}\};${ws}class_with_anon_union & operator=\\(class_with_anon_union const &\\);${ws}class_with_anon_union\\(class_with_anon_union const &\\);${ws}class_with_anon_union\\(void\\);${ws}\}$nl$gdb_prompt $" {
|
285 |
|
|
pass "print type of anonymous union"
|
286 |
|
|
}
|
287 |
|
|
-re "type = (struct|class).*\{.*int one;.*union \{.*int a;.*(long|long int|int) b;.*\};.*\}$nl$gdb_prompt $" {
|
288 |
|
|
pass "print type of anonymous union (obsolete gcc or gdb)"
|
289 |
|
|
}
|
290 |
|
|
-re ".*$nl$gdb_prompt $" {
|
291 |
|
|
fail "print type of anonymous union"
|
292 |
|
|
}
|
293 |
|
|
timeout {
|
294 |
|
|
fail "print type of anonymous union (timeout)"
|
295 |
|
|
}
|
296 |
|
|
}
|
297 |
|
|
}
|
298 |
|
|
|
299 |
|
|
#
|
300 |
|
|
# Multiple inheritance, print individual members.
|
301 |
|
|
#
|
302 |
|
|
|
303 |
|
|
proc test_print_mi_members {} {
|
304 |
|
|
global gdb_prompt
|
305 |
|
|
global nl
|
306 |
|
|
global hp_aCC_compiler
|
307 |
|
|
|
308 |
|
|
# Print all members of g_A.
|
309 |
|
|
|
310 |
|
|
gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a"
|
311 |
|
|
|
312 |
|
|
gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x"
|
313 |
|
|
|
314 |
|
|
# Print all members of g_B.
|
315 |
|
|
|
316 |
|
|
gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a"
|
317 |
|
|
|
318 |
|
|
gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x"
|
319 |
|
|
|
320 |
|
|
gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b"
|
321 |
|
|
|
322 |
|
|
gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x"
|
323 |
|
|
|
324 |
|
|
# Print all members of g_C.
|
325 |
|
|
|
326 |
|
|
gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a"
|
327 |
|
|
|
328 |
|
|
gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x"
|
329 |
|
|
|
330 |
|
|
gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c"
|
331 |
|
|
|
332 |
|
|
gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x"
|
333 |
|
|
|
334 |
|
|
# Print all members of g_D.
|
335 |
|
|
|
336 |
|
|
# The following is ambiguous, and gdb should detect this.
|
337 |
|
|
# For now, accept gdb's behavior as an expected failure if it
|
338 |
|
|
# simply prints either member correctly.
|
339 |
|
|
|
340 |
|
|
if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
|
341 |
|
|
send_gdb "print g_D.A::a\n"
|
342 |
|
|
gdb_expect {
|
343 |
|
|
-re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 15$nl$gdb_prompt $" {
|
344 |
|
|
pass "print g_D.A::a"
|
345 |
|
|
}
|
346 |
|
|
-re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 11$nl$gdb_prompt $" {
|
347 |
|
|
pass "print g_D.A::a (using B)"
|
348 |
|
|
}
|
349 |
|
|
-re ".* = 15$nl$gdb_prompt $" {
|
350 |
|
|
fail "print g_D.A::a (FIXME)"
|
351 |
|
|
}
|
352 |
|
|
-re ".* = 11$nl$gdb_prompt $" {
|
353 |
|
|
fail "print g_D.A::a (FIXME)"
|
354 |
|
|
}
|
355 |
|
|
-re ".*$gdb_prompt $" { fail "print g_D.A::a" }
|
356 |
|
|
timeout { fail "print g_D.A::a (timeout)" ; return }
|
357 |
|
|
}
|
358 |
|
|
|
359 |
|
|
# The following is ambiguous, and gdb should detect this.
|
360 |
|
|
# For now, accept gdb's behavior as an expected failure if it
|
361 |
|
|
# simply prints either member correctly.
|
362 |
|
|
|
363 |
|
|
if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
|
364 |
|
|
send_gdb "print g_D.A::x\n"
|
365 |
|
|
gdb_expect {
|
366 |
|
|
-re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 16$nl$gdb_prompt $" {
|
367 |
|
|
pass "print g_D.A::x"
|
368 |
|
|
}
|
369 |
|
|
-re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 12$nl$gdb_prompt $" {
|
370 |
|
|
pass "print g_D.A::x (using B)"
|
371 |
|
|
}
|
372 |
|
|
-re ".* = 16$nl$gdb_prompt $" {
|
373 |
|
|
fail "print g_D.A::x (FIXME)"
|
374 |
|
|
}
|
375 |
|
|
-re ".* = 12$nl$gdb_prompt $" {
|
376 |
|
|
fail "print g_D.A::x (FIXME)"
|
377 |
|
|
}
|
378 |
|
|
-re ".*$gdb_prompt $" { fail "print g_D.A::x" }
|
379 |
|
|
timeout { fail "print g_D.A::x (timeout)" ; return }
|
380 |
|
|
}
|
381 |
|
|
|
382 |
|
|
gdb_test "print g_D.B::b" ".* = 13" "print g_D.B::b"
|
383 |
|
|
|
384 |
|
|
gdb_test "print g_D.B::x" ".* = 14" "print g_D.B::x"
|
385 |
|
|
|
386 |
|
|
setup_xfail_format "DWARF 1"
|
387 |
|
|
gdb_test "print g_D.C::c" ".* = 17" "print g_D.C::c"
|
388 |
|
|
|
389 |
|
|
setup_xfail_format "DWARF 1"
|
390 |
|
|
gdb_test "print g_D.C::x" ".* = 18" "print g_D.C::x"
|
391 |
|
|
|
392 |
|
|
gdb_test "print g_D.D::d" ".* = 19" "print g_D.D::d"
|
393 |
|
|
|
394 |
|
|
gdb_test "print g_D.D::x" ".* = 20" "print g_D.D::x"
|
395 |
|
|
|
396 |
|
|
# Print all members of g_E.
|
397 |
|
|
|
398 |
|
|
# The following is ambiguous, and gdb should detect this.
|
399 |
|
|
# For now, accept gdb's behavior as an expected failure if it
|
400 |
|
|
# simply prints either member correctly.
|
401 |
|
|
|
402 |
|
|
setup_xfail "*-*-*"
|
403 |
|
|
send_gdb "print g_E.A::a\n"
|
404 |
|
|
gdb_expect {
|
405 |
|
|
-re ".* = 21$nl$gdb_prompt $" {
|
406 |
|
|
fail "print g_E.A::a (FIXME)"
|
407 |
|
|
}
|
408 |
|
|
-re ".* = 25$nl$gdb_prompt $" {
|
409 |
|
|
fail "print g_E.A::a (FIXME)"
|
410 |
|
|
}
|
411 |
|
|
-re ".*$gdb_prompt $" { fail "print g_E.A::a" }
|
412 |
|
|
timeout { fail "print g_E.A::a (timeout)" ; return }
|
413 |
|
|
}
|
414 |
|
|
|
415 |
|
|
# The following is ambiguous, and gdb should detect this.
|
416 |
|
|
# For now, accept gdb's behavior as an expected failure if it
|
417 |
|
|
# simply prints either member correctly.
|
418 |
|
|
|
419 |
|
|
if {!$hp_aCC_compiler} {setup_xfail "*-*-*"}
|
420 |
|
|
send_gdb "print g_E.A::x\n"
|
421 |
|
|
gdb_expect {
|
422 |
|
|
-re "warning: A ambiguous; using E::D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 26$nl$gdb_prompt $" {
|
423 |
|
|
pass "print g_E.A::x"
|
424 |
|
|
}
|
425 |
|
|
-re "warning: A ambiguous; using E::D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 22$nl$gdb_prompt $" {
|
426 |
|
|
pass "print g_E.A::x (using B)"
|
427 |
|
|
}
|
428 |
|
|
-re ".* = 26$nl$gdb_prompt $" {
|
429 |
|
|
fail "print g_E.A::x (FIXME)"
|
430 |
|
|
}
|
431 |
|
|
-re ".* = 22$nl$gdb_prompt $" {
|
432 |
|
|
fail "print g_E.A::x (FIXME)"
|
433 |
|
|
}
|
434 |
|
|
-re ".*$gdb_prompt $" { fail "print g_E.A::x" }
|
435 |
|
|
timeout { fail "print g_E.A::x (timeout)" ; return }
|
436 |
|
|
}
|
437 |
|
|
|
438 |
|
|
gdb_test "print g_E.B::b" ".* = 23" "print g_E.B::b"
|
439 |
|
|
|
440 |
|
|
gdb_test "print g_E.B::x" ".* = 24" "print g_E.B::x"
|
441 |
|
|
|
442 |
|
|
setup_xfail_format "DWARF 1"
|
443 |
|
|
gdb_test "print g_E.C::c" ".* = 27" "print g_E.C::c"
|
444 |
|
|
|
445 |
|
|
setup_xfail_format "DWARF 1"
|
446 |
|
|
gdb_test "print g_E.C::x" ".* = 28" "print g_E.C::x"
|
447 |
|
|
|
448 |
|
|
gdb_test "print g_E.D::d" ".* = 29" "print g_E.D::d"
|
449 |
|
|
|
450 |
|
|
gdb_test "print g_E.D::x" ".* = 30" "print g_E.D::x"
|
451 |
|
|
|
452 |
|
|
gdb_test "print g_E.E::e" ".* = 31" "print g_E.E::e"
|
453 |
|
|
|
454 |
|
|
gdb_test "print g_E.E::x" ".* = 32" "print g_E.E::x"
|
455 |
|
|
}
|
456 |
|
|
|
457 |
|
|
#
|
458 |
|
|
# Multiple inheritance, print type definitions.
|
459 |
|
|
#
|
460 |
|
|
|
461 |
|
|
proc test_ptype_mi {} {
|
462 |
|
|
global nl
|
463 |
|
|
|
464 |
|
|
setup_xfail_format "DWARF 1"
|
465 |
|
|
gdb_test "ptype D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype D"
|
466 |
|
|
|
467 |
|
|
setup_xfail_format "DWARF 1"
|
468 |
|
|
gdb_test "ptype class D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype class D"
|
469 |
|
|
|
470 |
|
|
setup_xfail_format "DWARF 1"
|
471 |
|
|
gdb_test "ptype g_D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype g_D"
|
472 |
|
|
|
473 |
|
|
setup_xfail_format "DWARF 1"
|
474 |
|
|
gdb_test "ptype E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype E"
|
475 |
|
|
|
476 |
|
|
setup_xfail_format "DWARF 1"
|
477 |
|
|
gdb_test "ptype class E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype class E"
|
478 |
|
|
|
479 |
|
|
setup_xfail_format "DWARF 1"
|
480 |
|
|
gdb_test "ptype g_E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype g_E"
|
481 |
|
|
}
|
482 |
|
|
|
483 |
|
|
#
|
484 |
|
|
# Multiple inheritance, print complete classes.
|
485 |
|
|
#
|
486 |
|
|
|
487 |
|
|
proc test_print_mi_classes {} {
|
488 |
|
|
# Print all members of g_D.
|
489 |
|
|
|
490 |
|
|
setup_xfail_format "DWARF 1"
|
491 |
|
|
gdb_test "print g_D" ".* = \{\<(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\}" "print g_D"
|
492 |
|
|
|
493 |
|
|
# Print all members of g_E.
|
494 |
|
|
|
495 |
|
|
setup_xfail_format "DWARF 1"
|
496 |
|
|
gdb_test "print g_E" ".* = \{\<(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\}" "print g_E"
|
497 |
|
|
}
|
498 |
|
|
|
499 |
|
|
#
|
500 |
|
|
# Single virtual inheritance, print individual members.
|
501 |
|
|
#
|
502 |
|
|
|
503 |
|
|
proc test_print_svi_members {} {
|
504 |
|
|
global gdb_prompt
|
505 |
|
|
global decimal
|
506 |
|
|
global nl
|
507 |
|
|
|
508 |
|
|
# Print all members of g_vA.
|
509 |
|
|
|
510 |
|
|
gdb_test "print g_vA.vA::va" ".* = 1" "print g_vA.vA::va"
|
511 |
|
|
|
512 |
|
|
gdb_test "print g_vA.vA::vx" ".* = 2" "print g_vA.vA::vx"
|
513 |
|
|
|
514 |
|
|
# Print members of g_vA using compact form.
|
515 |
|
|
|
516 |
|
|
gdb_test "print g_vA.va" ".* = 1" "print g_vA.va"
|
517 |
|
|
|
518 |
|
|
gdb_test "print g_vA.vx" ".* = 2" "print g_vA.vx"
|
519 |
|
|
|
520 |
|
|
# Print all members of g_vB.
|
521 |
|
|
|
522 |
|
|
setup_xfail_format "DWARF 1"
|
523 |
|
|
send_gdb "print g_vB.vA::va\n"
|
524 |
|
|
gdb_expect {
|
525 |
|
|
-re ".* = 3$nl$gdb_prompt $" { pass "print g_vB.vA::va" }
|
526 |
|
|
-re ".*virtual baseclass botch.*$gdb_prompt $" {
|
527 |
|
|
# Does not happen with gcc cygnus-2.4.5-930828
|
528 |
|
|
fail "print g_vB.vA::va (known bug with gcc cygnus-2.4.5-930417)"
|
529 |
|
|
# Many of the rest of these tests have the same problem.
|
530 |
|
|
return 0
|
531 |
|
|
}
|
532 |
|
|
-re ".*$gdb_prompt $" { fail "print g_vB.vA::va" }
|
533 |
|
|
timeout { fail "print g_vB.vA::va (timeout)" ; return }
|
534 |
|
|
}
|
535 |
|
|
|
536 |
|
|
setup_xfail_format "DWARF 1"
|
537 |
|
|
gdb_test "print g_vB.vA::vx" ".* = 4" "print g_vB.vA::vx"
|
538 |
|
|
|
539 |
|
|
gdb_test "print g_vB.vB::vb" ".* = 5" "print g_vB.vB::vb"
|
540 |
|
|
|
541 |
|
|
gdb_test "print g_vB.vB::vx" ".* = 6" "print g_vB.vB::vx"
|
542 |
|
|
|
543 |
|
|
# Print members of g_vB using compact form.
|
544 |
|
|
|
545 |
|
|
setup_xfail_format "DWARF 1"
|
546 |
|
|
gdb_test "print g_vB.va" ".* = 3" "print g_vB.va"
|
547 |
|
|
|
548 |
|
|
gdb_test "print g_vB.vb" ".* = 5" "print g_vB.vb"
|
549 |
|
|
|
550 |
|
|
gdb_test "print g_vB.vx" ".* = 6" "print g_vB.vx"
|
551 |
|
|
|
552 |
|
|
# Print all members of g_vC.
|
553 |
|
|
|
554 |
|
|
setup_xfail_format "DWARF 1"
|
555 |
|
|
gdb_test "print g_vC.vA::va" ".* = 7" "print g_vC.vA::va"
|
556 |
|
|
|
557 |
|
|
setup_xfail_format "DWARF 1"
|
558 |
|
|
gdb_test "print g_vC.vA::vx" ".* = 8" "print g_vC.vA::vx"
|
559 |
|
|
|
560 |
|
|
gdb_test "print g_vC.vC::vc" ".* = 9" "print g_vC.vC::vc"
|
561 |
|
|
|
562 |
|
|
gdb_test "print g_vC.vC::vx" ".* = 10" "print g_vC.vC::vx"
|
563 |
|
|
|
564 |
|
|
# Print members of g_vC using compact form.
|
565 |
|
|
|
566 |
|
|
setup_xfail_format "DWARF 1"
|
567 |
|
|
gdb_test "print g_vC.va" ".* = 7" "print g_vC.va"
|
568 |
|
|
|
569 |
|
|
gdb_test "print g_vC.vc" ".* = 9" "print g_vC.vc"
|
570 |
|
|
|
571 |
|
|
gdb_test "print g_vC.vx" ".* = 10" "print g_vC.vx"
|
572 |
|
|
}
|
573 |
|
|
|
574 |
|
|
#
|
575 |
|
|
# Single virtual inheritance, print type definitions.
|
576 |
|
|
#
|
577 |
|
|
|
578 |
|
|
proc test_ptype_vi {} {
|
579 |
|
|
global gdb_prompt
|
580 |
|
|
global ws
|
581 |
|
|
global nl
|
582 |
|
|
global vbptr
|
583 |
|
|
|
584 |
|
|
# This class does not use any C++-specific features, so it's fine for
|
585 |
|
|
# it to print as "struct".
|
586 |
|
|
send_gdb "ptype vA\n"
|
587 |
|
|
gdb_expect {
|
588 |
|
|
-re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
589 |
|
|
pass "ptype vA"
|
590 |
|
|
}
|
591 |
|
|
-re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
|
592 |
|
|
pass "ptype vA"
|
593 |
|
|
}
|
594 |
|
|
-re ".*$gdb_prompt $" { fail "ptype vA" }
|
595 |
|
|
timeout { fail "ptype vA (timeout)" ; return }
|
596 |
|
|
}
|
597 |
|
|
|
598 |
|
|
# This class does not use any C++-specific features, so it's fine for
|
599 |
|
|
# it to print as "struct".
|
600 |
|
|
send_gdb "ptype class vA\n"
|
601 |
|
|
gdb_expect {
|
602 |
|
|
-re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
603 |
|
|
pass "ptype class vA"
|
604 |
|
|
}
|
605 |
|
|
-re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
|
606 |
|
|
pass "ptype class vA"
|
607 |
|
|
}
|
608 |
|
|
-re ".*$gdb_prompt $" { fail "ptype class vA" }
|
609 |
|
|
timeout { fail "ptype class vA (timeout)" ; return }
|
610 |
|
|
}
|
611 |
|
|
|
612 |
|
|
# This class does not use any C++-specific features, so it's fine for
|
613 |
|
|
# it to print as "struct".
|
614 |
|
|
send_gdb "ptype g_vA\n"
|
615 |
|
|
gdb_expect {
|
616 |
|
|
-re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
617 |
|
|
pass "ptype g_vA"
|
618 |
|
|
}
|
619 |
|
|
-re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" {
|
620 |
|
|
pass "ptype g_vA"
|
621 |
|
|
}
|
622 |
|
|
-re ".*$gdb_prompt $" { fail "ptype g_vA" }
|
623 |
|
|
timeout { fail "ptype g_vA (timeout)" ; return }
|
624 |
|
|
}
|
625 |
|
|
|
626 |
|
|
setup_xfail_format "DWARF 1"
|
627 |
|
|
send_gdb "ptype vB\n"
|
628 |
|
|
gdb_expect {
|
629 |
|
|
-re "ptype vB${nl}type = class vB : public virtual vA \{$nl private:${ws}vA \\*${vbptr}vA;$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" {
|
630 |
|
|
pass "ptype vB"
|
631 |
|
|
}
|
632 |
|
|
-re "ptype vB${nl}type = class vB : public virtual vA \{$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" {
|
633 |
|
|
pass "ptype vB (aCC)"
|
634 |
|
|
}
|
635 |
|
|
-re ".*$gdb_prompt $" { fail "ptype vB" }
|
636 |
|
|
timeout { fail "ptype vB (timeout)" }
|
637 |
|
|
}
|
638 |
|
|
|
639 |
|
|
setup_xfail_format "DWARF 1"
|
640 |
|
|
send_gdb "ptype class vB\n"
|
641 |
|
|
gdb_expect {
|
642 |
|
|
-re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
643 |
|
|
pass "ptype class vB"
|
644 |
|
|
}
|
645 |
|
|
-re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
646 |
|
|
pass "ptype class vB (aCC)"
|
647 |
|
|
}
|
648 |
|
|
-re ".*$gdb_prompt $" { fail "ptype class vB" }
|
649 |
|
|
timeout { fail "ptype class vB (timeout)" }
|
650 |
|
|
}
|
651 |
|
|
|
652 |
|
|
setup_xfail_format "DWARF 1"
|
653 |
|
|
send_gdb "ptype g_vB\n"
|
654 |
|
|
gdb_expect {
|
655 |
|
|
-re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
656 |
|
|
pass "ptype g_vB"
|
657 |
|
|
}
|
658 |
|
|
-re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
659 |
|
|
pass "ptype g_vB (aCC)"
|
660 |
|
|
}
|
661 |
|
|
-re ".*$gdb_prompt $" { fail "ptype g_vB" }
|
662 |
|
|
timeout { fail "ptype g_vB (timeout)" }
|
663 |
|
|
}
|
664 |
|
|
|
665 |
|
|
setup_xfail_format "DWARF 1"
|
666 |
|
|
send_gdb "ptype vC\n"
|
667 |
|
|
gdb_expect {
|
668 |
|
|
-re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
669 |
|
|
pass "ptype vC"
|
670 |
|
|
}
|
671 |
|
|
-re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
672 |
|
|
pass "ptype vC (aCC)"
|
673 |
|
|
}
|
674 |
|
|
-re ".*$gdb_prompt $" { fail "ptype vC" }
|
675 |
|
|
timeout { fail "ptype vC (timeout)" }
|
676 |
|
|
}
|
677 |
|
|
|
678 |
|
|
setup_xfail_format "DWARF 1"
|
679 |
|
|
send_gdb "ptype class vC\n"
|
680 |
|
|
gdb_expect {
|
681 |
|
|
-re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
682 |
|
|
pass "ptype class vC"
|
683 |
|
|
}
|
684 |
|
|
-re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
685 |
|
|
pass "ptype class vC (aCC)"
|
686 |
|
|
}
|
687 |
|
|
-re ".*$gdb_prompt $" { fail "ptype class vC" }
|
688 |
|
|
timeout { fail "ptype class vC (timeout)" }
|
689 |
|
|
}
|
690 |
|
|
|
691 |
|
|
setup_xfail_format "DWARF 1"
|
692 |
|
|
send_gdb "ptype g_vC\n"
|
693 |
|
|
gdb_expect {
|
694 |
|
|
-re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
695 |
|
|
pass "ptype g_vC"
|
696 |
|
|
}
|
697 |
|
|
-re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" {
|
698 |
|
|
pass "ptype g_vC (aCC)"
|
699 |
|
|
}
|
700 |
|
|
-re ".*$gdb_prompt $" { fail "ptype g_vC" }
|
701 |
|
|
timeout { fail "ptype g_vC (timeout)" }
|
702 |
|
|
}
|
703 |
|
|
}
|
704 |
|
|
|
705 |
|
|
#
|
706 |
|
|
# Single virtual inheritance, print complete classes.
|
707 |
|
|
#
|
708 |
|
|
|
709 |
|
|
proc test_print_svi_classes {} {
|
710 |
|
|
global gdb_prompt
|
711 |
|
|
global hex
|
712 |
|
|
global decimal
|
713 |
|
|
global nl
|
714 |
|
|
global vbptr
|
715 |
|
|
|
716 |
|
|
# Print all members of g_vA.
|
717 |
|
|
|
718 |
|
|
gdb_test "print g_vA" ".* = \{va = 1, vx = 2\}" "print g_vA"
|
719 |
|
|
|
720 |
|
|
# Print all members of g_vB.
|
721 |
|
|
|
722 |
|
|
setup_xfail_format "DWARF 1"
|
723 |
|
|
send_gdb "print g_vB\n"
|
724 |
|
|
gdb_expect {
|
725 |
|
|
-re ".* = \{\ = \{va = 3, vx = 4\}, vb = 5, vx = 6, Virtual table at $hex\}$nl$gdb_prompt $" {
|
726 |
|
|
pass "print g_vB (aCC)"
|
727 |
|
|
}
|
728 |
|
|
-re ".* = \{\ = \{va = 3, vx = 4\}, vb = 5, vx = 6, __vfp = $hex\}$nl$gdb_prompt $" {
|
729 |
|
|
pass "print g_vB (aCC)"
|
730 |
|
|
}
|
731 |
|
|
-re ".* = \{\ = \{va = 3, vx = 4\}, ${vbptr}vA = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
|
732 |
|
|
pass "print g_vB"
|
733 |
|
|
}
|
734 |
|
|
-re ".*invalid address 0x0.*$gdb_prompt $" {
|
735 |
|
|
# Does not happen with gcc cygnus-2.4.5-930828
|
736 |
|
|
fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)"
|
737 |
|
|
# Many of the rest of these tests have the same problem.
|
738 |
|
|
return 0
|
739 |
|
|
}
|
740 |
|
|
-re ".*$gdb_prompt $" { fail "print g_vB" }
|
741 |
|
|
timeout { fail "print g_vB (timeout)" ; return }
|
742 |
|
|
}
|
743 |
|
|
|
744 |
|
|
# Print all members of g_vC.
|
745 |
|
|
|
746 |
|
|
setup_xfail_format "DWARF 1"
|
747 |
|
|
send_gdb "print g_vC\n"
|
748 |
|
|
gdb_expect {
|
749 |
|
|
-re ".* = \{\ = \{va = 7, vx = 8\}, vc = 9, vx = 10, Virtual table at $hex\}$nl$gdb_prompt $" {
|
750 |
|
|
pass "print g_vC (aCC)"
|
751 |
|
|
}
|
752 |
|
|
-re ".* = \{\ = \{va = 7, vx = 8\}, vc = 9, vx = 10, __vfp = $hex\}$nl$gdb_prompt $" {
|
753 |
|
|
pass "print g_vC (aCC)"
|
754 |
|
|
}
|
755 |
|
|
-re ".* = \{\ = \{va = 7, vx = 8\}, ${vbptr}vA = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
|
756 |
|
|
pass "print g_vC"
|
757 |
|
|
}
|
758 |
|
|
-re ".*$gdb_prompt $" { fail "print g_vC" }
|
759 |
|
|
timeout { fail "print g_vC (timeout)" }
|
760 |
|
|
}
|
761 |
|
|
}
|
762 |
|
|
|
763 |
|
|
#
|
764 |
|
|
# Multiple virtual inheritance, print individual members.
|
765 |
|
|
#
|
766 |
|
|
|
767 |
|
|
proc test_print_mvi_members {} {
|
768 |
|
|
global gdb_prompt
|
769 |
|
|
global decimal
|
770 |
|
|
global nl
|
771 |
|
|
|
772 |
|
|
# Print all members of g_vD.
|
773 |
|
|
|
774 |
|
|
setup_xfail_format "DWARF 1"
|
775 |
|
|
send_gdb "print g_vD.vA::va\n"
|
776 |
|
|
gdb_expect {
|
777 |
|
|
-re ".* = 19$nl$gdb_prompt $" { pass "print g_vD.vA::va" }
|
778 |
|
|
-re ".*virtual baseclass botch.*$gdb_prompt $" {
|
779 |
|
|
# Does not happen with gcc cygnus-2.4.5-930828
|
780 |
|
|
fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)"
|
781 |
|
|
# Many of the rest of these tests have the same problem.
|
782 |
|
|
return 0
|
783 |
|
|
}
|
784 |
|
|
-re ".*$gdb_prompt $" { fail "print g_vD.vA::va" }
|
785 |
|
|
timeout { fail "print g_vD.vA::va (timeout)" ; return }
|
786 |
|
|
}
|
787 |
|
|
|
788 |
|
|
setup_xfail_format "DWARF 1"
|
789 |
|
|
gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx"
|
790 |
|
|
|
791 |
|
|
setup_xfail_format "DWARF 1"
|
792 |
|
|
gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb"
|
793 |
|
|
|
794 |
|
|
setup_xfail_format "DWARF 1"
|
795 |
|
|
gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx"
|
796 |
|
|
|
797 |
|
|
setup_xfail_format "DWARF 1"
|
798 |
|
|
gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc"
|
799 |
|
|
|
800 |
|
|
setup_xfail_format "DWARF 1"
|
801 |
|
|
gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx"
|
802 |
|
|
|
803 |
|
|
gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd"
|
804 |
|
|
|
805 |
|
|
gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx"
|
806 |
|
|
|
807 |
|
|
# Print all members of g_vE.
|
808 |
|
|
|
809 |
|
|
setup_xfail_format "DWARF 1"
|
810 |
|
|
gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va"
|
811 |
|
|
|
812 |
|
|
setup_xfail_format "DWARF 1"
|
813 |
|
|
gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx"
|
814 |
|
|
|
815 |
|
|
setup_xfail_format "DWARF 1"
|
816 |
|
|
gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb"
|
817 |
|
|
|
818 |
|
|
setup_xfail_format "DWARF 1"
|
819 |
|
|
gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx"
|
820 |
|
|
|
821 |
|
|
setup_xfail_format "DWARF 1"
|
822 |
|
|
gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc"
|
823 |
|
|
|
824 |
|
|
setup_xfail_format "DWARF 1"
|
825 |
|
|
gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx"
|
826 |
|
|
|
827 |
|
|
setup_xfail_format "DWARF 1"
|
828 |
|
|
gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd"
|
829 |
|
|
|
830 |
|
|
gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx"
|
831 |
|
|
|
832 |
|
|
gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve"
|
833 |
|
|
|
834 |
|
|
gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx"
|
835 |
|
|
}
|
836 |
|
|
|
837 |
|
|
#
|
838 |
|
|
# Multiple virtual inheritance, print type definitions.
|
839 |
|
|
#
|
840 |
|
|
|
841 |
|
|
proc test_ptype_mvi {} {
|
842 |
|
|
global gdb_prompt
|
843 |
|
|
global ws
|
844 |
|
|
global nl
|
845 |
|
|
global vbptr
|
846 |
|
|
|
847 |
|
|
setup_xfail_format "DWARF 1"
|
848 |
|
|
send_gdb "ptype vD\n"
|
849 |
|
|
gdb_expect {
|
850 |
|
|
-re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
|
851 |
|
|
pass "ptype vD"
|
852 |
|
|
}
|
853 |
|
|
-re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
|
854 |
|
|
pass "ptype vD"
|
855 |
|
|
}
|
856 |
|
|
-re ".*$gdb_prompt $" { fail "ptype vD" }
|
857 |
|
|
timeout { fail "(timeout) ptype vD" }
|
858 |
|
|
}
|
859 |
|
|
|
860 |
|
|
setup_xfail_format "DWARF 1"
|
861 |
|
|
send_gdb "ptype class vD\n"
|
862 |
|
|
gdb_expect {
|
863 |
|
|
-re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
|
864 |
|
|
pass "ptype class vD"
|
865 |
|
|
}
|
866 |
|
|
-re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" {
|
867 |
|
|
pass "ptype class vD"
|
868 |
|
|
}
|
869 |
|
|
-re ".*$gdb_prompt $" { fail "ptype class vD" }
|
870 |
|
|
timeout { fail "(timeout) ptype class vD" }
|
871 |
|
|
}
|
872 |
|
|
|
873 |
|
|
setup_xfail_format "DWARF 1"
|
874 |
|
|
send_gdb "ptype g_vD\n"
|
875 |
|
|
gdb_expect {
|
876 |
|
|
-re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
|
877 |
|
|
pass "ptype g_vD"
|
878 |
|
|
}
|
879 |
|
|
-re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
|
880 |
|
|
pass "ptype g_vD"
|
881 |
|
|
}
|
882 |
|
|
-re ".*$gdb_prompt $" { fail "ptype g_vD" }
|
883 |
|
|
timeout { fail "(timeout) ptype g_vD" }
|
884 |
|
|
}
|
885 |
|
|
|
886 |
|
|
setup_xfail_format "DWARF 1"
|
887 |
|
|
send_gdb "ptype vE\n"
|
888 |
|
|
gdb_expect {
|
889 |
|
|
-re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
|
890 |
|
|
pass "ptype vE"
|
891 |
|
|
}
|
892 |
|
|
-re ".*class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
|
893 |
|
|
pass "ptype vE"
|
894 |
|
|
}
|
895 |
|
|
-re ".*$gdb_prompt $" { fail "ptype vE" }
|
896 |
|
|
timeout { fail "(timeout) ptype vE" }
|
897 |
|
|
}
|
898 |
|
|
|
899 |
|
|
setup_xfail_format "DWARF 1"
|
900 |
|
|
send_gdb "ptype class vE\n"
|
901 |
|
|
gdb_expect {
|
902 |
|
|
-re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
|
903 |
|
|
pass "ptype class vE"
|
904 |
|
|
}
|
905 |
|
|
-re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
|
906 |
|
|
pass "ptype class vE"
|
907 |
|
|
}
|
908 |
|
|
-re ".*$gdb_prompt $" { fail "ptype class vE" }
|
909 |
|
|
timeout { fail "(timeout) ptype class vE" }
|
910 |
|
|
}
|
911 |
|
|
|
912 |
|
|
setup_xfail_format "DWARF 1"
|
913 |
|
|
send_gdb "ptype g_vE\n"
|
914 |
|
|
gdb_expect {
|
915 |
|
|
-re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" {
|
916 |
|
|
pass "ptype g_vE"
|
917 |
|
|
}
|
918 |
|
|
-re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" {
|
919 |
|
|
pass "ptype g_vE"
|
920 |
|
|
}
|
921 |
|
|
-re ".*$gdb_prompt $" { fail "ptype g_vE" }
|
922 |
|
|
timeout { fail "(timeout) ptype g_vE" }
|
923 |
|
|
}
|
924 |
|
|
}
|
925 |
|
|
|
926 |
|
|
#
|
927 |
|
|
# Multiple virtual inheritance, print complete classes.
|
928 |
|
|
#
|
929 |
|
|
|
930 |
|
|
proc test_print_mvi_classes {} {
|
931 |
|
|
global gdb_prompt
|
932 |
|
|
global hex
|
933 |
|
|
global decimal
|
934 |
|
|
global nl
|
935 |
|
|
global vbptr
|
936 |
|
|
|
937 |
|
|
# Print all members of g_vD.
|
938 |
|
|
|
939 |
|
|
setup_xfail_format "DWARF 1"
|
940 |
|
|
send_gdb "print g_vD\n"
|
941 |
|
|
gdb_expect {
|
942 |
|
|
-re ".* = \{\ = \{\ = \{va = 19, vx = 20\}, vb = 21, vx = 22, Virtual table at $hex\}, \ = \{vc = 23, vx = 24, Virtual table at $hex\}, vd = 25, vx = 26, Virtual table at $hex\}$nl$gdb_prompt $" {
|
943 |
|
|
pass "print g_vD (aCC)"
|
944 |
|
|
}
|
945 |
|
|
-re ".* = \{\ = \{\ = \{va = 19, vx = 20\}, vb = 21, vx = 22, __vfp = $hex\}, \ = \{vc = 23, vx = 24, __vfp = $hex\}, vd = 25, vx = 26, __vfp = $hex\}$nl$gdb_prompt $" {
|
946 |
|
|
pass "print g_vD (aCC)"
|
947 |
|
|
}
|
948 |
|
|
-re ".* = \{\ = \{\ = \{va = 19, vx = 20\}, ${vbptr}vA = $hex, vb = 21, vx = 22\}, \ = \{${vbptr}vA = $hex, vc = 23, vx = 24\}, ${vbptr}vC = $hex, ${vbptr}vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
|
949 |
|
|
pass "print g_vD"
|
950 |
|
|
}
|
951 |
|
|
-re ".*invalid address 0x0.*$gdb_prompt $" {
|
952 |
|
|
# Does not happen with gcc cygnus-2.4.5-930828
|
953 |
|
|
fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)"
|
954 |
|
|
# Many of the rest of these tests have the same problem.
|
955 |
|
|
return 0
|
956 |
|
|
}
|
957 |
|
|
-re ".*$gdb_prompt $" { fail "print g_vD" }
|
958 |
|
|
timeout { fail "print g_vD (timeout)" ; return }
|
959 |
|
|
}
|
960 |
|
|
|
961 |
|
|
# Print all members of g_vE.
|
962 |
|
|
|
963 |
|
|
setup_xfail_format "DWARF 1"
|
964 |
|
|
send_gdb "print g_vE\n"
|
965 |
|
|
gdb_expect {
|
966 |
|
|
-re ".* = \{\ = \{\ = \{\ = \{va = 0, vx = 0\}, vb = 0, vx = 0, Virtual table at $hex\}, \ = \{vc = 0, vx = 0, Virtual table at $hex\}, vd = 0, vx = 0, Virtual table at $hex\}, ve = 27, vx = 28, Virtual table at $hex\}$nl$gdb_prompt $" {
|
967 |
|
|
pass "print g_vE (aCC)"
|
968 |
|
|
}
|
969 |
|
|
-re ".* = \{\ = \{\ = \{\ = \{va = 0, vx = 0\}, vb = 0, vx = 0, __vfp = $hex\}, \ = \{vc = 0, vx = 0, __vfp = $hex\}, vd = 0, vx = 0, __vfp = $hex\}, ve = 27, vx = 28, __vfp = $hex\}$nl$gdb_prompt $" {
|
970 |
|
|
pass "print g_vE (aCC)"
|
971 |
|
|
}
|
972 |
|
|
-re ".* = \{\ = \{\ = \{\ = \{va = 0, vx = 0\}, ${vbptr}vA = $hex, vb = 0, vx = 0\}, \ = \{${vbptr}vA = $hex, vc = 0, vx = 0\}, ${vbptr}vC = $hex, ${vbptr}vB = $hex, vd = 0, vx = 0\}, ${vbptr}vD = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
|
973 |
|
|
pass "print g_vE"
|
974 |
|
|
}
|
975 |
|
|
-re ".*$gdb_prompt $" { fail "print g_vE" }
|
976 |
|
|
timeout { fail "print g_vE (timeout)" }
|
977 |
|
|
}
|
978 |
|
|
}
|
979 |
|
|
|
980 |
|
|
proc do_tests {} {
|
981 |
|
|
global prms_id
|
982 |
|
|
global bug_id
|
983 |
|
|
global subdir
|
984 |
|
|
global objdir
|
985 |
|
|
global srcdir
|
986 |
|
|
global binfile
|
987 |
|
|
|
988 |
|
|
set prms_id 0
|
989 |
|
|
set bug_id 0
|
990 |
|
|
|
991 |
|
|
# Start with a fresh gdb.
|
992 |
|
|
|
993 |
|
|
gdb_exit
|
994 |
|
|
gdb_start
|
995 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
996 |
|
|
gdb_load $binfile
|
997 |
|
|
|
998 |
|
|
gdb_test "set language c++" ""
|
999 |
|
|
gdb_test "set width 0" ""
|
1000 |
|
|
|
1001 |
|
|
# Get the debug format for the compiled test case.
|
1002 |
|
|
|
1003 |
|
|
if { ![ runto_main] } {
|
1004 |
|
|
gdb_suppress_tests;
|
1005 |
|
|
} else {
|
1006 |
|
|
get_debug_format
|
1007 |
|
|
}
|
1008 |
|
|
|
1009 |
|
|
test_ptype_si
|
1010 |
|
|
test_ptype_mi
|
1011 |
|
|
test_ptype_vi
|
1012 |
|
|
test_ptype_mvi
|
1013 |
|
|
|
1014 |
|
|
gdb_stop_suppressing_tests;
|
1015 |
|
|
|
1016 |
|
|
if { ![ runto 'inheritance2' ] } {
|
1017 |
|
|
gdb_suppress_tests;
|
1018 |
|
|
}
|
1019 |
|
|
|
1020 |
|
|
test_print_si_members
|
1021 |
|
|
test_print_si_classes
|
1022 |
|
|
test_print_mi_members
|
1023 |
|
|
test_print_mi_classes
|
1024 |
|
|
test_print_anon_union
|
1025 |
|
|
|
1026 |
|
|
gdb_stop_suppressing_tests;
|
1027 |
|
|
|
1028 |
|
|
if { ![ runto 'inheritance4' ] } {
|
1029 |
|
|
gdb_suppress_tests;
|
1030 |
|
|
}
|
1031 |
|
|
|
1032 |
|
|
test_print_svi_members
|
1033 |
|
|
test_print_svi_classes
|
1034 |
|
|
test_print_mvi_members
|
1035 |
|
|
test_print_mvi_classes
|
1036 |
|
|
}
|
1037 |
|
|
|
1038 |
|
|
do_tests
|