]>
Commit | Line | Data |
---|---|---|
4a94e368 | 1 | # Copyright 1992-2022 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 SS |
16 | # This file was written by Fred Fish. (fnf@cygnus.com) |
17 | ||
18 | set ws "\[\r\n\t \]+" | |
19 | ||
d4f3574e SS |
20 | if { [skip_cplus_tests] } { continue } |
21 | ||
f5f3a911 | 22 | standard_testfile .cc |
c906108c | 23 | |
8f5d31b8 TV |
24 | set flags [list debug c++] |
25 | if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } { | |
26 | # Work around PR gcc/101452. | |
27 | lappend flags additional_flags=-DGCC_BUG | |
28 | } | |
29 | ||
30 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} { | |
f5f3a911 | 31 | return -1 |
c906108c SS |
32 | } |
33 | ||
c906108c SS |
34 | # |
35 | # Test printing of the types of templates. | |
36 | # | |
37 | ||
38 | proc test_ptype_of_templates {} { | |
39 | global gdb_prompt | |
40 | global ws | |
41 | ||
bd69fc68 | 42 | gdb_test_multiple "ptype/r T5<int>" "ptype T5<int>" { |
1bc05c3a | 43 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
3b7962f9 | 44 | xfail "ptype T5<int> -- new without size_t" |
c906108c | 45 | } |
3b0cb202 | 46 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}\}\r\n$gdb_prompt $" { |
3b7962f9 | 47 | xfail "ptype T5<int> -- new without size_t" |
3b0cb202 | 48 | } |
5f4d1085 | 49 | -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(()\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}${ws}$gdb_prompt $" { |
3b7962f9 | 50 | xfail "ptype T5<int> -- new with unsigned int" |
f8d3bf8f | 51 | } |
5f4d1085 | 52 | -re "type = class T5<int> \\{.*public:.*static int X;.*int x;.*int val;.*T5 \\(int\\);.*T5 \\(const class T5<int> &\\);.*void ~T5 \\(\\);.*static void \\* new \\(unsigned long\\);.*static void delete \\(void ?\\*\\);.*int value \\((void|)\\);.*\\}\r\n$gdb_prompt $" { |
3b7962f9 | 53 | xfail "ptype T5<int> -- new with unsigned long" |
f8d3bf8f | 54 | } |
1bc05c3a | 55 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\((T5<int> const|const T5<int>) ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" { |
3b7962f9 | 56 | xfail "ptype T5<int> (obsolescent gcc or gdb)" |
c906108c | 57 | } |
5f4d1085 | 58 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
5330f2db DC |
59 | # This also triggers gdb/1113... |
60 | kfail "gdb/1111" "ptype T5<int>" | |
3b7962f9 | 61 | # Add here a PASS case when PR gdb/1111 gets fixed. |
7d27a96d TT |
62 | # These are really: |
63 | # http://sourceware.org/bugzilla/show_bug.cgi?id=8216 | |
64 | # http://sourceware.org/bugzilla/show_bug.cgi?id=8218 | |
65 | } | |
66 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { | |
67 | # http://sourceware.org/bugzilla/show_bug.cgi?id=8218 | |
68 | # The destructor has an argument type. | |
69 | kfail "gdb/8218" "ptype T5<int>" | |
5330f2db | 70 | } |
137c886e | 71 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(void\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
5f4d1085 KS |
72 | pass "ptype T5<int>" |
73 | } | |
c906108c SS |
74 | } |
75 | ||
bd69fc68 | 76 | gdb_test_multiple "ptype/r t5i" "ptype t5i" { |
f8d3bf8f | 77 | -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5\\(int\\);${ws}T5\\(T5<int> const ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { |
3b7962f9 | 78 | xfail "ptype T5<int> -- with several fixes from 4.17 -- without size_t" |
f8d3bf8f | 79 | } |
5f4d1085 | 80 | -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { |
3b7962f9 | 81 | xfail "ptype t5i<int> -- new with unsigned int -- without size_t" |
f8d3bf8f | 82 | } |
5f4d1085 | 83 | -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(\\);${ws}static void \\* new \\(unsigned long\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { |
3b7962f9 | 84 | xfail "ptype t5i<int> -- new with unsigned long -- without size_t" |
f8d3bf8f | 85 | } |
5f4d1085 | 86 | -re "type = class T5<int> \{.*public:.*static int X;.*int x;.*int val;.*.*T5 \\(int\\);.*.*void ~T5 \\(\\).*.*.*int value \\((void|)\\);.*\}.*$gdb_prompt $" { |
3b7962f9 | 87 | xfail "ptype t5i -- without size_t" |
a0b3c4fd | 88 | } |
1bc05c3a | 89 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
3b7962f9 | 90 | xfail "ptype t5i -- without size_t" |
c906108c | 91 | } |
3b0cb202 | 92 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}\}\r\n$gdb_prompt $" { |
3b7962f9 | 93 | xfail "ptype t5i -- without size_t" |
3b0cb202 | 94 | } |
3b2a7ae5 | 95 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\(T5<int> const ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" { |
3b7962f9 | 96 | xfail "ptype t5i (obsolescent gcc or gdb) -- without size_t" |
c906108c | 97 | } |
5f4d1085 | 98 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
5330f2db | 99 | # This also triggers gdb/1113... |
5f4d1085 | 100 | kfail "gdb/1111" "ptype t5i" |
3b7962f9 | 101 | # Add here a PASS case when PR gdb/1111 gets fixed. |
7d27a96d TT |
102 | # These are really: |
103 | # http://sourceware.org/bugzilla/show_bug.cgi?id=8216 | |
104 | # http://sourceware.org/bugzilla/show_bug.cgi?id=8218 | |
105 | } | |
106 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { | |
107 | # http://sourceware.org/bugzilla/show_bug.cgi?id=8218 | |
108 | # The destructor has an argument type. | |
5f4d1085 KS |
109 | kfail "gdb/8218" "ptype t5i" |
110 | } | |
137c886e | 111 | -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(void\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { |
5f4d1085 | 112 | pass "ptype t5i" |
5330f2db | 113 | } |
c906108c SS |
114 | } |
115 | } | |
116 | ||
117 | # | |
118 | # Test breakpoint setting on template methods. | |
119 | # | |
120 | ||
121 | proc test_template_breakpoints {} { | |
122 | global gdb_prompt | |
123 | global testfile | |
124 | global srcdir | |
125 | ||
b598bfda | 126 | gdb_test_multiple "break T5<int>::T5" "constructor breakpoint" { |
f8eba3c6 | 127 | -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2.*templates.cc:T5<int>::T5\\((T5<int> const|const T5<int>) ?&\\)\[\r\n\]*.3.*templates.cc:T5<int>::T5\\(int\\)\[\r\n\]*> $" { |
c906108c | 128 | gdb_test "0" \ |
a9e2e984 | 129 | "canceled" \ |
c906108c SS |
130 | "constructor breakpoint" |
131 | } | |
5330f2db DC |
132 | -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5 at .*\[\r\n\]*.3. T5 at .*\[\r\n\]*> $" { |
133 | setup_kfail "gdb/1062" "*-*-*" | |
134 | gdb_test "0" \ | |
135 | "nonsense intended to insure that this test fails" \ | |
136 | "constructor breakpoint" | |
137 | } | |
760f6330 MS |
138 | -re ".*\n> $" { |
139 | gdb_test "0" \ | |
140 | "nonsense intended to insure that this test fails" \ | |
141 | "constructor breakpoint (bad menu choices)" | |
142 | } | |
c906108c SS |
143 | } |
144 | ||
5330f2db DC |
145 | gdb_test_multiple "break T5<int>::~T5" "destructor_breakpoint" { |
146 | -re "Breakpoint.*at.* file .*${testfile}.cc, line.*$gdb_prompt $" | |
147 | { | |
148 | pass "destructor breakpoint" | |
149 | } | |
150 | -re "the class `T5<int>' does not have destructor defined\r\nHint: try 'T5<int>::~T5<TAB> or 'T5<int>::~T5<ESC-\\?>\r\n\\(Note leading single quote.\\)\r\n$gdb_prompt $" | |
151 | { | |
152 | kfail "gdb/1112" "destructor breakpoint" | |
153 | } | |
154 | } | |
c906108c SS |
155 | |
156 | gdb_test "break T5<int>::value" \ | |
157 | "Breakpoint.*at.* file .*${testfile}.cc, line.*" \ | |
158 | "value method breakpoint" | |
159 | ||
945a118d JG |
160 | set bp_location [gdb_get_line_number \ |
161 | "set breakpoint on a line with no real code"] | |
f8eba3c6 TT |
162 | |
163 | gdb_test_multiple "break ${testfile}.cc:${bp_location}" \ | |
164 | "breakpoint on a line with no real code" { | |
165 | -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2.*templates.cc:GetMax<int>\\(int, int\\)\[\r\n\]*.3.*templates.cc:GetMax<long>\\(long, long\\)\[\r\n\]*> $" { | |
166 | gdb_test "0" \ | |
167 | "canceled" \ | |
168 | "breakpoint on a line with no real code" | |
169 | } | |
170 | -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2.*\[\r\n\]*.3.*\[\r\n\]*> $" { | |
171 | gdb_test "0" \ | |
172 | "nonsense intended to insure that this test fails" \ | |
173 | "breakpoint on a line with no real code" | |
174 | } | |
175 | -re ".*\n> $" { | |
176 | gdb_test "0" \ | |
177 | "nonsense intended to insure that this test fails" \ | |
178 | "breakpoint on a line with no real code" | |
179 | } | |
180 | } | |
181 | ||
c906108c SS |
182 | delete_breakpoints |
183 | } | |
184 | ||
185 | # | |
186 | # Test calling of template methods. | |
187 | # | |
188 | ||
189 | proc test_template_calls {} { | |
190 | global gdb_prompt | |
191 | ||
192 | if [target_info exists gdb,cannot_call_functions] { | |
bc6c7af4 | 193 | unsupported "this target can not call functions" |
c906108c SS |
194 | return |
195 | } | |
196 | ||
b6304613 | 197 | setup_xfail hppa*-*-* |
f8d3bf8f MS |
198 | gdb_test_multiple "print t5i.value()" "print t5i.value()" { |
199 | -re ".* = 2\[\r\n\]*$gdb_prompt $" { | |
200 | pass "print t5i.value()" | |
201 | } | |
c906108c SS |
202 | -re "Cannot invoke functions on this machine.*$gdb_prompt $" { |
203 | fail "print t5i.value()" | |
204 | } | |
a0b3c4fd JM |
205 | -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { |
206 | setup_xfail hppa*-*-* CLLbs16899 | |
207 | xfail "print t5i.value" | |
208 | } | |
c906108c SS |
209 | } |
210 | } | |
211 | ||
3fe8f3b3 | 212 | proc test_template_typedef {} { |
ae1a303e | 213 | global gdb_prompt |
3fe8f3b3 KS |
214 | |
215 | gdb_test "print intBazOne::baz" ".*baz\\(int, int\\)>" \ | |
216 | "print method of template typedef" | |
217 | ||
ae1a303e JK |
218 | set test "print destructor of template typedef" |
219 | gdb_test_multiple "print intBazOne::~Baz" $test { | |
220 | -re "~Baz(\\(\\))?>\r\n$gdb_prompt $" { | |
221 | pass $test | |
222 | } | |
223 | -re "There is no field named ~Baz\r\n$gdb_prompt $" { | |
224 | set test2 "verify GCC PR debug/51668" | |
225 | gdb_test_multiple "whatis intBazOne" $test2 { | |
226 | -re "type = Baz<int, \\(char\\)'\\\\001'>\r\n$gdb_prompt $" { | |
227 | setup_xfail gcc/51668 "*-*-*" | |
228 | xfail $test | |
229 | pass $test2 | |
230 | } | |
231 | -re "\r\n$gdb_prompt $" { | |
232 | # Some unexpected response. | |
233 | fail $test | |
234 | fail $test2 | |
235 | } | |
236 | } | |
237 | } | |
238 | } | |
3fe8f3b3 | 239 | } |
c906108c | 240 | |
c767944b DJ |
241 | proc test_template_args {} { |
242 | ||
243 | set empty_re "Empty *<void *\\(FunctionArg *<int>\\)>" | |
bd69fc68 TT |
244 | gdb_test "ptype/r empty" \ |
245 | "type = (struct|class) $empty_re {.*<no data fields>.*}" \ | |
246 | "ptype empty" | |
c767944b | 247 | |
bd69fc68 TT |
248 | gdb_test "ptype/r arg" \ |
249 | "type = (struct|class) FunctionArg<int> {.*int method\\($empty_re \\&\\);.*}" \ | |
250 | "ptype arg" | |
c767944b DJ |
251 | } |
252 | ||
c906108c | 253 | proc do_tests {} { |
eae06beb JB |
254 | # Change multiple-symbols to "ask" in order to get the multiple-choice |
255 | # menu when breaking on overloaded methods. | |
a8d52276 | 256 | gdb_test_no_output "set multiple-symbols ask" |
eae06beb | 257 | |
40f235b7 | 258 | runto_main |
c906108c SS |
259 | |
260 | test_ptype_of_templates | |
261 | test_template_breakpoints | |
3fe8f3b3 | 262 | test_template_typedef |
c767944b | 263 | test_template_args |
c906108c SS |
264 | |
265 | if [ runto_main] { | |
266 | test_template_calls | |
267 | } | |
268 | } | |
269 | ||
270 | do_tests | |
271 | ||
a0b3c4fd JM |
272 | |
273 | # More tests for different kinds of template parameters, | |
274 | # templates with partial specializations, nested templates, etc. | |
707ed39a AB |
275 | |
276 | gdb_breakpoint [gdb_get_line_number "Final breakpoint"] | |
277 | gdb_continue_to_breakpoint "Final breakpoint" | |
f8d3bf8f MS |
278 | |
279 | gdb_test "print fint" \ | |
280 | "\\$\[0-9\]* = \\{x = 0, t = 0\\}" | |
281 | ||
775e0f04 YQ |
282 | # Prevent symbol on address 0x0 being printed. |
283 | gdb_test_no_output "set print symbol off" | |
f8d3bf8f MS |
284 | gdb_test "print fvpchar" \ |
285 | "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}" | |
a0b3c4fd JM |
286 | |
287 | # Template Foo<T> | |
288 | ||
dd14ab43 DC |
289 | # Neither stabs nor DWARF-2 contains type information about templates |
290 | # (as opposed to instantiations of templates), so in those | |
291 | # circumstances we expect GDB to not find a symbol. HP has a debug | |
292 | # format that contains more info, though, so it's also correct to | |
293 | # print out template info. (This affects several subsequent tests as | |
294 | # well.) | |
295 | ||
296 | # NOTE: carlton/2003-02-26: However, because of a bug in the way GDB | |
297 | # handles nested types, we don't get this right in the DWARF-2 case. | |
298 | ||
bd69fc68 | 299 | gdb_test_multiple "ptype/r Foo" "ptype Foo" { |
f8d3bf8f MS |
300 | -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Foo<volatile char \\*>\r\n\[ \t\]*(class |)Foo<char>\r\n\[ \t\]*(class |)Foo<int>\r\n$gdb_prompt $" { |
301 | pass "ptype Foo" | |
302 | } | |
303 | -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { | |
304 | xfail "ptype Foo" | |
305 | } | |
306 | -re "type = class Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { | |
307 | # GCC 3.1, DWARF-2 output. | |
308 | kfail "gdb/57" "ptype Foo" | |
309 | } | |
310 | -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" { | |
311 | # GCC 2.95.3, stabs+ output. | |
312 | pass "ptype Foo" | |
313 | } | |
a0b3c4fd | 314 | } |
f8d3bf8f | 315 | |
dd14ab43 | 316 | # -re "type = class Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo(int, int);\r\n\\}\r\n$gdb_prompt $" |
a0b3c4fd JM |
317 | |
318 | # ptype Foo<int> | |
319 | ||
bd69fc68 | 320 | gdb_test_multiple "ptype/r fint" "ptype fint" { |
f8d3bf8f MS |
321 | -re "type = (class |)Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { |
322 | pass "ptype fint" | |
323 | } | |
324 | -re "type = (class |)Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
325 | pass "ptype fint" | |
326 | } | |
a0b3c4fd JM |
327 | } |
328 | ||
329 | # ptype Foo<char> | |
330 | ||
bd69fc68 | 331 | gdb_test_multiple "ptype/r fchar" "ptype fchar" { |
f8d3bf8f MS |
332 | -re "type = (class |)Foo<char> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char foo\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { |
333 | pass "ptype fchar" | |
334 | } | |
335 | -re "type = (class |)Foo<char> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char foo\\(int, char\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
336 | pass "ptype fchar" | |
337 | } | |
a0b3c4fd JM |
338 | } |
339 | ||
340 | # ptype Foo<volatile char *> | |
341 | ||
bd69fc68 | 342 | gdb_test_multiple "ptype/r fvpchar" "ptype fvpchar" { |
f8d3bf8f MS |
343 | -re "type = (class |)Foo<volatile char ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" { |
344 | pass "ptype fvpchar" | |
345 | } | |
346 | -re "type = (class |)Foo<volatile char ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
347 | pass "ptype fvpchar" | |
348 | } | |
349 | -re "type = (class |)Foo<char volatile ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" { | |
350 | kfail "gdb/1512" "ptype fvpchar" | |
351 | } | |
a0b3c4fd JM |
352 | } |
353 | ||
354 | # print a function from Foo<volatile char *> | |
355 | ||
0b71dc91 DC |
356 | # This test is sensitive to whitespace matching, so we'll do it twice, |
357 | # varying the spacing, because of PR gdb/33. | |
358 | ||
f8d3bf8f MS |
359 | gdb_test_multiple "print Foo<volatile char *>::foo" "print Foo<volatile char *>::foo" { |
360 | -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { | |
361 | pass "print Foo<volatile char *>::foo" | |
362 | } | |
363 | -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $" { | |
71c25dea TT |
364 | # This used to be a kfail gdb/33 and then kfail gdb/931. |
365 | fail "print Foo<volatile char *>::foo" | |
85ca1584 | 366 | } |
0b71dc91 DC |
367 | } |
368 | ||
f8d3bf8f MS |
369 | gdb_test_multiple "print Foo<volatile char*>::foo" "print Foo<volatile char*>::foo" { |
370 | -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { | |
371 | pass "print Foo<volatile char*>::foo" | |
372 | } | |
373 | -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $" { | |
71c25dea TT |
374 | # This used to be a kfail gdb/33 and then kfail gdb/931. |
375 | fail "print Foo<volatile char*>::foo" | |
85ca1584 | 376 | } |
a0b3c4fd JM |
377 | } |
378 | ||
379 | # Template Bar<T, int> | |
380 | ||
e6d71bf3 | 381 | # same as Foo for g++ |
bd69fc68 | 382 | gdb_test_multiple "ptype/r Bar" "ptype Bar" { |
f8d3bf8f MS |
383 | -re "type = template <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)1>\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)33>\r\n$gdb_prompt $" { |
384 | pass "ptype Bar" | |
385 | } | |
386 | -re "type = <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { | |
387 | xfail "ptype Bar" | |
388 | } | |
389 | -re "ptype Bar\r\ntype = class Bar<int, ?33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $" { | |
390 | # GCC 3.1, DWARF-2 output. | |
391 | kfail "gdb/57" "ptype Bar" | |
392 | } | |
393 | -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $" { | |
394 | # GCC 2.95.3, stabs+ output. | |
395 | pass "ptype Bar" | |
396 | } | |
a0b3c4fd JM |
397 | } |
398 | ||
399 | ||
400 | # ptype Bar<int,33> | |
5a2a0a20 | 401 | |
bd69fc68 | 402 | gdb_test_multiple "ptype/r bint" "ptype bint" { |
f8d3bf8f MS |
403 | -re "type = (class |)Bar<int, ?(\\(int\\)|)33> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { |
404 | pass "ptype bint" | |
405 | } | |
406 | -re "type = (class |)Bar<int,(\\(int\\)|)33> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
407 | pass "ptype bint" | |
408 | } | |
a0b3c4fd JM |
409 | } |
410 | ||
411 | # ptype Bar<int, (4>3)> | |
412 | ||
bd69fc68 | 413 | gdb_test_multiple "ptype/r bint2" "ptype bint2" { |
f8d3bf8f MS |
414 | -re "type = (class |)Bar<int, ?(\\(int\\)|)1> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { |
415 | pass "ptype bint2" | |
416 | } | |
417 | -re "type = (class |)Bar<int,(\\(int\\)|)1> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
418 | pass "ptype bint2" | |
419 | } | |
a0b3c4fd JM |
420 | } |
421 | ||
422 | # Template Baz<T, char> | |
423 | ||
e6d71bf3 | 424 | # Same as Foo, for g++ |
bd69fc68 | 425 | gdb_test_multiple "ptype/r Baz" "ptype Baz" { |
f8d3bf8f MS |
426 | -re "type = template <(class |)T, ?(class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Baz<char,(\\(char\\)|)97>\r\n\[ \t\]*(class |)Baz<int,(\\(char\\)|)115>\r\n$gdb_prompt $" { |
427 | pass "ptype Baz" | |
428 | } | |
429 | -re "type = <(class |)T, ?(class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { | |
430 | xfail "ptype Baz" | |
431 | } | |
432 | -re "type = class Baz<int, ?'s'> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $" { | |
433 | # GCC 3.1, DWARF-2 output. | |
434 | kfail "gdb/57" "ptype Baz" | |
435 | } | |
436 | -re "type = class Baz<int, ?(\\(char\\))?115> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $" { | |
437 | # GCC 3.x, DWARF-2 output, running into gdb/57 and gdb/1512. | |
438 | kfail "gdb/57" "ptype Baz" | |
439 | } | |
440 | -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $" { | |
441 | # GCC 2.95.3, stabs+ output. | |
442 | pass "ptype Baz" | |
443 | } | |
a0b3c4fd JM |
444 | } |
445 | ||
446 | ||
447 | # ptype Baz<int, 's'> | |
448 | ||
bd69fc68 | 449 | gdb_test_multiple "ptype/r bazint" "ptype bazint" { |
f8d3bf8f MS |
450 | -re "type = (class |)Baz<int, ?(\\(char\\)|)(115|\\'s\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int baz\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { |
451 | pass "ptype bazint" | |
452 | } | |
453 | -re "type = (class |)Baz<int,(\\(char\\)|)(115|\\'s\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\).*;\r\n\\}\r\n$gdb_prompt $" { | |
454 | pass "ptype bazint" | |
455 | } | |
a0b3c4fd JM |
456 | } |
457 | ||
458 | # ptype Baz<char, 'a'> | |
459 | ||
bd69fc68 | 460 | gdb_test_multiple "ptype/r bazint2" "ptype bazint2" { |
f8d3bf8f MS |
461 | -re "type = (class |)Baz<char, ?(\\(char\\)|)(97|\\'a\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char baz\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { |
462 | pass "ptype bazint2" | |
463 | } | |
464 | -re "type = (class |)Baz<char,(\\(char\\)|)(97|\\'a\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char baz\\(int, char\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
465 | pass "ptype bazint2" | |
466 | } | |
a0b3c4fd JM |
467 | } |
468 | ||
469 | # Template Qux<T, int (*f)(int) > | |
e6d71bf3 | 470 | # Same as Foo for g++ |
bd69fc68 | 471 | gdb_test_multiple "ptype/r Qux" "ptype Qux" { |
f8d3bf8f MS |
472 | -re "type = template <(class |)T, ?(class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Qux<int,&string>\r\n\[ \t\]*(class |)Qux<char,&string>\r\n$gdb_prompt $" { |
473 | pass "ptype Qux" | |
474 | } | |
475 | -re ".*type = template <(class |)T.*, ?(class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}.*$gdb_prompt $" { | |
476 | pass "ptype Qux" | |
477 | } | |
478 | -re "type = class Qux<char, ?&string> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $" { | |
479 | # GCC 3.1, DWARF-2 output. | |
480 | kfail "gdb/57" "ptype Qux" | |
481 | } | |
482 | -re "type = class Qux<char, ?&\\(string\\)> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $" { | |
483 | # GCC 3.x, DWARF-2 output; gdb/57 + gdb/1512. | |
484 | kfail "gdb/57" "ptype Qux" | |
485 | } | |
486 | -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $" { | |
487 | # GCC 2.95.3, stabs+ output. | |
488 | pass "ptype Qux" | |
489 | } | |
a0b3c4fd JM |
490 | } |
491 | ||
492 | # pt Qux<int,&string> | |
493 | ||
bd69fc68 | 494 | gdb_test_multiple "ptype/r quxint" "ptype quxint" { |
f8d3bf8f MS |
495 | -re "type = class Qux<int, ?& ?string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int qux\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { |
496 | pass "ptype quxint" | |
497 | } | |
748aa9b6 AKS |
498 | -re "type = class Qux<int, string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int qux\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { |
499 | pass "ptype quxint" | |
500 | } | |
f8d3bf8f MS |
501 | -re "type = class Qux<int, ?& ?string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { |
502 | pass "ptype quxint" | |
503 | } | |
504 | -re "type = class Qux<int, ?\\(char ?\\*\\)\\(& ?\\(?string\\)?\\)> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
505 | pass "ptype quxint" | |
506 | } | |
507 | -re "type = class Qux<int, ?& ?\\(string\\)> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
508 | kfail "gdb/1512" "ptype quxint" | |
509 | } | |
a0b3c4fd JM |
510 | } |
511 | ||
a0b3c4fd JM |
512 | |
513 | # Template Spec<T1, T2> | |
514 | ||
e6d71bf3 | 515 | # Same as Foo for g++ |
bd69fc68 | 516 | gdb_test_multiple "ptype/r Spec" "ptype Spec" { |
f8d3bf8f MS |
517 | -re "type = template <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Spec<int,int \\*>\r\n\[ \t\]*(class |)Spec<int,char>\r\n$gdb_prompt $" { |
518 | pass "ptype Spec" | |
519 | } | |
520 | -re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { | |
521 | xfail "ptype Spec" | |
522 | } | |
523 | -re "type = class Spec<int, ?char> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(char\\);\r\n}\r\n$gdb_prompt $" { | |
524 | # GCC 3.1, DWARF-2 output. | |
525 | kfail "gdb/57" "ptype Spec" | |
526 | } | |
527 | -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $" { | |
528 | # GCC 2.95.3, stabs+ output. | |
529 | pass "ptype Spec" | |
530 | } | |
a0b3c4fd JM |
531 | } |
532 | ||
533 | # pt Spec<char,0> | |
534 | ||
bd69fc68 | 535 | gdb_test_multiple "ptype/r siip" "ptype siip" { |
f8d3bf8f MS |
536 | -re "type = class Spec<int, ?int ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*.*int spec\\(int ?\\*\\);\r\n\\}\r\n$gdb_prompt $" { |
537 | pass "ptype siip" | |
538 | } | |
539 | -re "type = class Spec<int,int ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(int ?\\*\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
540 | pass "ptype siip" | |
541 | } | |
a0b3c4fd JM |
542 | } |
543 | ||
999a4952 CS |
544 | # Check cv qualifiers and substitute parameters. |
545 | ||
546 | if {[test_compiler_info {clang-*}]} { | |
547 | setup_kfail "llvm/52262 " "*-*-*" | |
548 | } | |
549 | gdb_test "ptype cfoo" [multi_line \ | |
550 | "type = (class |)Cfoo<double> \\\[with DataT = double\\\] \\{" \ | |
551 | "\[ \t\]*public:" \ | |
552 | "\[ \t\]*DataT me0;" \ | |
553 | "\[ \t\]*const DataT me1;" \ | |
554 | "\[ \t\]*const myfloat me2;" \ | |
555 | "\[ \t\]*const int me3;" \ | |
556 | "" \ | |
557 | "\[ \t\]*private:" \ | |
558 | "\[ \t\]*typedef float myfloat;" \ | |
559 | "\\}" \ | |
560 | ] "print type of cfoo" | |
561 | ||
562 | # Check cv qualifiers and do not substitute. | |
563 | ||
564 | if {[test_compiler_info {clang-*}]} { | |
565 | setup_kfail "llvm/52262 " "*-*-*" | |
566 | } | |
567 | gdb_test "ptype/r cfoo" [multi_line \ | |
568 | "type = (class |)Cfoo<double> \\{" \ | |
569 | "\[ \t\]*public:" \ | |
570 | "\[ \t\]*double me0;" \ | |
571 | "\[ \t\]*const double me1;" \ | |
572 | "\[ \t\]*const Cfoo<double>::myfloat me2;" \ | |
573 | "\[ \t\]*const int me3;" \ | |
574 | "" \ | |
575 | "\[ \t\]*private:" \ | |
576 | "\[ \t\]*typedef float myfloat;" \ | |
577 | "\\}" \ | |
578 | ] "print raw type of cfoo" | |
579 | ||
a0b3c4fd JM |
580 | # pt Garply<int> |
581 | ||
bd69fc68 | 582 | gdb_test_multiple "ptype/r Garply<int>" "ptype Garply<int>" { |
f8d3bf8f MS |
583 | -re "type = class Garply<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int garply\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { |
584 | pass "ptype Garply<int>" | |
585 | } | |
586 | -re "type = class Garply<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int garply\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
587 | pass "ptype Garply<int>" | |
588 | } | |
a0b3c4fd JM |
589 | } |
590 | ||
591 | # ptype of nested template name | |
592 | ||
bd69fc68 | 593 | gdb_test_multiple "ptype/r Garply<Garply<char> >" "ptype Garply<Garply<char> >" { |
f8d3bf8f MS |
594 | -re "type = (class |)Garply<Garply<char> > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply<char> t;\r\n\r\n\[ \t\]*.*(class |)Garply<char> garply\\(int, (class |)Garply<char>\\);\r\n\\}\r\n$gdb_prompt $" { |
595 | pass "ptype Garply<Garply<char> >" | |
596 | } | |
597 | -re "type = (class |)Garply<Garply<char> > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply<char> t;\r\n\r\n\[ \t\]*(class |)Garply<char> garply\\(int, (class |)Garply<char>\\);.*\r\n\\}\r\n$gdb_prompt $" { | |
598 | pass "ptype Garply<Garply<char> >" | |
599 | } | |
a0b3c4fd JM |
600 | } |
601 | ||
602 | # print out a function from a nested template name | |
603 | ||
f8d3bf8f | 604 | gdb_test "print Garply<Garply<char> >::garply" \ |
e96ec2ba | 605 | "\\$\[0-9\]* = \\{(class |)Garply<char> \\((class |)Garply<Garply<char> > \\*(| const), int, (class |)Garply<char>\\)\\} $hex <Garply<Garply<char>\[ \t\]*>::garply\\(int, (class |)Garply<char>\\)>" |
a0b3c4fd | 606 | |
e6d71bf3 DB |
607 | # djb - 06-03-2000 |
608 | # Now should work fine | |
b598bfda DJ |
609 | gdb_test "break Garply<Garply<char> >::garply" \ |
610 | "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*" | |
64a97606 KS |
611 | |
612 | # | |
613 | # Template wild-matching tests | |
614 | # | |
615 | ||
616 | # Turn off "ask" when multiple symbols are seen. | |
617 | gdb_test_no_output "set multiple-symbols all" | |
618 | ||
619 | # Test setting breakpoints in a method of all class template instantiations, | |
620 | # including overloads. | |
621 | gdb_test "break Foo::foo" "Breakpoint.*at.* \\(3 locations\\)" | |
622 | foreach t [list "int" "char" "volatile char *"] { | |
623 | gdb_breakpoint "Foo<$t>::foo (int, $t)" | |
624 | gdb_breakpoint "Foo::foo (int, $t)" | |
625 | } | |
626 | ||
627 | gdb_test "break Bar::bar" "Breakpoint.*at.* \\(2 locations\\)" | |
628 | gdb_test "break Bar::bar (int, int)" "Breakpoint.*at.* \\(2 locations\\)" | |
629 | foreach val [list 1 33] { | |
630 | gdb_breakpoint "Bar<int, $val>::bar (int, int)" | |
631 | } | |
632 | ||
633 | # Test setting breakpoints in a member function template of a class template, | |
634 | # including overloads. | |
635 | gdb_test "break Foozle::fogey" "Breakpoint.*at.* \\(9 locations\\)" \ | |
636 | "break at template method fogey" | |
637 | foreach t [list "int" "char" "Empty<int>"] { | |
638 | gdb_test "break Foozle::fogey ($t)" "Breakpoint.*at.* \\(3 locations\\)" | |
639 | gdb_test "break Foozle::fogey<$t>" "Breakpoint.*at.* \\(3 locations\\)" | |
640 | foreach u [list "int" "char" "Empty<int>"] { | |
641 | gdb_breakpoint "Foozle<$t>::fogey<$u>" message | |
642 | gdb_breakpoint "Foozle<$t>::fogey<$u> ($u)" message | |
643 | } | |
644 | } | |
645 | ||
646 | # Test templated operators < and <<. Restrict results to only the test | |
647 | # source file. | |
648 | # operator<: | |
649 | # 1. operator< (const T2&, const T2&) | |
650 | # 2. operator< (const T2&, char) | |
651 | # 3. operator< <Empty<int>> | |
652 | # 4. operator< <Foozle<in>> | |
653 | # | |
654 | # operator<<: | |
655 | # 1. operator<< <Empty<int>> | |
656 | # 2. operator<< <Foozle<int>> | |
657 | gdb_test "break -source $srcfile -func operator<" \ | |
658 | "Breakpoint.*at.* \\(4 locations\\)" | |
659 | gdb_test "break -source $srcfile -func operator<<" \ | |
660 | "Breakpoint.*at.* \\(2 locations\\)" | |
661 | foreach t [list "Empty" "Foozle"] { | |
662 | set tt "$t<int>" | |
663 | gdb_breakpoint "operator< <$tt>" message | |
664 | gdb_breakpoint "operator<< <$tt>" message | |
665 | ||
666 | # Try a specific instance, both with and without whitespace | |
667 | # after the template-template parameter. | |
668 | gdb_breakpoint "operator< <$tt> ($tt&, $tt&)" message | |
669 | gdb_breakpoint "operator< <$tt > ($tt&, $tt&)" message | |
670 | gdb_breakpoint "operator<< <$tt> ($tt&, $tt&)" message | |
671 | gdb_breakpoint "operator<< <$tt > ($tt&, $tt&)" message | |
672 | } | |
673 | ||
674 | # Test that "-qualified" finds no matching locations. | |
675 | gdb_test_no_output "set breakpoint pending off" | |
676 | gdb_test "break -qualified Foozle::fogey" \ | |
677 | "Function \"Foozle::fogey\" not defined." |