Commit | Line | Data |
---|---|---|
40f235b7 | 1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
184ad485 | 2 | # 2003, 2004 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) | |
1cd3489f | 22 | # And rewritten by Michael Chastain <mec.gnu@mindspring.com>. |
c906108c SS |
23 | |
24 | set ws "\[\r\n\t \]+" | |
25 | set nl "\[\r\n\]+" | |
26 | ||
27 | if $tracelevel then { | |
1cd3489f | 28 | strace $tracelevel |
c906108c SS |
29 | } |
30 | ||
d4f3574e | 31 | if { [skip_cplus_tests] } { continue } |
c906108c SS |
32 | |
33 | set testfile "misc" | |
34 | set srcfile ${testfile}.cc | |
35 | set binfile ${objdir}/${subdir}/${testfile} | |
36 | ||
c906108c SS |
37 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { |
38 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
39 | } | |
40 | ||
c906108c SS |
41 | # Test ptype of class objects. |
42 | # | |
1cd3489f MC |
43 | # This code accepts the output of gcc v2 and v3, dwarf-2 and stabs+. |
44 | # It could use some expansion with other compilers such as hp-ux ac++. | |
45 | # | |
46 | # There are lots of variations in the output: | |
47 | # | |
48 | # . gcc -stabs+ emits debug info for implicit member functions: | |
49 | # operator=, copy ctor, ctor. gcc -gdwarf-2 does not. | |
50 | # | |
51 | # . gcc with abi version 1 puts the implicit member functions | |
52 | # at the beginning of the member function list; with abi version 2, | |
53 | # the implicit member functions are at the end of the member function | |
54 | # list. This appears as an output difference with -gstabs+. | |
55 | # gcc 3.3.X defaults to abi version 1, and gcc 3.4 will default | |
56 | # to abi version 2. | |
57 | # | |
58 | # . gcc v2 shows data members for virtual base pointers. | |
59 | # gcc v3 does not. | |
60 | # | |
61 | # . gdb always prints "class" for both "class" and "struct". | |
62 | # In the future, I should accept "struct" in case gdb improves. | |
c906108c SS |
63 | |
64 | proc test_ptype_class_objects {} { | |
65 | global gdb_prompt | |
66 | global ws | |
67 | global nl | |
68 | ||
1cd3489f | 69 | # Simple type. |
c906108c | 70 | |
1cd3489f MC |
71 | gdb_test_multiple "ptype struct default_public_struct" "ptype struct default_public_struct" { |
72 | -re "type = class default_public_struct \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
73 | # gcc 2.95.3 -gdwarf-2 | |
74 | # gcc 3.3.2 -gdwarf-2 | |
75 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
c906108c SS |
76 | pass "ptype struct default_public_struct" |
77 | } | |
1cd3489f MC |
78 | -re "type = class default_public_struct \{${ws}public:${ws}int a;${ws}int b;${ws}default_public_struct ?& ?operator ?=\\(default_public_struct const ?&\\);${ws}default_public_struct\\(default_public_struct const ?&\\);${ws}default_public_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
79 | # gcc 2.95.3 -gstabs+ | |
80 | # gcc 3.3.2 -gstabs+ | |
81 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
f683e100 | 82 | pass "ptype struct default_public_struct" |
c906108c | 83 | } |
c906108c SS |
84 | } |
85 | ||
1cd3489f | 86 | # Same test, slightly different type. |
c906108c | 87 | |
1cd3489f MC |
88 | gdb_test_multiple "ptype struct explicit_public_struct" "ptype struct explicit_public_struct" { |
89 | -re "type = class explicit_public_struct \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
90 | # gcc 2.95.3 -gdwarf-2 | |
91 | # gcc 3.3.2 -gdwarf-2 | |
92 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
c906108c SS |
93 | pass "ptype struct explicit_public_struct" |
94 | } | |
1cd3489f MC |
95 | -re "type = class explicit_public_struct \{${ws}public:${ws}int a;${ws}int b;${ws}explicit_public_struct ?& ?operator ?=\\(explicit_public_struct const ?&\\);${ws}explicit_public_struct\\(explicit_public_struct const ?&\\);${ws}explicit_public_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
96 | # gcc 2.95.3 -gstabs+ | |
97 | # gcc 3.3.2 -gstabs+ | |
98 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
f683e100 | 99 | pass "ptype struct explicit_public_struct" |
c906108c | 100 | } |
c906108c SS |
101 | } |
102 | ||
1cd3489f | 103 | # Same test, slightly different type. |
c906108c | 104 | |
1cd3489f MC |
105 | gdb_test_multiple "ptype struct protected_struct" "ptype struct protected_struct" { |
106 | -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
107 | # gcc 2.95.3 -gdwarf-2 | |
108 | # gcc 3.3.2 -gdwarf-2 | |
109 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
f683e100 | 110 | pass "ptype struct protected_struct" |
c906108c | 111 | } |
1cd3489f MC |
112 | -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;${ws}public:${ws}protected_struct ?& ?operator ?=\\(protected_struct const ?&\\);${ws}protected_struct\\(protected_struct const ?&\\);${ws}protected_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
113 | # gcc 2.95.3 -gstabs+ | |
114 | # gcc 3.3.2 -gstabs+ | |
115 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
f683e100 | 116 | pass "ptype struct protected_struct" |
c906108c | 117 | } |
c906108c SS |
118 | } |
119 | ||
1cd3489f | 120 | # Same test, slightly different type. |
c906108c | 121 | |
1cd3489f MC |
122 | gdb_test_multiple "ptype struct private_struct" "ptype struct private_struct" { |
123 | -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
124 | # gcc 2.95.3 -gdwarf-2 | |
125 | # gcc 3.3.2 -gdwarf-2 | |
126 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
f683e100 | 127 | pass "ptype struct private_struct" |
c906108c | 128 | } |
1cd3489f MC |
129 | -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;${ws}public:${ws}private_struct ?& ?operator ?=\\(private_struct const ?&\\);${ws}private_struct\\(private_struct const ?&\\);${ws}private_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
130 | # gcc 2.95.3 -gstabs+ | |
131 | # gcc 3.3.2 -gstabs+ | |
132 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
f683e100 | 133 | pass "ptype struct private_struct" |
c906108c | 134 | } |
c906108c SS |
135 | } |
136 | ||
1cd3489f | 137 | # Similar test, bigger type. |
c906108c | 138 | |
1cd3489f MC |
139 | gdb_test_multiple "ptype struct mixed_protection_struct" "ptype struct mixed_protection_struct" { |
140 | -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 $" { | |
141 | # gcc 2.95.3 -gdwarf-2 | |
142 | # gcc 3.3.2 -gdwarf-2 | |
143 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
f683e100 | 144 | pass "ptype struct mixed_protection_struct" |
c906108c | 145 | } |
1cd3489f MC |
146 | -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;${ws}public:${ws}mixed_protection_struct ?& ?operator ?=\\(mixed_protection_struct const ?&\\);${ws}mixed_protection_struct\\(mixed_protection_struct const ?&\\);${ws}mixed_protection_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
147 | # gcc 2.95.3 -gstabs+ | |
148 | # gcc 3.3.2 -gstabs+ | |
149 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
f683e100 | 150 | pass "ptype struct mixed_protection_struct" |
c906108c | 151 | } |
c906108c SS |
152 | } |
153 | ||
1cd3489f MC |
154 | # All that again with "class" instead of "struct". |
155 | # gdb does not care about the difference anyways. | |
c906108c | 156 | |
1cd3489f MC |
157 | gdb_test_multiple "ptype class public_class" "ptype class public_class" { |
158 | -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
159 | # gcc 2.95.3 -gdwarf-2 | |
160 | # gcc 3.3.2 -gdwarf-2 | |
161 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
f683e100 | 162 | pass "ptype class public_class" |
c906108c | 163 | } |
1cd3489f MC |
164 | -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;${ws}public_class ?& ?operator ?=\\(public_class const ?&\\);${ws}public_class\\(public_class const ?&\\);${ws}public_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
165 | # gcc 2.95.3 -gstabs+ | |
166 | # gcc 3.3.2 -gstabs+ | |
167 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
8a151ee0 | 168 | pass "ptype class public_class" |
c906108c | 169 | } |
c906108c SS |
170 | } |
171 | ||
1cd3489f MC |
172 | # Same test, slightly different type. |
173 | ||
174 | gdb_test_multiple "ptype class protected_class" "ptype class protected_class" { | |
175 | -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
176 | # gcc 2.95.3 -gdwarf-2 | |
177 | # gcc 3.3.2 -gdwarf-2 | |
178 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
c906108c SS |
179 | pass "ptype class protected_class" |
180 | } | |
1cd3489f MC |
181 | -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;${ws}public:${ws}protected_class ?& ?operator ?=\\(protected_class const ?&\\);${ws}protected_class\\(protected_class const ?&\\);${ws}protected_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
182 | # gcc 2.95.3 -gstabs+ | |
183 | # gcc 3.3.2 -gstabs+ | |
184 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
185 | pass "ptype class protected_class" | |
c906108c | 186 | } |
c906108c SS |
187 | } |
188 | ||
1cd3489f MC |
189 | # Same test, slightly different type. |
190 | # The 'private' is optional but gdb always prints it. | |
c906108c | 191 | |
1cd3489f MC |
192 | gdb_test_multiple "ptype class default_private_class" "ptype class default_private_class" { |
193 | -re "type = class default_private_class \{${ws}(private:${ws}|)int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
194 | # gcc 2.95.3 -gdwarf-2 | |
195 | # gcc 3.3.2 -gdwarf-2 | |
196 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
f683e100 | 197 | pass "ptype class default_private_class" |
c906108c | 198 | } |
1cd3489f MC |
199 | -re "type = class default_private_class \{${ws}(private:${ws}|)int a;${ws}int b;${ws}public:${ws}default_private_class ?& ?operator ?=\\(default_private_class const ?&\\);${ws}default_private_class\\(default_private_class const ?&\\);${ws}default_private_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
200 | # gcc 2.95.3 -gstabs+ | |
201 | # gcc 3.3.2 -gstabs+ | |
202 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
f683e100 | 203 | pass "ptype class default_private_class" |
c906108c | 204 | } |
c906108c SS |
205 | } |
206 | ||
1cd3489f MC |
207 | # Same test, slightly different type. |
208 | ||
209 | gdb_test_multiple "ptype class explicit_private_class" "ptype class explicit_private_class" { | |
210 | -re "type = class explicit_private_class \{${ws}(private:${ws}|)int a;${ws}int b;$nl\}$nl$gdb_prompt $" { | |
211 | # gcc 2.95.3 -gdwarf-2 | |
212 | # gcc 3.3.2 -gdwarf-2 | |
213 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
c906108c SS |
214 | pass "ptype class explicit_private_class" |
215 | } | |
1cd3489f MC |
216 | -re "type = class explicit_private_class \{${ws}(private:${ws}|)int a;${ws}int b;${ws}public:${ws}explicit_private_class ?& ?operator ?=\\(explicit_private_class const ?&\\);${ws}explicit_private_class\\(explicit_private_class const ?&\\);${ws}explicit_private_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
217 | # gcc 2.95.3 -gstabs+ | |
218 | # gcc 3.3.2 -gstabs+ | |
219 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
220 | pass "ptype class explicit_private_class" | |
c906108c | 221 | } |
c906108c SS |
222 | } |
223 | ||
1cd3489f MC |
224 | # Similar test, bigger type. |
225 | ||
226 | gdb_test_multiple "ptype class mixed_protection_class" "ptype struct mixed_protection_class" { | |
227 | -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 $" { | |
228 | # gcc 2.95.3 -gdwarf-2 | |
229 | # gcc 3.3.2 -gdwarf-2 | |
230 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
c906108c SS |
231 | pass "ptype class mixed_protection_class" |
232 | } | |
1cd3489f MC |
233 | -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;${ws}public:${ws}mixed_protection_class ?& ?operator ?=\\(mixed_protection_class const ?&\\);${ws}mixed_protection_class\\(mixed_protection_class const ?&\\);${ws}mixed_protection_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
234 | # gcc 2.95.3 -gstabs+ | |
235 | # gcc 3.3.2 -gstabs+ | |
236 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
237 | pass "ptype class mixed_protection_class" | |
c906108c | 238 | } |
c906108c SS |
239 | } |
240 | ||
1cd3489f MC |
241 | # Here are some classes with inheritance. |
242 | ||
243 | # Base class. | |
244 | ||
245 | gdb_test_multiple "ptype class A" "ptype class A" { | |
246 | -re "type = class A \{${ws}public:${ws}int a;${ws}int x;$nl\}$nl$gdb_prompt $" { | |
247 | # gcc 2.95.3 -gdwarf-2 | |
248 | # gcc 3.3.2 -gdwarf-2 | |
249 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
c906108c SS |
250 | pass "ptype class A" |
251 | } | |
1cd3489f MC |
252 | -re "type = class A \{${ws}public:${ws}int a;${ws}int x;${ws}A ?& ?operator ?=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
253 | # gcc 2.95.3 -gstabs+ | |
254 | # gcc 3.3.2 -gstabs+ | |
255 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
256 | pass "ptype class A" | |
c906108c SS |
257 | } |
258 | } | |
259 | ||
1cd3489f MC |
260 | # Derived class. |
261 | ||
262 | gdb_test_multiple "ptype class B" "ptype class B" { | |
263 | -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;$nl\}$nl$gdb_prompt $" { | |
264 | # gcc 2.95.3 -gdwarf-2 | |
265 | # gcc 3.3.2 -gdwarf-2 | |
266 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
184ad485 MC |
267 | # TODO: this is not obsolescent! |
268 | pass "ptype class B (obsolescent gcc or gdb)" | |
c906108c | 269 | } |
1cd3489f MC |
270 | -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|)\\);$nl\}$nl$gdb_prompt $" { |
271 | # gcc 2.95.3 -gstabs+ | |
272 | # gcc 3.3.2 -gstabs+ | |
273 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
274 | pass "ptype class B" | |
c906108c SS |
275 | } |
276 | } | |
277 | ||
1cd3489f MC |
278 | # Derived class. |
279 | ||
280 | gdb_test_multiple "ptype class C" "ptype class C" { | |
281 | -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;$nl\}$nl$gdb_prompt $" { | |
282 | # gcc 2.95.3 -gdwarf-2 | |
283 | # gcc 3.3.2 -gdwarf-2 | |
284 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
184ad485 MC |
285 | # TODO: this is not obsolescent! |
286 | pass "ptype class C (obsolescent gcc or gdb)" | |
c906108c | 287 | } |
1cd3489f MC |
288 | -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|)\\);$nl\}$nl$gdb_prompt $" { |
289 | # gcc 2.95.3 -gstabs+ | |
290 | # gcc 3.3.2 -gstabs+ | |
291 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
292 | pass "ptype class C" | |
c906108c SS |
293 | } |
294 | } | |
295 | ||
1cd3489f MC |
296 | # Derived class, multiple inheritance. |
297 | ||
298 | gdb_test_multiple "ptype class D" "ptype class D" { | |
299 | -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;$nl\}$nl$gdb_prompt $" { | |
300 | # gcc 2.95.3 -gdwarf-2 | |
301 | # gcc 3.3.2 -gdwarf-2 | |
302 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
184ad485 MC |
303 | # TODO: this is not obsolescent! |
304 | pass "ptype class D (obsolescent gcc or gdb)" | |
c906108c | 305 | } |
1cd3489f MC |
306 | -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|)\\);$nl\}$nl$gdb_prompt $" { |
307 | # gcc 2.95.3 -gstabs+ | |
308 | # gcc 3.3.2 -gstabs+ | |
309 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
310 | pass "ptype class D" | |
c906108c SS |
311 | } |
312 | } | |
313 | ||
1cd3489f MC |
314 | # Derived class. |
315 | ||
316 | gdb_test_multiple "ptype class E" "ptype class E" { | |
317 | -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;$nl\}$nl$gdb_prompt $" { | |
318 | # gcc 2.95.3 -gdwarf-2 | |
319 | # gcc 3.3.2 -gdwarf-2 | |
320 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
c906108c SS |
321 | pass "ptype class E" |
322 | } | |
1cd3489f MC |
323 | -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|)\\);$nl\}$nl$gdb_prompt $" { |
324 | # gcc 2.95.3 -gstabs+ | |
325 | # gcc 3.3.2 -gstabs+ | |
326 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
c906108c SS |
327 | pass "ptype class E" |
328 | } | |
c906108c SS |
329 | } |
330 | ||
1cd3489f MC |
331 | # This is a break from inheritance tests. |
332 | # | |
333 | # gcc 2.X with stabs (stabs or stabs+?) used to have a problem with | |
334 | # static methods whose name is the same as their argument mangling. | |
335 | ||
336 | gdb_test_multiple "ptype class Static" "ptype class Static" { | |
337 | -re "type = class Static \{${ws}public:${ws}static void ii\\(int, int\\);$nl\}$nl$gdb_prompt $" { | |
338 | # gcc 2.95.3 -gdwarf-2 | |
339 | # gcc 3.3.2 -gdwarf-2 | |
340 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
af890c52 DJ |
341 | pass "ptype class Static" |
342 | } | |
1cd3489f MC |
343 | -re "type = class Static \{${ws}public:${ws}Static ?& ?operator ?=\\(Static const ?&\\);${ws}Static\\(Static const ?&\\);${ws}Static\\((void|)\\);${ws}static void ii\\(int, int\\);$nl\}$nl$gdb_prompt $" { |
344 | # gcc 2.95.3 -gstabs+ | |
345 | # gcc 3.3.2 -gstabs+ | |
3e36a0f4 DJ |
346 | pass "ptype class Static" |
347 | } | |
1cd3489f MC |
348 | -re "type = class Static \{${ws}public:${ws}static void ii\\(int, int\\);${ws}Static ?& ?operator ?=\\(Static const ?&\\);${ws}Static\\(Static const ?&\\);${ws}Static\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
349 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
184ad485 MC |
350 | # TODO: this is okay. It is just ABI 2. |
351 | fail "ptype class Static" | |
af890c52 DJ |
352 | } |
353 | } | |
354 | ||
1cd3489f MC |
355 | # Here are some virtual inheritance tests. |
356 | ||
357 | gdb_test_multiple "ptype class vA" "ptype class vA" { | |
358 | -re "type = class vA \{${ws}public:${ws}int va;${ws}int vx;$nl\}$nl$gdb_prompt $" { | |
359 | # gcc 2.95.3 -gdwarf-2 | |
360 | # gcc 3.3.2 -gdwarf-2 | |
361 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
3e36a0f4 DJ |
362 | pass "ptype class vA" |
363 | } | |
1cd3489f MC |
364 | -re "type = class vA \{${ws}public:${ws}int va;${ws}int vx;${ws}vA ?& ?operator ?=\\(vA const ?&\\);${ws}vA\\(vA const ?&\\);${ws}vA\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
365 | # gcc 2.95.3 -gstabs+ | |
366 | # gcc 3.3.2 -gstabs+ | |
367 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
c906108c SS |
368 | pass "ptype class vA" |
369 | } | |
c906108c SS |
370 | } |
371 | ||
184ad485 | 372 | # With gcc 2, gdb prints the virtual base pointer. |
1cd3489f | 373 | # With gcc 3, gdb does not print the virtual base pointer. |
184ad485 | 374 | # drow considers it a gdb bug if gdb prints the vbptr. |
c906108c | 375 | |
1cd3489f MC |
376 | gdb_test_multiple "ptype class vB" "ptype class vB" { |
377 | -re "type = class vB : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.2vA;${ws}public:${ws}int vb;${ws}int vx;$nl\}$nl$gdb_prompt $" { | |
378 | # gcc 2.95.3 -gdwarf-2 | |
184ad485 MC |
379 | # TODO: kfail this |
380 | fail "ptype class vB" | |
5178b9d6 | 381 | } |
1cd3489f MC |
382 | -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;$nl\}$nl$gdb_prompt $" { |
383 | # gcc 3.3.2 -gdwarf-2 | |
384 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
385 | pass "ptype class vB" | |
c906108c | 386 | } |
1cd3489f MC |
387 | -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\\);$nl\}$nl$gdb_prompt $" { |
388 | # gcc 2.95.3 -gstabs+ | |
389 | # See the hidden "in-charge" ctor parameter! | |
184ad485 MC |
390 | # TODO: kfail this |
391 | setup_xfail "*-*-*" | |
392 | fail "ptype class vB (FIXME: non-portable virtual table constructs)" | |
c906108c | 393 | } |
1cd3489f MC |
394 | -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}vB ?& ?operator ?=\\(vB const ?&\\);${ws}vB\\(vB const ?&\\);${ws}vB\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
395 | # gcc 3.3.2 -gstabs+ | |
396 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
397 | pass "ptype class vB" | |
c906108c SS |
398 | } |
399 | } | |
400 | ||
1cd3489f | 401 | # Another class with a virtual base. |
c906108c | 402 | |
1cd3489f MC |
403 | gdb_test_multiple "ptype class vC" "ptype class vC" { |
404 | -re "type = class vC : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.2vA;${ws}public:${ws}int vc;${ws}int vx;$nl\}$nl$gdb_prompt $" { | |
405 | # gcc 2.95.3 -gdwarf-2 | |
184ad485 MC |
406 | # TODO: kfail |
407 | fail "ptype class vC" | |
5178b9d6 | 408 | } |
1cd3489f MC |
409 | -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;$nl\}$nl$gdb_prompt $" { |
410 | # gcc 3.3.2 -gdwarf-2 | |
411 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
412 | pass "ptype class vC" | |
c906108c | 413 | } |
1cd3489f MC |
414 | -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\\);$nl\}$nl$gdb_prompt $" { |
415 | # gcc 2.95.3 -gstabs+ | |
416 | # See the hidden "in-charge" ctor parameter! | |
184ad485 MC |
417 | # TODO: kfail |
418 | setup_xfail "*-*-*" | |
419 | fail "ptype class vC (FIXME: non-portable virtual table constructs)" | |
c906108c | 420 | } |
1cd3489f MC |
421 | -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}vC ?& ?operator ?=\\(vC const ?&\\);${ws}vC\\(vC const ?&\\);${ws}vC\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
422 | # gcc 3.3.2 -gstabs+ | |
423 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
424 | pass "ptype class vC" | |
c906108c SS |
425 | } |
426 | } | |
427 | ||
1cd3489f | 428 | # The classic diamond inheritance. |
c906108c | 429 | |
1cd3489f MC |
430 | gdb_test_multiple "ptype class vD" "ptype class vD" { |
431 | -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC ?\\* ?_vb.2vC;${ws}vB ?\\* ?_vb.2vB;${ws}public:${ws}int vd;${ws}int vx;$nl\}$nl$gdb_prompt $" { | |
432 | # gcc 2.95.3 -gdwarf-2 | |
184ad485 MC |
433 | # TODO: kfail |
434 | fail "ptype class vD" | |
5178b9d6 | 435 | } |
1cd3489f MC |
436 | -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;$nl\}$nl$gdb_prompt $" { |
437 | # gcc 3.3.2 -gdwarf-2 | |
438 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
439 | pass "ptype class vD" | |
c906108c | 440 | } |
1cd3489f MC |
441 | -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\\);$nl\}$nl$gdb_prompt $" { |
442 | # gcc 2.95.3 -gstabs+ | |
443 | # See the hidden "in-charge" ctor parameter! | |
184ad485 MC |
444 | # TODO: kfail |
445 | setup_xfail "*-*-*" | |
446 | fail "ptype class vD (FIXME: non-portable virtual table constructs)" | |
c906108c | 447 | } |
1cd3489f MC |
448 | -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 ?&\\);${ws}vD\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
449 | # gcc 3.3.2 -gstabs+ | |
450 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
451 | pass "ptype class vD" | |
c906108c SS |
452 | } |
453 | } | |
454 | ||
1cd3489f | 455 | # One more case of virtual derivation. |
c906108c | 456 | |
1cd3489f MC |
457 | gdb_test_multiple "ptype class vE" "ptype class vE" { |
458 | -re "type = class vE : public virtual vD \{${ws}private:${ws}vD ?\\* ?_vb.2vD;${ws}public:${ws}int ve;${ws}int vx;$nl\}$nl$gdb_prompt $" { | |
459 | # gcc 2.95.3 -gdwarf-2 | |
184ad485 MC |
460 | # TODO: kfail |
461 | fail "ptype class vE" | |
5178b9d6 | 462 | } |
1cd3489f MC |
463 | -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;$nl\}$nl$gdb_prompt $" { |
464 | # gcc 3.3.2 -gdwarf-2 | |
465 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
466 | pass "ptype class vE" | |
c906108c | 467 | } |
1cd3489f MC |
468 | -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\\);$nl\}$nl$gdb_prompt $" { |
469 | # gcc 2.95.3 -gstabs+ | |
470 | # See the hidden "in-charge" ctor parameter! | |
184ad485 MC |
471 | # TODO: kfail |
472 | setup_xfail "*-*-*" | |
473 | fail "ptype class vE (FIXME: non-portable virtual table constructs)" | |
c906108c | 474 | } |
1cd3489f MC |
475 | -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}vE ?& ?operator ?=\\(vE const ?&\\);${ws}vE\\(vE const ?&\\);${ws}vE\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
476 | # gcc 3.3.2 -gstabs+ | |
477 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
478 | pass "ptype class vE" | |
c906108c SS |
479 | } |
480 | } | |
481 | ||
1cd3489f MC |
482 | # Another inheritance series. |
483 | ||
484 | gdb_test_multiple "ptype class Base1" "ptype class Base1" { | |
485 | -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);$nl\}$nl$gdb_prompt $" { | |
486 | # gcc 2.95.3 -gdwarf-2 | |
487 | # gcc 3.3.2 -gdwarf-2 | |
488 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
c906108c SS |
489 | pass "ptype class Base1" |
490 | } | |
1cd3489f MC |
491 | -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 ?& ?operator ?=\\(Base1 const ?&\\);${ws}Base1\\(Base1 const ?&\\);${ws}Base1\\(int\\);$nl\}$nl$gdb_prompt $" { |
492 | # gcc 2.95.3 -gstabs+ | |
493 | # gcc 3.3.2 -gstabs+ | |
3e36a0f4 DJ |
494 | pass "ptype class Base1" |
495 | } | |
1cd3489f MC |
496 | -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);${ws}Base1 ?& ?operator ?=\\(Base1 const ?&\\);${ws}Base1\\(Base1 const ?&\\);$nl\}$nl$gdb_prompt $" { |
497 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
184ad485 MC |
498 | # TODO: this is not obsolescent! |
499 | pass "ptype class Base1 (obsolescent gcc or gdb)" | |
c906108c SS |
500 | } |
501 | } | |
502 | ||
1cd3489f MC |
503 | # The second base class. |
504 | ||
505 | gdb_test_multiple "ptype class Foo" "ptype class Foo" { | |
506 | -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" { | |
507 | # gcc 2.95.3 -gdwarf-2 | |
508 | # gcc 3.3.2 -gdwarf-2 | |
509 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
c906108c SS |
510 | pass "ptype class Foo" |
511 | } | |
1cd3489f MC |
512 | -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\\);$nl\}$nl$gdb_prompt $" { |
513 | # gcc 2.95.3 -gstabs+ | |
184ad485 MC |
514 | # TODO: "int operator int()" is a bug |
515 | # TODO: this is not obsolescent! | |
516 | # kfail "gdb/1497" "ptype class Foo" | |
517 | pass "ptype class Foo (obsolescent gcc or gdb)" | |
c906108c | 518 | } |
1cd3489f MC |
519 | -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}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" { |
520 | # gcc 3.3.2 -gstabs+ | |
521 | pass "ptype class Foo" | |
c906108c | 522 | } |
1cd3489f MC |
523 | -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);${ws}Foo ?& ?operator ?=\\(Foo const ?&\\);${ws}Foo\\(Foo const ?&\\);$nl\}$nl$gdb_prompt $" { |
524 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
184ad485 MC |
525 | # TODO: this is okay, just the new ABI |
526 | fail "ptype class Foo" | |
c906108c SS |
527 | } |
528 | } | |
529 | ||
1cd3489f MC |
530 | # A multiple inheritance derived class. |
531 | ||
532 | gdb_test_multiple "ptype class Bar" "ptype class Bar" { | |
533 | -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar\\(int, int, int\\);$nl\}$nl$gdb_prompt $" { | |
534 | # gcc 2.95.3 -gdwarf-2 | |
535 | # gcc 3.3.2 -gdwarf-2 | |
536 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
184ad485 MC |
537 | # TODO: this is not obsolescent! |
538 | pass "ptype class Bar (obsolescent gcc or gdb)" | |
c906108c | 539 | } |
1cd3489f MC |
540 | -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\\);$nl\}$nl$gdb_prompt $" { |
541 | # gcc 2.95.3 -gstabs+ | |
542 | # gcc 3.3.2 -gstabs+ | |
543 | pass "ptype class Bar" | |
c906108c | 544 | } |
1cd3489f MC |
545 | -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar\\(int, int, int\\);${ws}Bar ?& ?operator ?=\\(Bar const ?&\\);${ws}Bar\\(Bar const ?&\\);$nl\}$nl$gdb_prompt $" { |
546 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
184ad485 MC |
547 | # TODO: this is not obsolescent! |
548 | pass "ptype class Bar (obsolescent gcc or gdb)" | |
c906108c SS |
549 | } |
550 | } | |
551 | } | |
552 | ||
c906108c | 553 | # Test simple access to class members. |
1cd3489f MC |
554 | # TODO: these test names are gross! |
555 | # Just let the test name default. | |
c906108c SS |
556 | |
557 | proc test_non_inherited_member_access {} { | |
558 | global gdb_prompt | |
559 | ||
560 | # Print non-inherited members of g_A. | |
c906108c | 561 | gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect" |
c906108c SS |
562 | gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect" |
563 | ||
564 | # Print non-inherited members of g_B. | |
c906108c | 565 | gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect" |
c906108c SS |
566 | gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect" |
567 | ||
568 | # Print non-inherited members of g_C. | |
c906108c | 569 | gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect" |
c906108c SS |
570 | gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect" |
571 | ||
572 | # Print non-inherited members of g_D. | |
c906108c | 573 | gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect" |
c906108c SS |
574 | gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect" |
575 | ||
576 | # Print non-inherited members of g_E. | |
c906108c | 577 | gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect" |
c906108c SS |
578 | gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect" |
579 | } | |
580 | ||
1cd3489f MC |
581 | # Test access to members of other classes. |
582 | # gdb should refuse to print them. | |
583 | # (I feel old -- I remember when this was legal in C -- chastain). | |
584 | # TODO: Again, change the silly test names. | |
c906108c SS |
585 | |
586 | proc test_wrong_class_members {} { | |
587 | global gdb_prompt | |
588 | ||
589 | gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error" | |
c906108c | 590 | gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error" |
c906108c | 591 | gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error" |
c906108c | 592 | gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error" |
c906108c | 593 | gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error" |
c906108c SS |
594 | gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error" |
595 | } | |
596 | ||
1cd3489f MC |
597 | # Test access to names that are not members of any class. |
598 | # TODO: test names again. | |
c906108c | 599 | |
2bec0572 | 600 | proc test_nonexistent_members {} { |
c906108c SS |
601 | global gdb_prompt |
602 | ||
603 | gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error" | |
c906108c | 604 | gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error" |
c906108c | 605 | gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error" |
c906108c SS |
606 | gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error" |
607 | } | |
608 | ||
54602222 ND |
609 | # Call a method that expects a base class parameter with base, inherited, |
610 | # and unrelated class arguments. | |
54602222 ND |
611 | |
612 | proc test_method_param_class {} { | |
613 | gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a" | |
614 | gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2" "base class param->x" | |
615 | gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3" "inherited class param->a" | |
616 | gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4" "inherited class param->x" | |
617 | gdb_test "call class_param.Aref_a (g_A)" ".* = 1" "base class (¶m)->a" | |
618 | gdb_test "call class_param.Aref_x (g_A)" ".* = 2" "base class (¶m)->x" | |
619 | gdb_test "call class_param.Aref_a (g_B)" ".* = 3" "inherited class (¶m)->a" | |
620 | gdb_test "call class_param.Aref_x (g_B)" ".* = 4" "inherited class (¶m)->x" | |
621 | gdb_test "call class_param.Aval_a (g_A)" ".* = 1" "base class param.a" | |
622 | gdb_test "call class_param.Aval_x (g_A)" ".* = 2" "base class param.x" | |
623 | gdb_test "call class_param.Aval_a (g_B)" ".* = 3" "inherited class param.a" | |
624 | gdb_test "call class_param.Aval_x (g_B)" ".* = 4" "inherited class param.x" | |
625 | ||
626 | gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param" | |
627 | gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class ¶m" | |
628 | gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param" | |
629 | } | |
630 | ||
2bec0572 | 631 | # Examine a class with an enum field. |
2bec0572 ND |
632 | |
633 | proc test_enums {} { | |
634 | global gdb_prompt | |
1cd3489f MC |
635 | global nl |
636 | global ws | |
2bec0572 ND |
637 | |
638 | # print the object | |
2bec0572 | 639 | |
1cd3489f MC |
640 | gdb_test "print obj_with_enum" \ |
641 | "\\$\[0-9\]+ = \{priv_enum = red, x = 0\}" \ | |
642 | "print obj_with_enum (1)" | |
643 | ||
644 | # advance one line | |
645 | ||
646 | gdb_test "next" "" | |
647 | ||
648 | # TODO: with gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2, | |
649 | # gdb says that obj_with_enum is out of scope here and the | |
650 | # tests after this FAIL. This needs investigation. | |
651 | # -- chastain 2003-12-30 | |
2bec0572 ND |
652 | |
653 | # print the object again | |
2bec0572 | 654 | |
1cd3489f MC |
655 | gdb_test "print obj_with_enum" \ |
656 | "\\$\[0-9\]+ = \{priv_enum = green, x = 0\}" \ | |
657 | "print obj_with_enum (2)" | |
658 | ||
659 | # print the enum member | |
660 | ||
661 | gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = green" | |
2bec0572 ND |
662 | |
663 | # ptype on the enum member | |
1cd3489f MC |
664 | |
665 | gdb_test_multiple "ptype obj_with_enum.priv_enum" "ptype obj_with_enum.priv_enum" { | |
666 | -re "type = enum ClassWithEnum::PrivEnum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" { | |
667 | pass "ptype obj_with_enum.priv_enum" | |
668 | } | |
669 | -re "type = enum PrivEnum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" { | |
670 | # gcc 2.95.3 -gdwarf-2 | |
671 | # gcc 3.3.2 -gdwarf-2 | |
672 | pass "ptype obj_with_enum.priv_enum" | |
673 | } | |
674 | -re "type = enum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" { | |
675 | # This case case is a little dubious, but it's not clear what | |
676 | # ought to be required of a ptype on a private enum... | |
677 | # -sts 19990324 | |
678 | # | |
679 | # It bugs me that this happens with gcc 3. | |
680 | # -- chastain 2003-12-30 | |
681 | # | |
682 | # gcc 2.95.3 -gstabs+ | |
683 | # gcc 3.3.2 -gstabs+ | |
684 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
685 | pass "ptype obj_with_enum.priv_enum" | |
686 | } | |
2bec0572 ND |
687 | } |
688 | ||
689 | # ptype on the object | |
1cd3489f MC |
690 | gdb_test_multiple "ptype obj_with_enum" "ptype obj_with_enum" { |
691 | -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)ClassWithEnum::PrivEnum priv_enum;${ws}int x;$nl\}$nl$gdb_prompt $" { | |
692 | pass "ptype obj_with_enum" | |
693 | } | |
694 | -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)PrivEnum priv_enum;${ws}int x;$nl\}$nl$gdb_prompt $" { | |
6ece72da DC |
695 | # NOTE: carlton/2003-02-28: One could certainly argue that |
696 | # this output is acceptable: PrivEnum is a member of | |
697 | # ClassWithEnum, so there's no need to explicitly qualify | |
698 | # its name with "ClassWithEnum::". The truth, though, is | |
699 | # that GDB is simply forgetting that PrivEnum is a member | |
700 | # of ClassWithEnum, so we do that output for a bad reason | |
701 | # instead of a good reason. Under stabs, we probably | |
702 | # can't get this right; under DWARF-2, we can. | |
1cd3489f MC |
703 | # |
704 | # gcc 2.95.3 -gdwarf-2 | |
705 | # gcc 3.3.2 -gdwarf-2 | |
706 | kfail "gdb/57" "ptype obj_with_enum" | |
707 | } | |
708 | -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)PrivEnum priv_enum;${ws}int x;${ws}ClassWithEnum ?& ?operator ?=\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\((void|)\\);$nl\}$nl$gdb_prompt $" { | |
709 | # gcc 2.95.3 -gstabs+ | |
6ece72da DC |
710 | kfail "gdb/57" "ptype obj_with_enum" |
711 | } | |
1cd3489f MC |
712 | -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)ClassWithEnum::PrivEnum priv_enum;${ws}int x;${ws}ClassWithEnum ?& ?operator ?=\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\((void|)\\);$nl\}$nl$gdb_prompt $" { |
713 | # I think this is a PASS, but only carlton knows for sure. | |
714 | # -- chastain 2003-12-30 | |
715 | # | |
716 | # gcc 3.3.2 -gstabs+ | |
717 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
184ad485 | 718 | fail "ptype obj_with_enum" |
1cd3489f | 719 | } |
2bec0572 ND |
720 | } |
721 | ||
1cd3489f MC |
722 | # I'll do this test two different ways, because of a parser bug. |
723 | # See PR gdb/826. | |
6ece72da | 724 | |
1cd3489f MC |
725 | gdb_test_multiple "print (ClassWithEnum::PrivEnum) 42" "print (ClassWithEnum::PrivEnum) 42" { |
726 | -re "\\$\[0-9\]+ = yellow$nl$gdb_prompt $" { | |
727 | pass "print (ClassWithEnum::PrivEnum) 42" | |
d8a2d9e7 | 728 | } |
1cd3489f MC |
729 | -re "A (parse|syntax) error in expression, near `42'.$nl$gdb_prompt $" { |
730 | # "parse error" is bison 1.35. | |
731 | # "syntax error" is bison 1.875. | |
d8a2d9e7 MC |
732 | kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42" |
733 | } | |
2bec0572 | 734 | } |
6ece72da | 735 | |
1cd3489f MC |
736 | gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" { |
737 | -re "\\$\[0-9\]+ = yellow$nl$gdb_prompt $" { | |
738 | # gcc 3.3.2 -gstabs+ | |
739 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
740 | pass "print ('ClassWithEnum::PrivEnum') 42" | |
741 | } | |
742 | -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.$nl$gdb_prompt $" { | |
743 | # gcc 2.95.3 -gdwarf-2 | |
744 | # gcc 3.3.2 -gdwarf-2 | |
745 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
746 | # gcc 2.95.3 -gstabs+ | |
747 | kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42" | |
748 | } | |
6ece72da | 749 | } |
2bec0572 ND |
750 | } |
751 | ||
c906108c | 752 | # Pointers to class members |
c906108c SS |
753 | |
754 | proc test_pointers_to_class_members {} { | |
755 | global gdb_prompt | |
c906108c | 756 | |
1cd3489f MC |
757 | gdb_test "print Bar::z" "\\$\[0-9\]+ = \\(int ?\\( ?Bar::& ?\\) ?\\) ?Bar::z" |
758 | gdb_test "print &Foo::x" "\\$\[0-9\]+ = \\(int ?\\( ?Foo::\\* ?\\) ?\\) ?&Foo::x" | |
759 | gdb_test "print (int)&Foo::x" "\\$\[0-9\]+ = 0" | |
760 | gdb_test "print (int)&Bar::y == 2*sizeof(int)" "\\$\[0-9\]+ = true" | |
184ad485 MC |
761 | |
762 | # TODO: this is a bogus test. It's looking at a variable that | |
763 | # has not even been declared yet, so it's accessing random junk | |
764 | # on the stack and comparing that it's NOT equal to a specific | |
765 | # value. It's been like this since gdb 4.10 in 1993! | |
766 | # -- chastain 2004-01-01 | |
767 | gdb_test "print (int)pmi == sizeof(int)" ".* = false" | |
c906108c SS |
768 | } |
769 | ||
c906108c | 770 | # Test static members. |
c906108c SS |
771 | |
772 | proc test_static_members {} { | |
773 | global gdb_prompt | |
774 | global hex | |
c906108c | 775 | |
1cd3489f | 776 | gdb_test "print Foo::st" "\\$\[0-9\]+ = 100" |
184ad485 | 777 | gdb_test "set foo.st = 200" "" "" |
1cd3489f MC |
778 | gdb_test "print bar.st" "\\$\[0-9\]+ = 200" |
779 | gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex" | |
780 | gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex" | |
781 | gdb_test "print *\$" "\\$\[0-9\]+ = 200" | |
c906108c SS |
782 | |
783 | gdb_test "set print static-members off" "" | |
784 | gdb_test "print csi" \ | |
785 | "{x = 10, y = 20}" \ | |
786 | "print csi without static members" | |
787 | gdb_test "print cnsi" \ | |
788 | "{x = 30, y = 40}" \ | |
789 | "print cnsi without static members" | |
790 | ||
791 | gdb_test "set print static-members on" "" | |
c906108c SS |
792 | gdb_test "print csi" \ |
793 | "{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \ | |
794 | "print csi with static members" | |
c906108c SS |
795 | gdb_test "print cnsi" \ |
796 | "{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>}" \ | |
797 | "print cnsi with static members" | |
798 | } | |
799 | ||
800 | proc do_tests {} { | |
801 | global prms_id | |
802 | global bug_id | |
803 | global subdir | |
804 | global objdir | |
805 | global srcdir | |
806 | global binfile | |
807 | global gdb_prompt | |
1cd3489f | 808 | global nl |
c906108c SS |
809 | |
810 | set prms_id 0 | |
811 | set bug_id 0 | |
812 | ||
813 | # Start with a fresh gdb. | |
814 | ||
815 | gdb_exit | |
816 | gdb_start | |
817 | gdb_reinitialize_dir $srcdir/$subdir | |
818 | gdb_load $binfile | |
819 | ||
1cd3489f MC |
820 | gdb_test "set language c++" "" "" |
821 | gdb_test "set width 0" "" "" | |
c906108c | 822 | |
1cd3489f MC |
823 | if ![runto_main ] then { |
824 | perror "couldn't run to breakpoint" | |
825 | return | |
2bec0572 ND |
826 | } |
827 | ||
1cd3489f MC |
828 | gdb_breakpoint inheritance2 |
829 | gdb_test "continue" ".*Breakpoint .* inheritance2.*" "" | |
c906108c | 830 | |
1cd3489f MC |
831 | test_ptype_class_objects |
832 | test_non_inherited_member_access | |
833 | test_wrong_class_members | |
834 | test_nonexistent_members | |
835 | test_method_param_class | |
c906108c | 836 | |
1cd3489f | 837 | gdb_breakpoint enums2 |
184ad485 | 838 | gdb_test "continue" ".*Breakpoint .* enums2.*" "continue to enums2(\\(\\)|)" |
1cd3489f MC |
839 | gdb_test "finish" "" "" |
840 | test_enums | |
841 | ||
184ad485 MC |
842 | gdb_test "finish" "" "" |
843 | test_pointers_to_class_members | |
844 | test_static_members | |
845 | ||
1cd3489f MC |
846 | # Now some random tests that were just thrown in here. |
847 | ||
848 | gdb_breakpoint marker_reg1 | |
849 | gdb_test "continue" ".*Breakpoint .* marker_reg1.*" "" | |
850 | gdb_test "finish" "Run till exit from.*" "finish from marker_reg1" | |
851 | ||
852 | # This class is so small that an instance of it can fit in a register. | |
853 | # When gdb tries to call a method, it gets embarrassed about taking | |
854 | # the address of a register. | |
855 | # | |
856 | # TODO: I think that message should be a PASS, not an XFAIL. | |
857 | # gdb prints an informative message and declines to do something | |
858 | # impossible. | |
859 | # | |
860 | # The method call actually succeeds if the compiler allocates very | |
861 | # small classes in memory instead of registers. So this test does | |
862 | # not tell us anything interesting if the call succeeds. | |
863 | # | |
864 | # -- chastain 2003-12-31 | |
865 | gdb_test_multiple "print v.method ()" "calling method for small class" { | |
866 | -re "\\$\[0-9\]+ = 82$nl$gdb_prompt $" { | |
867 | # gcc 3.3.2 -gdwarf-2 | |
868 | # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 | |
869 | # gcc 3.3.2 -gstabs+ | |
870 | # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ | |
871 | pass "calling method for small class" | |
872 | } | |
873 | -re "Address requested for identifier \"v\" which is in register .*$nl$gdb_prompt $" { | |
874 | # gcc 2.95.3 -gdwarf-2 | |
875 | # gcc 2.95.3 -gstabs+ | |
876 | setup_xfail "*-*-*" 2972 | |
877 | fail "calling method for small class" | |
c906108c SS |
878 | } |
879 | } | |
184ad485 MC |
880 | |
881 | # This is a random v2 demangling test. | |
882 | # This is redundant with existing tests in demangle.exp. | |
883 | # TODO: Just remove this. | |
884 | gdb_test "maint demangle inheritance1__Fv" "inheritance1\\(void\\)" "demangle" | |
c906108c SS |
885 | } |
886 | ||
887 | do_tests |