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