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