d0db7557fd143e0547b38d65d7d155c116778266
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.c++ / virtfunc.exp
1 # Copyright (C) 1992, 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
29 set testfile "virtfunc"
30 set srcfile ${testfile}.cc
31 set binfile ${objdir}/${subdir}/${testfile}
32
33 if [get_compiler_info ${binfile} "c++"] {
34 return -1
35 }
36
37 # if we are on HPUX and we are not compiled with gcc, then skip these tests.
38
39 if [istarget hppa*-*-hpux*] {
40 if {!$gcc_compiled} {
41 continue
42 }
43 }
44
45
46
47 # Check to see if we have an executable to test. If not, then either we
48 # haven't tried to compile one, or the compilation failed for some reason.
49 # In either case, just notify the user and skip the tests in this file.
50
51 set src "${srcdir}/${subdir}/${srcfile}"
52 if { [gdb_compile "${src}" "${binfile}" executable {c++ debug}] != "" } {
53 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
54 }
55
56 proc gdb_virtfunc_init {} {
57 global srcdir subdir binfile
58 global gdb_prompt
59
60 gdb_reinitialize_dir $srcdir/$subdir
61 gdb_load $binfile
62
63 send_gdb "set language c++\n"
64 gdb_expect -re "$gdb_prompt $"
65 send_gdb "set width 0\n"
66 gdb_expect -re "$gdb_prompt $"
67 }
68
69 proc gdb_virtfunc_restart {} {
70 gdb_exit;
71 gdb_start;
72 gdb_virtfunc_init;
73 runto 'test_calls(void)';
74 }
75
76 #
77 # Test printing of the types of various classes.
78 #
79
80 proc test_ptype_of_classes {} {
81 global gdb_prompt
82 global ws
83 global nl
84
85 # This used to be a fail if it printed "struct" not "class". But
86 # since this struct doesn't use any special C++ features, it is
87 # considered right for GDB to print it as "struct".
88 send_gdb "ptype VA\n"
89 gdb_expect {
90 -re "type = (struct|class) VA \{(${ws}public:|)${ws}int va;${ws}VA & operator=\\(VA const &\\);${ws}VA\\(VA const &\\);${ws}VA\\(void\\);${ws}\}.*$gdb_prompt $" {
91 pass "ptype VA"
92 }
93 -re "type = (struct|class) VA \{(${ws}public:|)${ws}int va;((${ws}VA & operator=\\(VA const &\\);)|(${ws}VA\\(VA const &\\);)|(${ws}VA\\(void\\);))*${ws}\}.*$gdb_prompt $" {
94 pass "ptype VA (obsolescent gcc or gdb)"
95 }
96 -re ".*$gdb_prompt $" {
97 fail "ptype VA"
98 }
99 timeout {
100 fail "ptype VA (timeout)"
101 }
102 }
103
104 send_gdb "ptype VB\n"
105 gdb_expect {
106 -re "type = class VB \{${ws}public:${ws}int vb;${ws}VB & operator=\\(VB const &\\);${ws}VB\\(VB const &\\);${ws}VB\\(void\\);${ws}int fvb\\(void\\);${ws}virtual int vvb\\(void\\);${ws}\}.*$gdb_prompt $" {
107 pass "ptype VB"
108 }
109 -re "type = class VB \{${ws}public:${ws}int vb;((${ws}VB & operator=\\(VB const &\\);)|(${ws}VB\\(VB const &\\);)|(${ws}VB\\(void\\);)|(${ws}int fvb\\(void\\);)|(${ws}virtual int vvb\\(void\\);))*${ws}\}.*$gdb_prompt $" {
110 pass "ptype VB (obsolescent gcc or gdb)"
111 }
112 -re ".*$gdb_prompt $" {
113 fail "ptype VB"
114 }
115 timeout {
116 fail "ptype VB (timeout)"
117 }
118 }
119
120 send_gdb "ptype V\n"
121 gdb_expect {
122 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const &\\);${ws}V\\(V const &\\);${ws}V\\(void\\);${ws}int f\\(void\\);${ws}virtual int vv\\(void\\);${ws}\}$nl$gdb_prompt $" {
123 pass "ptype V"
124 }
125 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const &\\);)|(${ws}V\\(V const &\\);)|(${ws}V\\(void\\);)|(${ws}int f\\(void\\);)|(${ws}virtual int vv\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
126 pass "ptype V (obsolescent gcc or gdb)"
127 }
128 -re ".*$gdb_prompt $" {
129 fail "ptype V"
130 }
131 timeout {
132 fail "ptype V (timeout)"
133 }
134 }
135
136 send_gdb "ptype A\n"
137 gdb_expect {
138 -re "type = class A : public virtual V \{${ws}private:${ws}V \[*\]+_vb\[\\\$\.\]+V;${ws}int a;${ws}public:${ws}A & operator=\\(A const &\\);${ws}A\\(int, A const &\\);${ws}A\\(int\\);${ws}virtual int f\\(void\\);${ws}\}$nl$gdb_prompt $" {
139 pass "ptype A"
140 }
141 -re "type = class A : public virtual V \{${ws}private:${ws}V \[*\]+_vb\[\\\$\.\]+V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const &\\);)|(${ws}A\\(int, A const &\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
142 pass "ptype A (obsolescent gcc or gdb)"
143 }
144 -re "type = class A : public virtual V \{${ws}private:${ws}V \[*\]+_vb.FOO;${ws}int a;${ws}public:${ws}virtual int f.void.;${ws}\}$nl$gdb_prompt $" {
145 # This happens because the type is defined only after it is
146 # too late.
147 fail "ptype A (known failure with gcc cygnus-2.4.5-930417)"
148 # Many of the rest of these tests have the same problem.
149 return 0
150 }
151 -re ".*$gdb_prompt $" {
152 fail "ptype A"
153 }
154 timeout {
155 fail "ptype A (timeout)"
156 }
157 }
158
159 send_gdb "ptype B\n"
160 gdb_expect {
161 -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const &\\);${ws}B\\(int, B const &\\);${ws}B\\(int\\);${ws}virtual int f\\(void\\);${ws}\}$nl$gdb_prompt $" {
162 pass "ptype B"
163 }
164 -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:((${ws}B & operator=\\(B const &\\);)|(${ws}B\\(int, B const &\\);)|(${ws}B\\(int\\);)|(${ws}virtual int f\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
165 pass "ptype B (obsolescent gcc or gdb)"
166 }
167 -re ".*$gdb_prompt $" {
168 fail "ptype B"
169 }
170 timeout {
171 fail "ptype B (timeout)"
172 }
173 }
174
175 send_gdb "ptype C\n"
176 gdb_expect {
177 -re "type = class C : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int c;${ws}C & operator=\\(C const &\\);${ws}C\\(int, C const &\\);${ws}C\\(int\\);${ws}\}$nl$gdb_prompt $" {
178 pass "ptype C"
179 }
180 -re "type = class C : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int c;((${ws}C & operator=\\(C const &\\);)|(${ws}C\\(int, C const &\\);)|(${ws}C\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
181 pass "ptype C (obsolescent gcc or gdb)"
182 }
183 -re ".*$gdb_prompt $" {
184 fail "ptype C"
185 }
186 timeout {
187 fail "ptype C (timeout)"
188 }
189 }
190
191 send_gdb "ptype AD\n"
192 gdb_expect {
193 -re "type = class AD \{${ws}public:${ws}AD & operator=\\(AD const &\\);${ws}AD\\(AD const &\\);${ws}AD\\(void\\);${ws}virtual int vg\\(void\\);${ws}\}$nl$gdb_prompt $" {
194 pass "ptype AD"
195 }
196 -re "type = class AD \{${ws}public:((${ws}AD & operator=\\(AD const &\\);)|(${ws}AD\\(AD const &\\);)|(${ws}AD\\(void\\);)|(${ws}virtual int vg\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
197 pass "ptype AD (obsolescent gcc or gdb)"
198 }
199 -re ".*$gdb_prompt $" {
200 fail "ptype AD"
201 }
202 timeout {
203 fail "ptype AD (timeout)"
204 }
205 }
206
207 send_gdb "ptype D\n"
208 gdb_expect {
209 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;${ws}D & operator=\\(D const &\\);${ws}D\\(int, D const &\\);${ws}D\\(int\\);${ws}static void s\\(void\\);${ws}virtual int vg\\(void\\);${ws}virtual int vd\\(void\\);${ws}int fd\\(void\\);${ws}\}$nl$gdb_prompt $" {
210 pass "ptype D"
211 }
212 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const &\\);)|(${ws}D\\(int, D const &\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\(void\\);)|(${ws}virtual int vg\\(void\\);)|(${ws}virtual int vd\\(void\\);)|(${ws}int fd\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
213 pass "ptype D (obsolescent gcc or gdb)"
214 }
215 -re ".*$gdb_prompt $" {
216 fail "ptype D"
217 }
218 timeout {
219 fail "ptype D (timeout)"
220 }
221 }
222
223 send_gdb "ptype E\n"
224 gdb_expect {
225 -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const &\\);${ws}E\\(int, E const &\\);${ws}E\\(int\\);${ws}virtual int f\\(void\\);${ws}virtual int vg\\(void\\);${ws}virtual int vv\\(void\\);${ws}\}$nl$gdb_prompt $" {
226 pass "ptype E"
227 }
228 -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;((${ws}E & operator=\\(E const &\\);)|(${ws}E\\(int, E const &\\);)|(${ws}E\\(int\\);)|(${ws}virtual int f\\(void\\);)|(${ws}virtual int vg\\(void\\);)|(${ws}virtual int vv\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
229 pass "ptype E (obsolescent gcc or gdb)"
230 }
231 -re ".*$gdb_prompt $" {
232 fail "ptype E"
233 }
234 timeout {
235 fail "ptype E (timeout)"
236 }
237 }
238
239 send_gdb "ptype dd\n"
240 gdb_expect {
241 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;${ws}D & operator=\\(D const &\\);${ws}D\\(int, D const &\\);${ws}D\\(int\\);${ws}static void s\\(void\\);${ws}virtual int vg\\(void\\);${ws}virtual int vd\\(void\\);${ws}int fd\\(void\\);${ws}\}$nl$gdb_prompt $" {
242 pass "ptype dd"
243 }
244 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const &\\);)|(${ws}D\\(int, D const &\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\(void\\);)|(${ws}virtual int vg\\(void\\);)|(${ws}virtual int vd\\(void\\);)|(${ws}int fd\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
245 pass "ptype dd (obsolescent gcc or gdb)"
246 }
247 -re ".*$gdb_prompt $" {
248 fail "ptype dd"
249 }
250 timeout {
251 fail "ptype dd (timeout)"
252 }
253 }
254
255 send_gdb "ptype ppd\n"
256 gdb_expect {
257 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;${ws}D & operator=\\(D const &\\);${ws}D\\(int, D const &\\);${ws}D\\(int\\);${ws}static void s\\(void\\);${ws}virtual int vg\\(void\\);${ws}virtual int vd\\(void\\);${ws}int fd\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
258 pass "ptype ppd"
259 }
260 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const &\\);)|(${ws}D\\(int, D const &\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\(void\\);)|(${ws}virtual int vg\\(void\\);)|(${ws}virtual int vd\\(void\\);)|(${ws}int fd\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
261 pass "ptype ppd (obsolescent gcc or gdb)"
262 }
263 -re ".*$gdb_prompt $" {
264 fail "ptype ppd"
265 }
266 timeout {
267 fail "ptype ppd (timeout)"
268 }
269 }
270
271 send_gdb "ptype pAd\n"
272 gdb_expect {
273 -re "type = class AD \{${ws}public:${ws}AD & operator=\\(AD const &\\);${ws}AD\\(AD const &\\);${ws}AD\\(void\\);${ws}virtual int vg\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
274 pass "ptype pAd"
275 }
276 -re "type = class AD \{${ws}public:((${ws}AD & operator=\\(AD const &\\);)|(${ws}AD\\(AD const &\\);)|(${ws}AD\\(void\\);)|(${ws}virtual int vg\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
277 pass "ptype pAd (obsolescent gcc or gdb)"
278 }
279 -re ".*$gdb_prompt $" {
280 fail "ptype pAd"
281 }
282 timeout {
283 fail "ptype pAd (timeout)"
284 }
285 }
286
287 send_gdb "ptype a\n"
288 gdb_expect {
289 -re "type = class A : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}int a;${ws}public:${ws}A & operator=\\(A const &\\);${ws}A\\(int, A const &\\);${ws}A\\(int\\);${ws}virtual int f\\(void\\);${ws}\}$nl$gdb_prompt $" {
290 pass "ptype a"
291 }
292 -re "type = class A : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const &\\);)|(${ws}A\\(int, A const &\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
293 pass "ptype a (obsolescent gcc or gdb)"
294 }
295 -re ".*$gdb_prompt $" {
296 fail "ptype a"
297 }
298 timeout {
299 fail "ptype a (timeout)"
300 }
301 }
302
303 send_gdb "ptype b\n"
304 gdb_expect {
305 -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const &\\);${ws}B\\(int, B const &\\);${ws}B\\(int\\);${ws}virtual int f\\(void\\);${ws}\}$nl$gdb_prompt $" {
306 pass "ptype b"
307 }
308 -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:((${ws}B & operator=\\(B const &\\);)|(${ws}B\\(int, B const &\\);)|(${ws}B\\(int\\);)|(${ws}virtual int f\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
309 pass "ptype b (obsolescent gcc or gdb)"
310 }
311 -re ".*$gdb_prompt $" {
312 fail "ptype b"
313 }
314 timeout {
315 fail "ptype b (timeout)"
316 }
317 }
318
319 send_gdb "ptype c\n"
320 gdb_expect {
321 -re "type = class C : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int c;${ws}C & operator=\\(C const &\\);${ws}C\\(int, C const &\\);${ws}C\\(int\\);${ws}\}$nl$gdb_prompt $" {
322 pass "ptype c"
323 }
324 -re "type = class C : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int c;((${ws}C & operator=\\(C const &\\);)|(${ws}C\\(int, C const &\\);)|(${ws}C\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
325 pass "ptype c (obsolescent gcc or gdb)"
326 }
327 -re ".*$gdb_prompt $" {
328 fail "ptype c"
329 }
330 timeout {
331 fail "ptype c (timeout)"
332 }
333 }
334
335 send_gdb "ptype d\n"
336 gdb_expect {
337 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;${ws}D & operator=\\(D const &\\);${ws}D\\(int, D const &\\);${ws}D\\(int\\);${ws}static void s\\(void\\);${ws}virtual int vg\\(void\\);${ws}virtual int vd\\(void\\);${ws}int fd\\(void\\);${ws}\}$nl$gdb_prompt $" {
338 pass "ptype d"
339 }
340 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const &\\);)|(${ws}D\\(int, D const &\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\(void\\);)|(${ws}virtual int vg\\(void\\);)|(${ws}virtual int vd\\(void\\);)|(${ws}int fd\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
341 pass "ptype d (obsolescent gcc or gdb)"
342 }
343 -re ".*$gdb_prompt $" {
344 fail "ptype d"
345 }
346 timeout {
347 fail "ptype d (timeout)"
348 }
349 }
350
351 send_gdb "ptype e\n"
352 gdb_expect {
353 -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const &\\);${ws}E\\(int, E const &\\);${ws}E\\(int\\);${ws}virtual int f\\(void\\);${ws}virtual int vg\\(void\\);${ws}virtual int vv\\(void\\);${ws}\}$nl$gdb_prompt $" {
354 pass "ptype e"
355 }
356 -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;((${ws}E & operator=\\(E const &\\);)|(${ws}E\\(int, E const &\\);)|(${ws}E\\(int\\);)|(${ws}virtual int f\\(void\\);)|(${ws}virtual int vg\\(void\\);)|(${ws}virtual int vv\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
357 pass "ptype e (obsolescent gcc or gdb)"
358 }
359 -re ".*$gdb_prompt $" {
360 fail "ptype e"
361 }
362 timeout {
363 fail "ptype e (timeout)"
364 }
365 }
366
367 send_gdb "ptype v\n"
368 gdb_expect {
369 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const &\\);${ws}V\\(V const &\\);${ws}V\\(void\\);${ws}int f\\(void\\);${ws}virtual int vv\\(void\\);${ws}\}$nl$gdb_prompt $" {
370 pass "ptype v"
371 }
372 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const &\\);)|(${ws}V\\(V const &\\);)|(${ws}V\\(void\\);)|(${ws}int f\\(void\\);)|(${ws}virtual int vv\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
373 pass "ptype v (obsolescent gcc or gdb)"
374 }
375 -re ".*$gdb_prompt $" {
376 fail "ptype v"
377 }
378 timeout {
379 fail "ptype v (timeout)"
380 }
381 }
382
383 send_gdb "ptype vb\n"
384 gdb_expect {
385 -re "type = class VB \{${ws}public:${ws}int vb;${ws}VB & operator=\\(VB const &\\);${ws}VB\\(VB const &\\);${ws}VB\\(void\\);${ws}int fvb\\(void\\);${ws}virtual int vvb\\(void\\);${ws}\}$nl$gdb_prompt $" {
386 pass "ptype vb"
387 }
388 -re "type = class VB \{${ws}public:${ws}int vb;((${ws}VB & operator=\\(VB const &\\);)|(${ws}VB\\(VB const &\\);)|(${ws}VB\\(void\\);)|(${ws}int fvb\\(void\\);)|(${ws}virtual int vvb\\(void\\);))*${ws}\}$nl$gdb_prompt $" {
389 pass "ptype vb (obsolescent gcc or gdb)"
390 }
391 -re ".*$gdb_prompt $" {
392 fail "ptype vb"
393 }
394 timeout {
395 fail "ptype vb (timeout)"
396 }
397 }
398
399 send_gdb "ptype pAa\n"
400 gdb_expect {
401 -re "type = class A : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}int a;${ws}public:${ws}A & operator=\\(A const &\\);${ws}A\\(int, A const &\\);${ws}A\\(int\\);${ws}virtual int f\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
402 pass "ptype pAa"
403 }
404 -re "type = class A : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const &\\);)|(${ws}A\\(int, A const &\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
405 pass "ptype pAa (obsolescent gcc or gdb)"
406 }
407 -re ".*$gdb_prompt $" {
408 fail "ptype pAa"
409 }
410 timeout {
411 fail "ptype pAa (timeout)"
412 }
413 }
414
415 send_gdb "ptype pAe\n"
416 gdb_expect {
417 -re "type = class A : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}int a;${ws}public:${ws}A & operator=\\(A const &\\);${ws}A\\(int, A const &\\);${ws}A\\(int\\);${ws}virtual int f\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
418 pass "ptype pAe"
419 }
420 -re "type = class A : public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const &\\);)|(${ws}A\\(int, A const &\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
421 pass "ptype pAe (obsolescent gcc or gdb)"
422 }
423 -re ".*$gdb_prompt $" {
424 fail "ptype pAe"
425 }
426 timeout {
427 fail "ptype pAe (timeout)"
428 }
429 }
430
431 send_gdb "ptype pBe\n"
432 gdb_expect {
433 -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const &\\);${ws}B\\(int, B const &\\);${ws}B\\(int\\);${ws}virtual int f\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
434 pass "ptype pBe"
435 }
436 -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:((${ws}B & operator=\\(B const &\\);)|(${ws}B\\(int, B const &\\);)|(${ws}B\\(int\\);)|(${ws}virtual int f\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
437 pass "ptype pBe (obsolescent gcc or gdb)"
438 }
439 -re ".*$gdb_prompt $" {
440 fail "ptype pBe"
441 }
442 timeout {
443 fail "ptype pBe (timeout)"
444 }
445 }
446
447 send_gdb "ptype pDd\n"
448 gdb_expect {
449 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;${ws}D & operator=\\(D const &\\);${ws}D\\(int, D const &\\);${ws}D\\(int\\);${ws}static void s\\(void\\);${ws}virtual int vg\\(void\\);${ws}virtual int vd\\(void\\);${ws}int fd\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
450 pass "ptype pDd"
451 }
452 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const &\\);)|(${ws}D\\(int, D const &\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\(void\\);)|(${ws}virtual int vg\\(void\\);)|(${ws}virtual int vd\\(void\\);)|(${ws}int fd\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
453 pass "ptype pDd (obsolescent gcc or gdb)"
454 }
455 -re ".*$gdb_prompt $" {
456 fail "ptype pDd"
457 }
458 timeout {
459 fail "ptype pDd (timeout)"
460 }
461 }
462
463 send_gdb "ptype pDe\n"
464 gdb_expect {
465 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;${ws}D & operator=\\(D const &\\);${ws}D\\(int, D const &\\);${ws}D\\(int\\);${ws}static void s\\(void\\);${ws}virtual int vg\\(void\\);${ws}virtual int vd\\(void\\);${ws}int fd\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
466 pass "ptype pDe"
467 }
468 -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \[*\]+_vb.V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const &\\);)|(${ws}D\\(int, D const &\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\(void\\);)|(${ws}virtual int vg\\(void\\);)|(${ws}virtual int vd\\(void\\);)|(${ws}int fd\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
469 pass "ptype pDe (obsolescent gcc or gdb)"
470 }
471 -re ".*$gdb_prompt $" {
472 fail "ptype pDe"
473 }
474 timeout {
475 fail "ptype pDe (timeout)"
476 }
477 }
478
479 send_gdb "ptype pVa\n"
480 gdb_expect {
481 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const &\\);${ws}V\\(V const &\\);${ws}V\\(void\\);${ws}int f\\(void\\);${ws}virtual int vv\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
482 pass "ptype pVa"
483 }
484 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const &\\);)|(${ws}V\\(V const &\\);)|(${ws}V\\(void\\);)|(${ws}int f\\(void\\);)|(${ws}virtual int vv\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
485 pass "ptype pVa (obsolescent gcc or gdb)"
486 }
487 -re ".*$gdb_prompt $" {
488 fail "ptype pVa"
489 }
490 timeout {
491 fail "ptype pVa (timeout)"
492 }
493 }
494
495 send_gdb "ptype pVv\n"
496 gdb_expect {
497 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const &\\);${ws}V\\(V const &\\);${ws}V\\(void\\);${ws}int f\\(void\\);${ws}virtual int vv\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
498 pass "ptype pVv"
499 }
500 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const &\\);)|(${ws}V\\(V const &\\);)|(${ws}V\\(void\\);)|(${ws}int f\\(void\\);)|(${ws}virtual int vv\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
501 pass "ptype pVv (obsolescent gcc or gdb)"
502 }
503 -re ".*$gdb_prompt $" {
504 fail "ptype pVv"
505 }
506 timeout {
507 fail "ptype pVv (timeout)"
508 }
509 }
510
511 send_gdb "ptype pVe\n"
512 gdb_expect {
513 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const &\\);${ws}V\\(V const &\\);${ws}V\\(void\\);${ws}int f\\(void\\);${ws}virtual int vv\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
514 pass "ptype pVe"
515 }
516 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const &\\);)|(${ws}V\\(V const &\\);)|(${ws}V\\(void\\);)|(${ws}int f\\(void\\);)|(${ws}virtual int vv\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
517 pass "ptype pVe (obsolescent gcc or gdb)"
518 }
519 -re ".*$gdb_prompt $" {
520 fail "ptype pVe"
521 }
522 timeout {
523 fail "ptype pVe (timeout)"
524 }
525 }
526
527 send_gdb "ptype pVd\n"
528 gdb_expect {
529 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const &\\);${ws}V\\(V const &\\);${ws}V\\(void\\);${ws}int f\\(void\\);${ws}virtual int vv\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
530 pass "ptype pVd"
531 }
532 -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const &\\);)|(${ws}V\\(V const &\\);)|(${ws}V\\(void\\);)|(${ws}int f\\(void\\);)|(${ws}virtual int vv\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
533 pass "ptype pVd (obsolescent gcc or gdb)"
534 }
535 -re ".*$gdb_prompt $" {
536 fail "ptype pVd"
537 }
538 timeout {
539 fail "ptype pVd (timeout)"
540 }
541 }
542
543 send_gdb "ptype pADe\n"
544 gdb_expect {
545 -re "type = class AD \{${ws}public:${ws}AD & operator=\\(AD const &\\);${ws}AD\\(AD const &\\);${ws}AD\\(void\\);${ws}virtual int vg\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
546 pass "ptype pADe"
547 }
548 -re "type = class AD \{${ws}public:((${ws}AD & operator=\\(AD const &\\);)|(${ws}AD\\(AD const &\\);)|(${ws}AD\\(void\\);)|(${ws}virtual int vg\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
549 pass "ptype pADe (obsolescent gcc or gdb)"
550 }
551 -re ".*$gdb_prompt $" {
552 fail "ptype pADe"
553 }
554 timeout {
555 fail "ptype pADe (timeout)"
556 }
557 }
558
559 send_gdb "ptype pEe\n"
560 gdb_expect {
561 -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const &\\);${ws}E\\(int, E const &\\);${ws}E\\(int\\);${ws}virtual int f\\(void\\);${ws}virtual int vg\\(void\\);${ws}virtual int vv\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
562 pass "ptype pEe"
563 }
564 -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;((${ws}E & operator=\\(E const &\\);)|(${ws}E\\(int, E const &\\);)|(${ws}E\\(int\\);)|(${ws}virtual int f\\(void\\);)|(${ws}virtual int vg\\(void\\);)|(${ws}virtual int vv\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
565 pass "ptype pEe (obsolescent gcc or gdb)"
566 }
567 -re ".*$gdb_prompt $" {
568 fail "ptype pEe"
569 }
570 timeout {
571 fail "ptype pEe (timeout)"
572 }
573 }
574
575 send_gdb "ptype pVB\n"
576 gdb_expect {
577 -re "type = class VB \{${ws}public:${ws}int vb;${ws}VB & operator=\\(VB const &\\);${ws}VB\\(VB const &\\);${ws}VB\\(void\\);${ws}int fvb\\(void\\);${ws}virtual int vvb\\(void\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
578 pass "ptype pVB"
579 }
580 -re "type = class VB \{${ws}public:${ws}int vb;((${ws}VB & operator=\\(VB const &\\);)|(${ws}VB\\(VB const &\\);)|(${ws}VB\\(void\\);)|(${ws}int fvb\\(void\\);)|(${ws}virtual int vvb\\(void\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
581 pass "ptype pVB (obsolescent gcc or gdb)"
582 }
583 -re ".*$gdb_prompt $" {
584 fail "ptype pVB"
585 }
586 timeout {
587 fail "ptype pVB (timeout)"
588 }
589 }
590 }
591
592 #
593 # Test calling of virtual functions.
594 #
595
596 proc test_virtual_calls {} {
597 global gdb_prompt
598 global GDB
599 global nl
600
601 if [target_info exists gdb,cannot_call_functions] {
602 setup_xfail "*-*-*" 2416
603 fail "This target can not call functions"
604 return 0
605 }
606
607 send_gdb "print pAe->f()\n"
608 gdb_expect {
609 -re ".* = 20$nl$gdb_prompt $" { pass "print pAe->f()" }
610 -re "Cannot invoke functions on this machine.*$gdb_prompt $" {
611 fail "print pAe->f() (cannot invoke functions, skipping virtual calls)"
612 return 0
613 }
614 -re ".*Cannot access memory at address 0x8.*$gdb_prompt $" {
615 fail "print pAe->f() \
616 (known failure with gcc cygnus-2.4.5-930417, skipping virtual calls)"
617 return 0
618 }
619 -re ".*$gdb_prompt $" { fail "print pAe->f()" }
620 timeout { fail "print pAe->f() (timeout)" }
621 eof { fail "print pAe->f() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
622 }
623
624 send_gdb "print pAa->f()\n"
625 gdb_expect {
626 -re ".* = 1$nl$gdb_prompt $" { pass "print pAa->f()" }
627 -re ".*$gdb_prompt $" { fail "print pAa->f()" }
628 timeout { fail "print pAa->f() (timeout)" }
629 eof { fail "print pAa->f() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
630 }
631
632 send_gdb "print pDe->vg()\n"
633 # setup_xfail "*-*-*"
634 gdb_expect {
635 -re ".* = 202$nl$gdb_prompt $" { pass "print pDe->vg()" }
636 -re ".*$gdb_prompt $" { fail "print pDe->vg()" }
637 timeout { fail "print pDe->vg() (timeout)" }
638 eof { fail "print pDe->vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
639 }
640
641 send_gdb "print pADe->vg()\n"
642 gdb_expect {
643 -re ".* = 202$nl$gdb_prompt $" { pass "print pADe->vg()" }
644 -re ".*$gdb_prompt $" { fail "print pADe->vg()" }
645 timeout { fail "print pADe->vg() (timeout)" }
646 eof { fail "print pADe->vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
647 }
648
649 send_gdb "print pDd->vg()\n"
650 # setup_xfail "*-*-*"
651 gdb_expect {
652 -re ".* = 101$nl$gdb_prompt $" { pass "print pDd->vg()" }
653 -re ".*$gdb_prompt $" { fail "print pDd->vg()" }
654 timeout { fail "print pDd->vg() (timeout)" }
655 eof { fail "print pDd->vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
656 }
657
658 send_gdb "print pEe->vvb()\n"
659 # setup_xfail "*-*-*"
660 gdb_expect {
661 -re ".* = 411$nl$gdb_prompt $" { pass "print pEe->vvb()" }
662 -re ".*$gdb_prompt $" { fail "print pEe->vvb()" }
663 timeout { fail "print pEe->vvb() (timeout)" }
664 eof { fail "print pEe->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
665 }
666
667 send_gdb "print pVB->vvb()\n"
668 gdb_expect {
669 -re ".* = 407$nl$gdb_prompt $" { pass "print pVB->vvb()" }
670 -re ".*$gdb_prompt $" { fail "print pVB->vvb()" }
671 timeout { fail "print pVB->vvb() (timeout)" }
672 eof { fail "print pVB->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
673 }
674
675 send_gdb "print pBe->vvb()\n"
676 # setup_xfail "*-*-*"
677 gdb_expect {
678 -re ".* = 411$nl$gdb_prompt $" { pass "print pBe->vvb()" }
679 -re ".*$gdb_prompt $" { fail "print pBe->vvb()" }
680 timeout { fail "print pBe->vvb() (timeout)" }
681 eof { fail "print pBe->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
682 }
683
684 send_gdb "print pDe->vvb()\n"
685 # setup_xfail "*-*-*"
686 gdb_expect {
687 -re ".* = 411$nl$gdb_prompt $" { pass "print pDe->vvb()" }
688 -re ".*$gdb_prompt $" { fail "print pDe->vvb()" }
689 timeout { fail "print pDe->vvb() (timeout)" }
690 eof { fail "print pDe->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
691 }
692
693 send_gdb "print pEe->vd()\n"
694 # setup_xfail "*-*-*"
695 gdb_expect {
696 -re ".* = 282$nl$gdb_prompt $" { pass "print pEe->vd()" }
697 -re ".*$gdb_prompt $" { fail "print pEe->vd()" }
698 timeout { fail "print pEe->vd() (timeout)" }
699 eof { fail "print pEe->vd() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
700 }
701
702 send_gdb "print pEe->fvb()\n"
703 # setup_xfail "*-*-*"
704 gdb_expect {
705 -re ".* = 311$nl$gdb_prompt $" { pass "print pEe->fvb()" }
706 -re ".*$gdb_prompt $" { fail "print pEe->fvb()" }
707 timeout { fail "print pEe->fvb() (timeout)" }
708 eof { fail "print pEe->fvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
709 }
710
711 send_gdb "print pEe->D::vg()\n"
712 setup_xfail "*-*-*"
713 gdb_expect {
714 -re ".* = 102$nl$gdb_prompt $" { pass "print pEe->D::vg()" }
715 -re ".*$gdb_prompt $" { fail "print pEe->D::vg()" }
716 timeout { fail "print pEe->D::vg() (timeout)" }
717 eof { fail "print pEe->D::vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
718 }
719 }
720
721 proc do_tests {} {
722 global prms_id
723 global bug_id
724
725 set prms_id 0
726 set bug_id 0
727
728 gdb_start;
729 gdb_virtfunc_init;
730
731 # Get the debug format for the compiled test case. If that
732 # format is DWARF 1 then just skip all the tests since none of
733 # them will pass.
734
735 if [ runto_main ] then {
736 get_debug_format
737 if [ setup_xfail_format "DWARF 1" ] then {
738 fail "C++ tests skipped due to limited C++ support in DWARF 1 debug format"
739 return
740 }
741 clear_xfail "*-*-*"
742 }
743
744 test_ptype_of_classes
745
746 if [ runto 'test_calls(void)' ] then {
747 test_virtual_calls
748 }
749 }
750
751 do_tests
This page took 0.046546 seconds and 3 git commands to generate.