]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # Copyright (C) 1992, 1994, 1995, 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 | # [email protected] | |
19 | ||
20 | # This file was written by Fred Fish. ([email protected]) | |
21 | ||
22 | set ws "\[\r\n\t \]+" | |
23 | ||
24 | if $tracelevel then { | |
25 | strace $tracelevel | |
26 | } | |
27 | ||
7a292a7a | 28 | if { [skip_hp_tests] } then { continue } |
c906108c SS |
29 | |
30 | # Check to see if we have an executable to test. If not, then either we | |
31 | # haven't tried to compile one, or the compilation failed for some reason. | |
32 | # In either case, just notify the user and skip the tests in this file. | |
33 | ||
34 | set testfile "misc-hp" | |
35 | set srcfile ${testfile}.cc | |
36 | set binfile ${objdir}/${subdir}/${testfile} | |
37 | ||
38 | if [get_compiler_info ${binfile} "c++"] { | |
39 | return -1; | |
40 | } | |
7a292a7a SS |
41 | |
42 | if { $gcc_compiled } then { continue } | |
c906108c SS |
43 | |
44 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { | |
45 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
46 | } | |
47 | ||
48 | # | |
49 | # Test ptype of class objects. | |
50 | # | |
51 | ||
52 | proc test_ptype_class_objects {} { | |
53 | global gdb_prompt | |
54 | global ws | |
55 | ||
56 | # Note that struct members are public by default, so we don't print | |
57 | # "public:" for the public members of structs. | |
58 | # Accept it as an expected failure if gdb just fails to distinguish between | |
59 | # class and struct, and everything else is OK. | |
60 | ||
61 | send_gdb "ptype struct default_public_struct\n" | |
62 | gdb_expect { | |
63 | -re "type = struct default_public_struct \{${ws}int a;${ws}int b;\r\n\}\r\n$gdb_prompt $" { | |
64 | pass "ptype struct default_public_struct" | |
65 | } | |
66 | -re "type = class default_public_struct \{\r\n.*int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
67 | setup_xfail "*-*-*" | |
68 | fail "ptype struct default_public_struct" | |
69 | } | |
70 | -re ".*$gdb_prompt $" { fail "ptype struct default_public_struct" } | |
71 | timeout { fail "ptype struct default_public_struct (timeout)" ; return } | |
72 | } | |
73 | ||
74 | # Note that struct members are public by default, so we don't print | |
75 | # "public:" for the public members of structs. | |
76 | # Accept it as an expected failure if gdb just fails to distinguish between | |
77 | # class and struct, and everything else is OK. | |
78 | ||
79 | send_gdb "ptype struct explicit_public_struct\n" | |
80 | gdb_expect { | |
81 | -re "type = struct explicit_public_struct \{${ws}int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
82 | pass "ptype struct explicit_public_struct" | |
83 | } | |
84 | -re "type = class explicit_public_struct \{\r\n.*int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
85 | setup_xfail "*-*-*" | |
86 | fail "ptype struct explicit_public_struct" | |
87 | } | |
88 | -re ".*$gdb_prompt $" { fail "ptype struct explicit_public_struct" } | |
89 | timeout { fail "ptype struct explicit_public_struct (timeout)" ; return } | |
90 | } | |
91 | ||
92 | # Accept it as an expected failure if gdb just fails to distinguish between | |
93 | # class and struct, and everything else is OK. | |
94 | ||
95 | setup_xfail_format "DWARF 1" | |
96 | send_gdb "ptype struct protected_struct\n" | |
97 | gdb_expect { | |
98 | -re "type = struct protected_struct \{${ws}protected:${ws}int a;${ws}int b;\r\n\}\r\n$gdb_prompt $" { | |
99 | pass "ptype struct protected_struct (FIXME)" | |
100 | } | |
101 | -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
102 | setup_xfail "*-*-*" | |
103 | fail "ptype struct protected_struct (FIXME)" | |
104 | } | |
105 | -re ".*$gdb_prompt $" { fail "ptype struct protected_struct" } | |
106 | timeout { fail "ptype struct protected_struct (timeout)" ; return } | |
107 | } | |
108 | ||
109 | # Accept it as an expected failure if gdb just fails to distinguish between | |
110 | # class and struct, and everything else is OK. | |
111 | ||
112 | setup_xfail_format "DWARF 1" | |
113 | send_gdb "ptype struct private_struct\n" | |
114 | gdb_expect { | |
115 | -re "type = struct private_struct \{${ws}private:${ws}int a;${ws}int b;\r\n\}\r\n$gdb_prompt $" { | |
116 | pass "ptype struct private_struct (FIXME)" | |
117 | } | |
118 | -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
119 | setup_xfail "*-*-*" | |
120 | fail "ptype struct private_struct (FIXME)" | |
121 | } | |
122 | -re ".*$gdb_prompt $" { fail "ptype struct private_struct" } | |
123 | timeout { fail "ptype struct private_struct (timeout)" ; return } | |
124 | } | |
125 | ||
126 | # Accept it as an expected failure if gdb just fails to distinguish between | |
127 | # class and struct, and everything else is OK. | |
128 | ||
129 | setup_xfail_format "DWARF 1" | |
130 | send_gdb "ptype struct mixed_protection_struct\n" | |
131 | gdb_expect { | |
132 | -re "type = struct mixed_protection_struct \{${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;\[\r\n\]+\}\[\r\n\]+$gdb_prompt $" { | |
133 | pass "ptype struct mixed_protection_struct (FIXME)" | |
134 | } | |
135 | -re "type = struct mixed_protection_struct \{\r\n\[ \]*public:\r\n\[ \]*int a;\r\n\[ \]*int b;\r\n\[ \]*private:\r\n\[ \]*int c;\r\n\[ \]*int d;\r\n\[ \]*protected:\r\n\[ \]*int e;\r\n\[ \]*int f;\r\n\[ \]*public:\r\n\[ \]*int g;\r\n\[ \]*private:\r\n\[ \]*int h;\r\n\[ \]*protected:\r\n\[ \]*int i;\r\n.*\}\r\n$gdb_prompt $" { | |
136 | pass "ptype struct mixed_protection_struct (extra public)" | |
137 | } | |
138 | -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;\r\n.*\}\r\n$gdb_prompt $" { | |
139 | setup_xfail "*-*-*" | |
140 | fail "ptype struct mixed_protection_struct (FIXME)" | |
141 | } | |
142 | -re ".*$gdb_prompt $" { fail "ptype struct mixed_protection_struct" } | |
143 | timeout { fail "ptype struct mixed_protection_struct (timeout)" ; return } | |
144 | } | |
145 | ||
146 | # Accept it as an expected failure if gdb just fails to distinguish between | |
147 | # class and struct, and everything else is OK. | |
148 | ||
149 | send_gdb "ptype class public_class\n" | |
150 | gdb_expect { | |
151 | -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
152 | pass "ptype class public_class (FIXME)" | |
153 | } | |
154 | -re "type = struct public_class \{${ws}int a;${ws}int b;\r\n\}\r\n$gdb_prompt $" { | |
155 | setup_xfail "*-*-*" | |
156 | fail "ptype class public_class (FIXME)" | |
157 | } | |
158 | -re ".*$gdb_prompt $" { fail "ptype class public_class" } | |
159 | timeout { fail "ptype class public_class (timeout)" ; return } | |
160 | } | |
161 | ||
162 | send_gdb "ptype class protected_class\n" | |
163 | gdb_expect { | |
164 | -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
165 | pass "ptype class protected_class" | |
166 | } | |
167 | -re "type = struct protected_class \{${ws}int a;${ws}int b;\r\n\}\r\n$gdb_prompt $" { | |
168 | setup_xfail "*-*-*" | |
169 | fail "ptype class protected_class" | |
170 | } | |
171 | -re ".*$gdb_prompt $" { fail "ptype class protected_class" } | |
172 | timeout { fail "ptype class protected_class (timeout)" ; return } | |
173 | } | |
174 | ||
175 | # Accept it as an expected failure if gdb just emits a superflous "private:" | |
176 | # attribute, since classes default to private and for consistency with | |
177 | # structs (where we don't print the "public:" attribute) we don't print | |
178 | # the "private:" attribute. | |
179 | ||
180 | setup_xfail_format "DWARF 1" | |
181 | send_gdb "ptype class default_private_class\n" | |
182 | gdb_expect { | |
183 | -re "type = class default_private_class \{${ws}int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
184 | pass "ptype class default_private_class (FIXME)" | |
185 | } | |
186 | -re "type = class default_private_class \{${ws}private:${ws}int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
187 | setup_xfail "*-*-*" | |
188 | fail "ptype class default_private_class (FIXME)" | |
189 | } | |
190 | -re ".*$gdb_prompt $" { fail "ptype class default_private_class" } | |
191 | timeout { fail "ptype class default_private_class (timeout)" ; return } | |
192 | } | |
193 | ||
194 | send_gdb "ptype class explicit_private_class\n" | |
195 | gdb_expect { | |
196 | -re "type = class explicit_private_class \{${ws}private:${ws}int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
197 | pass "ptype class explicit_private_class" | |
198 | } | |
199 | -re "type = class explicit_private_class \{\r\n\[ \]*int a;\r\n\[ \]*int b;\r\n.*\}\r\n$gdb_prompt $" { | |
200 | pass "ptype class explicit_private_class (OK for HP aCC)" | |
201 | } | |
202 | -re "type = struct explicit_private_class \{${ws}int a;${ws}int b;\r\n.*\}\r\n$gdb_prompt $" { | |
203 | setup_xfail "*-*-*" | |
204 | fail "ptype class explicit_private_class" | |
205 | } | |
206 | -re ".*$gdb_prompt $" { fail "ptype class explicit_private_class" } | |
207 | timeout { fail "ptype class explicit_private_class (timeout)" ; return } | |
208 | } | |
209 | ||
210 | send_gdb "ptype class mixed_protection_class\n" | |
211 | gdb_expect { | |
212 | -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;\r\n.*\}\r\n$gdb_prompt $" { | |
213 | pass "ptype class mixed_protection_class" | |
214 | } | |
215 | -re "type = struct mixed_protection_class \{${ws}int a;${ws}int b;${ws}int c;${ws}int d;${ws}int e;${ws}int f;${ws}int g;${ws}int h;${ws}int i;\r\n.*\}\r\n$gdb_prompt $" { | |
216 | setup_xfail "*-*-*" | |
217 | fail "ptype class mixed_protection_class" | |
218 | } | |
219 | -re ".*$gdb_prompt $" { fail "ptype class mixed_protection_class" } | |
220 | timeout { fail "ptype class mixed_protection_class (timeout)" ; return } | |
221 | } | |
222 | ||
223 | # This class does not use any C++-specific features, so it's fine for | |
224 | # it to print as "struct". | |
225 | send_gdb "ptype class A\n" | |
226 | gdb_expect { | |
227 | -re "type = (class|struct) A \{(${ws}public:|)${ws}int a;${ws}int x;((${ws}A & operator=\\(A const &\\);)|(${ws}A\\(A const &\\);)|(${ws}A\\(void\\);))*${ws}\}\r\n$gdb_prompt $" { | |
228 | pass "ptype class A" | |
229 | } | |
230 | -re ".*$gdb_prompt $" { | |
231 | fail "ptype class A" | |
232 | } | |
233 | timeout { | |
234 | fail "ptype class A (timeout)" | |
235 | return | |
236 | } | |
237 | } | |
238 | ||
239 | setup_xfail_format "DWARF 1" | |
240 | send_gdb "ptype class B\n" | |
241 | gdb_expect { | |
242 | -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;${ws}B & operator=\\(B const &\\);${ws}B\\(B const &\\);${ws}B\\(void\\);${ws}\}\r\n$gdb_prompt $" { | |
243 | pass "ptype class B" | |
244 | } | |
245 | -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;((${ws}B & operator=\\(B const &\\);)|(${ws}B\\(B const &\\);)|(${ws}B\\(void\\);))*${ws}\}\r\n$gdb_prompt $" { | |
246 | pass "ptype class B (obsolescent gcc or gdb)" | |
247 | } | |
248 | -re ".*$gdb_prompt $" { | |
249 | fail "ptype class B" | |
250 | } | |
251 | timeout { | |
252 | fail "ptype class B (timeout)" | |
253 | return | |
254 | } | |
255 | } | |
256 | ||
257 | setup_xfail_format "DWARF 1" | |
258 | send_gdb "ptype class C\n" | |
259 | gdb_expect { | |
260 | -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;${ws}C & operator=\\(C const &\\);${ws}C\\(C const &\\);${ws}C\\(void\\);${ws}\}\r\n$gdb_prompt $" { | |
261 | pass "ptype class C" | |
262 | } | |
263 | -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;((${ws}C & operator=\\(C const &\\);)|(${ws}C\\(C const &\\);)|(${ws}C\\(void\\);))*${ws}\}\r\n$gdb_prompt $" { | |
264 | pass "ptype class C (obsolescent gcc or gdb)" | |
265 | } | |
266 | -re ".*$gdb_prompt $" { | |
267 | fail "ptype class C" | |
268 | } | |
269 | timeout { | |
270 | fail "ptype class C (timeout)" | |
271 | return | |
272 | } | |
273 | } | |
274 | ||
275 | setup_xfail_format "DWARF 1" | |
276 | send_gdb "ptype class D\n" | |
277 | gdb_expect { | |
278 | -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;${ws}D & operator=\\(D const &\\);${ws}D\\(D const &\\);${ws}D\\(void\\);${ws}\}\r\n$gdb_prompt $" { | |
279 | pass "ptype class D" | |
280 | } | |
281 | -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;((${ws}D & operator=\\(D const &\\);)|(${ws}D\\(D const &\\);)|(${ws}D\\(void\\);))*${ws}\}\r\n$gdb_prompt $" { | |
282 | pass "ptype class D (obsolescent gcc or gdb)" | |
283 | } | |
284 | -re ".*$gdb_prompt $" { | |
285 | fail "ptype class D" | |
286 | } | |
287 | timeout { | |
288 | fail "ptype class D (timeout)" | |
289 | return | |
290 | } | |
291 | } | |
292 | ||
293 | setup_xfail_format "DWARF 1" | |
294 | send_gdb "ptype class E\n" | |
295 | gdb_expect { | |
296 | -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;${ws}E & operator=\\(E const &\\);${ws}E\\(E const &\\);${ws}E\\(void\\);${ws}\}\r\n$gdb_prompt $" { | |
297 | pass "ptype class E" | |
298 | } | |
299 | -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;((${ws}E & operator=\\(E const &\\);)|(${ws}E\\(E const &\\);)|(${ws}E\\(void\\);))*${ws}\}\r\n$gdb_prompt $" { | |
300 | pass "ptype class E" | |
301 | } | |
302 | -re ".*$gdb_prompt $" { | |
303 | fail "ptype class E" | |
304 | } | |
305 | timeout { | |
306 | fail "ptype class E (timeout)" | |
307 | return | |
308 | } | |
309 | } | |
310 | ||
311 | send_gdb "ptype class vA\n" | |
312 | gdb_expect { | |
313 | -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}vA & operator=\\(vA const &\\);${ws}vA\\(vA const &\\);${ws}vA\\(void\\);${ws}\}\r\n$gdb_prompt $" { | |
314 | pass "ptype class vA" | |
315 | } | |
316 | -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;((${ws}vA & operator=\\(vA const &\\);)|(${ws}vA\\(vA const &\\);)|(${ws}vA\\(void\\);))*${ws}\}\r\n$gdb_prompt $" { | |
317 | pass "ptype class vA (obsolescent gcc or gdb)" | |
318 | } | |
319 | -re ".*$gdb_prompt $" { | |
320 | fail "ptype class vA" | |
321 | } | |
322 | timeout { | |
323 | fail "ptype class vA (timeout)" | |
324 | return | |
325 | } | |
326 | } | |
327 | ||
328 | # Accept the form with embedded GNU style mangled virtual table constructs | |
329 | # for now, but with a FIXME. At some future point, gdb should use a | |
330 | # portable representation for the virtual table constructs. | |
331 | ||
332 | setup_xfail_format "DWARF 1" | |
333 | send_gdb "ptype class vB\n" | |
334 | gdb_expect { | |
335 | -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const &\\);${ws}vB\\(int, vB const &\\);${ws}vB\\(int\\);${ws}\}\r\n$gdb_prompt $" { | |
336 | setup_xfail "*-*-*" | |
337 | fail "ptype class vB (FIXME: non-portable virtual table constructs)" | |
338 | } | |
339 | -re "type = class vB : public virtual vA \{\r\n\[ \]*public:\r\n\[ \]*int vb;\r\n\[ \]*int vx;\[\r\n\t \]+\}\r\n$gdb_prompt $" { | |
340 | pass "ptype class vB (aCC)" | |
341 | } | |
342 | -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vb;${ws}int vx;((${ws}vB & operator=\\(vB const &\\);)|(${ws}vB\\(int, vB const &\\);)|(${ws}vB\\(int\\);))*${ws}\}\r\n$gdb_prompt $" { | |
343 | setup_xfail "*-*-*" | |
344 | fail "ptype class vB (FIXME) (obsolescent gcc or gdb)" | |
345 | } | |
346 | -re ".*$gdb_prompt $" { | |
347 | fail "ptype class vB" | |
348 | } | |
349 | timeout { | |
350 | fail "ptype class vB (timeout)" | |
351 | return | |
352 | } | |
353 | } | |
354 | ||
355 | # Accept the form with embedded GNU style mangled virtual table constructs | |
356 | # for now, but with a FIXME. At some future point, gdb should use a | |
357 | # portable representation for the virtual table constructs. | |
358 | ||
359 | setup_xfail_format "DWARF 1" | |
360 | send_gdb "ptype class vC\n" | |
361 | gdb_expect { | |
362 | -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const &\\);${ws}vC\\(int, vC const &\\);${ws}vC\\(int\\);${ws}\}\r\n$gdb_prompt $" { | |
363 | setup_xfail "*-*-*" | |
364 | fail "ptype class vC (FIXME: non-portable virtual table constructs)" | |
365 | } | |
366 | -re "type = class vC : public virtual vA \{\r\n\[ \]*public:\r\n\[ \]*int vc;\r\n\[ \]*int vx;\[\r\n\t \]+\}\r\n$gdb_prompt $" { | |
367 | pass "ptype class vC (aCC)" | |
368 | } | |
369 | -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vc;${ws}int vx;((${ws}vC & operator=\\(vC const &\\);)|(${ws}vC\\(int, vC const &\\);)|(${ws}vC\\(int\\);))*${ws}\}\r\n$gdb_prompt $" { | |
370 | setup_xfail "*-*-*" | |
371 | fail "ptype class vC (FIXME) (obsolescent gcc or gdb)" | |
372 | } | |
373 | -re ".*$gdb_prompt $" { | |
374 | fail "ptype class vC" | |
375 | } | |
376 | timeout { | |
377 | fail "ptype class vC (timeout)" | |
378 | return | |
379 | } | |
380 | } | |
381 | ||
382 | # Accept the form with embedded GNU style mangled virtual table constructs | |
383 | # for now, but with a FIXME. At some future point, gdb should use a | |
384 | # portable representation for the virtual table constructs. | |
385 | ||
386 | setup_xfail_format "DWARF 1" | |
387 | send_gdb "ptype class vD\n" | |
388 | gdb_expect { | |
389 | -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;${ws}vD & operator=\\(vD const &\\);${ws}vD\\(int, vD const &\\);${ws}vD\\(int\\);${ws}\}\r\n$gdb_prompt $" { | |
390 | setup_xfail "*-*-*" | |
391 | fail "ptype class vD (FIXME: non-portable virtual table constructs)" | |
392 | } | |
393 | -re "type = class vD : public virtual vB, public virtual vC \{\r\n\[ \]*public:\r\n\[ \]*int vd;\r\n\[ \]*int vx;\[\r\n\t \]+\}\r\n$gdb_prompt $" { | |
394 | pass "ptype class vD (aCC)" | |
395 | } | |
396 | -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;((${ws}vD & operator=\\(vD const &\\);)|(${ws}vD\\(int, vD const &\\);)|(${ws}vD\\(int\\);))*${ws}\}\r\n$gdb_prompt $" { | |
397 | setup_xfail "*-*-*" | |
398 | fail "ptype class vD (FIXME) (obsolescent gcc or gdb)" | |
399 | } | |
400 | -re ".*$gdb_prompt $" { | |
401 | fail "ptype class vD" | |
402 | } | |
403 | timeout { | |
404 | fail "ptype class vD (timeout)" | |
405 | return | |
406 | } | |
407 | } | |
408 | ||
409 | # Accept the form with embedded GNU style mangled virtual table constructs | |
410 | # for now, but with a FIXME. At some future point, gdb should use a | |
411 | # portable representation for the virtual table constructs. | |
412 | ||
413 | setup_xfail_format "DWARF 1" | |
414 | send_gdb "ptype class vE\n" | |
415 | gdb_expect { | |
416 | -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*_vb.vD;${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const &\\);${ws}vE\\(int, vE const &\\);${ws}vE\\(int\\);${ws}\}\r\n$gdb_prompt $" { | |
417 | setup_xfail "*-*-*" | |
418 | fail "ptype class vE (FIXME: non-portable virtual table constructs)" | |
419 | } | |
420 | -re "type = class vE : public virtual vD \{\r\n\[ \]*public:\r\n\[ \]*int ve;\r\n\[ \]*int vx;\[\r\n\t \]+\}\r\n$gdb_prompt $" { | |
421 | pass "ptype class vE (aCC)" | |
422 | } | |
423 | -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*_vb.vD;${ws}public:${ws}int ve;${ws}int vx;((${ws}vE & operator=\\(vE const &\\);)|(${ws}vE\\(int, vE const &\\);)|(${ws}vE\\(int\\);))*${ws}\}\r\n$gdb_prompt $" { | |
424 | setup_xfail "*-*-*" | |
425 | fail "ptype class vE (FIXME) (obsolescent gcc or gdb)" | |
426 | } | |
427 | -re ".*$gdb_prompt $" { | |
428 | fail "ptype class vE" | |
429 | } | |
430 | timeout { | |
431 | fail "ptype class vE (timeout)" | |
432 | return | |
433 | } | |
434 | } | |
435 | ||
436 | setup_xfail_format "DWARF 1" | |
437 | send_gdb "ptype class Base1\n" | |
438 | gdb_expect { | |
439 | -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 & operator=\\(Base1 const &\\);${ws}Base1\\(Base1 const &\\);${ws}Base1\\(int\\);${ws}\}\r\n$gdb_prompt $" { | |
440 | pass "ptype class Base1" | |
441 | } | |
442 | -re "type = class Base1 \{${ws}public:${ws}int x;((${ws}Base1 & operator=\\(Base1 const &\\);)|(${ws}Base1\\(Base1 const &\\);)|(${ws}Base1\\(int\\);))*${ws}\}\r\n$gdb_prompt $" { | |
443 | pass "ptype class Base1 (obsolescent gcc or gdb)" | |
444 | } | |
445 | -re ".*$gdb_prompt $" { | |
446 | fail "ptype class Base1" | |
447 | } | |
448 | timeout { | |
449 | fail "ptype class Base1 (timeout)" | |
450 | return | |
451 | } | |
452 | } | |
453 | ||
454 | setup_xfail_format "DWARF 1" | |
455 | send_gdb "ptype class Foo\n" | |
456 | gdb_expect { | |
457 | -re "type = class Foo \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\[ \]*static int st;\r\n\r\n\[ \]*Foo\\(int, int\\);\r\n\[ \]*int operator!.void.;\r\n\[ \]*operator int.void.;\r\n\[ \]*int times.int.;\r\n\}\r\n$gdb_prompt $" { | |
458 | pass "ptype class Foo(aCC)" | |
459 | } | |
460 | -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo & operator=\\(Foo const &\\);${ws}Foo\\(Foo const &\\);${ws}Foo\\(int, int\\);${ws}int operator!\\(void\\);${ws}int operator int\\(void\\);${ws}int times\\(int\\);${ws}\}\r\n$gdb_prompt $" { | |
461 | pass "ptype class Foo" | |
462 | } | |
463 | -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;((${ws}Foo & operator=\\(Foo const &\\);)|(${ws}Foo\\(Foo const &\\);)|(${ws}Foo\\(int, int\\);)|(${ws}int operator!\\(void\\);)|(${ws}int operator int\\(void\\);)|(${ws}int times\\(int\\);))*${ws}\}\r\n$gdb_prompt $" { | |
464 | pass "ptype class Foo (obsolescent gcc or gdb)" | |
465 | } | |
466 | -re ".*$gdb_prompt $" { | |
467 | fail "ptype class Foo" | |
468 | } | |
469 | timeout { | |
470 | fail "ptype class Foo (timeout)" | |
471 | return | |
472 | } | |
473 | } | |
474 | ||
475 | setup_xfail_format "DWARF 1" | |
476 | send_gdb "ptype class Bar\n" | |
477 | gdb_expect { | |
478 | -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar & operator=\\(Bar const &\\);${ws}Bar\\(Bar const &\\);${ws}Bar\\(int, int, int\\);${ws}\}\r\n$gdb_prompt $" { | |
479 | pass "ptype class Bar" | |
480 | } | |
481 | -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;((${ws}Bar & operator=\\(Bar const &\\);)|(${ws}Bar\\(Bar const &\\);)|(${ws}Bar\\(int, int, int\\);))*${ws}\}\r\n$gdb_prompt $" { | |
482 | pass "ptype class Bar (obsolescent gcc or gdb)" | |
483 | } | |
484 | -re ".*$gdb_prompt $" { | |
485 | fail "ptype class Bar" | |
486 | } | |
487 | timeout { | |
488 | fail "ptype class Bar (timeout)" | |
489 | return | |
490 | } | |
491 | } | |
492 | } | |
493 | ||
494 | # | |
495 | # Test simple access to class members. | |
496 | # | |
497 | ||
498 | proc test_non_inherited_member_access {} { | |
499 | global gdb_prompt | |
500 | ||
501 | # Print non-inherited members of g_A. | |
502 | ||
503 | gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect" | |
504 | ||
505 | gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect" | |
506 | ||
507 | # Print non-inherited members of g_B. | |
508 | ||
509 | gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect" | |
510 | ||
511 | gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect" | |
512 | ||
513 | # Print non-inherited members of g_C. | |
514 | ||
515 | gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect" | |
516 | ||
517 | gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect" | |
518 | ||
519 | # Print non-inherited members of g_D. | |
520 | ||
521 | gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect" | |
522 | ||
523 | gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect" | |
524 | ||
525 | # Print non-inherited members of g_E. | |
526 | ||
527 | gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect" | |
528 | ||
529 | gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect" | |
530 | } | |
531 | ||
532 | # | |
533 | # Try access to non-members that are members of another class. | |
534 | # Should give errors. | |
535 | # | |
536 | ||
537 | proc test_wrong_class_members {} { | |
538 | global gdb_prompt | |
539 | ||
540 | gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error" | |
541 | ||
542 | gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error" | |
543 | ||
544 | gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error" | |
545 | ||
546 | gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error" | |
547 | ||
548 | gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error" | |
549 | ||
550 | gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error" | |
551 | } | |
552 | ||
553 | # | |
554 | # Try access to non-members that are not members of any class. | |
555 | # Should give errors. | |
556 | # | |
557 | ||
558 | proc test_nonexistant_members {} { | |
559 | global gdb_prompt | |
560 | ||
561 | gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error" | |
562 | ||
563 | gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error" | |
564 | ||
565 | gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error" | |
566 | ||
567 | gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error" | |
568 | } | |
569 | ||
570 | # | |
571 | # Pointers to class members | |
572 | # | |
573 | ||
574 | proc test_pointers_to_class_members {} { | |
575 | global gdb_prompt | |
576 | global decimal | |
577 | ||
578 | gdb_test "print Bar::z" ".* = .int\[ \]*\[( \]*Bar::&\[)\]+\[ \]*Bar::z" "print Bar::z" | |
579 | ||
580 | gdb_test "print &Foo::x" ".* = .int\[ \]*\[( \]*Foo::\[*)\]+\[ \]*&Foo::x" "print &Foo::x" | |
581 | ||
582 | gdb_test "print (int)&Foo::x" ".* = 0" "print (int)&Foo::x" | |
583 | ||
584 | send_gdb "print (int)&Bar::y == 2*sizeof(int)\n" | |
585 | gdb_expect { | |
586 | -re ".* = true\r\n$gdb_prompt $" { | |
587 | pass "print (int)&Bar::y == 2*sizeof(int)" | |
588 | } | |
589 | -re "There is no field named y.*$gdb_prompt $" { | |
590 | setup_xfail "*-*-*" | |
591 | fail "print (int)&Bar::y == 2*sizeof(int)" | |
592 | } | |
593 | -re ".*$gdb_prompt $" { fail "print (int)&Bar::y == 2*sizeof(int)" } | |
594 | timeout { fail "print (int)&Bar::y == 2*sizeof(int) (timeout)" ; return } | |
595 | } | |
596 | ||
597 | send_gdb "next\n" | |
598 | setup_xfail "*-*-*" | |
599 | gdb_expect { | |
600 | -re "$decimal\[ \t\]+inheritance3 \[)(\]+;\r\n$gdb_prompt $" {} | |
601 | -re ".*$gdb_prompt $" { fail "next to inheritance3" ; return } | |
602 | } | |
603 | clear_xfail "*-*-*" | |
604 | ||
605 | setup_xfail_format "DWARF 1" | |
606 | gdb_test "print (int)pmi == sizeof(int)" ".* = false" "print (int)pmi == sizeof(int)" | |
607 | } | |
608 | ||
609 | # | |
610 | # Test static members. | |
611 | # | |
612 | ||
613 | proc test_static_members {} { | |
614 | global gdb_prompt | |
615 | global hex | |
616 | ||
617 | send_gdb "print Foo::st\n" | |
618 | gdb_expect { | |
619 | -re ".* = 100\r\n$gdb_prompt $" { | |
620 | pass "print Foo::st" | |
621 | } | |
622 | -re "There is no field named st.*$gdb_prompt $" { | |
623 | setup_xfail "*-*-*" | |
624 | fail "print Foo::st" | |
625 | } | |
626 | -re ".*$gdb_prompt $" { fail "print Foo::st" } | |
627 | timeout { fail "print Foo::st (timeout)" ; return } | |
628 | } | |
629 | ||
630 | send_gdb "set foo.st = 200\n" | |
631 | gdb_expect { | |
632 | -re ".*$gdb_prompt $" {} | |
633 | } | |
634 | ||
635 | send_gdb "print bar.st\n" | |
636 | gdb_expect { | |
637 | -re ".* = 200\r\n$gdb_prompt $" { | |
638 | pass "print bar.st" | |
639 | } | |
640 | -re "There is no member( or method|) named st.*$gdb_prompt $" { | |
641 | setup_xfail "*-*-*" | |
642 | fail "print bar.st" | |
643 | } | |
644 | -re ".*$gdb_prompt $" { fail "print bar.st" } | |
645 | timeout { fail "print bar.st (timeout)" ; return } | |
646 | } | |
647 | ||
648 | send_gdb "print &foo.st\n" | |
649 | gdb_expect { | |
650 | -re ".* = .int \[*)\]+ $hex\r\n$gdb_prompt $" { | |
651 | pass "print &foo.st" | |
652 | } | |
653 | -re "There is no member( or method|) named st.*$gdb_prompt $" { | |
654 | setup_xfail "*-*-*" | |
655 | fail "print &foo.st" | |
656 | } | |
657 | -re ".*$gdb_prompt $" { fail "print &foo.st" } | |
658 | timeout { fail "print &foo.st (timeout)" ; return } | |
659 | } | |
660 | ||
661 | set got_bar_st 0 | |
662 | send_gdb "print &Bar::st\n" | |
663 | gdb_expect { | |
664 | -re ".* = .int \[*)\]+ $hex\r\n$gdb_prompt $" { | |
665 | pass "print &Bar::st" | |
666 | set got_bar_st 1 | |
667 | } | |
668 | -re "There is no field named st.*$gdb_prompt $" { | |
669 | setup_xfail "*-*-*" | |
670 | fail "print &Bar::st" | |
671 | } | |
672 | -re ".*$gdb_prompt $" { fail "print &Bar::st" } | |
673 | timeout { fail "print &Bar::st (timeout)" ; return } | |
674 | } | |
675 | ||
676 | if $got_bar_st then { | |
677 | gdb_test "print *\$" ".* = 200" "print *\$" | |
678 | } | |
679 | ||
680 | gdb_test "set print static-members off" "" | |
681 | gdb_test "print csi" \ | |
682 | "{x = 10, y = 20}" \ | |
683 | "print csi without static members" | |
684 | gdb_test "print cnsi" \ | |
685 | "{x = 30, y = 40}" \ | |
686 | "print cnsi without static members" | |
687 | ||
688 | gdb_test "set print static-members on" "" | |
689 | setup_xfail_format "DWARF 1" | |
690 | gdb_test "print csi" \ | |
691 | "{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \ | |
692 | "print csi with static members" | |
693 | setup_xfail_format "DWARF 1" | |
694 | gdb_test "print cnsi" \ | |
695 | "{x = 30, y = 40, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>, static yy = {z = 5, static xx = {x = 1, y = 2, static null = <same as static member of an already seen type>, static yy = <same as static member of an already seen type>}}}, static yy = <same as static member of an already seen type>}" \ | |
696 | "print cnsi with static members" | |
697 | } | |
698 | ||
699 | proc do_tests {} { | |
700 | global prms_id | |
701 | global bug_id | |
702 | global subdir | |
703 | global objdir | |
704 | global srcdir | |
705 | global binfile | |
706 | global gdb_prompt | |
707 | ||
708 | set prms_id 0 | |
709 | set bug_id 0 | |
710 | ||
711 | # Start with a fresh gdb. | |
712 | ||
713 | gdb_exit | |
714 | gdb_start | |
715 | gdb_reinitialize_dir $srcdir/$subdir | |
716 | gdb_load $binfile | |
717 | ||
718 | send_gdb "set language c++\n" | |
719 | gdb_expect -re "$gdb_prompt $" | |
720 | send_gdb "set width 0\n" | |
721 | gdb_expect -re "$gdb_prompt $" | |
722 | ||
723 | # Get the debug format for the compiled test case. | |
724 | ||
725 | if [ runto_main ] then { | |
726 | get_debug_format | |
727 | } | |
728 | ||
729 | test_ptype_class_objects | |
730 | ||
731 | if [ runto 'inheritance2(void)' ] then { | |
732 | test_non_inherited_member_access | |
733 | test_wrong_class_members | |
734 | test_nonexistant_members | |
735 | } | |
736 | ||
737 | if [istarget "mips-idt-*"] then { | |
738 | # Restart because IDT/SIM runs out of file descriptors. | |
739 | gdb_exit | |
740 | gdb_start | |
741 | gdb_reinitialize_dir $srcdir/$subdir | |
742 | gdb_load $binfile | |
743 | } | |
744 | ||
745 | if [ runto_main ] then { | |
746 | test_pointers_to_class_members | |
747 | test_static_members | |
748 | } | |
749 | ||
750 | if [istarget "mips-idt-*"] then { | |
751 | # Restart because IDT/SIM runs out of file descriptors. | |
752 | gdb_exit | |
753 | gdb_start | |
754 | gdb_reinitialize_dir $srcdir/$subdir | |
755 | gdb_load $binfile | |
756 | } | |
757 | ||
758 | if [ runto marker_reg1 ] then { | |
759 | ||
760 | gdb_test "finish" "Run till exit from.*" "finish from marker_reg1" | |
761 | ||
762 | send_gdb "print v.method ()\n" | |
763 | gdb_expect { | |
764 | -re "= 82.*$gdb_prompt $" { | |
765 | pass "calling method for small class" | |
766 | } | |
767 | -re "Address requested for identifier .v. which is in a register.*$gdb_prompt $" { | |
768 | setup_xfail "*-*-*" 2972 | |
769 | fail "calling method for small class" | |
770 | } | |
771 | -re ".*$gdb_prompt $" { fail "calling method for small class" } | |
772 | timeout { fail "calling method for small class (timeout)" } | |
773 | eof { fail "calling method for small class (eof)" } | |
774 | } | |
775 | } | |
776 | ||
777 | } | |
778 | ||
779 | do_tests | |
780 | ||
781 | ||
782 | # Some additional tests for enums inside classes | |
783 | ||
784 | ||
785 | # set a breakpoint and go there | |
786 | send_gdb "break 498\n" | |
787 | gdb_expect { | |
788 | -re "Breakpoint \[0-9\] at.*$gdb_prompt $" { pass "set break 498" } | |
789 | -re "$gdb_prompt $" { fail "set break 498" } | |
790 | timeout { fail "(timeout) set break 498" } | |
791 | } | |
792 | send_gdb "continue\n" | |
793 | gdb_expect { | |
794 | -re "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, main....at ${srcdir}/${subdir}/${srcfile}:498\r\n498.*\r\n$gdb_prompt $" { pass "continue" } | |
795 | -re "$gdb_prompt $" { fail "continue" } | |
796 | timeout { fail "(timeout) continue" } | |
797 | } | |
798 | ||
799 | # print the object | |
800 | send_gdb "print obj_with_enum\n" | |
801 | gdb_expect { | |
802 | -re "\\$\[0-9\]* = \\{priv_enum = red, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (1)" } | |
803 | -re "$gdb_prompt $" { fail "print obj_with_enum (1)" } | |
804 | timeout { fail "(timeout) print obj_with_enum (1)" } | |
805 | } | |
806 | ||
807 | send_gdb "next\n" | |
808 | gdb_expect { | |
809 | -re "$gdb_prompt $" { pass "next" } | |
810 | timeout { fail "(timeout) next" } | |
811 | } | |
812 | ||
813 | # print the object again | |
814 | send_gdb "print obj_with_enum\n" | |
815 | gdb_expect { | |
816 | -re "\\$\[0-9\]* = \\{priv_enum = green, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (2)" } | |
817 | -re "$gdb_prompt $" { fail "print obj_with_enum (2)" } | |
818 | timeout { fail "(timeout) print obj_with_enum (2)" } | |
819 | } | |
820 | ||
821 | # print out the enum member | |
822 | send_gdb "print obj_with_enum.priv_enum\n" | |
823 | gdb_expect { | |
824 | -re "\\$\[0-9\]* = green.*$gdb_prompt $" { pass "print obj_with_enum.priv_enum" } | |
825 | -re "$gdb_prompt $" { fail "print obj_with_enum.priv_enum" } | |
826 | timeout { fail "(timeout) print obj_with_enum.priv_enum" } | |
827 | } | |
828 | ||
829 | # ptype on the enum member | |
830 | send_gdb "ptype obj_with_enum.priv_enum\n" | |
831 | gdb_expect { | |
832 | -re "type = enum ClassWithEnum::PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } | |
833 | -re "$gdb_prompt $" { fail "ptype obj_with_enum.priv_enum" } | |
834 | timeout { fail "(timeout) ptype obj_with_enum.priv_enum" } | |
835 | } | |
836 | ||
837 | # ptype on the object | |
838 | send_gdb "ptype obj_with_enum\n" | |
839 | gdb_expect { | |
840 | -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*enum ClassWithEnum::PrivEnum priv_enum;\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { pass "ptype obj_with_enum" } | |
841 | -re "$gdb_prompt $" { fail "ptype obj_with_enum" } | |
842 | timeout { fail "(timeout) ptype obj_with_enum" } | |
843 | } | |
844 | ||
845 | send_gdb "print (ClassWithEnum::PrivEnum) 42\n" | |
846 | gdb_expect { | |
847 | -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print (ClassWithEnum::PrivEnum) 42" } | |
848 | -re "$gdb_prompt $" { fail "print (ClassWithEnum::PrivEnum) 42" } | |
849 | timeout { fail "(timeout) print (ClassWithEnum::PrivEnum) 42" } | |
850 | } | |
851 | ||
852 | ||
853 | send_gdb "maint demangle inheritance1__Fv\n" | |
854 | gdb_expect { | |
855 | -re "inheritance1\\(void\\).*$gdb_prompt $" { pass "demangle" } | |
856 | -re ".*$gdb_prompt $" { fail "demangle" } | |
857 | timeout { fail "(timeout) demangle" } | |
858 | } | |
859 |