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