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