Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 1992-2015 Free Software Foundation, Inc. |
c906108c SS |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
8 | # This program is distributed in the hope that it will be useful, |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c | 16 | # This file was written by Fred Fish. (fnf@cygnus.com) |
ebac27b4 | 17 | # And rewritten by Michael Chastain. (mec.gnu@mindspring.com) |
c906108c | 18 | |
ebac27b4 MC |
19 | set ws "\[\r\n\t \]+" |
20 | set nl "\[\r\n\]+" | |
21 | set vhn "\\$\[0-9\]+" | |
c2d11a7d | 22 | |
d4f3574e SS |
23 | if { [skip_cplus_tests] } { continue } |
24 | ||
25808999 MC |
25 | load_lib "cp-support.exp" |
26 | ||
f5f3a911 | 27 | standard_testfile misc.cc |
c906108c | 28 | |
f5f3a911 TT |
29 | if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { |
30 | return -1 | |
c906108c SS |
31 | } |
32 | ||
c906108c | 33 | # Single inheritance, print type definitions. |
c906108c | 34 | |
ebac27b4 | 35 | proc test_ptype_si { } { |
c906108c SS |
36 | global gdb_prompt |
37 | global ws | |
38 | global nl | |
39 | ||
25808999 | 40 | # A simple class. |
c906108c | 41 | |
25808999 | 42 | cp_test_ptype_class \ |
b3720c3a | 43 | "A" "ptype A (FIXME)" "class" "A" \ |
25808999 MC |
44 | { |
45 | { field public "int a;" } | |
46 | { field public "int x;" } | |
ebac27b4 | 47 | } |
b3720c3a TT |
48 | cp_test_ptype_class "class A" "ptype class A (FIXME)" "class" "A" ibid |
49 | cp_test_ptype_class "g_A" "ptype g_A (FIXME)" "class" "A" ibid | |
c906108c | 50 | |
25808999 | 51 | # A derived class. |
c906108c | 52 | |
25808999 | 53 | cp_test_ptype_class \ |
b3720c3a | 54 | "B" "" "class" "B" \ |
25808999 MC |
55 | { |
56 | { base "public A" } | |
57 | { field public "int b;" } | |
58 | { field public "int x;" } | |
ebac27b4 | 59 | } |
b3720c3a TT |
60 | cp_test_ptype_class "class B" "" "class" "B" ibid |
61 | cp_test_ptype_class "g_B" "" "class" "B" ibid | |
c906108c | 62 | |
25808999 | 63 | # Another derived class. |
c906108c | 64 | |
25808999 | 65 | cp_test_ptype_class \ |
b3720c3a | 66 | "C" "" "class" "C" \ |
25808999 MC |
67 | { |
68 | { base "public A" } | |
69 | { field public "int c;" } | |
70 | { field public "int x;" } | |
ebac27b4 | 71 | } |
b3720c3a TT |
72 | cp_test_ptype_class "class C" "" "class" "C" ibid |
73 | cp_test_ptype_class "g_C" "" "class" "C" ibid | |
c906108c | 74 | |
25808999 MC |
75 | # A structure with no tag. |
76 | # TODO: move this mess into a separate file, and re-specify | |
77 | # which results are PASS, KFAIL, XFAIL, and FAIL. | |
ebac27b4 MC |
78 | |
79 | set re_tag "tagless_struct" | |
80 | set XX_tag "\\._1" | |
81 | set re_class "(class $re_tag \{${ws}public:|class \{${ws}public:|struct $re_tag \{|struct \{)" | |
82 | set XX_class "(class $XX_tag \{${ws}public:|struct $XX_tag \{)" | |
83 | set re_fields "int one;${ws}int two;" | |
84 | set re_synth_gcc_23 "$re_tag & operator=\\($re_tag const ?&\\);${ws}$re_tag\\($re_tag const ?&\\);${ws}$re_tag\\((void|)\\);" | |
85 | set XX_synth_gcc_23 "($re_tag|$XX_tag) & operator=\\($XX_tag const ?&\\);${ws}$XX_tag\\($XX_tag const ?&\\);${ws}$XX_tag\\((void|)\\);" | |
86 | ||
87 | set name "ptype tagless struct" | |
88 | gdb_test_multiple "ptype tagless_struct" $name { | |
89 | -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
90 | # gcc 2.95.3 -gdwarf-2 | |
9366563b | 91 | pass "$name" |
c906108c | 92 | } |
ebac27b4 MC |
93 | -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
94 | # gcc 2.95.3 -gstabs+ | |
9366563b | 95 | pass "$name" |
c906108c | 96 | } |
ebac27b4 | 97 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { |
9366563b MC |
98 | # gcc 3.3.4 -gdwarf-2 |
99 | # gcc 3.4.1 -gdwarf-2 | |
100 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
101 | # gcc HEAD 2004-07-31 -gstabs+ | |
102 | pass "$name" | |
c906108c | 103 | } |
ebac27b4 | 104 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
9366563b MC |
105 | # gcc 3.3.4 -gstabs+ |
106 | # gcc 3.4.1 -gstabs+ | |
ebac27b4 | 107 | pass "$name" |
c906108c | 108 | } |
907af001 UW |
109 | -re "No symbol \"tagless_struct\" in current context.$nl$gdb_prompt $" { |
110 | # Several GCC 4.x versions provide neither a DW_TAG_typedef DIE | |
111 | # nor use the typedef name as struct tag name. | |
112 | xfail "$name" | |
113 | } | |
c906108c SS |
114 | } |
115 | ||
ebac27b4 MC |
116 | set name "ptype variable of type tagless struct" |
117 | gdb_test_multiple "ptype v_tagless" $name { | |
118 | -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
119 | # gcc 2.95.3 -gdwarf-2 | |
9366563b | 120 | pass "$name" |
3e36a0f4 | 121 | } |
ebac27b4 MC |
122 | -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
123 | # gcc 2.95.3 -gstabs+ | |
9366563b | 124 | pass "$name" |
c906108c | 125 | } |
ebac27b4 | 126 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { |
9366563b MC |
127 | # gcc 3.3.4 -gdwarf-2 |
128 | # gcc 3.4.1 -gdwarf-2 | |
129 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
130 | # gcc HEAD 2004-07-31 -gstabs+ | |
131 | pass "$name" | |
c906108c | 132 | } |
ebac27b4 | 133 | -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { |
9366563b MC |
134 | # gcc 3.3.4 -gstabs+ |
135 | # gcc 3.4.1 -gstabs+ | |
ebac27b4 | 136 | pass "$name" |
c906108c SS |
137 | } |
138 | } | |
139 | } | |
140 | ||
ebac27b4 | 141 | # Multiple inheritance, print type definitions. |
c906108c | 142 | |
ebac27b4 | 143 | proc test_ptype_mi { } { |
ebac27b4 | 144 | |
25808999 | 145 | # A class with two bases. |
ebac27b4 | 146 | |
25808999 | 147 | cp_test_ptype_class \ |
b3720c3a | 148 | "D" "" "class" "D" \ |
25808999 MC |
149 | { |
150 | { base "public B" } | |
151 | { base "public C" } | |
152 | { field public "int d;" } | |
153 | { field public "int x;" } | |
c906108c | 154 | } |
b3720c3a TT |
155 | cp_test_ptype_class "class D" "" "class" "D" ibid |
156 | cp_test_ptype_class "g_D" "" "class" "D" ibid | |
ebac27b4 | 157 | |
25808999 | 158 | # A class derived from the previous class. |
ebac27b4 | 159 | |
25808999 | 160 | cp_test_ptype_class \ |
b3720c3a | 161 | "E" "" "class" "E" \ |
25808999 MC |
162 | { |
163 | { base "public D" } | |
164 | { field public "int e;" } | |
165 | { field public "int x;" } | |
3e36a0f4 | 166 | } |
b3720c3a TT |
167 | cp_test_ptype_class "class E" "" "class" "E" ibid |
168 | cp_test_ptype_class "g_E" "" "class" "E" ibid | |
c906108c SS |
169 | } |
170 | ||
ebac27b4 | 171 | # Single virtual inheritance, print type definitions. |
c906108c | 172 | |
ebac27b4 | 173 | proc test_ptype_vi { } { |
c906108c | 174 | |
25808999 | 175 | # class vA |
c906108c | 176 | |
25808999 | 177 | cp_test_ptype_class \ |
b3720c3a | 178 | "vA" "" "class" "vA" \ |
25808999 MC |
179 | { |
180 | { field public "int va;" } | |
181 | { field public "int vx;" } | |
ebac27b4 | 182 | } |
b3720c3a TT |
183 | cp_test_ptype_class "class vA" "" "class" "vA" ibid |
184 | cp_test_ptype_class "g_vA" "" "class" "vA" ibid | |
c906108c | 185 | |
25808999 | 186 | # class vB |
c906108c | 187 | |
25808999 | 188 | cp_test_ptype_class \ |
b3720c3a | 189 | "vB" "" "class" "vB" \ |
25808999 MC |
190 | { |
191 | { base "public virtual vA" } | |
192 | { vbase "vA" } | |
193 | { field public "int vb;" } | |
194 | { field public "int vx;" } | |
ebac27b4 | 195 | } |
b3720c3a TT |
196 | cp_test_ptype_class "class vB" "" "class" "vB" ibid |
197 | cp_test_ptype_class "g_vB" "" "class" "vB" ibid | |
c906108c | 198 | |
25808999 | 199 | # class vC |
c906108c | 200 | |
25808999 | 201 | cp_test_ptype_class \ |
b3720c3a | 202 | "vC" "" "class" "vC" \ |
25808999 MC |
203 | { |
204 | { base "public virtual vA" } | |
205 | { vbase "vA" } | |
206 | { field public "int vc;" } | |
207 | { field public "int vx;" } | |
ebac27b4 | 208 | } |
b3720c3a TT |
209 | cp_test_ptype_class "class vC" "" "class" "vC" ibid |
210 | cp_test_ptype_class "g_vC" "" "class" "vC" ibid | |
c906108c | 211 | |
ebac27b4 | 212 | } |
c906108c | 213 | |
ebac27b4 | 214 | # Multiple virtual inheritance, print type definitions. |
c906108c | 215 | |
ebac27b4 | 216 | proc test_ptype_mvi { } { |
c906108c | 217 | |
25808999 | 218 | # class vD |
c906108c | 219 | |
25808999 | 220 | cp_test_ptype_class \ |
b3720c3a | 221 | "vD" "" "class" "vD" \ |
25808999 MC |
222 | { |
223 | { base "public virtual vB" } | |
224 | { base "public virtual vC" } | |
225 | { vbase "vC" } | |
226 | { vbase "vB" } | |
227 | { field public "int vd;" } | |
228 | { field public "int vx;" } | |
ebac27b4 | 229 | } |
b3720c3a TT |
230 | cp_test_ptype_class "class vD" "" "class" "vD" ibid |
231 | cp_test_ptype_class "g_vD" "" "class" "vD" ibid | |
c906108c | 232 | |
25808999 | 233 | # class vE |
c906108c | 234 | |
25808999 | 235 | cp_test_ptype_class \ |
b3720c3a | 236 | "vE" "" "class" "vE" \ |
25808999 MC |
237 | { |
238 | { base "public virtual vD" } | |
239 | { vbase "vD" } | |
240 | { field public "int ve;" } | |
241 | { field public "int vx;" } | |
ebac27b4 | 242 | } |
b3720c3a TT |
243 | cp_test_ptype_class "class vE" "" "class" "vE" ibid |
244 | cp_test_ptype_class "g_vE" "" "class" "vE" ibid | |
c906108c | 245 | |
c906108c SS |
246 | } |
247 | ||
ebac27b4 | 248 | # Single inheritance, print individual members. |
c906108c | 249 | |
ebac27b4 MC |
250 | proc test_print_si_members { } { |
251 | global vhn | |
c906108c | 252 | |
ebac27b4 MC |
253 | # Print all members of g_A using fully qualified form. |
254 | gdb_test "print g_A.A::a" "$vhn = 1" | |
255 | gdb_test "print g_A.A::x" "$vhn = 2" | |
c906108c | 256 | |
ebac27b4 MC |
257 | # Print members of g_A using nonambiguous compact form. |
258 | gdb_test "print g_A.a" "$vhn = 1" | |
259 | gdb_test "print g_A.x" "$vhn = 2" | |
c906108c | 260 | |
ebac27b4 MC |
261 | # Print all members of g_B using fully qualified form. |
262 | gdb_test "print g_B.A::a" "$vhn = 3" | |
263 | gdb_test "print g_B.A::x" "$vhn = 4" | |
264 | gdb_test "print g_B.B::b" "$vhn = 5" | |
265 | gdb_test "print g_B.B::x" "$vhn = 6" | |
c906108c | 266 | |
ebac27b4 MC |
267 | # Print members of g_B using nonambiguous compact form. |
268 | gdb_test "print g_B.a" "$vhn = 3" | |
269 | gdb_test "print g_B.b" "$vhn = 5" | |
270 | gdb_test "print g_B.x" "$vhn = 6" | |
c906108c | 271 | |
ebac27b4 MC |
272 | # Print all members of g_C using fully qualified form. |
273 | gdb_test "print g_C.A::a" "$vhn = 7" | |
274 | gdb_test "print g_C.A::x" "$vhn = 8" | |
275 | gdb_test "print g_C.C::c" "$vhn = 9" | |
276 | gdb_test "print g_C.C::x" "$vhn = 10" | |
c906108c | 277 | |
ebac27b4 MC |
278 | # Print members of g_C using nonambiguous compact form. |
279 | gdb_test "print g_C.a" "$vhn = 7" | |
280 | gdb_test "print g_C.c" "$vhn = 9" | |
281 | gdb_test "print g_C.x" "$vhn = 10" | |
c906108c SS |
282 | } |
283 | ||
ebac27b4 | 284 | # Single inheritance, print complete classes. |
c906108c | 285 | |
ebac27b4 MC |
286 | proc test_print_si_classes { } { |
287 | global vhn | |
c906108c | 288 | |
ebac27b4 MC |
289 | # Print all members of g_A, g_B, g_C. |
290 | gdb_test "print g_A" "$vhn = \{a = 1, x = 2\}" | |
291 | gdb_test "print g_B" "$vhn = \{<(class A|A)> = \{a = 3, x = 4\}, b = 5, x = 6\}" | |
292 | gdb_test "print g_C" "$vhn = \{<(class A|A)> = \{a = 7, x = 8\}, c = 9, x = 10\}" | |
c906108c SS |
293 | } |
294 | ||
ebac27b4 | 295 | # Multiple inheritance, print individual members. |
c906108c | 296 | |
ebac27b4 | 297 | proc test_print_mi_members {} { |
c906108c | 298 | global gdb_prompt |
c906108c | 299 | global nl |
ebac27b4 | 300 | global vhn |
c906108c | 301 | |
ebac27b4 MC |
302 | # Print all members of g_A. |
303 | gdb_test "print g_A.A::a" "$vhn = 1" | |
304 | gdb_test "print g_A.A::x" "$vhn = 2" | |
c906108c | 305 | |
ebac27b4 MC |
306 | # Print all members of g_B. |
307 | gdb_test "print g_B.A::a" "$vhn = 3" | |
308 | gdb_test "print g_B.A::x" "$vhn = 4" | |
309 | gdb_test "print g_B.B::b" "$vhn = 5" | |
310 | gdb_test "print g_B.B::x" "$vhn = 6" | |
c906108c | 311 | |
ebac27b4 MC |
312 | # Print all members of g_C. |
313 | gdb_test "print g_C.A::a" "$vhn = 7" | |
314 | gdb_test "print g_C.A::x" "$vhn = 8" | |
315 | gdb_test "print g_C.C::c" "$vhn = 9" | |
316 | gdb_test "print g_C.C::x" "$vhn = 10" | |
c906108c | 317 | |
ebac27b4 MC |
318 | # Print all members of g_D. |
319 | # | |
b1af9e97 TT |
320 | # g_D.A::a and g_D.A::x are ambiguous member accesses. |
321 | gdb_test "print g_D.A::a" "base class 'A' is ambiguous in type 'D'" | |
322 | gdb_test "print g_D.C::a" "$vhn = 15" | |
323 | gdb_test "print g_D.B::a" "$vhn = 11" | |
324 | gdb_test "print g_D.A::x" "base class 'A' is ambiguous in type 'D'" | |
ebac27b4 MC |
325 | gdb_test "print g_D.B::b" "$vhn = 13" |
326 | gdb_test "print g_D.B::x" "$vhn = 14" | |
327 | gdb_test "print g_D.C::c" "$vhn = 17" | |
328 | gdb_test "print g_D.C::x" "$vhn = 18" | |
329 | gdb_test "print g_D.D::d" "$vhn = 19" | |
330 | gdb_test "print g_D.D::x" "$vhn = 20" | |
c906108c | 331 | |
ebac27b4 MC |
332 | # Print all members of g_E. |
333 | # g_E.A::a and g_E.A::x are ambiguous. | |
c906108c | 334 | |
b1af9e97 TT |
335 | gdb_test "print g_E.A::a" "base class 'A' is ambiguous in type 'E'" |
336 | gdb_test "print g_E.A::x" "base class 'A' is ambiguous in type 'E'" | |
ebac27b4 MC |
337 | gdb_test "print g_E.B::b" "$vhn = 23" |
338 | gdb_test "print g_E.B::x" "$vhn = 24" | |
339 | gdb_test "print g_E.C::c" "$vhn = 27" | |
340 | gdb_test "print g_E.C::x" "$vhn = 28" | |
341 | gdb_test "print g_E.D::d" "$vhn = 29" | |
342 | gdb_test "print g_E.D::x" "$vhn = 30" | |
343 | gdb_test "print g_E.E::e" "$vhn = 31" | |
344 | gdb_test "print g_E.E::x" "$vhn = 32" | |
345 | } | |
c906108c | 346 | |
9733fc94 DJ |
347 | # Multiple inheritance, print individual member types. |
348 | ||
349 | proc test_print_mi_member_types {} { | |
350 | global gdb_prompt | |
351 | global nl | |
352 | global vhn | |
353 | ||
354 | # Print the types of some members of g_D without qualifying them. | |
355 | gdb_test "ptype g_D.b" "type = int" | |
356 | gdb_test "ptype g_D.c" "type = int" | |
357 | gdb_test "ptype g_D.d" "type = int" | |
358 | ||
359 | # Print the types of qualified members; none of these tests pass today. | |
360 | ||
361 | # Print all members of g_A. | |
9733fc94 | 362 | gdb_test "ptype g_A.A::a" "type = int" |
9733fc94 DJ |
363 | gdb_test "ptype g_A.A::x" "type = int" |
364 | ||
365 | # Print all members of g_B. | |
9733fc94 | 366 | gdb_test "ptype g_B.A::a" "type = int" |
9733fc94 | 367 | gdb_test "ptype g_B.A::x" "type = int" |
9733fc94 | 368 | gdb_test "ptype g_B.B::b" "type = int" |
9733fc94 DJ |
369 | gdb_test "ptype g_B.B::x" "type = int" |
370 | ||
371 | # Print all members of g_C. | |
9733fc94 | 372 | gdb_test "ptype g_C.A::a" "type = int" |
9733fc94 | 373 | gdb_test "ptype g_C.A::x" "type = int" |
9733fc94 | 374 | gdb_test "ptype g_C.C::c" "type = int" |
9733fc94 DJ |
375 | gdb_test "ptype g_C.C::x" "type = int" |
376 | ||
377 | # Print all members of g_D. | |
378 | # | |
b1af9e97 | 379 | # g_D.A::a and g_D.A::x are ambiguous member accesses. |
9733fc94 | 380 | |
b1af9e97 TT |
381 | gdb_test "ptype g_D.A::a" "base class 'A' is ambiguous in type 'D'" |
382 | gdb_test "ptype g_D.A::x" "base class 'A' is ambiguous in type 'D'" | |
9733fc94 | 383 | gdb_test "ptype g_D.B::b" "type = int" |
9733fc94 | 384 | gdb_test "ptype g_D.B::x" "type = int" |
9733fc94 | 385 | gdb_test "ptype g_D.C::c" "type = int" |
9733fc94 | 386 | gdb_test "ptype g_D.C::x" "type = int" |
9733fc94 | 387 | gdb_test "ptype g_D.D::d" "type = int" |
9733fc94 DJ |
388 | gdb_test "ptype g_D.D::x" "type = int" |
389 | ||
390 | # Print all members of g_E. | |
391 | # g_E.A::a and g_E.A::x are ambiguous. | |
392 | ||
b1af9e97 TT |
393 | gdb_test "ptype g_E.A::a" "base class 'A' is ambiguous in type 'E'" |
394 | gdb_test "ptype g_E.A::x" "base class 'A' is ambiguous in type 'E'" | |
9733fc94 | 395 | gdb_test "ptype g_E.B::b" "type = int" |
9733fc94 | 396 | gdb_test "ptype g_E.B::x" "type = int" |
9733fc94 | 397 | gdb_test "ptype g_E.C::c" "type = int" |
9733fc94 | 398 | gdb_test "ptype g_E.C::x" "type = int" |
9733fc94 | 399 | gdb_test "ptype g_E.D::d" "type = int" |
9733fc94 | 400 | gdb_test "ptype g_E.D::x" "type = int" |
9733fc94 | 401 | gdb_test "ptype g_E.E::e" "type = int" |
9733fc94 DJ |
402 | gdb_test "ptype g_E.E::x" "type = int" |
403 | } | |
404 | ||
ebac27b4 | 405 | # Multiple inheritance, print complete classes. |
c906108c | 406 | |
ebac27b4 MC |
407 | proc test_print_mi_classes { } { |
408 | global vhn | |
c906108c | 409 | |
ebac27b4 MC |
410 | # Print all members of g_D. |
411 | 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 | 412 | |
ebac27b4 MC |
413 | # Print all members of g_E. |
414 | 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 |
415 | } |
416 | ||
ebac27b4 MC |
417 | # Single inheritance, print anonymous unions. |
418 | # GDB versions prior to 4.14 entered an infinite loop when printing | |
419 | # the type of a class containing an anonymous union, and they were also | |
420 | # incapable of printing the member of an anonymous union. | |
421 | # We test the printing of the member first, and perform the other tests | |
422 | # only if the test succeeds, to avoid the infinite loop. | |
c906108c | 423 | # |
ebac27b4 MC |
424 | # GDB HEAD 2004-01-27 with hp aCC A.03.45 crashes on the first test. |
425 | # -- chastain 2004-01-27 | |
c906108c | 426 | |
ebac27b4 | 427 | proc test_print_anon_union {} { |
c906108c | 428 | global gdb_prompt |
a0b3c4fd | 429 | global ws |
c906108c | 430 | global nl |
ebac27b4 | 431 | global vhn |
c906108c | 432 | |
ebac27b4 | 433 | gdb_test "print g_anon_union.a" "$vhn = 2" "print anonymous union member" |
c906108c | 434 | |
ebac27b4 MC |
435 | set name "print variable of type anonymous union" |
436 | gdb_test_multiple "print g_anon_union" $name { | |
907af001 | 437 | -re "$vhn = \{one = 1, \{a = 2, b = \[0-9\]+\}\}$nl$gdb_prompt $" { |
ebac27b4 | 438 | pass $name |
c906108c | 439 | } |
c906108c SS |
440 | } |
441 | ||
907af001 UW |
442 | set name "print type of anonymous union" |
443 | set re_tag "class_with_anon_union" | |
5984a431 | 444 | set re_class "(class $re_tag \{${ws}public:|struct $re_tag \{)" |
907af001 UW |
445 | set re_fields "int one;${ws}union \{${ws}int a;${ws}long( int)? b;${ws}\};" |
446 | gdb_test_multiple "ptype g_anon_union" $name { | |
447 | -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { | |
448 | pass $name | |
a0b3c4fd | 449 | } |
907af001 | 450 | } |
ebac27b4 | 451 | } |
c906108c | 452 | |
c906108c | 453 | |
ebac27b4 | 454 | # Single virtual inheritance, print individual members. |
c906108c | 455 | |
ebac27b4 MC |
456 | proc test_print_svi_members { } { |
457 | global vhn | |
c906108c | 458 | |
ebac27b4 MC |
459 | # Print all members of g_vA. |
460 | gdb_test "print g_vA.vA::va" "$vhn = 1" | |
461 | gdb_test "print g_vA.vA::vx" "$vhn = 2" | |
c906108c | 462 | |
ebac27b4 MC |
463 | # Print members of g_vA using compact form. |
464 | gdb_test "print g_vA.va" "$vhn = 1" | |
465 | gdb_test "print g_vA.vx" "$vhn = 2" | |
466 | ||
467 | # Print all members of g_vB. | |
468 | gdb_test "print g_vB.vA::va" "$vhn = 3" | |
469 | gdb_test "print g_vB.vA::vx" "$vhn = 4" | |
470 | gdb_test "print g_vB.vB::vb" "$vhn = 5" | |
471 | gdb_test "print g_vB.vB::vx" "$vhn = 6" | |
472 | ||
473 | # Print members of g_vB using compact form. | |
474 | gdb_test "print g_vB.va" "$vhn = 3" | |
475 | gdb_test "print g_vB.vb" "$vhn = 5" | |
476 | gdb_test "print g_vB.vx" "$vhn = 6" | |
477 | ||
478 | # Print all members of g_vC. | |
479 | gdb_test "print g_vC.vA::va" "$vhn = 7" | |
480 | gdb_test "print g_vC.vA::vx" "$vhn = 8" | |
481 | gdb_test "print g_vC.vC::vc" "$vhn = 9" | |
482 | gdb_test "print g_vC.vC::vx" "$vhn = 10" | |
483 | ||
484 | # Print members of g_vC using compact form. | |
485 | gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va" | |
486 | gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc" | |
487 | gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx" | |
c906108c SS |
488 | } |
489 | ||
c906108c | 490 | # Single virtual inheritance, print complete classes. |
c906108c | 491 | |
ebac27b4 | 492 | proc test_print_svi_classes { } { |
c906108c SS |
493 | global gdb_prompt |
494 | global hex | |
c906108c | 495 | global nl |
ebac27b4 | 496 | global vhn |
c906108c SS |
497 | |
498 | # Print all members of g_vA. | |
ebac27b4 | 499 | gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}" |
c906108c SS |
500 | |
501 | # Print all members of g_vB. | |
ebac27b4 MC |
502 | set re_vbptr_2 "(_vb.2vA|_vb.vA)" |
503 | set re_vbptr_3 "_vptr.vB" | |
504 | ||
505 | set name "print g_vB" | |
506 | gdb_test_multiple "print g_vB" $name { | |
507 | -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { | |
508 | # gcc 2.95.3 -gdwarf-2 | |
509 | # gcc 2.95.3 -gstabs+ | |
510 | pass $name | |
511 | } | |
512 | -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { | |
9366563b MC |
513 | # gcc 3.3.4 -gdwarf-2 |
514 | # gcc 3.4.1 -gdwarf-2 | |
515 | # gcc 3.4.1 -gstabs+ | |
516 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
ebac27b4 MC |
517 | pass "$name (FIXME v3 vtbl ptr)" |
518 | } | |
519 | -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" { | |
9366563b MC |
520 | # gcc 3.3.4 -gstabs+ |
521 | pass $name | |
522 | } | |
523 | -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <typeinfo for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" { | |
524 | # gcc HEAD 2004-07-31 -gstabs+ | |
ebac27b4 | 525 | pass $name |
5178b9d6 | 526 | } |
b32b93c6 AS |
527 | -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = ${hex}( <\[^>]*>)?, vb = 5, vx = 6\}$nl$gdb_prompt $" { |
528 | # gcc HEAD 2015?+ | |
529 | # the vptr is set to the address *after* the vtable, | |
530 | # so the # symbol shown is unpredictable | |
531 | pass "$name (symbols ignored)" | |
532 | } | |
c906108c SS |
533 | } |
534 | ||
535 | # Print all members of g_vC. | |
ebac27b4 MC |
536 | set re_vbptr_2 "(_vb.2vA|_vb.vA)" |
537 | set re_vbptr_3 "_vptr.vC" | |
538 | ||
539 | set name "print g_vC" | |
540 | gdb_test_multiple "print g_vC" $name { | |
541 | -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { | |
542 | # gcc 2.95.3 -gdwarf-2 | |
543 | # gcc 2.95.3 -gstabs+ | |
544 | pass $name | |
545 | } | |
546 | -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { | |
9366563b MC |
547 | # gcc 3.3.4 -gdwarf-2 |
548 | # gcc 3.4.1 -gdwarf-2 | |
549 | # gcc 3.4.1 -gstabs+ | |
550 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
ebac27b4 MC |
551 | pass "$name (FIXME v3 vtbl ptr)" |
552 | } | |
553 | -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" { | |
9366563b MC |
554 | # gcc 3.3.4 -gstabs+ |
555 | pass $name | |
556 | } | |
557 | -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <typeinfo for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" { | |
558 | # gcc HEAD 2004-07-31 -gstabs+ | |
ebac27b4 | 559 | pass $name |
a0b3c4fd | 560 | } |
b32b93c6 AS |
561 | -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = ${hex}( <\[^>]*>)?, vc = 9, vx = 10\}$nl$gdb_prompt $" { |
562 | # gcc HEAD 2015?+ | |
563 | # the vptr is set to the address *after* the vtable, | |
564 | # so the symbol shown is unpredictable | |
565 | pass "$name (symbols ignored)" | |
566 | } | |
a0b3c4fd | 567 | } |
c906108c SS |
568 | } |
569 | ||
c906108c | 570 | # Multiple virtual inheritance, print individual members. |
c906108c | 571 | |
ebac27b4 MC |
572 | proc test_print_mvi_members { } { |
573 | global vhn | |
c906108c SS |
574 | |
575 | # Print all members of g_vD. | |
ebac27b4 MC |
576 | gdb_test "print g_vD.vA::va" "$vhn = 19" |
577 | gdb_test "print g_vD.vA::vx" "$vhn = 20" | |
578 | gdb_test "print g_vD.vB::vb" "$vhn = 21" | |
579 | gdb_test "print g_vD.vB::vx" "$vhn = 22" | |
580 | gdb_test "print g_vD.vC::vc" "$vhn = 23" | |
581 | gdb_test "print g_vD.vC::vx" "$vhn = 24" | |
582 | gdb_test "print g_vD.vD::vd" "$vhn = 25" | |
583 | gdb_test "print g_vD.vD::vx" "$vhn = 26" | |
c906108c SS |
584 | |
585 | # Print all members of g_vE. | |
ebac27b4 MC |
586 | gdb_test "print g_vE.vA::va" "$vhn = 0" |
587 | gdb_test "print g_vE.vA::vx" "$vhn = 0" | |
588 | gdb_test "print g_vE.vB::vb" "$vhn = 0" | |
589 | gdb_test "print g_vE.vB::vx" "$vhn = 0" | |
590 | gdb_test "print g_vE.vC::vc" "$vhn = 0" | |
591 | gdb_test "print g_vE.vC::vx" "$vhn = 0" | |
592 | gdb_test "print g_vE.vD::vd" "$vhn = 0" | |
593 | gdb_test "print g_vE.vD::vx" "$vhn = 0" | |
594 | gdb_test "print g_vE.vE::ve" "$vhn = 27" | |
595 | gdb_test "print g_vE.vE::vx" "$vhn = 28" | |
c906108c SS |
596 | } |
597 | ||
ebac27b4 | 598 | # Multiple virtual inheritance, print complete classes. |
c906108c | 599 | |
ebac27b4 | 600 | proc test_print_mvi_classes { } { |
a0b3c4fd | 601 | global gdb_prompt |
ebac27b4 | 602 | global hex |
a0b3c4fd | 603 | global ws |
c906108c | 604 | global nl |
ebac27b4 | 605 | global vhn |
c906108c | 606 | |
ebac27b4 | 607 | # Virtual base pointers for everybody. |
c906108c | 608 | |
ebac27b4 MC |
609 | set re_vbptr_2_vA "(_vb.2vA|_vb.vA)" |
610 | set re_vbptr_2_vB "(_vb.2vB|_vb.vB)" | |
611 | set re_vbptr_2_vC "(_vb.2vC|_vb.vC)" | |
612 | set re_vbptr_2_vD "(_vb.2vD|_vb.vD)" | |
613 | set re_vbptr_3_vA "_vptr.vA" | |
614 | set re_vbptr_3_vB "_vptr.vB" | |
615 | set re_vbptr_3_vC "_vptr.vC" | |
616 | set re_vbptr_3_vD "_vptr.vD" | |
617 | set re_vbptr_3_vE "_vptr.vE" | |
c906108c SS |
618 | |
619 | # Print all members of g_vD. | |
620 | ||
ebac27b4 MC |
621 | set name "print g_vD" |
622 | gdb_test_multiple "print g_vD" $name { | |
623 | -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 $" { | |
624 | # gcc 2.95.3 -gdwarf-2 | |
625 | # gcc 2.95.3 -gstabs+ | |
626 | pass $name | |
c906108c | 627 | } |
410528f0 | 628 | -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = ${hex}( <vtable for vD.*>)?, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <vtable for vC.*>)?, vc = 23, vx = 24\}, $re_vbptr_3_vD = ${hex}( <vtable for vD.*>)?, vd = 25, vx = 26\}$nl$gdb_prompt $" { |
ebac27b4 MC |
629 | # gcc 3.3.2 -gdwarf-2 |
630 | # gcc HEAD 2004-01-21 -gdwarf-2 | |
631 | # gcc HEAD 2004-01-21 -gstabs+ | |
632 | pass "$name (FIXME v3 vtbl ptr)" | |
5178b9d6 | 633 | } |
ebac27b4 MC |
634 | -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 $" { |
635 | # gcc 3.3.2 -gstabs+ | |
636 | pass "$name" | |
3c6cb4a1 | 637 | } |
b32b93c6 AS |
638 | -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 $" { |
639 | # gcc HEAD 2015?+ | |
640 | # the vptr is set to the address *after* the vtable, | |
641 | # so the symbol shown is unpredictable | |
642 | pass "$name (symbols ignored)" | |
643 | } | |
c906108c SS |
644 | } |
645 | ||
646 | # Print all members of g_vE. | |
647 | ||
ebac27b4 MC |
648 | set name "print g_vE" |
649 | gdb_test_multiple "print g_vE" $name { | |
650 | -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 $" { | |
651 | # gcc 2.95.3 -gdwarf-2 | |
652 | # gcc 2.95.3 -gstabs+ | |
653 | pass $name | |
a0b3c4fd | 654 | } |
410528f0 | 655 | -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = ${hex}( <vtable for vE.*>)?, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <vtable for vE.*>)?, vc = 0, vx = 0\}, $re_vbptr_3_vD = ${hex}( <vtable for vE.*>)?, vd = 0, vx = 0\}, $re_vbptr_3_vE = ${hex}( <vtable for vE.*>)?, ve = 27, vx = 28\}$nl$gdb_prompt $" { |
9366563b MC |
656 | # gcc 3.3.4 -gdwarf-2 |
657 | # gcc 3.3.4 -gstabs+ | |
658 | # gcc 3.4.1 -gdwarf-2 | |
659 | # gcc 3.4.1 -gstabs+ | |
660 | # gcc HEAD 2004-07-31 -gdwarf-2 | |
ebac27b4 | 661 | pass "$name (FIXME v3 vtbl ptr)" |
5178b9d6 | 662 | } |
ec4646ef MC |
663 | -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 $" { |
664 | # gcc 3.2.7-rh -gstabs+ | |
9366563b MC |
665 | pass $name |
666 | } | |
667 | -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 $" { | |
668 | # gcc HEAD 2004-07-31 -gstabs+ | |
669 | pass $name | |
ec4646ef | 670 | } |
b32b93c6 AS |
671 | -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 $" { |
672 | # gcc HEAD 2015?+ | |
673 | # the vptr is set to the address *after* the vtable, | |
674 | # so the symbol shown is unpredictable | |
675 | pass "$name (symbols ignored)" | |
676 | } | |
a0b3c4fd | 677 | } |
c906108c SS |
678 | } |
679 | ||
ebac27b4 | 680 | proc do_tests { } { |
a8d52276 | 681 | gdb_test_no_output "set width 0" |
c906108c | 682 | |
ebac27b4 MC |
683 | if { ![runto_main] } then { |
684 | perror "couldn't run to main" | |
685 | return | |
c906108c SS |
686 | } |
687 | ||
1cf0e11f | 688 | gdb_test_no_output "set language c++" |
c906108c SS |
689 | test_ptype_si |
690 | test_ptype_mi | |
691 | test_ptype_vi | |
692 | test_ptype_mvi | |
693 | ||
ebac27b4 MC |
694 | if { ![runto 'inheritance2'] } then { |
695 | perror "couldn't run to inheritance2" | |
696 | return | |
c906108c SS |
697 | } |
698 | ||
699 | test_print_si_members | |
700 | test_print_si_classes | |
701 | test_print_mi_members | |
9733fc94 | 702 | test_print_mi_member_types |
c906108c SS |
703 | test_print_mi_classes |
704 | test_print_anon_union | |
705 | ||
ebac27b4 MC |
706 | if { ![runto 'inheritance4'] } { |
707 | perror "couldn't run to inheritance4" | |
708 | return | |
c906108c SS |
709 | } |
710 | ||
711 | test_print_svi_members | |
712 | test_print_svi_classes | |
713 | test_print_mvi_members | |
714 | test_print_mvi_classes | |
715 | } | |
716 | ||
717 | do_tests |