Commit | Line | Data |
---|---|---|
1bc05c3a | 1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 |
b6ba6518 | 2 | # 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. | |
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;$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 $" { | |
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;$nl.*\}$nl$gdb_prompt $" { | |
82 | pass "ptype struct explicit_public_struct" | |
83 | } | |
84 | -re "type = class explicit_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$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;$nl\}$nl$gdb_prompt $" { | |
99 | pass "ptype struct protected_struct (FIXME)" | |
100 | } | |
101 | -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$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;$nl\}$nl$gdb_prompt $" { | |
116 | pass "ptype struct private_struct (FIXME)" | |
117 | } | |
118 | -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$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;$nl\}$nl$gdb_prompt $" { | |
133 | pass "ptype struct mixed_protection_struct (FIXME)" | |
134 | } | |
a0b3c4fd JM |
135 | -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 $" { |
136 | pass "ptype struct mixed_protection_struct (extra public)" | |
137 | } | |
c906108c SS |
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;$nl.*\}$nl$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;$nl.*\}$nl$gdb_prompt $" { | |
152 | pass "ptype class public_class (FIXME)" | |
153 | } | |
154 | -re "type = struct public_class \{${ws}int a;${ws}int b;$nl\}$nl$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;$nl.*\}$nl$gdb_prompt $" { | |
165 | pass "ptype class protected_class" | |
166 | } | |
167 | -re "type = struct protected_class \{${ws}int a;${ws}int b;$nl\}$nl$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;$nl.*\}$nl$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;$nl.*\}$nl$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;$nl.*\}$nl$gdb_prompt $" { | |
197 | pass "ptype class explicit_private_class" | |
198 | } | |
a0b3c4fd JM |
199 | -re "type = class explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { |
200 | pass "ptype class explicit_private_class (OK for HP aCC)" | |
201 | } | |
c906108c SS |
202 | -re "type = struct explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$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;$nl.*\}$nl$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;$nl.*\}$nl$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 { | |
1bc05c3a | 227 | -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 |
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 { | |
1bc05c3a | 242 | -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 |
243 | pass "ptype class B" |
244 | } | |
5178b9d6 | 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}\}$nl$gdb_prompt $" { |
c906108c SS |
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 { | |
1bc05c3a | 260 | -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 |
261 | pass "ptype class C" |
262 | } | |
5178b9d6 | 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}\}$nl$gdb_prompt $" { |
c906108c SS |
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 { | |
1bc05c3a | 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|const D) ?&\\);${ws}D\\((void|)\\);${ws}\}$nl$gdb_prompt $" { |
c906108c SS |
279 | pass "ptype class D" |
280 | } | |
5178b9d6 | 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}\}$nl$gdb_prompt $" { |
c906108c SS |
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 { | |
1bc05c3a | 296 | -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 |
297 | pass "ptype class E" |
298 | } | |
1bc05c3a | 299 | -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 |
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 | ||
af890c52 DJ |
311 | # With g++ 2.x and stabs debug info, we misinterpret static methods |
312 | # whose name matches their argument mangling. | |
313 | send_gdb "ptype class Static\n" | |
314 | gdb_expect { | |
1bc05c3a | 315 | -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 |
316 | pass "ptype class Static" |
317 | } | |
318 | -re ".*$gdb_prompt $" { | |
319 | fail "ptype class Static" | |
320 | } | |
321 | timeout { | |
322 | fail "ptype class Static (timeout)" | |
323 | return | |
324 | } | |
325 | } | |
326 | ||
c906108c SS |
327 | send_gdb "ptype class vA\n" |
328 | gdb_expect { | |
1bc05c3a | 329 | -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 |
330 | pass "ptype class vA" |
331 | } | |
5178b9d6 | 332 | -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 |
333 | pass "ptype class vA (obsolescent gcc or gdb)" |
334 | } | |
335 | -re ".*$gdb_prompt $" { | |
336 | fail "ptype class vA" | |
337 | } | |
338 | timeout { | |
339 | fail "ptype class vA (timeout)" | |
340 | return | |
341 | } | |
342 | } | |
343 | ||
344 | # Accept the form with embedded GNU style mangled virtual table constructs | |
345 | # for now, but with a FIXME. At some future point, gdb should use a | |
346 | # portable representation for the virtual table constructs. | |
347 | ||
c2d11a7d JM |
348 | # The format of a g++ virtual base pointer. |
349 | set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?" | |
350 | ||
c906108c SS |
351 | setup_xfail_format "DWARF 1" |
352 | send_gdb "ptype class vB\n" | |
353 | gdb_expect { | |
1bc05c3a | 354 | -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\\(\\);${ws}\}$nl$gdb_prompt $" { |
5178b9d6 DJ |
355 | pass "ptype class vB" |
356 | } | |
357 | -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 |
358 | setup_xfail "*-*-*" |
359 | fail "ptype class vB (FIXME: non-portable virtual table constructs)" | |
360 | } | |
a0b3c4fd JM |
361 | -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}\}$nl$gdb_prompt $" { |
362 | pass "ptype class vB (aCC)" | |
363 | } | |
5178b9d6 | 364 | -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 |
365 | setup_xfail "*-*-*" |
366 | fail "ptype class vB (FIXME) (obsolescent gcc or gdb)" | |
367 | } | |
368 | -re ".*$gdb_prompt $" { | |
369 | fail "ptype class vB" | |
370 | } | |
371 | timeout { | |
372 | fail "ptype class vB (timeout)" | |
373 | return | |
374 | } | |
375 | } | |
376 | ||
377 | # Accept the form with embedded GNU style mangled virtual table constructs | |
378 | # for now, but with a FIXME. At some future point, gdb should use a | |
379 | # portable representation for the virtual table constructs. | |
380 | ||
381 | setup_xfail_format "DWARF 1" | |
382 | send_gdb "ptype class vC\n" | |
383 | gdb_expect { | |
1bc05c3a | 384 | -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\\(\\);${ws}\}$nl$gdb_prompt $" { |
5178b9d6 DJ |
385 | pass "ptype class vC" |
386 | } | |
387 | -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 |
388 | setup_xfail "*-*-*" |
389 | fail "ptype class vC (FIXME: non-portable virtual table constructs)" | |
390 | } | |
a0b3c4fd JM |
391 | -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}\}$nl$gdb_prompt $" { |
392 | pass "ptype class vC (aCC)" | |
393 | } | |
5178b9d6 | 394 | -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 |
395 | setup_xfail "*-*-*" |
396 | fail "ptype class vC (FIXME) (obsolescent gcc or gdb)" | |
397 | } | |
398 | -re ".*$gdb_prompt $" { | |
399 | fail "ptype class vC" | |
400 | } | |
401 | timeout { | |
402 | fail "ptype class vC (timeout)" | |
403 | return | |
404 | } | |
405 | } | |
406 | ||
407 | # Accept the form with embedded GNU style mangled virtual table constructs | |
408 | # for now, but with a FIXME. At some future point, gdb should use a | |
409 | # portable representation for the virtual table constructs. | |
410 | ||
411 | setup_xfail_format "DWARF 1" | |
412 | send_gdb "ptype class vD\n" | |
413 | gdb_expect { | |
1bc05c3a | 414 | -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\\(\\);${ws}\}$nl$gdb_prompt $" { |
5178b9d6 DJ |
415 | pass "ptype class vD" |
416 | } | |
417 | -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 |
418 | setup_xfail "*-*-*" |
419 | fail "ptype class vD (FIXME: non-portable virtual table constructs)" | |
420 | } | |
a0b3c4fd JM |
421 | -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}\}$nl$gdb_prompt $" { |
422 | pass "ptype class vD (aCC)" | |
423 | } | |
5178b9d6 | 424 | -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 |
425 | setup_xfail "*-*-*" |
426 | fail "ptype class vD (FIXME) (obsolescent gcc or gdb)" | |
427 | } | |
428 | -re ".*$gdb_prompt $" { | |
429 | fail "ptype class vD" | |
430 | } | |
431 | timeout { | |
432 | fail "ptype class vD (timeout)" | |
433 | return | |
434 | } | |
435 | } | |
436 | ||
437 | # Accept the form with embedded GNU style mangled virtual table constructs | |
438 | # for now, but with a FIXME. At some future point, gdb should use a | |
439 | # portable representation for the virtual table constructs. | |
440 | ||
441 | setup_xfail_format "DWARF 1" | |
442 | send_gdb "ptype class vE\n" | |
443 | gdb_expect { | |
1bc05c3a | 444 | -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\\(\\);${ws}\}$nl$gdb_prompt $" { |
5178b9d6 DJ |
445 | pass "ptype class vE" |
446 | } | |
447 | -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 |
448 | setup_xfail "*-*-*" |
449 | fail "ptype class vE (FIXME: non-portable virtual table constructs)" | |
450 | } | |
a0b3c4fd JM |
451 | -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}\}$nl$gdb_prompt $" { |
452 | pass "ptype class vE (aCC)" | |
453 | } | |
5178b9d6 | 454 | -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 |
455 | setup_xfail "*-*-*" |
456 | fail "ptype class vE (FIXME) (obsolescent gcc or gdb)" | |
457 | } | |
458 | -re ".*$gdb_prompt $" { | |
459 | fail "ptype class vE" | |
460 | } | |
461 | timeout { | |
462 | fail "ptype class vE (timeout)" | |
463 | return | |
464 | } | |
465 | } | |
466 | ||
467 | setup_xfail_format "DWARF 1" | |
468 | send_gdb "ptype class Base1\n" | |
469 | gdb_expect { | |
1bc05c3a | 470 | -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 |
471 | pass "ptype class Base1" |
472 | } | |
5178b9d6 | 473 | -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 |
474 | pass "ptype class Base1 (obsolescent gcc or gdb)" |
475 | } | |
476 | -re ".*$gdb_prompt $" { | |
477 | fail "ptype class Base1" | |
478 | } | |
479 | timeout { | |
480 | fail "ptype class Base1 (timeout)" | |
481 | return | |
482 | } | |
483 | } | |
484 | ||
485 | setup_xfail_format "DWARF 1" | |
486 | send_gdb "ptype class Foo\n" | |
487 | gdb_expect { | |
a0b3c4fd JM |
488 | -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 $" { |
489 | pass "ptype class Foo(aCC)" | |
490 | } | |
1bc05c3a | 491 | -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 |
492 | pass "ptype class Foo" |
493 | } | |
5178b9d6 | 494 | -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 |
495 | pass "ptype class Foo (obsolescent gcc or gdb)" |
496 | } | |
497 | -re ".*$gdb_prompt $" { | |
498 | fail "ptype class Foo" | |
499 | } | |
500 | timeout { | |
501 | fail "ptype class Foo (timeout)" | |
502 | return | |
503 | } | |
504 | } | |
505 | ||
506 | setup_xfail_format "DWARF 1" | |
507 | send_gdb "ptype class Bar\n" | |
508 | gdb_expect { | |
1bc05c3a | 509 | -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 |
510 | pass "ptype class Bar" |
511 | } | |
5178b9d6 | 512 | -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 |
513 | pass "ptype class Bar (obsolescent gcc or gdb)" |
514 | } | |
515 | -re ".*$gdb_prompt $" { | |
516 | fail "ptype class Bar" | |
517 | } | |
518 | timeout { | |
519 | fail "ptype class Bar (timeout)" | |
520 | return | |
521 | } | |
522 | } | |
523 | } | |
524 | ||
525 | # | |
526 | # Test simple access to class members. | |
527 | # | |
528 | ||
529 | proc test_non_inherited_member_access {} { | |
530 | global gdb_prompt | |
531 | ||
532 | # Print non-inherited members of g_A. | |
533 | ||
534 | gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect" | |
535 | ||
536 | gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect" | |
537 | ||
538 | # Print non-inherited members of g_B. | |
539 | ||
540 | gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect" | |
541 | ||
542 | gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect" | |
543 | ||
544 | # Print non-inherited members of g_C. | |
545 | ||
546 | gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect" | |
547 | ||
548 | gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect" | |
549 | ||
550 | # Print non-inherited members of g_D. | |
551 | ||
552 | gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect" | |
553 | ||
554 | gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect" | |
555 | ||
556 | # Print non-inherited members of g_E. | |
557 | ||
558 | gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect" | |
559 | ||
560 | gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect" | |
561 | } | |
562 | ||
563 | # | |
564 | # Try access to non-members that are members of another class. | |
565 | # Should give errors. | |
566 | # | |
567 | ||
568 | proc test_wrong_class_members {} { | |
569 | global gdb_prompt | |
570 | ||
571 | gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error" | |
572 | ||
573 | gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error" | |
574 | ||
575 | gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error" | |
576 | ||
577 | gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error" | |
578 | ||
579 | gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error" | |
580 | ||
581 | gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error" | |
582 | } | |
583 | ||
584 | # | |
585 | # Try access to non-members that are not members of any class. | |
586 | # Should give errors. | |
587 | # | |
588 | ||
2bec0572 | 589 | proc test_nonexistent_members {} { |
c906108c SS |
590 | global gdb_prompt |
591 | ||
592 | gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error" | |
593 | ||
594 | gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error" | |
595 | ||
596 | gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error" | |
597 | ||
598 | gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error" | |
599 | } | |
600 | ||
54602222 ND |
601 | # |
602 | # Call a method that expects a base class parameter with base, inherited, | |
603 | # and unrelated class arguments. | |
604 | # | |
605 | ||
606 | proc test_method_param_class {} { | |
607 | gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a" | |
608 | gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2" "base class param->x" | |
609 | gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3" "inherited class param->a" | |
610 | gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4" "inherited class param->x" | |
611 | gdb_test "call class_param.Aref_a (g_A)" ".* = 1" "base class (¶m)->a" | |
612 | gdb_test "call class_param.Aref_x (g_A)" ".* = 2" "base class (¶m)->x" | |
613 | gdb_test "call class_param.Aref_a (g_B)" ".* = 3" "inherited class (¶m)->a" | |
614 | gdb_test "call class_param.Aref_x (g_B)" ".* = 4" "inherited class (¶m)->x" | |
615 | gdb_test "call class_param.Aval_a (g_A)" ".* = 1" "base class param.a" | |
616 | gdb_test "call class_param.Aval_x (g_A)" ".* = 2" "base class param.x" | |
617 | gdb_test "call class_param.Aval_a (g_B)" ".* = 3" "inherited class param.a" | |
618 | gdb_test "call class_param.Aval_x (g_B)" ".* = 4" "inherited class param.x" | |
619 | ||
620 | gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param" | |
621 | gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class ¶m" | |
622 | gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param" | |
623 | } | |
624 | ||
2bec0572 ND |
625 | # |
626 | # Examine a class with an enum field. | |
627 | # | |
628 | ||
629 | proc test_enums {} { | |
630 | global gdb_prompt | |
631 | global hp_aCC_compiler | |
632 | ||
633 | # print the object | |
634 | send_gdb "print obj_with_enum\n" | |
635 | gdb_expect { | |
636 | -re "\\$\[0-9\]* = \\{priv_enum = red, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (1)" } | |
637 | -re "$gdb_prompt $" { fail "print obj_with_enum (1)" } | |
638 | timeout { fail "(timeout) print obj_with_enum (1)" } | |
639 | } | |
640 | ||
641 | send_gdb "next\n" | |
642 | gdb_expect { | |
643 | -re "$gdb_prompt $" { pass "next" } | |
644 | timeout { fail "(timeout) next" } | |
645 | } | |
646 | ||
647 | # print the object again | |
648 | send_gdb "print obj_with_enum\n" | |
649 | gdb_expect { | |
650 | -re "\\$\[0-9\]* = \\{priv_enum = green, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (2)" } | |
651 | -re "$gdb_prompt $" { fail "print obj_with_enum (2)" } | |
652 | timeout { fail "(timeout) print obj_with_enum (2)" } | |
653 | } | |
654 | ||
655 | # print out the enum member | |
656 | send_gdb "print obj_with_enum.priv_enum\n" | |
657 | gdb_expect { | |
658 | -re "\\$\[0-9\]* = green.*$gdb_prompt $" { pass "print obj_with_enum.priv_enum" } | |
659 | -re "$gdb_prompt $" { fail "print obj_with_enum.priv_enum" } | |
660 | timeout { fail "(timeout) print obj_with_enum.priv_enum" } | |
661 | } | |
662 | ||
663 | # ptype on the enum member | |
664 | # The third success case is a little dubious, but it's not clear what | |
665 | # ought to be required of a ptype on a private enum... -sts 19990324 | |
666 | send_gdb "ptype obj_with_enum.priv_enum\n" | |
667 | gdb_expect { | |
668 | -re "type = enum ClassWithEnum::PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } | |
669 | -re "type = enum PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } | |
670 | -re "type = enum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } | |
671 | -re "$gdb_prompt $" { fail "ptype obj_with_enum.priv_enum" } | |
672 | timeout { fail "(timeout) ptype obj_with_enum.priv_enum" } | |
673 | } | |
674 | ||
675 | # ptype on the object | |
676 | # g++ is putting out the wrong debug info. This works with aCC | |
677 | if {!$hp_aCC_compiler} {setup_xfail "*-*-*"} | |
678 | send_gdb "ptype obj_with_enum\n" | |
679 | gdb_expect { | |
680 | -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" } | |
681 | -re "$gdb_prompt $" { fail "ptype obj_with_enum" } | |
682 | timeout { fail "(timeout) ptype obj_with_enum" } | |
683 | } | |
684 | ||
685 | # g++ is putting out the wrong debug info. This works with aCC | |
686 | if {!$hp_aCC_compiler} {setup_xfail "*-*-*"} | |
687 | send_gdb "print (ClassWithEnum::PrivEnum) 42\n" | |
688 | gdb_expect { | |
689 | -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print (ClassWithEnum::PrivEnum) 42" } | |
690 | -re "$gdb_prompt $" { fail "print (ClassWithEnum::PrivEnum) 42" } | |
691 | timeout { fail "(timeout) print (ClassWithEnum::PrivEnum) 42" } | |
692 | } | |
693 | } | |
694 | ||
c906108c SS |
695 | # |
696 | # Pointers to class members | |
697 | # | |
698 | ||
699 | proc test_pointers_to_class_members {} { | |
700 | global gdb_prompt | |
701 | global decimal | |
702 | global nl | |
703 | ||
704 | gdb_test "print Bar::z" ".* = .int\[ \]*\[( \]*Bar::&\[)\]+\[ \]*Bar::z" "print Bar::z" | |
705 | ||
706 | gdb_test "print &Foo::x" ".* = .int\[ \]*\[( \]*Foo::\[*)\]+\[ \]*&Foo::x" "print &Foo::x" | |
707 | ||
708 | gdb_test "print (int)&Foo::x" ".* = 0" "print (int)&Foo::x" | |
709 | ||
710 | send_gdb "print (int)&Bar::y == 2*sizeof(int)\n" | |
711 | gdb_expect { | |
712 | -re ".* = true$nl$gdb_prompt $" { | |
713 | pass "print (int)&Bar::y == 2*sizeof(int)" | |
714 | } | |
715 | -re "There is no field named y.*$gdb_prompt $" { | |
716 | setup_xfail "*-*-*" | |
717 | fail "print (int)&Bar::y == 2*sizeof(int)" | |
718 | } | |
719 | -re ".*$gdb_prompt $" { fail "print (int)&Bar::y == 2*sizeof(int)" } | |
720 | timeout { fail "print (int)&Bar::y == 2*sizeof(int) (timeout)" ; return } | |
721 | } | |
722 | ||
a0b3c4fd | 723 | send_gdb "next 2\n" |
c906108c SS |
724 | setup_xfail "*-*-*" |
725 | gdb_expect { | |
726 | -re "$decimal\[ \t\]+inheritance3 \[)(\]+;$nl$gdb_prompt $" {} | |
727 | -re ".*$gdb_prompt $" { fail "next to inheritance3" ; return } | |
728 | } | |
729 | clear_xfail "*-*-*" | |
730 | ||
731 | setup_xfail_format "DWARF 1" | |
732 | gdb_test "print (int)pmi == sizeof(int)" ".* = false" "print (int)pmi == sizeof(int)" | |
733 | } | |
734 | ||
735 | # | |
736 | # Test static members. | |
737 | # | |
738 | ||
739 | proc test_static_members {} { | |
740 | global gdb_prompt | |
741 | global hex | |
742 | global nl | |
743 | ||
744 | send_gdb "print Foo::st\n" | |
745 | gdb_expect { | |
746 | -re ".* = 100$nl$gdb_prompt $" { | |
747 | pass "print Foo::st" | |
748 | } | |
749 | -re "There is no field named st.*$gdb_prompt $" { | |
750 | setup_xfail "*-*-*" | |
751 | fail "print Foo::st" | |
752 | } | |
753 | -re ".*$gdb_prompt $" { fail "print Foo::st" } | |
754 | timeout { fail "print Foo::st (timeout)" ; return } | |
755 | } | |
756 | ||
757 | send_gdb "set foo.st = 200\n" | |
758 | gdb_expect { | |
759 | -re ".*$gdb_prompt $" {} | |
760 | } | |
761 | ||
762 | send_gdb "print bar.st\n" | |
763 | gdb_expect { | |
764 | -re ".* = 200$nl$gdb_prompt $" { | |
765 | pass "print bar.st" | |
766 | } | |
767 | -re "There is no member( or method|) named st.*$gdb_prompt $" { | |
768 | setup_xfail "*-*-*" | |
769 | fail "print bar.st" | |
770 | } | |
771 | -re ".*$gdb_prompt $" { fail "print bar.st" } | |
772 | timeout { fail "print bar.st (timeout)" ; return } | |
773 | } | |
774 | ||
775 | send_gdb "print &foo.st\n" | |
776 | gdb_expect { | |
777 | -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { | |
778 | pass "print &foo.st" | |
779 | } | |
780 | -re "There is no member( or method|) named st.*$gdb_prompt $" { | |
781 | setup_xfail "*-*-*" | |
782 | fail "print &foo.st" | |
783 | } | |
784 | -re ".*$gdb_prompt $" { fail "print &foo.st" } | |
785 | timeout { fail "print &foo.st (timeout)" ; return } | |
786 | } | |
787 | ||
788 | set got_bar_st 0 | |
789 | send_gdb "print &Bar::st\n" | |
790 | gdb_expect { | |
791 | -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { | |
792 | pass "print &Bar::st" | |
793 | set got_bar_st 1 | |
794 | } | |
795 | -re "There is no field named st.*$gdb_prompt $" { | |
796 | setup_xfail "*-*-*" | |
797 | fail "print &Bar::st" | |
798 | } | |
799 | -re ".*$gdb_prompt $" { fail "print &Bar::st" } | |
800 | timeout { fail "print &Bar::st (timeout)" ; return } | |
801 | } | |
802 | ||
803 | if $got_bar_st then { | |
804 | gdb_test "print *\$" ".* = 200" "print *\$" | |
805 | } | |
806 | ||
807 | gdb_test "set print static-members off" "" | |
808 | gdb_test "print csi" \ | |
809 | "{x = 10, y = 20}" \ | |
810 | "print csi without static members" | |
811 | gdb_test "print cnsi" \ | |
812 | "{x = 30, y = 40}" \ | |
813 | "print cnsi without static members" | |
814 | ||
815 | gdb_test "set print static-members on" "" | |
816 | setup_xfail_format "DWARF 1" | |
817 | gdb_test "print csi" \ | |
818 | "{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \ | |
819 | "print csi with static members" | |
820 | setup_xfail_format "DWARF 1" | |
821 | gdb_test "print cnsi" \ | |
822 | "{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>}" \ | |
823 | "print cnsi with static members" | |
824 | } | |
825 | ||
826 | proc do_tests {} { | |
827 | global prms_id | |
828 | global bug_id | |
829 | global subdir | |
830 | global objdir | |
831 | global srcdir | |
832 | global binfile | |
833 | global gdb_prompt | |
834 | ||
835 | set prms_id 0 | |
836 | set bug_id 0 | |
837 | ||
838 | # Start with a fresh gdb. | |
839 | ||
840 | gdb_exit | |
841 | gdb_start | |
842 | gdb_reinitialize_dir $srcdir/$subdir | |
843 | gdb_load $binfile | |
844 | ||
845 | send_gdb "set language c++\n" | |
846 | gdb_expect -re "$gdb_prompt $" | |
847 | send_gdb "set width 0\n" | |
848 | gdb_expect -re "$gdb_prompt $" | |
849 | ||
850 | # Get the debug format for the compiled test case. | |
851 | ||
852 | if [ runto_main ] then { | |
853 | get_debug_format | |
854 | } | |
855 | ||
856 | test_ptype_class_objects | |
857 | ||
1fa449a4 | 858 | if [ runto 'inheritance2' ] then { |
c906108c SS |
859 | test_non_inherited_member_access |
860 | test_wrong_class_members | |
2bec0572 | 861 | test_nonexistent_members |
54602222 | 862 | test_method_param_class |
2bec0572 ND |
863 | } |
864 | ||
865 | gdb_breakpoint enums2 | |
5178b9d6 | 866 | if [ gdb_continue "enums2(\\(\\)|)" ]==0 then { |
73d28ce1 | 867 | gdb_test "finish" "" "" |
2bec0572 | 868 | test_enums |
c906108c SS |
869 | } |
870 | ||
871 | if [istarget "mips-idt-*"] then { | |
872 | # Restart because IDT/SIM runs out of file descriptors. | |
873 | gdb_exit | |
874 | gdb_start | |
875 | gdb_reinitialize_dir $srcdir/$subdir | |
876 | gdb_load $binfile | |
877 | } | |
878 | ||
879 | if [ runto_main ] then { | |
880 | test_pointers_to_class_members | |
881 | test_static_members | |
882 | } | |
883 | ||
884 | if [istarget "mips-idt-*"] then { | |
885 | # Restart because IDT/SIM runs out of file descriptors. | |
886 | gdb_exit | |
887 | gdb_start | |
888 | gdb_reinitialize_dir $srcdir/$subdir | |
889 | gdb_load $binfile | |
890 | } | |
2bec0572 | 891 | |
c906108c SS |
892 | if [ runto marker_reg1 ] then { |
893 | ||
894 | gdb_test "finish" "Run till exit from.*" "finish from marker_reg1" | |
895 | ||
896 | send_gdb "print v.method ()\n" | |
897 | gdb_expect { | |
898 | -re "= 82.*$gdb_prompt $" { | |
899 | pass "calling method for small class" | |
900 | } | |
901 | -re "Address requested for identifier .v. which is in a register.*$gdb_prompt $" { | |
902 | setup_xfail "*-*-*" 2972 | |
903 | fail "calling method for small class" | |
904 | } | |
905 | -re ".*$gdb_prompt $" { fail "calling method for small class" } | |
906 | timeout { fail "calling method for small class (timeout)" } | |
907 | eof { fail "calling method for small class (eof)" } | |
908 | } | |
909 | } | |
910 | ||
911 | } | |
912 | ||
913 | do_tests | |
914 | ||
c906108c SS |
915 | send_gdb "maint demangle inheritance1__Fv\n" |
916 | gdb_expect { | |
917 | -re "inheritance1\\(void\\).*$gdb_prompt $" { pass "demangle" } | |
918 | -re ".*$gdb_prompt $" { fail "demangle" } | |
919 | timeout { fail "(timeout) demangle" } | |
920 | } |