* valprint.c (val_print_string): Don't print leading space.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / classes.exp
CommitLineData
0b302171 1# Copyright 1992, 1994-2004, 2006-2012 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)
1cd3489f 17# And rewritten by Michael Chastain <mec.gnu@mindspring.com>.
c906108c 18
c906108c
SS
19set nl "\[\r\n\]+"
20
d4f3574e 21if { [skip_cplus_tests] } { continue }
c906108c 22
2d3a7986
MC
23load_lib "cp-support.exp"
24
ed69573c 25set testfile "classes"
c906108c
SS
26set srcfile ${testfile}.cc
27set binfile ${objdir}/${subdir}/${testfile}
28
c906108c 29if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
b60f0898
JB
30 untested classes.exp
31 return -1
c906108c
SS
32}
33
c906108c 34# Test ptype of class objects.
c906108c
SS
35
36proc test_ptype_class_objects {} {
c906108c 37
1cd3489f 38 # Simple type.
c906108c 39
2d3a7986
MC
40 cp_test_ptype_class \
41 "ptype struct default_public_struct" "" "struct" "default_public_struct" \
42 {
43 { field public "int a;" }
44 { field public "int b;" }
c906108c 45 }
c906108c 46
2d3a7986 47 # Another simple type.
c906108c 48
2d3a7986
MC
49 cp_test_ptype_class \
50 "ptype struct explicit_public_struct" "" "struct" "explicit_public_struct" \
51 {
52 { field public "int a;" }
53 { field public "int b;" }
c906108c 54 }
c906108c 55
2d3a7986 56 # Another simple type.
2fc1f950 57
2d3a7986
MC
58 cp_test_ptype_class \
59 "ptype struct protected_struct" "" "struct" "protected_struct" \
60 {
61 { field protected "int a;" }
62 { field protected "int b;" }
c906108c 63 }
c906108c 64
2d3a7986 65 # Another simple type.
2fc1f950 66
2d3a7986
MC
67 cp_test_ptype_class \
68 "ptype struct private_struct" "" "struct" "private_struct" \
69 {
70 { field private "int a;" }
71 { field private "int b;" }
c906108c 72 }
c906108c 73
2d3a7986 74 # A bigger type.
2fc1f950 75
2d3a7986
MC
76 cp_test_ptype_class \
77 "ptype struct mixed_protection_struct" "" "struct" "mixed_protection_struct" \
78 {
79 { field public "int a;" }
80 { field public "int b;" }
81 { field private "int c;" }
82 { field private "int d;" }
83 { field protected "int e;" }
84 { field protected "int f;" }
85 { field public "int g;" }
86 { field private "int h;" }
87 { field protected "int i;" }
c906108c 88 }
c906108c 89
1cd3489f
MC
90 # All that again with "class" instead of "struct".
91 # gdb does not care about the difference anyways.
c906108c 92
2d3a7986
MC
93 cp_test_ptype_class \
94 "ptype class public_class" "" "class" "public_class" \
95 {
96 { field public "int a;" }
97 { field public "int b;" }
c906108c 98 }
1cd3489f 99
2d3a7986 100 # Another simple type.
2fc1f950 101
2d3a7986
MC
102 cp_test_ptype_class \
103 "ptype class protected_class" "" "class" "protected_class" \
104 {
105 { field protected "int a;" }
106 { field protected "int b;" }
c906108c 107 }
c906108c 108
2d3a7986 109 # Another simple type.
2fc1f950 110
2d3a7986
MC
111 cp_test_ptype_class \
112 "ptype class default_private_class" "" "class" "default_private_class" \
113 {
114 { field private "int a;" }
115 { field private "int b;" }
c906108c 116 }
1cd3489f 117
2d3a7986 118 # Another simple type.
2fc1f950 119
2d3a7986
MC
120 cp_test_ptype_class \
121 "ptype class explicit_private_class" "" "class" "explicit_private_class" \
122 {
123 { field private "int a;" }
124 { field private "int b;" }
c906108c 125 }
c906108c 126
2d3a7986 127 # A bigger type.
1cd3489f 128
2d3a7986
MC
129 cp_test_ptype_class \
130 "ptype class mixed_protection_class" "" "class" "mixed_protection_class" \
131 {
2fc1f950 132
2d3a7986
MC
133 { field public "int a;" }
134 { field public "int b;" }
135 { field private "int c;" }
136 { field private "int d;" }
137 { field protected "int e;" }
138 { field protected "int f;" }
139 { field public "int g;" }
140 { field private "int h;" }
141 { field protected "int i;" }
c906108c 142 }
c906108c 143
1cd3489f
MC
144 # Here are some classes with inheritance.
145
146 # Base class.
147
2d3a7986
MC
148 cp_test_ptype_class \
149 "ptype class A" "" "class" "A" \
150 {
151 { field public "int a;" }
152 { field public "int x;" }
c906108c 153 }
c906108c 154
1cd3489f
MC
155 # Derived class.
156
2d3a7986
MC
157 cp_test_ptype_class \
158 "ptype class B" "" "class" "B" \
159 {
160 { base "public A" }
161 { field public "int b;" }
162 { field public "int x;" }
c906108c 163 }
c906108c 164
1cd3489f
MC
165 # Derived class.
166
2d3a7986
MC
167 cp_test_ptype_class \
168 "ptype class C" "" "class" "C" \
169 {
170 { base "public A" }
171 { field public "int c;" }
172 { field public "int x;" }
c906108c 173 }
c906108c 174
1cd3489f
MC
175 # Derived class, multiple inheritance.
176
2d3a7986
MC
177 cp_test_ptype_class \
178 "ptype class D" "" "class" "D" \
179 {
180 { base "public B" }
181 { base "public C" }
182 { field public "int d;" }
183 { field public "int x;" }
c906108c 184 }
c906108c 185
1cd3489f
MC
186 # Derived class.
187
2d3a7986
MC
188 cp_test_ptype_class \
189 "ptype class E" "" "class" "E" \
190 {
191 { base "public D" }
192 { field public "int e;" }
193 { field public "int x;" }
c906108c 194 }
c906108c 195
1cd3489f
MC
196 # This is a break from inheritance tests.
197 #
198 # gcc 2.X with stabs (stabs or stabs+?) used to have a problem with
199 # static methods whose name is the same as their argument mangling.
200
2d3a7986
MC
201 cp_test_ptype_class \
202 "ptype class Static" "" "class" "Static" \
203 {
204 { method public "static void ii(int, int);" }
3e36a0f4 205 }
af890c52 206
1cd3489f
MC
207 # Here are some virtual inheritance tests.
208
2d3a7986 209 # A virtual base class.
2fc1f950 210
2d3a7986
MC
211 cp_test_ptype_class \
212 "ptype class vA" "" "class" "vA" \
213 {
214 { field public "int va;" }
215 { field public "int vx;" }
c906108c 216 }
c906108c 217
2d3a7986 218 # A derived class with a virtual base.
2fc1f950 219
2d3a7986
MC
220 cp_test_ptype_class \
221 "ptype class vB" "" "class" "vB" \
222 {
223 { base "public virtual vA" }
224 { vbase "vA" }
225 { field public "int vb;" }
226 { field public "int vx;" }
2fc1f950 227 }
c906108c 228
2d3a7986 229 # Another derived class with a virtual base.
c906108c 230
2d3a7986
MC
231 cp_test_ptype_class \
232 "ptype class vC" "" "class" "vC" \
233 {
234 { base "public virtual vA" }
235 { vbase "vA" }
236 { field public "int vc;" }
237 { field public "int vx;" }
c906108c 238 }
c906108c 239
2d3a7986 240 # A classic diamond class.
2fc1f950 241
2d3a7986
MC
242 cp_test_ptype_class \
243 "ptype class vD" "" "class" "vD" \
244 {
245 { base "public virtual vB" }
246 { base "public virtual vC" }
247 { vbase "vC" }
248 { vbase "vB" }
249 { field public "int vd;" }
250 { field public "int vx;" }
c906108c 251 }
c906108c 252
2d3a7986 253 # A class derived from a diamond class.
c906108c 254
2d3a7986
MC
255 cp_test_ptype_class \
256 "ptype class vE" "" "class" "vE" \
257 {
258 { base "public virtual vD" }
259 { vbase "vD" }
260 { field public "int ve;" }
261 { field public "int vx;" }
5178b9d6 262 }
c906108c 263
1cd3489f
MC
264 # Another inheritance series.
265
2d3a7986
MC
266 # A base class.
267
268 cp_test_ptype_class \
269 "ptype class Base1" "" "class" "Base1" \
270 {
271 { field public "int x;" }
272 { method public "Base1(int);" }
273 }
274
275 # Another base class.
276
277 cp_test_ptype_class \
278 "ptype class Foo" "" "class" "Foo" \
279 {
280 { field public "int x;" }
281 { field public "int y;" }
282 { field public "static int st;" }
283 { method public "Foo(int, int);" }
284 { method public "int operator!();" }
285 { method public "operator int();" }
286 { method public "int times(int);" }
287 } \
288 "" \
289 {
290 {
291 "operator int();"
292 "int operator int();"
293 { setup_kfail "gdb/1497" "*-*-*" }
294 }
295 {
296 "operator int();"
297 "int operator int(void);"
298 { setup_kfail "gdb/1497" "*-*-*" }
299 }
3e36a0f4 300 }
c906108c 301
1cd3489f
MC
302 # A multiple inheritance derived class.
303
2d3a7986
MC
304 cp_test_ptype_class \
305 "ptype class Bar" "" "class" "Bar" \
306 {
307 { base "public Base1" }
308 { base "public Foo" }
309 { field public "int z;" }
310 { method public "Bar(int, int, int);" }
c906108c 311 }
2d3a7986 312
c906108c
SS
313}
314
c906108c 315# Test simple access to class members.
c906108c
SS
316
317proc test_non_inherited_member_access {} {
c906108c
SS
318
319 # Print non-inherited members of g_A.
226a8d71
MC
320 gdb_test "print g_A.a" ".* = 1"
321 gdb_test "print g_A.x" ".* = 2"
c906108c
SS
322
323 # Print non-inherited members of g_B.
226a8d71
MC
324 gdb_test "print g_B.b" ".* = 5"
325 gdb_test "print g_B.x" ".* = 6"
c906108c
SS
326
327 # Print non-inherited members of g_C.
226a8d71
MC
328 gdb_test "print g_C.c" ".* = 9"
329 gdb_test "print g_C.x" ".* = 10"
c906108c
SS
330
331 # Print non-inherited members of g_D.
226a8d71
MC
332 gdb_test "print g_D.d" ".* = 19"
333 gdb_test "print g_D.x" ".* = 20"
c906108c
SS
334
335 # Print non-inherited members of g_E.
226a8d71
MC
336 gdb_test "print g_E.e" ".* = 31"
337 gdb_test "print g_E.x" ".* = 32"
c906108c
SS
338}
339
1cd3489f
MC
340# Test access to members of other classes.
341# gdb should refuse to print them.
342# (I feel old -- I remember when this was legal in C -- chastain).
c906108c
SS
343
344proc test_wrong_class_members {} {
226a8d71
MC
345 gdb_test "print g_A.b" "There is no member( or method|) named b."
346 gdb_test "print g_B.c" "There is no member( or method|) named c."
347 gdb_test "print g_B.d" "There is no member( or method|) named d."
348 gdb_test "print g_C.b" "There is no member( or method|) named b."
349 gdb_test "print g_C.d" "There is no member( or method|) named d."
350 gdb_test "print g_D.e" "There is no member( or method|) named e."
c906108c
SS
351}
352
1cd3489f 353# Test access to names that are not members of any class.
c906108c 354
2bec0572 355proc test_nonexistent_members {} {
226a8d71
MC
356 gdb_test "print g_A.y" "There is no member( or method|) named y."
357 gdb_test "print g_B.z" "There is no member( or method|) named z."
358 gdb_test "print g_C.q" "There is no member( or method|) named q."
359 gdb_test "print g_D.p" "There is no member( or method|) named p."
c906108c
SS
360}
361
54602222
ND
362# Call a method that expects a base class parameter with base, inherited,
363# and unrelated class arguments.
54602222
ND
364
365proc test_method_param_class {} {
226a8d71
MC
366 gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1"
367 gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2"
368 gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3"
369 gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4"
370 gdb_test "call class_param.Aref_a (g_A)" ".* = 1"
371 gdb_test "call class_param.Aref_x (g_A)" ".* = 2"
372 gdb_test "call class_param.Aref_a (g_B)" ".* = 3"
373 gdb_test "call class_param.Aref_x (g_B)" ".* = 4"
374 gdb_test "call class_param.Aval_a (g_A)" ".* = 1"
375 gdb_test "call class_param.Aval_x (g_A)" ".* = 2"
376 gdb_test "call class_param.Aval_a (g_B)" ".* = 3"
377 gdb_test "call class_param.Aval_x (g_B)" ".* = 4"
54602222
ND
378
379 gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param"
380 gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class &param"
381 gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param"
382}
383
2bec0572 384# Examine a class with an enum field.
2bec0572
ND
385
386proc test_enums {} {
387 global gdb_prompt
1cd3489f 388 global nl
2bec0572
ND
389
390 # print the object
2bec0572 391
0114d602
DJ
392 # We match the enum values with and without qualifiers. As of
393 # 2008-08-21 we can output the qualifiers for DWARF-2.
394
1cd3489f 395 gdb_test "print obj_with_enum" \
0114d602 396 "\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?red, x = 0\}" \
1cd3489f
MC
397 "print obj_with_enum (1)"
398
399 # advance one line
400
f6978de9 401 gdb_test "next" ".*"
1cd3489f 402
2bec0572 403 # print the object again
2bec0572 404
1cd3489f 405 gdb_test "print obj_with_enum" \
0114d602 406 "\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?green, x = 0\}" \
1cd3489f
MC
407 "print obj_with_enum (2)"
408
409 # print the enum member
410
0114d602 411 gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green"
2bec0572
ND
412
413 # ptype on the enum member
1cd3489f
MC
414
415 gdb_test_multiple "ptype obj_with_enum.priv_enum" "ptype obj_with_enum.priv_enum" {
0114d602 416 -re "type = enum ClassWithEnum::PrivEnum \{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?green, (ClassWithEnum::)?blue, (ClassWithEnum::)?yellow = 42 ?\}$nl$gdb_prompt $" {
1cd3489f
MC
417 pass "ptype obj_with_enum.priv_enum"
418 }
0114d602 419 -re "type = enum PrivEnum \{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?green, (ClassWithEnum::)?blue, (ClassWithEnum::)?yellow = 42 ?\}$nl$gdb_prompt $" {
1cd3489f
MC
420 # gcc 2.95.3 -gdwarf-2
421 # gcc 3.3.2 -gdwarf-2
422 pass "ptype obj_with_enum.priv_enum"
423 }
424 -re "type = enum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" {
425 # This case case is a little dubious, but it's not clear what
426 # ought to be required of a ptype on a private enum...
427 # -sts 19990324
428 #
429 # It bugs me that this happens with gcc 3.
430 # -- chastain 2003-12-30
431 #
432 # gcc 2.95.3 -gstabs+
433 # gcc 3.3.2 -gstabs+
434 # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
435 pass "ptype obj_with_enum.priv_enum"
436 }
2bec0572
ND
437 }
438
439 # ptype on the object
2fc1f950 440
2d3a7986
MC
441 # NOTE: carlton/2003-02-28: One could certainly argue that plain
442 # "PrivEnum"
443 # is acceptable: PrivEnum is a member of ClassWithEnum, so
444 # there's no need to explicitly qualify its name with
445 # "ClassWithEnum::". The truth, though, is that GDB is simply
446 # forgetting that PrivEnum is a member of ClassWithEnum, so we do
447 # that output for a bad reason instead of a good reason. Under
448 # stabs, we probably can't get this right; under DWARF-2, we can.
449
450 cp_test_ptype_class \
451 "ptype obj_with_enum" "" "class" "ClassWithEnum" \
452 {
453 { field public "ClassWithEnum::PrivEnum priv_enum;" }
454 { field public "int x;" }
455 } \
456 "" \
457 {
458 {
459 "ClassWithEnum::PrivEnum priv_enum;"
460 "PrivEnum priv_enum;"
461 { setup_kfail "gdb/57" "*-*-*" }
462 }
1cd3489f 463 }
2bec0572 464
1cd3489f 465 # I'll do this test two different ways, because of a parser bug.
23c73aa3 466 # See PR gdb/1588.
6ece72da 467
1cd3489f 468 gdb_test_multiple "print (ClassWithEnum::PrivEnum) 42" "print (ClassWithEnum::PrivEnum) 42" {
0114d602 469 -re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
1cd3489f 470 pass "print (ClassWithEnum::PrivEnum) 42"
d8a2d9e7 471 }
1cd3489f
MC
472 -re "A (parse|syntax) error in expression, near `42'.$nl$gdb_prompt $" {
473 # "parse error" is bison 1.35.
474 # "syntax error" is bison 1.875.
23c73aa3 475 kfail "gdb/1588" "print (ClassWithEnum::PrivEnum) 42"
d8a2d9e7 476 }
2bec0572 477 }
6ece72da 478
1cd3489f 479 gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" {
0114d602 480 -re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
1cd3489f
MC
481 # gcc 3.3.2 -gstabs+
482 # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
483 pass "print ('ClassWithEnum::PrivEnum') 42"
484 }
485 -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.$nl$gdb_prompt $" {
486 # gcc 2.95.3 -gdwarf-2
487 # gcc 3.3.2 -gdwarf-2
488 # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
489 # gcc 2.95.3 -gstabs+
490 kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42"
491 }
6ece72da 492 }
2bec0572
ND
493}
494
c906108c 495# Pointers to class members
c906108c
SS
496
497proc test_pointers_to_class_members {} {
0d5de010
DJ
498 gdb_test "print Bar::z" "Cannot reference non-static field \"z\""
499 gdb_test "print &Foo::x" "\\$\[0-9\]+ = &Foo::x"
1cd3489f
MC
500 gdb_test "print (int)&Foo::x" "\\$\[0-9\]+ = 0"
501 gdb_test "print (int)&Bar::y == 2*sizeof(int)" "\\$\[0-9\]+ = true"
184ad485 502
0d5de010
DJ
503 gdb_test "ptype Bar::z" "type = int"
504 gdb_test "ptype &Bar::z" "type = int Bar::\\*"
505
184ad485
MC
506 # TODO: this is a bogus test. It's looking at a variable that
507 # has not even been declared yet, so it's accessing random junk
508 # on the stack and comparing that it's NOT equal to a specific
509 # value. It's been like this since gdb 4.10 in 1993!
510 # -- chastain 2004-01-01
511 gdb_test "print (int)pmi == sizeof(int)" ".* = false"
c906108c
SS
512}
513
c906108c 514# Test static members.
c906108c
SS
515
516proc test_static_members {} {
c906108c 517 global hex
c906108c 518
1cd3489f 519 gdb_test "print Foo::st" "\\$\[0-9\]+ = 100"
35ec993f 520 gdb_test_no_output "set foo.st = 200" ""
1cd3489f
MC
521 gdb_test "print bar.st" "\\$\[0-9\]+ = 200"
522 gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
523 gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
524 gdb_test "print *\$" "\\$\[0-9\]+ = 200"
c906108c 525
a8d52276 526 gdb_test_no_output "set print static-members off"
c906108c
SS
527 gdb_test "print csi" \
528 "{x = 10, y = 20}" \
529 "print csi without static members"
530 gdb_test "print cnsi" \
531 "{x = 30, y = 40}" \
532 "print cnsi without static members"
533
a8d52276 534 gdb_test_no_output "set print static-members on"
c906108c
SS
535 gdb_test "print csi" \
536 "{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \
537 "print csi with static members"
c906108c
SS
538 gdb_test "print cnsi" \
539 "{x = 30, y = 40, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>, static yy = {z = 5, static xx = {x = 1, y = 2, static null = <same as static member of an already seen type>, static yy = <same as static member of an already seen type>}}}, static yy = <same as static member of an already seen type>}" \
540 "print cnsi with static members"
541}
542
543proc do_tests {} {
c906108c
SS
544 global subdir
545 global objdir
546 global srcdir
547 global binfile
548 global gdb_prompt
1cd3489f 549 global nl
c906108c 550
c906108c
SS
551
552 # Start with a fresh gdb.
553
554 gdb_exit
555 gdb_start
556 gdb_reinitialize_dir $srcdir/$subdir
557 gdb_load $binfile
558
35ec993f
MS
559 gdb_test_no_output "set language c++" ""
560 gdb_test_no_output "set width 0" ""
c906108c 561
1cd3489f
MC
562 if ![runto_main ] then {
563 perror "couldn't run to breakpoint"
564 return
2bec0572
ND
565 }
566
1cd3489f
MC
567 gdb_breakpoint inheritance2
568 gdb_test "continue" ".*Breakpoint .* inheritance2.*" ""
c906108c 569
1cd3489f
MC
570 test_ptype_class_objects
571 test_non_inherited_member_access
572 test_wrong_class_members
573 test_nonexistent_members
574 test_method_param_class
c906108c 575
1cd3489f 576 gdb_breakpoint enums2
184ad485 577 gdb_test "continue" ".*Breakpoint .* enums2.*" "continue to enums2(\\(\\)|)"
471ba8c9
DJ
578 # Leave enums2. Make sure we reach the next line, in case there
579 # are any more instructions to finish the function call.
580 gdb_test_multiple "finish" "" {
581 -re "enums2 \\(\\);.*$gdb_prompt $" {
de7ff789 582 gdb_test "next" ".*" ""
471ba8c9
DJ
583 }
584 -re "$gdb_prompt $" { }
585 }
1cd3489f
MC
586 test_enums
587
de7ff789 588 gdb_test "finish" ".*" ""
184ad485
MC
589 test_pointers_to_class_members
590 test_static_members
591
1cd3489f
MC
592 # Now some random tests that were just thrown in here.
593
594 gdb_breakpoint marker_reg1
595 gdb_test "continue" ".*Breakpoint .* marker_reg1.*" ""
596 gdb_test "finish" "Run till exit from.*" "finish from marker_reg1"
597
598 # This class is so small that an instance of it can fit in a register.
599 # When gdb tries to call a method, it gets embarrassed about taking
600 # the address of a register.
601 #
602 # TODO: I think that message should be a PASS, not an XFAIL.
603 # gdb prints an informative message and declines to do something
604 # impossible.
605 #
606 # The method call actually succeeds if the compiler allocates very
607 # small classes in memory instead of registers. So this test does
608 # not tell us anything interesting if the call succeeds.
609 #
610 # -- chastain 2003-12-31
611 gdb_test_multiple "print v.method ()" "calling method for small class" {
612 -re "\\$\[0-9\]+ = 82$nl$gdb_prompt $" {
613 # gcc 3.3.2 -gdwarf-2
614 # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
615 # gcc 3.3.2 -gstabs+
616 # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
617 pass "calling method for small class"
618 }
619 -re "Address requested for identifier \"v\" which is in register .*$nl$gdb_prompt $" {
620 # gcc 2.95.3 -gdwarf-2
621 # gcc 2.95.3 -gstabs+
622 setup_xfail "*-*-*" 2972
623 fail "calling method for small class"
c906108c
SS
624 }
625 }
3fe8f3b3
KS
626
627 gdb_test "print base1::Base1" "<.*Base1.*>" "print ctor of typedef class"
628 gdb_test "print base1::~Base1" "<.*~Base1(\\(\\))?>" \
629 "print dtor of typedef class"
40f0318e
KS
630
631 gdb_test "list ByAnyOtherName::times" ".*int Foo::times.*"
c906108c
SS
632}
633
634do_tests
This page took 1.264805 seconds and 4 git commands to generate.