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