]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/rtti.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / rtti.exp
CommitLineData
1d506c26 1# Copyright 2003-2024 Free Software Foundation, Inc.
58da2eb2
DC
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
58da2eb2 6# (at your option) any later version.
e22f8b7c 7#
58da2eb2
DC
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#
58da2eb2 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/>.
58da2eb2
DC
15
16# This file is part of the gdb testsuite.
17
18# This contains tests for GDB's use of RTTI information. This stems
19# from a bug reported in PR gdb/488 and other places, which leads to
20# statements like 'warning: can't find class named 'C::D', as given by
21# C++ RTTI'. It arises from GDB not knowing about classes that are
22# defined in namespaces.
23
24# NOTE: carlton/2003-05-16: I suspect it could arise from nested class
25# issues, too, and even once we fix that, there might be situations
26# (involving templates, in particular) where this problem triggers
27# because GDB and GCC have different ideas what a class is called.
28
0b94d2b9 29require allow_cplus_tests
58da2eb2
DC
30
31#
32# test running programs
33#
58da2eb2 34
f5f3a911 35standard_testfile rtti1.cc rtti2.cc
58da2eb2 36
722c4596
TV
37include_file rtti.h
38
5b362f04 39if {[prepare_for_testing "failed to prepare" $testfile \
f5f3a911
TT
40 [list $srcfile $srcfile2] {debug c++}]} {
41 return -1
42}
58da2eb2 43
95701cae 44if {![runto_main]} {
cdd42066 45 return
58da2eb2
DC
46}
47
48# First, run to after we've constructed the object:
49
f5f3a911 50gdb_breakpoint [gdb_get_line_number "main-constructs-done" "$srcfile"]
b368761e 51gdb_continue_to_breakpoint "end of constructors in main"
58da2eb2
DC
52
53gdb_test_multiple "print *e1" "print *e1" {
374451f0
MC
54 -re "warning: RTTI symbol not found for class 'n1::D1'.*$gdb_prompt $" {
55 # gdb HEAD 2003-12-05
56 kfail "gdb/488" "print *e1"
57 }
58da2eb2 58 -re "warning: can't find class named `n1::D1', as given by C\\+\\+ RTTI.*$gdb_prompt $" {
374451f0 59 # gdb 6.0
58da2eb2
DC
60 kfail "gdb/488" "print *e1"
61 }
62 -re "\\$\[0-9\]* = {<n1::Base1> = .*}\r\n$gdb_prompt $" {
63 pass "print *e1"
64 }
65 -re "\\$\[0-9\]* = {<Base1> = .*}\r\n$gdb_prompt $" {
66 # NOTE: carlton/2003-05-16: If code is compiled by GCC2, we
67 # don't print the warning (for no particular reason), but we
68 # still call the class via the wrong name; PR gdb/57 is our
69 # catch-all PR for nested type problems.
70 kfail "gdb/57" "print *e1"
71 }
72}
73
3e5fc8d2
DC
74# NOTE: carlton/2004-01-14: This test with an "<incomplete type>"
75# message because, within rtt1.cc, GDB has no way of knowing that the
76# class is called 'n2::D2' instead of just 'D2'. This is an artifical
77# test case, though: if we were using these classes in a more
78# substantial way, G++ would emit more debug info. As is, I don't
79# think there's anything that GDB can do about this case until G++
80# starts emitting DW_TAG_namespace info; this should arrive with GCC
81# 3.4.
58da2eb2
DC
82
83gdb_test_multiple "print *e2" "print *e2" {
374451f0
MC
84 -re "warning: RTTI symbol not found for class 'n2::D2'.*$gdb_prompt $" {
85 # gdb HEAD 2003-12-05
86 kfail "gdb/488" "print *e2"
87 }
58da2eb2 88 -re "warning: can't find class named `n2::D2', as given by C\\+\\+ RTTI.*$gdb_prompt $" {
374451f0 89 # gdb 6.0
58da2eb2
DC
90 kfail "gdb/488" "print *e2"
91 }
92 -re "\\$\[0-9\]* = <incomplete type>\r\n$gdb_prompt $" {
3e5fc8d2 93 kfail "gdb/1511" "print *e2"
58da2eb2
DC
94 }
95 -re "\\$\[0-9\]* = {<n2::Base2> = .*}\r\n$gdb_prompt $" {
96 pass "print *e2"
97 }
98 -re "\\$\[0-9\]* = {<Base2> = .*}\r\n$gdb_prompt $" {
99 kfail "gdb/57" "print *e2"
100 }
101}
102
b368761e
DC
103# Now we test the hack that's been implemented to get around some
104# instances of PR gdb/1511.
105
f5f3a911 106gdb_breakpoint [gdb_get_line_number "func-constructs-done" "$srcfile"]
b368761e
DC
107gdb_continue_to_breakpoint "end of constructors in func"
108
109gdb_test "print *obj" "\\$\[0-9\]* = {<n2::Base2> = .*}"
110
f5f3a911 111gdb_breakpoint [gdb_get_line_number "func3-constructs-done" "$srcfile"]
1198ecbe
DC
112gdb_continue_to_breakpoint "end of constructors in func3"
113
114gdb_test "print *obj3" "\\$\[0-9\]* = {<n2::C2> = .*}"
115
58da2eb2 116gdb_exit