Commit | Line | Data |
---|---|---|
ebac27b4 MC |
1 | # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, |
2 | # 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 | ||
c906108c | 18 | # This file was written by Fred Fish. (fnf@cygnus.com) |
ebac27b4 | 19 | # And rewritten by Michael Chastain. (mec.gnu@mindspring.com) |
c906108c | 20 | |
ebac27b4 MC |
21 | set ws "\[\r\n\t \]+" |
22 | set nl "\[\r\n\]+" | |
23 | set vhn "\\$\[0-9\]+" | |
c2d11a7d | 24 | |
c906108c | 25 | if $tracelevel then { |
ebac27b4 | 26 | strace $tracelevel |
c906108c SS |
27 | } |
28 | ||
d4f3574e SS |
29 | if { [skip_cplus_tests] } { continue } |
30 | ||
c906108c SS |
31 | set testfile "inherit" |
32 | set srcfile misc.cc | |
33 | set binfile ${objdir}/${subdir}/${testfile} | |
34 | ||
c906108c SS |
35 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { |
36 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
37 | } | |
38 | ||
c906108c | 39 | # Single inheritance, print type definitions. |
c906108c | 40 | |
ebac27b4 | 41 | proc test_ptype_si { } { |
c906108c SS |
42 | global gdb_prompt |
43 | global ws | |
44 | global nl | |
45 | ||
46 | # Print class A as a type. | |
47 | ||
9366563b | 48 | set re_class "((class|struct) A \{${ws}public:|struct A \{)" |
ebac27b4 MC |
49 | set re_fields "int a;${ws}int x;" |
50 | set re_synth_gcc_23 "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" | |
51 | ||
52 | set name "ptype A (FIXME)" | |
53 | gdb_test_multiple "ptype A" $name { | |
54 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
55 | pass $name | |
c906108c | 56 | } |
ebac27b4 MC |
57 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
58 | pass $name | |
c906108c | 59 | } |
c906108c SS |
60 | } |
61 | ||
62 | # Print class A as an explicit class. | |
63 | ||
ebac27b4 MC |
64 | set name "ptype class A (FIXME)" |
65 | gdb_test_multiple "ptype class A" $name { | |
66 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
67 | pass $name | |
c906108c | 68 | } |
ebac27b4 MC |
69 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
70 | pass $name | |
c906108c | 71 | } |
c906108c SS |
72 | } |
73 | ||
74 | # Print type of an object of type A. | |
75 | ||
ebac27b4 MC |
76 | set name "ptype g_A (FIXME)" |
77 | gdb_test_multiple "ptype g_A" $name { | |
78 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
79 | pass $name | |
c906108c | 80 | } |
ebac27b4 MC |
81 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
82 | pass $name | |
c906108c | 83 | } |
c906108c SS |
84 | } |
85 | ||
86 | # Print class B as a type. | |
87 | ||
9366563b | 88 | set re_class "((class|struct) B : public A \{${ws}public:|struct B : public A \{)" |
ebac27b4 MC |
89 | set re_fields "int b;${ws}int x;" |
90 | set re_synth_gcc_23 "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);" | |
91 | ||
92 | set name "ptype B" | |
93 | gdb_test_multiple "ptype B" $name { | |
94 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
95 | pass $name | |
96 | } | |
97 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { | |
98 | pass $name | |
99 | } | |
100 | } | |
c906108c SS |
101 | |
102 | # Print class B as an explicit class. | |
103 | ||
ebac27b4 MC |
104 | set name "ptype class B" |
105 | gdb_test_multiple "ptype class B" $name { | |
106 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
107 | pass $name | |
108 | } | |
109 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { | |
110 | pass $name | |
111 | } | |
112 | } | |
c906108c SS |
113 | |
114 | # Print type of an object of type B. | |
115 | ||
ebac27b4 MC |
116 | set name "ptype g_B" |
117 | gdb_test_multiple "ptype g_B" $name { | |
118 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
119 | pass $name | |
120 | } | |
121 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { | |
122 | pass $name | |
123 | } | |
124 | } | |
c906108c SS |
125 | |
126 | # Print class C as a type. | |
127 | ||
9366563b | 128 | set re_class "((class|struct) C : public A \{${ws}public:|struct C : public A \{)" |
ebac27b4 MC |
129 | set re_fields "int c;${ws}int x;" |
130 | set re_synth_gcc_23 "C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\((void|)\\);" | |
131 | ||
132 | set name "ptype C" | |
133 | gdb_test_multiple "ptype C" $name { | |
134 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
135 | pass $name | |
136 | } | |
137 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { | |
138 | pass $name | |
139 | } | |
140 | } | |
c906108c SS |
141 | |
142 | # Print class C as an explicit class. | |
143 | ||
ebac27b4 MC |
144 | set name "ptype class C" |
145 | gdb_test_multiple "ptype class C" $name { | |
146 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
147 | pass $name | |
148 | } | |
149 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { | |
150 | pass $name | |
151 | } | |
152 | } | |
c906108c SS |
153 | |
154 | # Print type of an object of type g_C. | |
155 | ||
ebac27b4 MC |
156 | set name "ptype g_C" |
157 | gdb_test_multiple "ptype g_C" $name { | |
158 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
159 | pass $name | |
3e36a0f4 | 160 | } |
ebac27b4 MC |
161 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
162 | pass $name | |
163 | } | |
164 | } | |
165 | ||
166 | # Print a structure with no tag. | |
167 | ||
168 | set re_tag "tagless_struct" | |
169 | set XX_tag "\\._1" | |
170 | set re_class "(class $re_tag \{${ws}public:|class \{${ws}public:|struct $re_tag \{|struct \{)" | |
171 | set XX_class "(class $XX_tag \{${ws}public:|struct $XX_tag \{)" | |
172 | set re_fields "int one;${ws}int two;" | |
173 | set re_synth_gcc_23 "$re_tag & operator=\\($re_tag const ?&\\);${ws}$re_tag\\($re_tag const ?&\\);${ws}$re_tag\\((void|)\\);" | |
174 | set XX_synth_gcc_23 "($re_tag|$XX_tag) & operator=\\($XX_tag const ?&\\);${ws}$XX_tag\\($XX_tag const ?&\\);${ws}$XX_tag\\((void|)\\);" | |
175 | ||
176 | set name "ptype tagless struct" | |
177 | gdb_test_multiple "ptype tagless_struct" $name { | |
178 | -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
179 | # gcc 2.95.3 -gdwarf-2 | |
9366563b | 180 | pass "$name" |
c906108c | 181 | } |
ebac27b4 MC |
182 | -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
183 | # gcc 2.95.3 -gstabs+ | |
9366563b | 184 | pass "$name" |
c906108c | 185 | } |
ebac27b4 | 186 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { |
9366563b MC |
187 | # gcc 3.3.4 -gdwarf-2 |
188 | # gcc 3.4.1 -gdwarf-2 | |
189 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
190 | # gcc HEAD 2004-07-31 -gstabs+ | |
191 | pass "$name" | |
c906108c | 192 | } |
ebac27b4 | 193 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
9366563b MC |
194 | # gcc 3.3.4 -gstabs+ |
195 | # gcc 3.4.1 -gstabs+ | |
ebac27b4 | 196 | pass "$name" |
c906108c SS |
197 | } |
198 | } | |
199 | ||
ebac27b4 MC |
200 | set name "ptype variable of type tagless struct" |
201 | gdb_test_multiple "ptype v_tagless" $name { | |
202 | -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
203 | # gcc 2.95.3 -gdwarf-2 | |
9366563b | 204 | pass "$name" |
3e36a0f4 | 205 | } |
ebac27b4 MC |
206 | -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
207 | # gcc 2.95.3 -gstabs+ | |
9366563b | 208 | pass "$name" |
c906108c | 209 | } |
ebac27b4 | 210 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { |
9366563b MC |
211 | # gcc 3.3.4 -gdwarf-2 |
212 | # gcc 3.4.1 -gdwarf-2 | |
213 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
214 | # gcc HEAD 2004-07-31 -gstabs+ | |
215 | pass "$name" | |
c906108c | 216 | } |
ebac27b4 | 217 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
9366563b MC |
218 | # gcc 3.3.4 -gstabs+ |
219 | # gcc 3.4.1 -gstabs+ | |
ebac27b4 | 220 | pass "$name" |
c906108c SS |
221 | } |
222 | } | |
223 | } | |
224 | ||
ebac27b4 | 225 | # Multiple inheritance, print type definitions. |
c906108c | 226 | |
ebac27b4 | 227 | proc test_ptype_mi { } { |
c906108c SS |
228 | global gdb_prompt |
229 | global ws | |
230 | global nl | |
231 | ||
ebac27b4 MC |
232 | set re_class "class D : public B, public C \{${ws}public:" |
233 | set re_fields "int d;${ws}int x;" | |
234 | set re_synth_gcc_23 "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" | |
235 | ||
236 | # ptype D: type, class, object. | |
237 | ||
238 | set name "ptype D" | |
239 | gdb_test_multiple "ptype D" $name { | |
240 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
241 | pass $name | |
c906108c | 242 | } |
ebac27b4 MC |
243 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
244 | pass $name | |
c906108c | 245 | } |
ebac27b4 MC |
246 | } |
247 | ||
248 | set name "ptype class D" | |
249 | gdb_test_multiple "ptype class D" $name { | |
250 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
251 | pass $name | |
252 | } | |
253 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { | |
254 | pass $name | |
255 | } | |
256 | } | |
257 | ||
258 | set name "ptype g_D" | |
259 | gdb_test_multiple "ptype g_D" $name { | |
260 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
261 | pass $name | |
c906108c | 262 | } |
ebac27b4 MC |
263 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
264 | pass $name | |
c906108c SS |
265 | } |
266 | } | |
ebac27b4 MC |
267 | |
268 | set re_class "class E : public D \{${ws}public:" | |
269 | set re_fields "int e;${ws}int x;" | |
270 | set re_synth_gcc_23 "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);" | |
271 | ||
272 | # ptype E: type, class, object. | |
273 | ||
274 | set name "ptype E" | |
275 | gdb_test_multiple "ptype E" $name { | |
276 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
277 | pass $name | |
c906108c | 278 | } |
ebac27b4 MC |
279 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
280 | pass $name | |
3e36a0f4 | 281 | } |
ebac27b4 MC |
282 | } |
283 | ||
284 | set name "ptype class E" | |
285 | gdb_test_multiple "ptype class E" $name { | |
286 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
287 | pass $name | |
3e36a0f4 | 288 | } |
ebac27b4 MC |
289 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
290 | pass $name | |
c906108c | 291 | } |
ebac27b4 MC |
292 | } |
293 | ||
294 | set name "ptype g_E" | |
295 | gdb_test_multiple "ptype g_E" $name { | |
296 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
297 | pass $name | |
c906108c | 298 | } |
ebac27b4 MC |
299 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
300 | pass $name | |
c906108c SS |
301 | } |
302 | } | |
303 | } | |
304 | ||
ebac27b4 | 305 | # Single virtual inheritance, print type definitions. |
c906108c | 306 | |
ebac27b4 | 307 | proc test_ptype_vi { } { |
c906108c | 308 | global gdb_prompt |
ebac27b4 | 309 | global ws |
c906108c | 310 | global nl |
c906108c | 311 | |
ebac27b4 | 312 | # ptype vA: type, class, object. |
c906108c | 313 | |
9366563b | 314 | set re_class "((class|struct) vA \{${ws}public:|struct vA \{)" |
ebac27b4 MC |
315 | set re_fields "int va;${ws}int vx;" |
316 | set re_synth_gcc_23 "vA & operator=\\(vA const ?&\\);${ws}vA\\(vA const ?&\\);${ws}vA\\((void|)\\);" | |
c906108c | 317 | |
ebac27b4 MC |
318 | set name "ptype vA" |
319 | gdb_test_multiple "ptype vA" $name { | |
320 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
321 | pass $name | |
322 | } | |
323 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { | |
324 | pass $name | |
325 | } | |
326 | } | |
c906108c | 327 | |
ebac27b4 MC |
328 | set name "ptype class vA" |
329 | gdb_test_multiple "ptype class vA" $name { | |
330 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
331 | pass $name | |
332 | } | |
333 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { | |
334 | pass $name | |
335 | } | |
336 | } | |
c906108c | 337 | |
ebac27b4 MC |
338 | set name "ptype g_vA" |
339 | gdb_test_multiple "ptype g_vA" $name { | |
340 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
341 | pass $name | |
342 | } | |
343 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { | |
344 | pass $name | |
345 | } | |
346 | } | |
c906108c | 347 | |
ebac27b4 | 348 | # ptype vB: type, class, object. |
c906108c | 349 | |
ebac27b4 MC |
350 | set re_class "class vB : public virtual vA \{(${ws}private:|)" |
351 | set re_vbptr "vA \\*(_vb.2vA|_vb.vA);${ws}" | |
352 | set re_access "public:" | |
353 | set re_fields "int vb;${ws}int vx;" | |
354 | set re_synth_gcc_2 "vB & operator=\\(vB const ?&\\);${ws}vB\\(int, vB const ?&\\);${ws}vB\\(int\\);" | |
9366563b | 355 | set re_synth_gcc_3 "(vB & operator=\\(vB const ?&\\);${ws}|)vB\\(vB const ?&\\);${ws}vB\\((void|)\\);" |
c906108c | 356 | |
ebac27b4 MC |
357 | set name "ptype vB" |
358 | gdb_test_multiple "ptype vB" $name { | |
359 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
360 | # gcc 2.95.3 -gdwarf-2 | |
361 | pass $name | |
362 | } | |
363 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { | |
364 | # gcc 2.95.3 -gstabs+ | |
365 | pass $name | |
366 | } | |
367 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
368 | # gcc 3.3.2 -gdwarf-2 | |
369 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
370 | pass "$name (aCC)" | |
371 | } | |
372 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { | |
373 | # gcc 3.3.2 -gstabs+ | |
374 | # gcc HEAD 2004-01-21 -gstabs+ | |
375 | pass "$name (aCC)" | |
376 | } | |
377 | } | |
c906108c | 378 | |
ebac27b4 MC |
379 | set name "ptype class vB" |
380 | gdb_test_multiple "ptype class vB" $name { | |
381 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
382 | # gcc 2.95.3 -gdwarf-2 | |
383 | pass $name | |
384 | } | |
385 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { | |
386 | # gcc 2.95.3 -gstabs+ | |
387 | pass $name | |
388 | } | |
389 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
390 | # gcc 3.3.2 -gdwarf-2 | |
391 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
392 | pass "$name (aCC)" | |
393 | } | |
394 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { | |
395 | # gcc 3.3.2 -gstabs+ | |
396 | # gcc HEAD 2004-01-21 -gstabs+ | |
397 | pass "$name (aCC)" | |
398 | } | |
399 | } | |
c906108c | 400 | |
ebac27b4 MC |
401 | set name "ptype g_vB" |
402 | gdb_test_multiple "ptype g_vB" $name { | |
403 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
404 | # gcc 2.95.3 -gdwarf-2 | |
405 | pass $name | |
406 | } | |
407 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { | |
408 | # gcc 2.95.3 -gstabs+ | |
409 | pass $name | |
410 | } | |
411 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
412 | # gcc 3.3.2 -gdwarf-2 | |
413 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
414 | pass "$name (aCC)" | |
415 | } | |
416 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { | |
417 | # gcc 3.3.2 -gstabs+ | |
418 | # gcc HEAD 2004-01-21 -gstabs+ | |
419 | pass "$name (aCC)" | |
420 | } | |
421 | } | |
c906108c | 422 | |
ebac27b4 | 423 | # ptype vC: type, class, object. |
c906108c | 424 | |
ebac27b4 MC |
425 | set re_class "class vC : public virtual vA \{(${ws}private:|)" |
426 | set re_vbptr "vA \\*(_vb.2vA|_vb.vA);${ws}" | |
427 | set re_access "public:" | |
428 | set re_fields "int vc;${ws}int vx;" | |
429 | set re_synth_gcc_2 "vC & operator=\\(vC const ?&\\);${ws}vC\\(int, vC const ?&\\);${ws}vC\\(int\\);" | |
9366563b | 430 | set re_synth_gcc_3 "(vC & operator=\\(vC const ?&\\);${ws}|)vC\\(vC const ?&\\);${ws}vC\\((void|)\\);" |
c906108c | 431 | |
ebac27b4 MC |
432 | set name "ptype vC" |
433 | gdb_test_multiple "ptype vC" $name { | |
434 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
435 | # gcc 2.95.3 -gdwarf-2 | |
436 | pass $name | |
a0b3c4fd | 437 | } |
ebac27b4 MC |
438 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { |
439 | # gcc 2.95.3 -gstabs+ | |
440 | pass $name | |
c906108c | 441 | } |
ebac27b4 MC |
442 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { |
443 | # gcc 3.3.2 -gdwarf-2 | |
444 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
445 | pass "$name (aCC)" | |
c906108c | 446 | } |
ebac27b4 MC |
447 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { |
448 | # gcc 3.3.2 -gstabs+ | |
449 | # gcc HEAD 2004-01-21 -gstabs+ | |
450 | pass "$name (aCC)" | |
a0b3c4fd | 451 | } |
c906108c SS |
452 | } |
453 | ||
ebac27b4 MC |
454 | set name "ptype class vC" |
455 | gdb_test_multiple "ptype class vC" $name { | |
456 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
457 | # gcc 2.95.3 -gdwarf-2 | |
458 | pass $name | |
a0b3c4fd | 459 | } |
ebac27b4 MC |
460 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { |
461 | # gcc 2.95.3 -gstabs+ | |
462 | pass $name | |
c906108c | 463 | } |
ebac27b4 MC |
464 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { |
465 | # gcc 3.3.2 -gdwarf-2 | |
466 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
467 | pass "$name (aCC)" | |
c906108c | 468 | } |
ebac27b4 MC |
469 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { |
470 | # gcc 3.3.2 -gstabs+ | |
471 | # gcc HEAD 2004-01-21 -gstabs+ | |
472 | pass "$name (aCC)" | |
a0b3c4fd | 473 | } |
c906108c SS |
474 | } |
475 | ||
ebac27b4 MC |
476 | set name "ptype g_vC" |
477 | gdb_test_multiple "ptype g_vC" $name { | |
478 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
479 | # gcc 2.95.3 -gdwarf-2 | |
480 | pass $name | |
481 | } | |
482 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { | |
483 | # gcc 2.95.3 -gstabs+ | |
484 | pass $name | |
485 | } | |
486 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
487 | # gcc 3.3.2 -gdwarf-2 | |
488 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
489 | pass "$name (aCC)" | |
490 | } | |
491 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { | |
492 | # gcc 3.3.2 -gstabs+ | |
493 | # gcc HEAD 2004-01-21 -gstabs+ | |
494 | pass "$name (aCC)" | |
495 | } | |
496 | } | |
497 | } | |
c906108c | 498 | |
ebac27b4 | 499 | # Multiple virtual inheritance, print type definitions. |
c906108c | 500 | |
ebac27b4 MC |
501 | proc test_ptype_mvi { } { |
502 | global gdb_prompt | |
503 | global ws | |
504 | global nl | |
c906108c | 505 | |
ebac27b4 | 506 | # ptype vD: type, class, object. |
c906108c | 507 | |
ebac27b4 MC |
508 | set re_class "class vD : public virtual vB, public virtual vC \{(${ws}private:|)" |
509 | set re_vbptr "vC \\*(_vb.2vC|_vb.vC);${ws}vB \\*(_vb.2vB|_vb.vB);" | |
510 | set re_access "public:" | |
511 | set re_fields "int vd;${ws}int vx;" | |
512 | set re_synth_gcc_2 "vD & operator=\\(vD const ?&\\);${ws}vD\\(int, vD const ?&\\);${ws}vD\\(int\\);" | |
9366563b | 513 | set re_synth_gcc_3 "(vD & operator=\\(vD const ?&\\);${ws}|)vD\\(vD const ?&\\);${ws}vD\\((void|)\\);" |
c906108c | 514 | |
ebac27b4 MC |
515 | set name "ptype vD" |
516 | gdb_test_multiple "ptype vD" $name { | |
517 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
518 | # gcc 2.95.3 -gdwarf-2 | |
519 | pass $name | |
c906108c | 520 | } |
ebac27b4 MC |
521 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { |
522 | # gcc 2.95.3 -gstabs+ | |
523 | pass $name | |
524 | } | |
525 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
526 | # gcc 3.3.2 -gdwarf-2 | |
527 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
528 | pass "$name" | |
529 | } | |
530 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { | |
531 | # gcc 3.3.2 -gstabs+ | |
532 | # gcc HEAD 2004-01-21 -gstabs+ | |
533 | pass "$name" | |
c906108c | 534 | } |
c906108c SS |
535 | } |
536 | ||
ebac27b4 MC |
537 | set name "ptype class vD" |
538 | gdb_test_multiple "ptype class vD" $name { | |
539 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
540 | # gcc 2.95.3 -gdwarf-2 | |
541 | pass $name | |
a0b3c4fd | 542 | } |
ebac27b4 MC |
543 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { |
544 | # gcc 2.95.3 -gstabs+ | |
545 | pass $name | |
c906108c | 546 | } |
ebac27b4 MC |
547 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { |
548 | # gcc 3.3.2 -gdwarf-2 | |
549 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
550 | pass "$name" | |
c906108c | 551 | } |
ebac27b4 MC |
552 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { |
553 | # gcc 3.3.2 -gstabs+ | |
554 | # gcc HEAD 2004-01-21 -gstabs+ | |
555 | pass "$name" | |
a0b3c4fd | 556 | } |
c906108c SS |
557 | } |
558 | ||
ebac27b4 MC |
559 | set name "ptype g_vD" |
560 | gdb_test_multiple "ptype g_vD" $name { | |
561 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
562 | # gcc 2.95.3 -gdwarf-2 | |
563 | pass $name | |
564 | } | |
565 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { | |
566 | # gcc 2.95.3 -gstabs+ | |
567 | pass $name | |
568 | } | |
569 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
570 | # gcc 3.3.2 -gdwarf-2 | |
571 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
572 | pass "$name" | |
573 | } | |
574 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { | |
575 | # gcc 3.3.2 -gstabs+ | |
576 | # gcc HEAD 2004-01-21 -gstabs+ | |
577 | pass "$name" | |
578 | } | |
579 | } | |
c906108c | 580 | |
ebac27b4 | 581 | # ptype vE: type, class, object. |
c906108c | 582 | |
ebac27b4 MC |
583 | set re_class "class vE : public virtual vD \{(${ws}private:|)" |
584 | set re_vbptr "vD \\*(_vb.2vD|_vb.vD);" | |
585 | set re_access "public:" | |
586 | set re_fields "int ve;${ws}int vx;" | |
587 | set re_synth_gcc_2 "vE & operator=\\(vE const ?&\\);${ws}vE\\(int, vE const ?&\\);${ws}vE\\(int\\);" | |
9366563b | 588 | set re_synth_gcc_3 "(vE & operator=\\(vE const ?&\\);${ws}|)vE\\(vE const ?&\\);${ws}vE\\((void|)\\);" |
c906108c | 589 | |
ebac27b4 MC |
590 | set name "ptype vE" |
591 | gdb_test_multiple "ptype vE" $name { | |
592 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
593 | # gcc 2.95.3 -gdwarf-2 | |
594 | pass $name | |
595 | } | |
596 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { | |
597 | # gcc 2.95.3 -gstabs+ | |
598 | pass $name | |
599 | } | |
600 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
601 | # gcc 3.3.2 -gdwarf-2 | |
602 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
603 | pass "$name" | |
604 | } | |
605 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { | |
606 | # gcc 3.3.2 -gstabs+ | |
607 | # gcc HEAD 2004-01-21 -gstabs+ | |
608 | pass "$name" | |
609 | } | |
610 | } | |
c906108c | 611 | |
ebac27b4 MC |
612 | set name "ptype class vE" |
613 | gdb_test_multiple "ptype class vE" $name { | |
614 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
615 | # gcc 2.95.3 -gdwarf-2 | |
616 | pass $name | |
617 | } | |
618 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { | |
619 | # gcc 2.95.3 -gstabs+ | |
620 | pass $name | |
621 | } | |
622 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
623 | # gcc 3.3.2 -gdwarf-2 | |
624 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
625 | pass "$name" | |
626 | } | |
627 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { | |
628 | # gcc 3.3.2 -gstabs+ | |
629 | # gcc HEAD 2004-01-21 -gstabs+ | |
630 | pass "$name" | |
631 | } | |
632 | } | |
c906108c | 633 | |
ebac27b4 MC |
634 | set name "ptype g_vE" |
635 | gdb_test_multiple "ptype g_vE" $name { | |
636 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
637 | # gcc 2.95.3 -gdwarf-2 | |
638 | pass $name | |
639 | } | |
640 | -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { | |
641 | # gcc 2.95.3 -gstabs+ | |
642 | pass $name | |
643 | } | |
644 | -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
645 | # gcc 3.3.2 -gdwarf-2 | |
646 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
647 | pass "$name" | |
648 | } | |
649 | -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { | |
650 | # gcc 3.3.2 -gstabs+ | |
651 | # gcc HEAD 2004-01-21 -gstabs+ | |
652 | pass "$name" | |
653 | } | |
654 | } | |
c906108c SS |
655 | } |
656 | ||
ebac27b4 | 657 | # Single inheritance, print individual members. |
c906108c | 658 | |
ebac27b4 MC |
659 | proc test_print_si_members { } { |
660 | global vhn | |
c906108c | 661 | |
ebac27b4 MC |
662 | # Print all members of g_A using fully qualified form. |
663 | gdb_test "print g_A.A::a" "$vhn = 1" | |
664 | gdb_test "print g_A.A::x" "$vhn = 2" | |
c906108c | 665 | |
ebac27b4 MC |
666 | # Print members of g_A using nonambiguous compact form. |
667 | gdb_test "print g_A.a" "$vhn = 1" | |
668 | gdb_test "print g_A.x" "$vhn = 2" | |
c906108c | 669 | |
ebac27b4 MC |
670 | # Print all members of g_B using fully qualified form. |
671 | gdb_test "print g_B.A::a" "$vhn = 3" | |
672 | gdb_test "print g_B.A::x" "$vhn = 4" | |
673 | gdb_test "print g_B.B::b" "$vhn = 5" | |
674 | gdb_test "print g_B.B::x" "$vhn = 6" | |
c906108c | 675 | |
ebac27b4 MC |
676 | # Print members of g_B using nonambiguous compact form. |
677 | gdb_test "print g_B.a" "$vhn = 3" | |
678 | gdb_test "print g_B.b" "$vhn = 5" | |
679 | gdb_test "print g_B.x" "$vhn = 6" | |
c906108c | 680 | |
ebac27b4 MC |
681 | # Print all members of g_C using fully qualified form. |
682 | gdb_test "print g_C.A::a" "$vhn = 7" | |
683 | gdb_test "print g_C.A::x" "$vhn = 8" | |
684 | gdb_test "print g_C.C::c" "$vhn = 9" | |
685 | gdb_test "print g_C.C::x" "$vhn = 10" | |
c906108c | 686 | |
ebac27b4 MC |
687 | # Print members of g_C using nonambiguous compact form. |
688 | gdb_test "print g_C.a" "$vhn = 7" | |
689 | gdb_test "print g_C.c" "$vhn = 9" | |
690 | gdb_test "print g_C.x" "$vhn = 10" | |
c906108c SS |
691 | } |
692 | ||
ebac27b4 | 693 | # Single inheritance, print complete classes. |
c906108c | 694 | |
ebac27b4 MC |
695 | proc test_print_si_classes { } { |
696 | global vhn | |
c906108c | 697 | |
ebac27b4 MC |
698 | # Print all members of g_A, g_B, g_C. |
699 | gdb_test "print g_A" "$vhn = \{a = 1, x = 2\}" | |
700 | gdb_test "print g_B" "$vhn = \{<(class A|A)> = \{a = 3, x = 4\}, b = 5, x = 6\}" | |
701 | gdb_test "print g_C" "$vhn = \{<(class A|A)> = \{a = 7, x = 8\}, c = 9, x = 10\}" | |
c906108c SS |
702 | } |
703 | ||
ebac27b4 | 704 | # Multiple inheritance, print individual members. |
c906108c | 705 | |
ebac27b4 | 706 | proc test_print_mi_members {} { |
c906108c | 707 | global gdb_prompt |
c906108c | 708 | global nl |
ebac27b4 | 709 | global vhn |
c906108c | 710 | |
ebac27b4 MC |
711 | # Print all members of g_A. |
712 | gdb_test "print g_A.A::a" "$vhn = 1" | |
713 | gdb_test "print g_A.A::x" "$vhn = 2" | |
c906108c | 714 | |
ebac27b4 MC |
715 | # Print all members of g_B. |
716 | gdb_test "print g_B.A::a" "$vhn = 3" | |
717 | gdb_test "print g_B.A::x" "$vhn = 4" | |
718 | gdb_test "print g_B.B::b" "$vhn = 5" | |
719 | gdb_test "print g_B.B::x" "$vhn = 6" | |
c906108c | 720 | |
ebac27b4 MC |
721 | # Print all members of g_C. |
722 | gdb_test "print g_C.A::a" "$vhn = 7" | |
723 | gdb_test "print g_C.A::x" "$vhn = 8" | |
724 | gdb_test "print g_C.C::c" "$vhn = 9" | |
725 | gdb_test "print g_C.C::x" "$vhn = 10" | |
c906108c | 726 | |
ebac27b4 MC |
727 | # Print all members of g_D. |
728 | # | |
729 | # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb | |
730 | # should detect these. There are no ways to PASS these tests | |
731 | # because I don't know what the gdb message will be. -- chastain | |
732 | # 2004-01-27. | |
733 | ||
734 | set name "print g_D.A::a" | |
735 | gdb_test_multiple "print g_D.A::a" $name { | |
736 | -re "$vhn = (15|11)$nl$gdb_prompt $" { | |
737 | kfail "gdb/68" "print g_D.A::a" | |
c906108c | 738 | } |
c906108c SS |
739 | } |
740 | ||
ebac27b4 MC |
741 | set name "print g_D.A::x" |
742 | gdb_test_multiple "print g_D.A::x" $name { | |
743 | -re "$vhn = (16|12)$nl$gdb_prompt $" { | |
744 | kfail "gdb/68" "print g_D.A::x" | |
745 | } | |
746 | } | |
c906108c | 747 | |
ebac27b4 MC |
748 | gdb_test "print g_D.B::b" "$vhn = 13" |
749 | gdb_test "print g_D.B::x" "$vhn = 14" | |
750 | gdb_test "print g_D.C::c" "$vhn = 17" | |
751 | gdb_test "print g_D.C::x" "$vhn = 18" | |
752 | gdb_test "print g_D.D::d" "$vhn = 19" | |
753 | gdb_test "print g_D.D::x" "$vhn = 20" | |
c906108c | 754 | |
ebac27b4 MC |
755 | # Print all members of g_E. |
756 | # g_E.A::a and g_E.A::x are ambiguous. | |
c906108c | 757 | |
ebac27b4 MC |
758 | set name "print g_E.A::a" |
759 | gdb_test_multiple "print g_E.A::a" $name { | |
760 | -re "$vhn = (21|25)$nl$gdb_prompt $" { | |
761 | kfail "gdb/68" "print g_E.A::a" | |
762 | } | |
763 | } | |
c906108c | 764 | |
ebac27b4 MC |
765 | set name "print g_E.A::x" |
766 | gdb_test_multiple "print g_E.A::x" $name { | |
767 | -re "$vhn = (26|22)$nl$gdb_prompt $" { | |
768 | kfail "gdb/68" "print g_E.A::x" | |
769 | } | |
770 | } | |
c906108c | 771 | |
ebac27b4 MC |
772 | gdb_test "print g_E.B::b" "$vhn = 23" |
773 | gdb_test "print g_E.B::x" "$vhn = 24" | |
774 | gdb_test "print g_E.C::c" "$vhn = 27" | |
775 | gdb_test "print g_E.C::x" "$vhn = 28" | |
776 | gdb_test "print g_E.D::d" "$vhn = 29" | |
777 | gdb_test "print g_E.D::x" "$vhn = 30" | |
778 | gdb_test "print g_E.E::e" "$vhn = 31" | |
779 | gdb_test "print g_E.E::x" "$vhn = 32" | |
780 | } | |
c906108c | 781 | |
ebac27b4 | 782 | # Multiple inheritance, print complete classes. |
c906108c | 783 | |
ebac27b4 MC |
784 | proc test_print_mi_classes { } { |
785 | global vhn | |
c906108c | 786 | |
ebac27b4 MC |
787 | # Print all members of g_D. |
788 | gdb_test "print g_D" "$vhn = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 11, x = 12\}, b = 13, x = 14\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 15, x = 16\}, c = 17, x = 18\}, d = 19, x = 20\}" | |
c906108c | 789 | |
ebac27b4 MC |
790 | # Print all members of g_E. |
791 | gdb_test "print g_E" "$vhn = \{\<(class |)D\> = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 21, x = 22\}, b = 23, x = 24\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 25, x = 26\}, c = 27, x = 28\}, d = 29, x = 30\}, e = 31, x = 32\}" | |
c906108c SS |
792 | } |
793 | ||
ebac27b4 MC |
794 | # Single inheritance, print anonymous unions. |
795 | # GDB versions prior to 4.14 entered an infinite loop when printing | |
796 | # the type of a class containing an anonymous union, and they were also | |
797 | # incapable of printing the member of an anonymous union. | |
798 | # We test the printing of the member first, and perform the other tests | |
799 | # only if the test succeeds, to avoid the infinite loop. | |
c906108c | 800 | # |
ebac27b4 MC |
801 | # GDB HEAD 2004-01-27 with hp aCC A.03.45 crashes on the first test. |
802 | # -- chastain 2004-01-27 | |
c906108c | 803 | |
ebac27b4 | 804 | proc test_print_anon_union {} { |
c906108c | 805 | global gdb_prompt |
a0b3c4fd | 806 | global ws |
c906108c | 807 | global nl |
ebac27b4 | 808 | global vhn |
c906108c | 809 | |
ebac27b4 | 810 | gdb_test "print g_anon_union.a" "$vhn = 2" "print anonymous union member" |
c906108c | 811 | |
ebac27b4 MC |
812 | set name "print variable of type anonymous union" |
813 | gdb_test_multiple "print g_anon_union" $name { | |
814 | -re "$vhn = \{one = 1, \{a = 2, b = 2\}\}$nl$gdb_prompt $" { | |
815 | pass $name | |
c906108c | 816 | } |
c906108c SS |
817 | } |
818 | ||
9366563b | 819 | set re_class "((struct|class) class_with_anon_union \{${ws}public:|struct class_with_anon_union \{)" |
ebac27b4 MC |
820 | set re_fields "int one;${ws}" |
821 | set re_anon_union "union \{${ws}int a;${ws}long int b;${ws}\};" | |
822 | set re_synth_gcc_23 "class_with_anon_union & operator=\\(class_with_anon_union const ?&\\);${ws}class_with_anon_union\\(class_with_anon_union const ?&\\);${ws}class_with_anon_union\\((void|)\\);" | |
c906108c | 823 | |
ebac27b4 MC |
824 | set name "print type of anonymous union" |
825 | gdb_test_multiple "ptype g_anon_union" $name { | |
826 | -re "type = $re_class${ws}$re_fields${ws}$re_anon_union$nl\}$nl$gdb_prompt $" { | |
827 | pass $name | |
a0b3c4fd | 828 | } |
ebac27b4 MC |
829 | -re "type = $re_class${ws}$re_fields${ws}$re_anon_union${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
830 | pass $name | |
a0b3c4fd | 831 | } |
a0b3c4fd | 832 | } |
ebac27b4 | 833 | } |
c906108c | 834 | |
c906108c | 835 | |
ebac27b4 | 836 | # Single virtual inheritance, print individual members. |
c906108c | 837 | |
ebac27b4 MC |
838 | proc test_print_svi_members { } { |
839 | global vhn | |
c906108c | 840 | |
ebac27b4 MC |
841 | # Print all members of g_vA. |
842 | gdb_test "print g_vA.vA::va" "$vhn = 1" | |
843 | gdb_test "print g_vA.vA::vx" "$vhn = 2" | |
c906108c | 844 | |
ebac27b4 MC |
845 | # Print members of g_vA using compact form. |
846 | gdb_test "print g_vA.va" "$vhn = 1" | |
847 | gdb_test "print g_vA.vx" "$vhn = 2" | |
848 | ||
849 | # Print all members of g_vB. | |
850 | gdb_test "print g_vB.vA::va" "$vhn = 3" | |
851 | gdb_test "print g_vB.vA::vx" "$vhn = 4" | |
852 | gdb_test "print g_vB.vB::vb" "$vhn = 5" | |
853 | gdb_test "print g_vB.vB::vx" "$vhn = 6" | |
854 | ||
855 | # Print members of g_vB using compact form. | |
856 | gdb_test "print g_vB.va" "$vhn = 3" | |
857 | gdb_test "print g_vB.vb" "$vhn = 5" | |
858 | gdb_test "print g_vB.vx" "$vhn = 6" | |
859 | ||
860 | # Print all members of g_vC. | |
861 | gdb_test "print g_vC.vA::va" "$vhn = 7" | |
862 | gdb_test "print g_vC.vA::vx" "$vhn = 8" | |
863 | gdb_test "print g_vC.vC::vc" "$vhn = 9" | |
864 | gdb_test "print g_vC.vC::vx" "$vhn = 10" | |
865 | ||
866 | # Print members of g_vC using compact form. | |
867 | gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va" | |
868 | gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc" | |
869 | gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx" | |
c906108c SS |
870 | } |
871 | ||
c906108c | 872 | # Single virtual inheritance, print complete classes. |
c906108c | 873 | |
ebac27b4 | 874 | proc test_print_svi_classes { } { |
c906108c SS |
875 | global gdb_prompt |
876 | global hex | |
c906108c | 877 | global nl |
ebac27b4 | 878 | global vhn |
c906108c SS |
879 | |
880 | # Print all members of g_vA. | |
ebac27b4 | 881 | gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}" |
c906108c SS |
882 | |
883 | # Print all members of g_vB. | |
ebac27b4 MC |
884 | set re_vbptr_2 "(_vb.2vA|_vb.vA)" |
885 | set re_vbptr_3 "_vptr.vB" | |
886 | ||
887 | set name "print g_vB" | |
888 | gdb_test_multiple "print g_vB" $name { | |
889 | -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { | |
890 | # gcc 2.95.3 -gdwarf-2 | |
891 | # gcc 2.95.3 -gstabs+ | |
892 | pass $name | |
893 | } | |
894 | -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { | |
9366563b MC |
895 | # gcc 3.3.4 -gdwarf-2 |
896 | # gcc 3.4.1 -gdwarf-2 | |
897 | # gcc 3.4.1 -gstabs+ | |
898 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
ebac27b4 MC |
899 | pass "$name (FIXME v3 vtbl ptr)" |
900 | } | |
901 | -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" { | |
9366563b MC |
902 | # gcc 3.3.4 -gstabs+ |
903 | pass $name | |
904 | } | |
905 | -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <typeinfo for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" { | |
906 | # gcc HEAD 2004-07-31 -gstabs+ | |
ebac27b4 | 907 | pass $name |
5178b9d6 | 908 | } |
c906108c SS |
909 | } |
910 | ||
911 | # Print all members of g_vC. | |
ebac27b4 MC |
912 | set re_vbptr_2 "(_vb.2vA|_vb.vA)" |
913 | set re_vbptr_3 "_vptr.vC" | |
914 | ||
915 | set name "print g_vC" | |
916 | gdb_test_multiple "print g_vC" $name { | |
917 | -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { | |
918 | # gcc 2.95.3 -gdwarf-2 | |
919 | # gcc 2.95.3 -gstabs+ | |
920 | pass $name | |
921 | } | |
922 | -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { | |
9366563b MC |
923 | # gcc 3.3.4 -gdwarf-2 |
924 | # gcc 3.4.1 -gdwarf-2 | |
925 | # gcc 3.4.1 -gstabs+ | |
926 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
ebac27b4 MC |
927 | pass "$name (FIXME v3 vtbl ptr)" |
928 | } | |
929 | -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" { | |
9366563b MC |
930 | # gcc 3.3.4 -gstabs+ |
931 | pass $name | |
932 | } | |
933 | -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <typeinfo for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" { | |
934 | # gcc HEAD 2004-07-31 -gstabs+ | |
ebac27b4 | 935 | pass $name |
a0b3c4fd | 936 | } |
a0b3c4fd | 937 | } |
c906108c SS |
938 | } |
939 | ||
c906108c | 940 | # Multiple virtual inheritance, print individual members. |
c906108c | 941 | |
ebac27b4 MC |
942 | proc test_print_mvi_members { } { |
943 | global vhn | |
c906108c SS |
944 | |
945 | # Print all members of g_vD. | |
ebac27b4 MC |
946 | gdb_test "print g_vD.vA::va" "$vhn = 19" |
947 | gdb_test "print g_vD.vA::vx" "$vhn = 20" | |
948 | gdb_test "print g_vD.vB::vb" "$vhn = 21" | |
949 | gdb_test "print g_vD.vB::vx" "$vhn = 22" | |
950 | gdb_test "print g_vD.vC::vc" "$vhn = 23" | |
951 | gdb_test "print g_vD.vC::vx" "$vhn = 24" | |
952 | gdb_test "print g_vD.vD::vd" "$vhn = 25" | |
953 | gdb_test "print g_vD.vD::vx" "$vhn = 26" | |
c906108c SS |
954 | |
955 | # Print all members of g_vE. | |
ebac27b4 MC |
956 | gdb_test "print g_vE.vA::va" "$vhn = 0" |
957 | gdb_test "print g_vE.vA::vx" "$vhn = 0" | |
958 | gdb_test "print g_vE.vB::vb" "$vhn = 0" | |
959 | gdb_test "print g_vE.vB::vx" "$vhn = 0" | |
960 | gdb_test "print g_vE.vC::vc" "$vhn = 0" | |
961 | gdb_test "print g_vE.vC::vx" "$vhn = 0" | |
962 | gdb_test "print g_vE.vD::vd" "$vhn = 0" | |
963 | gdb_test "print g_vE.vD::vx" "$vhn = 0" | |
964 | gdb_test "print g_vE.vE::ve" "$vhn = 27" | |
965 | gdb_test "print g_vE.vE::vx" "$vhn = 28" | |
c906108c SS |
966 | } |
967 | ||
ebac27b4 | 968 | # Multiple virtual inheritance, print complete classes. |
c906108c | 969 | |
ebac27b4 | 970 | proc test_print_mvi_classes { } { |
a0b3c4fd | 971 | global gdb_prompt |
ebac27b4 | 972 | global hex |
a0b3c4fd | 973 | global ws |
c906108c | 974 | global nl |
ebac27b4 | 975 | global vhn |
c906108c | 976 | |
ebac27b4 | 977 | # Virtual base pointers for everybody. |
c906108c | 978 | |
ebac27b4 MC |
979 | set re_vbptr_2_vA "(_vb.2vA|_vb.vA)" |
980 | set re_vbptr_2_vB "(_vb.2vB|_vb.vB)" | |
981 | set re_vbptr_2_vC "(_vb.2vC|_vb.vC)" | |
982 | set re_vbptr_2_vD "(_vb.2vD|_vb.vD)" | |
983 | set re_vbptr_3_vA "_vptr.vA" | |
984 | set re_vbptr_3_vB "_vptr.vB" | |
985 | set re_vbptr_3_vC "_vptr.vC" | |
986 | set re_vbptr_3_vD "_vptr.vD" | |
987 | set re_vbptr_3_vE "_vptr.vE" | |
c906108c SS |
988 | |
989 | # Print all members of g_vD. | |
990 | ||
ebac27b4 MC |
991 | set name "print g_vD" |
992 | gdb_test_multiple "print g_vD" $name { | |
993 | -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_2_vA = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_2_vA = $hex, vc = 23, vx = 24\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { | |
994 | # gcc 2.95.3 -gdwarf-2 | |
995 | # gcc 2.95.3 -gstabs+ | |
996 | pass $name | |
c906108c | 997 | } |
ebac27b4 MC |
998 | -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = $hex, vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { |
999 | # gcc 3.3.2 -gdwarf-2 | |
1000 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
1001 | # gcc HEAD 2004-01-21 -gstabs+ | |
1002 | pass "$name (FIXME v3 vtbl ptr)" | |
5178b9d6 | 1003 | } |
ebac27b4 MC |
1004 | -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = $hex <VTT for vD>, vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { |
1005 | # gcc 3.3.2 -gstabs+ | |
1006 | pass "$name" | |
3c6cb4a1 | 1007 | } |
c906108c SS |
1008 | } |
1009 | ||
1010 | # Print all members of g_vE. | |
1011 | ||
ebac27b4 MC |
1012 | set name "print g_vE" |
1013 | gdb_test_multiple "print g_vE" $name { | |
1014 | -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_2_vA = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_2_vA = $hex, vc = 0, vx = 0\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 0, vx = 0\}, $re_vbptr_2_vD = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { | |
1015 | # gcc 2.95.3 -gdwarf-2 | |
1016 | # gcc 2.95.3 -gstabs+ | |
1017 | pass $name | |
a0b3c4fd | 1018 | } |
ebac27b4 | 1019 | -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { |
9366563b MC |
1020 | # gcc 3.3.4 -gdwarf-2 |
1021 | # gcc 3.3.4 -gstabs+ | |
1022 | # gcc 3.4.1 -gdwarf-2 | |
1023 | # gcc 3.4.1 -gstabs+ | |
1024 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
ebac27b4 | 1025 | pass "$name (FIXME v3 vtbl ptr)" |
5178b9d6 | 1026 | } |
ec4646ef MC |
1027 | -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex <VTT for vD>, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { |
1028 | # gcc 3.2.7-rh -gstabs+ | |
9366563b MC |
1029 | pass $name |
1030 | } | |
1031 | -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex <typeinfo for vE>, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { | |
1032 | # gcc HEAD 2004-07-31 -gstabs+ | |
1033 | pass $name | |
ec4646ef | 1034 | } |
a0b3c4fd | 1035 | } |
c906108c SS |
1036 | } |
1037 | ||
ebac27b4 | 1038 | proc do_tests { } { |
c906108c SS |
1039 | global prms_id |
1040 | global bug_id | |
1041 | global subdir | |
1042 | global objdir | |
1043 | global srcdir | |
1044 | global binfile | |
1045 | ||
1046 | set prms_id 0 | |
1047 | set bug_id 0 | |
1048 | ||
1049 | # Start with a fresh gdb. | |
1050 | ||
1051 | gdb_exit | |
1052 | gdb_start | |
1053 | gdb_reinitialize_dir $srcdir/$subdir | |
1054 | gdb_load $binfile | |
1055 | ||
1056 | gdb_test "set language c++" "" | |
1057 | gdb_test "set width 0" "" | |
1058 | ||
ebac27b4 MC |
1059 | if { ![runto_main] } then { |
1060 | perror "couldn't run to main" | |
1061 | return | |
c906108c SS |
1062 | } |
1063 | ||
1064 | test_ptype_si | |
1065 | test_ptype_mi | |
1066 | test_ptype_vi | |
1067 | test_ptype_mvi | |
1068 | ||
ebac27b4 MC |
1069 | if { ![runto 'inheritance2'] } then { |
1070 | perror "couldn't run to inheritance2" | |
1071 | return | |
c906108c SS |
1072 | } |
1073 | ||
1074 | test_print_si_members | |
1075 | test_print_si_classes | |
1076 | test_print_mi_members | |
1077 | test_print_mi_classes | |
1078 | test_print_anon_union | |
1079 | ||
ebac27b4 MC |
1080 | if { ![runto 'inheritance4'] } { |
1081 | perror "couldn't run to inheritance4" | |
1082 | return | |
c906108c SS |
1083 | } |
1084 | ||
1085 | test_print_svi_members | |
1086 | test_print_svi_classes | |
1087 | test_print_mvi_members | |
1088 | test_print_mvi_classes | |
1089 | } | |
1090 | ||
1091 | do_tests |