Commit | Line | Data |
---|---|---|
40f235b7 MC |
1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
2 | # 2003 Free Software Foundation, Inc. | |
c906108c SS |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | ||
18 | # Please email any bugs, comments, and/or additions to this file to: | |
19 | # bug-gdb@prep.ai.mit.edu | |
20 | ||
21 | # This file was written by Fred Fish. (fnf@cygnus.com) | |
22 | ||
23 | set ws "\[\r\n\t \]+" | |
24 | set nl "\[\r\n\]+" | |
25 | ||
26 | if $tracelevel then { | |
27 | strace $tracelevel | |
28 | } | |
29 | ||
d4f3574e | 30 | if { [skip_cplus_tests] } { continue } |
c906108c SS |
31 | |
32 | set testfile "misc" | |
33 | set srcfile ${testfile}.cc | |
34 | set binfile ${objdir}/${subdir}/${testfile} | |
35 | ||
36 | # Create and source the file that provides information about the compiler | |
37 | # used to compile the test case. | |
38 | ||
39 | if [get_compiler_info ${binfile} "c++"] { | |
40 | return -1 | |
41 | } | |
42 | ||
c906108c SS |
43 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { |
44 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
45 | } | |
46 | ||
47 | # | |
48 | # Test ptype of class objects. | |
49 | # | |
50 | ||
51 | proc test_ptype_class_objects {} { | |
52 | global gdb_prompt | |
53 | global ws | |
54 | global nl | |
55 | ||
56 | # Note that struct members are public by default, so we don't print | |
57 | # "public:" for the public members of structs. | |
f683e100 | 58 | # Accept it if gdb just fails to distinguish between |
c906108c SS |
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;$nl\}$nl$gdb_prompt $" { | |
64 | pass "ptype struct default_public_struct" | |
65 | } | |
66 | -re "type = class default_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
f683e100 | 67 | pass "ptype struct default_public_struct" |
c906108c SS |
68 | } |
69 | -re ".*$gdb_prompt $" { fail "ptype struct default_public_struct" } | |
70 | timeout { fail "ptype struct default_public_struct (timeout)" ; return } | |
71 | } | |
72 | ||
73 | # Note that struct members are public by default, so we don't print | |
74 | # "public:" for the public members of structs. | |
f683e100 | 75 | # Accept it if gdb just fails to distinguish between |
c906108c SS |
76 | # class and struct, and everything else is OK. |
77 | ||
78 | send_gdb "ptype struct explicit_public_struct\n" | |
79 | gdb_expect { | |
80 | -re "type = struct explicit_public_struct \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
81 | pass "ptype struct explicit_public_struct" | |
82 | } | |
83 | -re "type = class explicit_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
f683e100 | 84 | pass "ptype struct explicit_public_struct" |
c906108c SS |
85 | } |
86 | -re ".*$gdb_prompt $" { fail "ptype struct explicit_public_struct" } | |
87 | timeout { fail "ptype struct explicit_public_struct (timeout)" ; return } | |
88 | } | |
89 | ||
f683e100 | 90 | # Accept it if gdb just fails to distinguish between |
c906108c SS |
91 | # class and struct, and everything else is OK. |
92 | ||
c906108c SS |
93 | send_gdb "ptype struct protected_struct\n" |
94 | gdb_expect { | |
95 | -re "type = struct protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
f683e100 | 96 | pass "ptype struct protected_struct" |
c906108c SS |
97 | } |
98 | -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
f683e100 | 99 | pass "ptype struct protected_struct" |
c906108c SS |
100 | } |
101 | -re ".*$gdb_prompt $" { fail "ptype struct protected_struct" } | |
102 | timeout { fail "ptype struct protected_struct (timeout)" ; return } | |
103 | } | |
104 | ||
f683e100 | 105 | # Accept it if gdb just fails to distinguish between |
c906108c SS |
106 | # class and struct, and everything else is OK. |
107 | ||
c906108c SS |
108 | send_gdb "ptype struct private_struct\n" |
109 | gdb_expect { | |
110 | -re "type = struct private_struct \{${ws}private:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
f683e100 | 111 | pass "ptype struct private_struct" |
c906108c SS |
112 | } |
113 | -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
f683e100 | 114 | pass "ptype struct private_struct" |
c906108c SS |
115 | } |
116 | -re ".*$gdb_prompt $" { fail "ptype struct private_struct" } | |
117 | timeout { fail "ptype struct private_struct (timeout)" ; return } | |
118 | } | |
119 | ||
f683e100 | 120 | # Accept it if gdb just fails to distinguish between |
c906108c SS |
121 | # class and struct, and everything else is OK. |
122 | ||
c906108c SS |
123 | send_gdb "ptype struct mixed_protection_struct\n" |
124 | gdb_expect { | |
125 | -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;$nl\}$nl$gdb_prompt $" { | |
f683e100 | 126 | pass "ptype struct mixed_protection_struct" |
c906108c | 127 | } |
a0b3c4fd JM |
128 | -re "type = struct 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;$nl.*\}$nl$gdb_prompt $" { |
129 | pass "ptype struct mixed_protection_struct (extra public)" | |
130 | } | |
c906108c | 131 | -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;$nl.*\}$nl$gdb_prompt $" { |
f683e100 | 132 | pass "ptype struct mixed_protection_struct" |
c906108c SS |
133 | } |
134 | -re ".*$gdb_prompt $" { fail "ptype struct mixed_protection_struct" } | |
135 | timeout { fail "ptype struct mixed_protection_struct (timeout)" ; return } | |
136 | } | |
137 | ||
f683e100 | 138 | # Accept it if gdb just fails to distinguish between |
c906108c SS |
139 | # class and struct, and everything else is OK. |
140 | ||
141 | send_gdb "ptype class public_class\n" | |
142 | gdb_expect { | |
143 | -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
f683e100 | 144 | pass "ptype class public_class" |
c906108c SS |
145 | } |
146 | -re "type = struct public_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
8a151ee0 | 147 | pass "ptype class public_class" |
c906108c SS |
148 | } |
149 | -re ".*$gdb_prompt $" { fail "ptype class public_class" } | |
150 | timeout { fail "ptype class public_class (timeout)" ; return } | |
151 | } | |
152 | ||
153 | send_gdb "ptype class protected_class\n" | |
154 | gdb_expect { | |
155 | -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
156 | pass "ptype class protected_class" | |
157 | } | |
158 | -re "type = struct protected_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
c906108c SS |
159 | fail "ptype class protected_class" |
160 | } | |
161 | -re ".*$gdb_prompt $" { fail "ptype class protected_class" } | |
162 | timeout { fail "ptype class protected_class (timeout)" ; return } | |
163 | } | |
164 | ||
f683e100 | 165 | # Accept it if gdb just emits a superflous "private:" |
c906108c SS |
166 | # attribute, since classes default to private and for consistency with |
167 | # structs (where we don't print the "public:" attribute) we don't print | |
168 | # the "private:" attribute. | |
169 | ||
c906108c SS |
170 | send_gdb "ptype class default_private_class\n" |
171 | gdb_expect { | |
172 | -re "type = class default_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
f683e100 | 173 | pass "ptype class default_private_class" |
c906108c SS |
174 | } |
175 | -re "type = class default_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
f683e100 | 176 | pass "ptype class default_private_class" |
c906108c SS |
177 | } |
178 | -re ".*$gdb_prompt $" { fail "ptype class default_private_class" } | |
179 | timeout { fail "ptype class default_private_class (timeout)" ; return } | |
180 | } | |
181 | ||
182 | send_gdb "ptype class explicit_private_class\n" | |
183 | gdb_expect { | |
184 | -re "type = class explicit_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { | |
185 | pass "ptype class explicit_private_class" | |
186 | } | |
a0b3c4fd | 187 | -re "type = class explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { |
f683e100 | 188 | pass "ptype class explicit_private_class" |
a0b3c4fd | 189 | } |
c906108c | 190 | -re "type = struct explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { |
c906108c SS |
191 | fail "ptype class explicit_private_class" |
192 | } | |
193 | -re ".*$gdb_prompt $" { fail "ptype class explicit_private_class" } | |
194 | timeout { fail "ptype class explicit_private_class (timeout)" ; return } | |
195 | } | |
196 | ||
197 | send_gdb "ptype class mixed_protection_class\n" | |
198 | gdb_expect { | |
199 | -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;$nl.*\}$nl$gdb_prompt $" { | |
200 | pass "ptype class mixed_protection_class" | |
201 | } | |
202 | -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;$nl.*\}$nl$gdb_prompt $" { | |
c906108c SS |
203 | fail "ptype class mixed_protection_class" |
204 | } | |
205 | -re ".*$gdb_prompt $" { fail "ptype class mixed_protection_class" } | |
206 | timeout { fail "ptype class mixed_protection_class (timeout)" ; return } | |
207 | } | |
208 | ||
209 | # This class does not use any C++-specific features, so it's fine for | |
210 | # it to print as "struct". | |
211 | send_gdb "ptype class A\n" | |
212 | gdb_expect { | |
1bc05c3a | 213 | -re "type = (class|struct) A \{(${ws}public:|)${ws}int a;${ws}int x;((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\((A const|const A) ?&\\);)|(${ws}A\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
214 | pass "ptype class A" |
215 | } | |
216 | -re ".*$gdb_prompt $" { | |
217 | fail "ptype class A" | |
218 | } | |
219 | timeout { | |
220 | fail "ptype class A (timeout)" | |
221 | return | |
222 | } | |
223 | } | |
224 | ||
c906108c SS |
225 | send_gdb "ptype class B\n" |
226 | gdb_expect { | |
1bc05c3a | 227 | -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
228 | pass "ptype class B" |
229 | } | |
5178b9d6 | 230 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
231 | pass "ptype class B (obsolescent gcc or gdb)" |
232 | } | |
233 | -re ".*$gdb_prompt $" { | |
234 | fail "ptype class B" | |
235 | } | |
236 | timeout { | |
237 | fail "ptype class B (timeout)" | |
238 | return | |
239 | } | |
240 | } | |
241 | ||
c906108c SS |
242 | send_gdb "ptype class C\n" |
243 | gdb_expect { | |
1bc05c3a | 244 | -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;${ws}C & operator=\\(C const ?&\\);${ws}C\\((C const|const C) ?&\\);${ws}C\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
245 | pass "ptype class C" |
246 | } | |
5178b9d6 | 247 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
248 | pass "ptype class C (obsolescent gcc or gdb)" |
249 | } | |
250 | -re ".*$gdb_prompt $" { | |
251 | fail "ptype class C" | |
252 | } | |
253 | timeout { | |
254 | fail "ptype class C (timeout)" | |
255 | return | |
256 | } | |
257 | } | |
258 | ||
c906108c SS |
259 | send_gdb "ptype class D\n" |
260 | gdb_expect { | |
1bc05c3a | 261 | -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|const D) ?&\\);${ws}D\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
262 | pass "ptype class D" |
263 | } | |
5178b9d6 | 264 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
265 | pass "ptype class D (obsolescent gcc or gdb)" |
266 | } | |
267 | -re ".*$gdb_prompt $" { | |
268 | fail "ptype class D" | |
269 | } | |
270 | timeout { | |
271 | fail "ptype class D (timeout)" | |
272 | return | |
273 | } | |
274 | } | |
275 | ||
c906108c SS |
276 | send_gdb "ptype class E\n" |
277 | gdb_expect { | |
1bc05c3a | 278 | -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
279 | pass "ptype class E" |
280 | } | |
1bc05c3a | 281 | -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\((E const|const E) ?&\\);)|(${ws}E\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
282 | pass "ptype class E" |
283 | } | |
284 | -re ".*$gdb_prompt $" { | |
285 | fail "ptype class E" | |
286 | } | |
287 | timeout { | |
288 | fail "ptype class E (timeout)" | |
289 | return | |
290 | } | |
291 | } | |
292 | ||
af890c52 DJ |
293 | # With g++ 2.x and stabs debug info, we misinterpret static methods |
294 | # whose name matches their argument mangling. | |
295 | send_gdb "ptype class Static\n" | |
296 | gdb_expect { | |
1bc05c3a | 297 | -re "type = (class|struct) Static \{(${ws}public:|)${ws}Static & operator=\\(Static const ?&\\);${ws}Static\\((Static const|const Static) ?&\\);${ws}Static\\((void|)\\);${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" { |
af890c52 DJ |
298 | pass "ptype class Static" |
299 | } | |
3e36a0f4 DJ |
300 | -re "type = (class|struct) Static \{(${ws}public:|)${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" { |
301 | pass "ptype class Static" | |
302 | } | |
af890c52 DJ |
303 | -re ".*$gdb_prompt $" { |
304 | fail "ptype class Static" | |
305 | } | |
306 | timeout { | |
307 | fail "ptype class Static (timeout)" | |
308 | return | |
309 | } | |
310 | } | |
311 | ||
c906108c SS |
312 | send_gdb "ptype class vA\n" |
313 | gdb_expect { | |
3e36a0f4 DJ |
314 | -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}\}$nl$gdb_prompt $" { |
315 | pass "ptype class vA" | |
316 | } | |
1bc05c3a | 317 | -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}vA & operator=\\(vA const ?&\\);${ws}vA\\((vA const|const vA) ?&\\);${ws}vA\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
318 | pass "ptype class vA" |
319 | } | |
5178b9d6 | 320 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
321 | pass "ptype class vA (obsolescent gcc or gdb)" |
322 | } | |
323 | -re ".*$gdb_prompt $" { | |
324 | fail "ptype class vA" | |
325 | } | |
326 | timeout { | |
327 | fail "ptype class vA (timeout)" | |
328 | return | |
329 | } | |
330 | } | |
331 | ||
332 | # Accept the form with embedded GNU style mangled virtual table constructs | |
333 | # for now, but with a FIXME. At some future point, gdb should use a | |
334 | # portable representation for the virtual table constructs. | |
335 | ||
c2d11a7d JM |
336 | # The format of a g++ virtual base pointer. |
337 | set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?" | |
338 | ||
c906108c SS |
339 | send_gdb "ptype class vB\n" |
340 | gdb_expect { | |
3e36a0f4 | 341 | -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\((vB const|const vB) ?&\\);${ws}vB\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
5178b9d6 DJ |
342 | pass "ptype class vB" |
343 | } | |
344 | -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\(int, vB const ?&\\);${ws}vB\\(int\\);${ws}\}$nl$gdb_prompt $" { | |
c906108c SS |
345 | setup_xfail "*-*-*" |
346 | fail "ptype class vB (FIXME: non-portable virtual table constructs)" | |
347 | } | |
a0b3c4fd | 348 | -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}\}$nl$gdb_prompt $" { |
3e36a0f4 | 349 | pass "ptype class vB" |
a0b3c4fd | 350 | } |
5178b9d6 | 351 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
352 | setup_xfail "*-*-*" |
353 | fail "ptype class vB (FIXME) (obsolescent gcc or gdb)" | |
354 | } | |
355 | -re ".*$gdb_prompt $" { | |
356 | fail "ptype class vB" | |
357 | } | |
358 | timeout { | |
359 | fail "ptype class vB (timeout)" | |
360 | return | |
361 | } | |
362 | } | |
363 | ||
364 | # Accept the form with embedded GNU style mangled virtual table constructs | |
365 | # for now, but with a FIXME. At some future point, gdb should use a | |
366 | # portable representation for the virtual table constructs. | |
367 | ||
c906108c SS |
368 | send_gdb "ptype class vC\n" |
369 | gdb_expect { | |
3e36a0f4 | 370 | -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\((vC const|const vC) ?&\\);${ws}vC\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
5178b9d6 DJ |
371 | pass "ptype class vC" |
372 | } | |
373 | -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\(int, vC const ?&\\);${ws}vC\\(int\\);${ws}\}$nl$gdb_prompt $" { | |
c906108c SS |
374 | setup_xfail "*-*-*" |
375 | fail "ptype class vC (FIXME: non-portable virtual table constructs)" | |
376 | } | |
a0b3c4fd | 377 | -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}\}$nl$gdb_prompt $" { |
3e36a0f4 | 378 | pass "ptype class vC" |
a0b3c4fd | 379 | } |
5178b9d6 | 380 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
381 | setup_xfail "*-*-*" |
382 | fail "ptype class vC (FIXME) (obsolescent gcc or gdb)" | |
383 | } | |
384 | -re ".*$gdb_prompt $" { | |
385 | fail "ptype class vC" | |
386 | } | |
387 | timeout { | |
388 | fail "ptype class vC (timeout)" | |
389 | return | |
390 | } | |
391 | } | |
392 | ||
393 | # Accept the form with embedded GNU style mangled virtual table constructs | |
394 | # for now, but with a FIXME. At some future point, gdb should use a | |
395 | # portable representation for the virtual table constructs. | |
396 | ||
c906108c SS |
397 | send_gdb "ptype class vD\n" |
398 | gdb_expect { | |
3e36a0f4 | 399 | -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\((vD const|const vD) ?&\\);${ws}vD\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
5178b9d6 DJ |
400 | pass "ptype class vD" |
401 | } | |
402 | -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\(int, vD const ?&\\);${ws}vD\\(int\\);${ws}\}$nl$gdb_prompt $" { | |
c906108c SS |
403 | setup_xfail "*-*-*" |
404 | fail "ptype class vD (FIXME: non-portable virtual table constructs)" | |
405 | } | |
a0b3c4fd | 406 | -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}\}$nl$gdb_prompt $" { |
3e36a0f4 | 407 | pass "ptype class vD" |
a0b3c4fd | 408 | } |
5178b9d6 | 409 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
410 | setup_xfail "*-*-*" |
411 | fail "ptype class vD (FIXME) (obsolescent gcc or gdb)" | |
412 | } | |
413 | -re ".*$gdb_prompt $" { | |
414 | fail "ptype class vD" | |
415 | } | |
416 | timeout { | |
417 | fail "ptype class vD (timeout)" | |
418 | return | |
419 | } | |
420 | } | |
421 | ||
422 | # Accept the form with embedded GNU style mangled virtual table constructs | |
423 | # for now, but with a FIXME. At some future point, gdb should use a | |
424 | # portable representation for the virtual table constructs. | |
425 | ||
c906108c SS |
426 | send_gdb "ptype class vE\n" |
427 | gdb_expect { | |
3e36a0f4 | 428 | -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\((vE const|const vE) ?&\\);${ws}vE\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
5178b9d6 DJ |
429 | pass "ptype class vE" |
430 | } | |
431 | -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\(int, vE const ?&\\);${ws}vE\\(int\\);${ws}\}$nl$gdb_prompt $" { | |
c906108c SS |
432 | setup_xfail "*-*-*" |
433 | fail "ptype class vE (FIXME: non-portable virtual table constructs)" | |
434 | } | |
a0b3c4fd | 435 | -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}\}$nl$gdb_prompt $" { |
3e36a0f4 | 436 | pass "ptype class vE" |
a0b3c4fd | 437 | } |
5178b9d6 | 438 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
439 | setup_xfail "*-*-*" |
440 | fail "ptype class vE (FIXME) (obsolescent gcc or gdb)" | |
441 | } | |
442 | -re ".*$gdb_prompt $" { | |
443 | fail "ptype class vE" | |
444 | } | |
445 | timeout { | |
446 | fail "ptype class vE (timeout)" | |
447 | return | |
448 | } | |
449 | } | |
450 | ||
c906108c SS |
451 | send_gdb "ptype class Base1\n" |
452 | gdb_expect { | |
1bc05c3a | 453 | -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 & operator=\\(Base1 const ?&\\);${ws}Base1\\(((Base1 const)|(const Base1)) ?&\\);${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
454 | pass "ptype class Base1" |
455 | } | |
3e36a0f4 DJ |
456 | -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" { |
457 | pass "ptype class Base1" | |
458 | } | |
5178b9d6 | 459 | -re "type = class Base1 \{${ws}public:${ws}int x;((${ws}Base1 & operator=\\(Base1 const ?&\\);)|(${ws}Base1\\(Base1 const ?&\\);)|(${ws}Base1\\(int\\);))*${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
460 | pass "ptype class Base1 (obsolescent gcc or gdb)" |
461 | } | |
462 | -re ".*$gdb_prompt $" { | |
463 | fail "ptype class Base1" | |
464 | } | |
465 | timeout { | |
466 | fail "ptype class Base1 (timeout)" | |
467 | return | |
468 | } | |
469 | } | |
470 | ||
c906108c SS |
471 | send_gdb "ptype class Foo\n" |
472 | gdb_expect { | |
3e36a0f4 DJ |
473 | -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;\r\n${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" { |
474 | pass "ptype class Foo" | |
a0b3c4fd | 475 | } |
1bc05c3a | 476 | -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|const Foo) ?&\\);${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
477 | pass "ptype class Foo" |
478 | } | |
5178b9d6 | 479 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
480 | pass "ptype class Foo (obsolescent gcc or gdb)" |
481 | } | |
482 | -re ".*$gdb_prompt $" { | |
483 | fail "ptype class Foo" | |
484 | } | |
485 | timeout { | |
486 | fail "ptype class Foo (timeout)" | |
487 | return | |
488 | } | |
489 | } | |
490 | ||
c906108c SS |
491 | send_gdb "ptype class Bar\n" |
492 | gdb_expect { | |
1bc05c3a | 493 | -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar & operator=\\(Bar const ?&\\);${ws}Bar\\((Bar const|const Bar) ?&\\);${ws}Bar\\(int, int, int\\);${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
494 | pass "ptype class Bar" |
495 | } | |
5178b9d6 | 496 | -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}\}$nl$gdb_prompt $" { |
c906108c SS |
497 | pass "ptype class Bar (obsolescent gcc or gdb)" |
498 | } | |
499 | -re ".*$gdb_prompt $" { | |
500 | fail "ptype class Bar" | |
501 | } | |
502 | timeout { | |
503 | fail "ptype class Bar (timeout)" | |
504 | return | |
505 | } | |
506 | } | |
507 | } | |
508 | ||
509 | # | |
510 | # Test simple access to class members. | |
511 | # | |
512 | ||
513 | proc test_non_inherited_member_access {} { | |
514 | global gdb_prompt | |
515 | ||
516 | # Print non-inherited members of g_A. | |
517 | ||
518 | gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect" | |
519 | ||
520 | gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect" | |
521 | ||
522 | # Print non-inherited members of g_B. | |
523 | ||
524 | gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect" | |
525 | ||
526 | gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect" | |
527 | ||
528 | # Print non-inherited members of g_C. | |
529 | ||
530 | gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect" | |
531 | ||
532 | gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect" | |
533 | ||
534 | # Print non-inherited members of g_D. | |
535 | ||
536 | gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect" | |
537 | ||
538 | gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect" | |
539 | ||
540 | # Print non-inherited members of g_E. | |
541 | ||
542 | gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect" | |
543 | ||
544 | gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect" | |
545 | } | |
546 | ||
547 | # | |
548 | # Try access to non-members that are members of another class. | |
549 | # Should give errors. | |
550 | # | |
551 | ||
552 | proc test_wrong_class_members {} { | |
553 | global gdb_prompt | |
554 | ||
555 | gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error" | |
556 | ||
557 | gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error" | |
558 | ||
559 | gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error" | |
560 | ||
561 | gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error" | |
562 | ||
563 | gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error" | |
564 | ||
565 | gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error" | |
566 | } | |
567 | ||
568 | # | |
569 | # Try access to non-members that are not members of any class. | |
570 | # Should give errors. | |
571 | # | |
572 | ||
2bec0572 | 573 | proc test_nonexistent_members {} { |
c906108c SS |
574 | global gdb_prompt |
575 | ||
576 | gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error" | |
577 | ||
578 | gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error" | |
579 | ||
580 | gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error" | |
581 | ||
582 | gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error" | |
583 | } | |
584 | ||
54602222 ND |
585 | # |
586 | # Call a method that expects a base class parameter with base, inherited, | |
587 | # and unrelated class arguments. | |
588 | # | |
589 | ||
590 | proc test_method_param_class {} { | |
591 | gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a" | |
592 | gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2" "base class param->x" | |
593 | gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3" "inherited class param->a" | |
594 | gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4" "inherited class param->x" | |
595 | gdb_test "call class_param.Aref_a (g_A)" ".* = 1" "base class (¶m)->a" | |
596 | gdb_test "call class_param.Aref_x (g_A)" ".* = 2" "base class (¶m)->x" | |
597 | gdb_test "call class_param.Aref_a (g_B)" ".* = 3" "inherited class (¶m)->a" | |
598 | gdb_test "call class_param.Aref_x (g_B)" ".* = 4" "inherited class (¶m)->x" | |
599 | gdb_test "call class_param.Aval_a (g_A)" ".* = 1" "base class param.a" | |
600 | gdb_test "call class_param.Aval_x (g_A)" ".* = 2" "base class param.x" | |
601 | gdb_test "call class_param.Aval_a (g_B)" ".* = 3" "inherited class param.a" | |
602 | gdb_test "call class_param.Aval_x (g_B)" ".* = 4" "inherited class param.x" | |
603 | ||
604 | gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param" | |
605 | gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class ¶m" | |
606 | gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param" | |
607 | } | |
608 | ||
2bec0572 ND |
609 | # |
610 | # Examine a class with an enum field. | |
611 | # | |
612 | ||
613 | proc test_enums {} { | |
614 | global gdb_prompt | |
615 | global hp_aCC_compiler | |
616 | ||
617 | # print the object | |
618 | send_gdb "print obj_with_enum\n" | |
619 | gdb_expect { | |
620 | -re "\\$\[0-9\]* = \\{priv_enum = red, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (1)" } | |
621 | -re "$gdb_prompt $" { fail "print obj_with_enum (1)" } | |
622 | timeout { fail "(timeout) print obj_with_enum (1)" } | |
623 | } | |
624 | ||
625 | send_gdb "next\n" | |
626 | gdb_expect { | |
627 | -re "$gdb_prompt $" { pass "next" } | |
628 | timeout { fail "(timeout) next" } | |
629 | } | |
630 | ||
631 | # print the object again | |
632 | send_gdb "print obj_with_enum\n" | |
633 | gdb_expect { | |
634 | -re "\\$\[0-9\]* = \\{priv_enum = green, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (2)" } | |
635 | -re "$gdb_prompt $" { fail "print obj_with_enum (2)" } | |
636 | timeout { fail "(timeout) print obj_with_enum (2)" } | |
637 | } | |
638 | ||
639 | # print out the enum member | |
640 | send_gdb "print obj_with_enum.priv_enum\n" | |
641 | gdb_expect { | |
642 | -re "\\$\[0-9\]* = green.*$gdb_prompt $" { pass "print obj_with_enum.priv_enum" } | |
643 | -re "$gdb_prompt $" { fail "print obj_with_enum.priv_enum" } | |
644 | timeout { fail "(timeout) print obj_with_enum.priv_enum" } | |
645 | } | |
646 | ||
647 | # ptype on the enum member | |
648 | # The third success case is a little dubious, but it's not clear what | |
649 | # ought to be required of a ptype on a private enum... -sts 19990324 | |
650 | send_gdb "ptype obj_with_enum.priv_enum\n" | |
651 | gdb_expect { | |
652 | -re "type = enum ClassWithEnum::PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } | |
653 | -re "type = enum PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } | |
654 | -re "type = enum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } | |
655 | -re "$gdb_prompt $" { fail "ptype obj_with_enum.priv_enum" } | |
656 | timeout { fail "(timeout) ptype obj_with_enum.priv_enum" } | |
657 | } | |
658 | ||
659 | # ptype on the object | |
2bec0572 ND |
660 | send_gdb "ptype obj_with_enum\n" |
661 | gdb_expect { | |
662 | -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" } | |
6ece72da DC |
663 | -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)PrivEnum priv_enum;\r\n\[ \t\]*int x;.*\\}\r\n$gdb_prompt $" |
664 | { | |
665 | # NOTE: carlton/2003-02-28: One could certainly argue that | |
666 | # this output is acceptable: PrivEnum is a member of | |
667 | # ClassWithEnum, so there's no need to explicitly qualify | |
668 | # its name with "ClassWithEnum::". The truth, though, is | |
669 | # that GDB is simply forgetting that PrivEnum is a member | |
670 | # of ClassWithEnum, so we do that output for a bad reason | |
671 | # instead of a good reason. Under stabs, we probably | |
672 | # can't get this right; under DWARF-2, we can. | |
673 | kfail "gdb/57" "ptype obj_with_enum" | |
674 | } | |
2bec0572 ND |
675 | -re "$gdb_prompt $" { fail "ptype obj_with_enum" } |
676 | timeout { fail "(timeout) ptype obj_with_enum" } | |
677 | } | |
678 | ||
6ece72da DC |
679 | # We'll do this test twice, because of a parser bug: see |
680 | # PR gdb/826. | |
681 | ||
2bec0572 ND |
682 | send_gdb "print (ClassWithEnum::PrivEnum) 42\n" |
683 | gdb_expect { | |
684 | -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print (ClassWithEnum::PrivEnum) 42" } | |
6ece72da DC |
685 | -re "A parse error in expression, near `42'.\r\n$gdb_prompt $" |
686 | { kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42" } | |
2bec0572 ND |
687 | -re "$gdb_prompt $" { fail "print (ClassWithEnum::PrivEnum) 42" } |
688 | timeout { fail "(timeout) print (ClassWithEnum::PrivEnum) 42" } | |
689 | } | |
6ece72da DC |
690 | |
691 | send_gdb "print ('ClassWithEnum::PrivEnum') 42\n" | |
692 | gdb_expect { | |
693 | -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print ('ClassWithEnum::PrivEnum') 42" } | |
694 | -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.\r\n$gdb_prompt $" | |
695 | { kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42" } | |
696 | -re "$gdb_prompt $" { fail "print ('ClassWithEnum::PrivEnum') 42" } | |
697 | timeout { fail "(timeout) print ('ClassWithEnum::PrivEnum') 42" } | |
698 | } | |
2bec0572 ND |
699 | } |
700 | ||
c906108c SS |
701 | # |
702 | # Pointers to class members | |
703 | # | |
704 | ||
705 | proc test_pointers_to_class_members {} { | |
706 | global gdb_prompt | |
707 | global decimal | |
708 | global nl | |
709 | ||
710 | gdb_test "print Bar::z" ".* = .int\[ \]*\[( \]*Bar::&\[)\]+\[ \]*Bar::z" "print Bar::z" | |
711 | ||
712 | gdb_test "print &Foo::x" ".* = .int\[ \]*\[( \]*Foo::\[*)\]+\[ \]*&Foo::x" "print &Foo::x" | |
713 | ||
714 | gdb_test "print (int)&Foo::x" ".* = 0" "print (int)&Foo::x" | |
715 | ||
716 | send_gdb "print (int)&Bar::y == 2*sizeof(int)\n" | |
717 | gdb_expect { | |
718 | -re ".* = true$nl$gdb_prompt $" { | |
719 | pass "print (int)&Bar::y == 2*sizeof(int)" | |
720 | } | |
721 | -re "There is no field named y.*$gdb_prompt $" { | |
722 | setup_xfail "*-*-*" | |
723 | fail "print (int)&Bar::y == 2*sizeof(int)" | |
724 | } | |
725 | -re ".*$gdb_prompt $" { fail "print (int)&Bar::y == 2*sizeof(int)" } | |
726 | timeout { fail "print (int)&Bar::y == 2*sizeof(int) (timeout)" ; return } | |
727 | } | |
728 | ||
a0b3c4fd | 729 | send_gdb "next 2\n" |
c906108c SS |
730 | setup_xfail "*-*-*" |
731 | gdb_expect { | |
732 | -re "$decimal\[ \t\]+inheritance3 \[)(\]+;$nl$gdb_prompt $" {} | |
733 | -re ".*$gdb_prompt $" { fail "next to inheritance3" ; return } | |
734 | } | |
735 | clear_xfail "*-*-*" | |
736 | ||
c906108c SS |
737 | gdb_test "print (int)pmi == sizeof(int)" ".* = false" "print (int)pmi == sizeof(int)" |
738 | } | |
739 | ||
740 | # | |
741 | # Test static members. | |
742 | # | |
743 | ||
744 | proc test_static_members {} { | |
745 | global gdb_prompt | |
746 | global hex | |
747 | global nl | |
748 | ||
749 | send_gdb "print Foo::st\n" | |
750 | gdb_expect { | |
751 | -re ".* = 100$nl$gdb_prompt $" { | |
752 | pass "print Foo::st" | |
753 | } | |
754 | -re "There is no field named st.*$gdb_prompt $" { | |
755 | setup_xfail "*-*-*" | |
756 | fail "print Foo::st" | |
757 | } | |
758 | -re ".*$gdb_prompt $" { fail "print Foo::st" } | |
759 | timeout { fail "print Foo::st (timeout)" ; return } | |
760 | } | |
761 | ||
762 | send_gdb "set foo.st = 200\n" | |
763 | gdb_expect { | |
764 | -re ".*$gdb_prompt $" {} | |
765 | } | |
766 | ||
767 | send_gdb "print bar.st\n" | |
768 | gdb_expect { | |
769 | -re ".* = 200$nl$gdb_prompt $" { | |
770 | pass "print bar.st" | |
771 | } | |
772 | -re "There is no member( or method|) named st.*$gdb_prompt $" { | |
773 | setup_xfail "*-*-*" | |
774 | fail "print bar.st" | |
775 | } | |
776 | -re ".*$gdb_prompt $" { fail "print bar.st" } | |
777 | timeout { fail "print bar.st (timeout)" ; return } | |
778 | } | |
779 | ||
780 | send_gdb "print &foo.st\n" | |
781 | gdb_expect { | |
782 | -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { | |
783 | pass "print &foo.st" | |
784 | } | |
785 | -re "There is no member( or method|) named st.*$gdb_prompt $" { | |
786 | setup_xfail "*-*-*" | |
787 | fail "print &foo.st" | |
788 | } | |
789 | -re ".*$gdb_prompt $" { fail "print &foo.st" } | |
790 | timeout { fail "print &foo.st (timeout)" ; return } | |
791 | } | |
792 | ||
793 | set got_bar_st 0 | |
794 | send_gdb "print &Bar::st\n" | |
795 | gdb_expect { | |
796 | -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { | |
797 | pass "print &Bar::st" | |
798 | set got_bar_st 1 | |
799 | } | |
800 | -re "There is no field named st.*$gdb_prompt $" { | |
801 | setup_xfail "*-*-*" | |
802 | fail "print &Bar::st" | |
803 | } | |
804 | -re ".*$gdb_prompt $" { fail "print &Bar::st" } | |
805 | timeout { fail "print &Bar::st (timeout)" ; return } | |
806 | } | |
807 | ||
808 | if $got_bar_st then { | |
809 | gdb_test "print *\$" ".* = 200" "print *\$" | |
810 | } | |
811 | ||
812 | gdb_test "set print static-members off" "" | |
813 | gdb_test "print csi" \ | |
814 | "{x = 10, y = 20}" \ | |
815 | "print csi without static members" | |
816 | gdb_test "print cnsi" \ | |
817 | "{x = 30, y = 40}" \ | |
818 | "print cnsi without static members" | |
819 | ||
820 | gdb_test "set print static-members on" "" | |
c906108c SS |
821 | gdb_test "print csi" \ |
822 | "{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \ | |
823 | "print csi with static members" | |
c906108c SS |
824 | gdb_test "print cnsi" \ |
825 | "{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>}" \ | |
826 | "print cnsi with static members" | |
827 | } | |
828 | ||
829 | proc do_tests {} { | |
830 | global prms_id | |
831 | global bug_id | |
832 | global subdir | |
833 | global objdir | |
834 | global srcdir | |
835 | global binfile | |
836 | global gdb_prompt | |
837 | ||
838 | set prms_id 0 | |
839 | set bug_id 0 | |
840 | ||
841 | # Start with a fresh gdb. | |
842 | ||
843 | gdb_exit | |
844 | gdb_start | |
845 | gdb_reinitialize_dir $srcdir/$subdir | |
846 | gdb_load $binfile | |
847 | ||
848 | send_gdb "set language c++\n" | |
849 | gdb_expect -re "$gdb_prompt $" | |
850 | send_gdb "set width 0\n" | |
851 | gdb_expect -re "$gdb_prompt $" | |
852 | ||
40f235b7 | 853 | runto_main |
c906108c SS |
854 | test_ptype_class_objects |
855 | ||
1fa449a4 | 856 | if [ runto 'inheritance2' ] then { |
c906108c SS |
857 | test_non_inherited_member_access |
858 | test_wrong_class_members | |
2bec0572 | 859 | test_nonexistent_members |
54602222 | 860 | test_method_param_class |
2bec0572 ND |
861 | } |
862 | ||
863 | gdb_breakpoint enums2 | |
5178b9d6 | 864 | if [ gdb_continue "enums2(\\(\\)|)" ]==0 then { |
73d28ce1 | 865 | gdb_test "finish" "" "" |
2bec0572 | 866 | test_enums |
c906108c SS |
867 | } |
868 | ||
869 | if [istarget "mips-idt-*"] then { | |
870 | # Restart because IDT/SIM runs out of file descriptors. | |
871 | gdb_exit | |
872 | gdb_start | |
873 | gdb_reinitialize_dir $srcdir/$subdir | |
874 | gdb_load $binfile | |
875 | } | |
876 | ||
877 | if [ runto_main ] then { | |
878 | test_pointers_to_class_members | |
879 | test_static_members | |
880 | } | |
881 | ||
882 | if [istarget "mips-idt-*"] then { | |
883 | # Restart because IDT/SIM runs out of file descriptors. | |
884 | gdb_exit | |
885 | gdb_start | |
886 | gdb_reinitialize_dir $srcdir/$subdir | |
887 | gdb_load $binfile | |
888 | } | |
2bec0572 | 889 | |
c906108c SS |
890 | if [ runto marker_reg1 ] then { |
891 | ||
892 | gdb_test "finish" "Run till exit from.*" "finish from marker_reg1" | |
893 | ||
894 | send_gdb "print v.method ()\n" | |
895 | gdb_expect { | |
896 | -re "= 82.*$gdb_prompt $" { | |
897 | pass "calling method for small class" | |
898 | } | |
dd0fd3ce | 899 | -re "Address requested for identifier .v. which is in register.*$gdb_prompt $" { |
c906108c SS |
900 | setup_xfail "*-*-*" 2972 |
901 | fail "calling method for small class" | |
902 | } | |
903 | -re ".*$gdb_prompt $" { fail "calling method for small class" } | |
904 | timeout { fail "calling method for small class (timeout)" } | |
905 | eof { fail "calling method for small class (eof)" } | |
906 | } | |
907 | } | |
908 | ||
909 | } | |
910 | ||
911 | do_tests | |
912 | ||
c906108c SS |
913 | send_gdb "maint demangle inheritance1__Fv\n" |
914 | gdb_expect { | |
915 | -re "inheritance1\\(void\\).*$gdb_prompt $" { pass "demangle" } | |
916 | -re ".*$gdb_prompt $" { fail "demangle" } | |
917 | timeout { fail "(timeout) demangle" } | |
918 | } |