OLD | NEW |
1 # Copyright 2003-2004, 2007-2012 Free Software Foundation, Inc. | 1 # Copyright 2003-2004, 2007-2012 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 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 | 4 # it under the terms of the GNU General Public License as published by |
5 # the Free Software Foundation; either version 3 of the License, or | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 # This file is part of the gdb testsuite. | 16 # This file is part of the gdb testsuite. |
17 | 17 |
18 # This contains tests for GDB's use of RTTI information. This stems | 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 | 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 | 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 | 21 # C++ RTTI'. It arises from GDB not knowing about classes that are |
22 # defined in namespaces. | 22 # defined in namespaces. |
23 | 23 |
24 # NOTE: carlton/2003-05-16: I suspect it could arise from nested class | 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 | 25 # issues, too, and even once we fix that, there might be situations |
26 # (involving templates, in particular) where this problem triggers | 26 # (involving templates, in particular) where this problem triggers |
27 # because GDB and GCC have different ideas what a class is called. | 27 # because GDB and GCC have different ideas what a class is called. |
28 | 28 |
29 if $tracelevel then { | |
30 strace $tracelevel | |
31 } | |
32 | |
33 if { [skip_cplus_tests] } { continue } | 29 if { [skip_cplus_tests] } { continue } |
34 | 30 |
35 # | 31 # |
36 # test running programs | 32 # test running programs |
37 # | 33 # |
38 | 34 |
39 set testfile "rtti" | 35 standard_testfile rtti1.cc rtti2.cc |
40 set srcfile1 "${testfile}1.cc" | |
41 set objfile1 "${testfile}1.o" | |
42 set srcfile2 "${testfile}2.cc" | |
43 set objfile2 "${testfile}2.o" | |
44 set binfile "${objdir}/${subdir}/${testfile}" | |
45 | 36 |
46 if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" objec
t {debug c++}] != "" } { | 37 if [get_compiler_info "c++"] { |
47 untested rtti.exp | |
48 return -1 | |
49 } | |
50 | |
51 if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" objec
t {debug c++}] != "" } { | |
52 untested rtti.exp | |
53 return -1 | |
54 } | |
55 | |
56 if { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binf
ile}" executable {debug c++}] != "" } { | |
57 untested rtti.exp | |
58 return -1 | |
59 } | |
60 | |
61 if [get_compiler_info ${binfile} "c++"] { | |
62 return -1 | 38 return -1 |
63 } | 39 } |
64 | 40 |
65 gdb_exit | 41 if {[prepare_for_testing $testfile.exp $testfile \ |
66 gdb_start | 42 » [list $srcfile $srcfile2] {debug c++}]} { |
67 gdb_reinitialize_dir $srcdir/$subdir | 43 return -1 |
68 gdb_load ${binfile} | 44 } |
69 | |
70 | 45 |
71 if ![runto_main] then { | 46 if ![runto_main] then { |
72 perror "couldn't run to breakpoint" | 47 perror "couldn't run to breakpoint" |
73 continue | 48 continue |
74 } | 49 } |
75 | 50 |
76 # First, run to after we've constructed the object: | 51 # First, run to after we've constructed the object: |
77 | 52 |
78 gdb_breakpoint [gdb_get_line_number "main-constructs-done" "$srcfile1"] | 53 gdb_breakpoint [gdb_get_line_number "main-constructs-done" "$srcfile"] |
79 gdb_continue_to_breakpoint "end of constructors in main" | 54 gdb_continue_to_breakpoint "end of constructors in main" |
80 | 55 |
81 gdb_test_multiple "print *e1" "print *e1" { | 56 gdb_test_multiple "print *e1" "print *e1" { |
82 -re "warning: RTTI symbol not found for class 'n1::D1'.*$gdb_prompt $" { | 57 -re "warning: RTTI symbol not found for class 'n1::D1'.*$gdb_prompt $" { |
83 # gdb HEAD 2003-12-05 | 58 # gdb HEAD 2003-12-05 |
84 kfail "gdb/488" "print *e1" | 59 kfail "gdb/488" "print *e1" |
85 } | 60 } |
86 -re "warning: can't find class named `n1::D1', as given by C\\+\\+ RTTI.*$gd
b_prompt $" { | 61 -re "warning: can't find class named `n1::D1', as given by C\\+\\+ RTTI.*$gd
b_prompt $" { |
87 # gdb 6.0 | 62 # gdb 6.0 |
88 kfail "gdb/488" "print *e1" | 63 kfail "gdb/488" "print *e1" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 pass "print *e2" | 99 pass "print *e2" |
125 } | 100 } |
126 -re "\\$\[0-9\]* = {<Base2> = .*}\r\n$gdb_prompt $" { | 101 -re "\\$\[0-9\]* = {<Base2> = .*}\r\n$gdb_prompt $" { |
127 kfail "gdb/57" "print *e2" | 102 kfail "gdb/57" "print *e2" |
128 } | 103 } |
129 } | 104 } |
130 | 105 |
131 # Now we test the hack that's been implemented to get around some | 106 # Now we test the hack that's been implemented to get around some |
132 # instances of PR gdb/1511. | 107 # instances of PR gdb/1511. |
133 | 108 |
134 gdb_breakpoint [gdb_get_line_number "func-constructs-done" "$srcfile1"] | 109 gdb_breakpoint [gdb_get_line_number "func-constructs-done" "$srcfile"] |
135 gdb_continue_to_breakpoint "end of constructors in func" | 110 gdb_continue_to_breakpoint "end of constructors in func" |
136 | 111 |
137 gdb_test "print *obj" "\\$\[0-9\]* = {<n2::Base2> = .*}" | 112 gdb_test "print *obj" "\\$\[0-9\]* = {<n2::Base2> = .*}" |
138 | 113 |
139 gdb_breakpoint [gdb_get_line_number "func3-constructs-done" "$srcfile1"] | 114 gdb_breakpoint [gdb_get_line_number "func3-constructs-done" "$srcfile"] |
140 gdb_continue_to_breakpoint "end of constructors in func3" | 115 gdb_continue_to_breakpoint "end of constructors in func3" |
141 | 116 |
142 gdb_test "print *obj3" "\\$\[0-9\]* = {<n2::C2> = .*}" | 117 gdb_test "print *obj3" "\\$\[0-9\]* = {<n2::C2> = .*}" |
143 | 118 |
144 gdb_exit | 119 gdb_exit |
145 return 0 | 120 return 0 |
OLD | NEW |