OLD | NEW |
1 # Copyright 1997-1998, 2000-2004, 2007-2012 Free Software Foundation, | 1 # Copyright 1997-1998, 2000-2004, 2007-2012 Free Software Foundation, |
2 # Inc. | 2 # Inc. |
3 | 3 |
4 # This program is free software; you can redistribute it and/or modify | 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 | 5 # it under the terms of the GNU General Public License as published by |
6 # the Free Software Foundation; either version 3 of the License, or | 6 # the Free Software Foundation; either version 3 of the License, or |
7 # (at your option) any later version. | 7 # (at your option) any later version. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 |
17 # tests for namespaces | 17 # tests for namespaces |
18 # Originally written by Satish Pai <pai@apollo.hp.com> 1997-07-23 | 18 # Originally written by Satish Pai <pai@apollo.hp.com> 1997-07-23 |
19 | 19 |
20 # This file is part of the gdb testsuite | 20 # This file is part of the gdb testsuite |
21 | 21 |
22 # Note: The original tests were geared to the HP aCC compiler, | 22 # Note: The original tests were geared to the HP aCC compiler, |
23 # which has an idiosyncratic way of emitting debug info | 23 # which has an idiosyncratic way of emitting debug info |
24 # for namespaces. | 24 # for namespaces. |
25 # Note: As of 2000-06-03, they passed under g++ - djb | 25 # Note: As of 2000-06-03, they passed under g++ - djb |
26 | 26 |
27 | 27 |
28 if $tracelevel then { | |
29 strace $tracelevel | |
30 } | |
31 | |
32 | 28 |
33 if { [skip_cplus_tests] } { continue } | 29 if { [skip_cplus_tests] } { continue } |
34 | 30 |
35 set testfile "namespace" | 31 standard_testfile .cc namespace1.cc |
36 set srcfile ${testfile}.cc | |
37 set objfile ${objdir}/${subdir}/${testfile}.o | |
38 set srcfile1 ${testfile}1.cc | |
39 set objfile1 ${objdir}/${subdir}/${testfile}1.o | |
40 set binfile ${objdir}/${subdir}/${testfile} | |
41 | 32 |
42 if [get_compiler_info ${binfile} c++] { | 33 if [get_compiler_info c++] { |
43 return -1; | 34 return -1; |
44 } | 35 } |
45 | 36 |
46 set xfail_class_types 0 | 37 set xfail_class_types 0 |
47 if {[test_compiler_info {gcc-[0-3]-*}] | 38 if {[test_compiler_info {gcc-[0-3]-*}] |
48 || [test_compiler_info {gcc-4-[0-4]-*}]} { | 39 || [test_compiler_info {gcc-4-[0-4]-*}]} { |
49 # The type in class is missing in older GCCs. | 40 # The type in class is missing in older GCCs. |
50 set xfail_class_types 1 | 41 set xfail_class_types 1 |
51 } | 42 } |
52 | 43 |
53 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug c
++}] != "" } { | 44 if {[prepare_for_testing $testfile.exp $testfile \ |
54 untested namespace.exp | 45 » [list $srcfile $srcfile2] {debug c++}]} { |
55 return -1 | 46 return -1 |
56 } | 47 } |
57 | 48 |
58 if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${objfile1}" object {debug
c++}] != "" } { | 49 gdb_test "show lang" "auto; currently c\\+\\+.*" |
59 untested namespace.exp | |
60 return -1 | |
61 } | |
62 | |
63 if { [gdb_compile "${objfile} ${objfile1}" "${binfile}" executable {debug c++}]
!= "" } { | |
64 untested namespace.exp | |
65 return -1 | |
66 } | |
67 | |
68 gdb_exit | |
69 gdb_start | |
70 gdb_reinitialize_dir $srcdir/$subdir | |
71 gdb_load ${binfile} | |
72 | |
73 | 50 |
74 # | 51 # |
75 # set it up at a breakpoint so we can play with the variable values | 52 # set it up at a breakpoint so we can play with the variable values |
76 # | 53 # |
77 if ![runto_main] then { | 54 if ![runto_main] then { |
78 perror "couldn't run to breakpoint" | 55 perror "couldn't run to breakpoint" |
79 continue | 56 continue |
80 } | 57 } |
81 | 58 |
82 if ![runto 'marker1'] then { | 59 if ![runto 'marker1'] then { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 112 |
136 gdb_test "print AAA::xyzq('x')" \ | 113 gdb_test "print AAA::xyzq('x')" \ |
137 "\\$\[0-9\]* = 97 'a'" \ | 114 "\\$\[0-9\]* = 97 'a'" \ |
138 "print AAA::xyzq('x')" | 115 "print AAA::xyzq('x')" |
139 | 116 |
140 # Break on a function in a namespace | 117 # Break on a function in a namespace |
141 | 118 |
142 gdb_test "break AAA::xyzq" \ | 119 gdb_test "break AAA::xyzq" \ |
143 "Breakpoint.*at $hex: file.*namespace.cc, line 47\\." | 120 "Breakpoint.*at $hex: file.*namespace.cc, line 47\\." |
144 | 121 |
| 122 # Break on a function in the global namespace. |
| 123 |
| 124 gdb_test "break ::ensureOtherRefs" \ |
| 125 "Breakpoint.*at $hex: file.*$srcfile2, line $decimal\\." |
| 126 |
145 # Call a function in a nested namespace | 127 # Call a function in a nested namespace |
146 | 128 |
147 gdb_test "print 'BBB::CCC::xyzq'('x')" \ | 129 gdb_test "print 'BBB::CCC::xyzq'('x')" \ |
148 "\\$\[0-9\]* = 122 'z'" \ | 130 "\\$\[0-9\]* = 122 'z'" \ |
149 "print 'BBB::CCC::xyzq'('x')" | 131 "print 'BBB::CCC::xyzq'('x')" |
150 | 132 |
151 gdb_test "print BBB::CCC::xyzq('x')" \ | 133 gdb_test "print BBB::CCC::xyzq('x')" \ |
152 "\\$\[0-9\]* = 122 'z'" \ | 134 "\\$\[0-9\]* = 122 'z'" \ |
153 "print BBB::CCC::xyzq('x')" | 135 "print BBB::CCC::xyzq('x')" |
154 | 136 |
155 # Break on a function in a nested namespace | 137 # Break on a function in a nested namespace |
156 | 138 |
157 gdb_test "break BBB::CCC::xyzq" \ | 139 gdb_test "break BBB::CCC::xyzq" \ |
158 "Breakpoint.*at $hex: file.*namespace.cc, line 63\\." | 140 "Breakpoint.*at $hex: file.*namespace.cc, line 63\\." |
159 | 141 |
| 142 # Break on the same function, starting with the global namespace. |
| 143 |
| 144 gdb_test "break ::BBB::CCC::xyzq" \ |
| 145 ".*Breakpoint.*at $hex: file.*$srcfile, line 63\\." |
| 146 |
160 # Print address of a function in a class in a namespace | 147 # Print address of a function in a class in a namespace |
161 | 148 |
162 gdb_test "print 'BBB::Class::xyzq'" \ | 149 gdb_test "print 'BBB::Class::xyzq'" \ |
163 "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <B
BB::Class::xyzq\\(char\\)>" \ | 150 "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <B
BB::Class::xyzq\\(char\\)>" \ |
164 "print 'BBB::Class::xyzq'" | 151 "print 'BBB::Class::xyzq'" |
165 | 152 |
166 gdb_test "print BBB::Class::xyzq" \ | 153 gdb_test "print BBB::Class::xyzq" \ |
167 "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <B
BB::Class::xyzq\\(char\\)>" \ | 154 "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <B
BB::Class::xyzq\\(char\\)>" \ |
168 "print BBB::Class::xyzq" | 155 "print BBB::Class::xyzq" |
169 | 156 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 gdb_test "print G::XgX" "\\$\[0-9\].* = 11" | 259 gdb_test "print G::XgX" "\\$\[0-9\].* = 11" |
273 gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context." | 260 gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context." |
274 gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context." | 261 gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context." |
275 | 262 |
276 # Enum tests. | 263 # Enum tests. |
277 gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA" | 264 gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA" |
278 | 265 |
279 # Regression tests for PR 9496. | 266 # Regression tests for PR 9496. |
280 gdb_test "whatis ::C::CClass::NestedClass" "type = C::CClass::NestedClass" | 267 gdb_test "whatis ::C::CClass::NestedClass" "type = C::CClass::NestedClass" |
281 gdb_test "whatis ::C::CClass::NestedClass *" "type = C::CClass::NestedClass \\*" | 268 gdb_test "whatis ::C::CClass::NestedClass *" "type = C::CClass::NestedClass \\*" |
OLD | NEW |