]>
Commit | Line | Data |
---|---|---|
0b302171 JB |
1 | # Copyright 1992, 1994-1997, 1999-2000, 2002-2004, 2007-2012 Free |
2 | # Software Foundation, Inc. | |
c906108c SS |
3 | |
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 | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # This file was written by Fred Fish. ([email protected]) |
18 | ||
19 | set ws "\[\r\n\t \]+" | |
20 | ||
21 | if $tracelevel then { | |
22 | strace $tracelevel | |
23 | } | |
24 | ||
d4f3574e SS |
25 | if { [skip_cplus_tests] } { continue } |
26 | ||
c906108c SS |
27 | set testfile "templates" |
28 | set srcfile ${testfile}.cc | |
29 | set binfile ${objdir}/${subdir}/${testfile} | |
30 | ||
31 | # Create and source the file that provides information about the compiler | |
32 | # used to compile the test case. | |
33 | if [get_compiler_info ${binfile} "c++"] { | |
34 | return -1 | |
35 | } | |
c906108c | 36 | |
c906108c | 37 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { |
b60f0898 JB |
38 | untested templates.exp |
39 | return -1 | |
c906108c SS |
40 | } |
41 | ||
c906108c SS |
42 | # |
43 | # Test printing of the types of templates. | |
44 | # | |
45 | ||
46 | proc test_ptype_of_templates {} { | |
47 | global gdb_prompt | |
48 | global ws | |
49 | ||
f8d3bf8f | 50 | gdb_test_multiple "ptype T5<int>" "ptype T5<int>" { |
1bc05c3a | 51 | -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 | 52 | xfail "ptype T5<int> -- new without size_t" |
c906108c | 53 | } |
3b0cb202 | 54 | -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 | 55 | xfail "ptype T5<int> -- new without size_t" |
3b0cb202 | 56 | } |
f8d3bf8f | 57 | -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 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}${ws}$gdb_prompt $" { |
3b7962f9 | 58 | xfail "ptype T5<int> -- new with unsigned int" |
f8d3bf8f MS |
59 | } |
60 | -re "type = class T5<int> \\{.*public:.*static int X;.*int x;.*int val;.*T5 \\(int\\);.*T5 \\(const class T5<int> &\\);.*void ~T5 \\(int\\);.*static void \\* new \\(unsigned long\\);.*static void delete \\(void ?\\*\\);.*int value \\((void|)\\);.*\\}\r\n$gdb_prompt $" { | |
3b7962f9 | 61 | xfail "ptype T5<int> -- new with unsigned long" |
f8d3bf8f | 62 | } |
1bc05c3a | 63 | -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 | 64 | xfail "ptype T5<int> (obsolescent gcc or gdb)" |
c906108c | 65 | } |
3b7962f9 | 66 | -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\\(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 $" { |
5330f2db DC |
67 | # This also triggers gdb/1113... |
68 | kfail "gdb/1111" "ptype T5<int>" | |
3b7962f9 | 69 | # Add here a PASS case when PR gdb/1111 gets fixed. |
5330f2db | 70 | } |
c906108c SS |
71 | } |
72 | ||
f8d3bf8f MS |
73 | gdb_test_multiple "ptype t5i" "ptype t5i" { |
74 | -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 | 75 | xfail "ptype T5<int> -- with several fixes from 4.17 -- without size_t" |
f8d3bf8f MS |
76 | } |
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 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { | |
3b7962f9 | 78 | xfail "ptype t5i<int> -- new with unsigned int -- without size_t" |
f8d3bf8f MS |
79 | } |
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 \\(int\\);${ws}static void \\* new \\(unsigned long\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { | |
3b7962f9 | 81 | xfail "ptype t5i<int> -- new with unsigned long -- without size_t" |
f8d3bf8f | 82 | } |
eef747c0 | 83 | -re "type = class T5<int> \{.*public:.*static int X;.*int x;.*int val;.*.*T5 \\(int\\);.*.*void ~T5 \\(int\\).*.*.*int value \\((void|)\\);.*\}.*$gdb_prompt $" { |
3b7962f9 | 84 | xfail "ptype t5i -- without size_t" |
a0b3c4fd | 85 | } |
1bc05c3a | 86 | -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 | 87 | xfail "ptype t5i -- without size_t" |
c906108c | 88 | } |
3b0cb202 | 89 | -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 | 90 | xfail "ptype t5i -- without size_t" |
3b0cb202 | 91 | } |
3b2a7ae5 | 92 | -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 | 93 | xfail "ptype t5i (obsolescent gcc or gdb) -- without size_t" |
c906108c | 94 | } |
3b7962f9 | 95 | -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\\(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 $" { |
5330f2db DC |
96 | # This also triggers gdb/1113... |
97 | kfail "gdb/1111" "ptype T5<int>" | |
3b7962f9 | 98 | # Add here a PASS case when PR gdb/1111 gets fixed. |
5330f2db | 99 | } |
c906108c SS |
100 | } |
101 | } | |
102 | ||
103 | # | |
104 | # Test breakpoint setting on template methods. | |
105 | # | |
106 | ||
107 | proc test_template_breakpoints {} { | |
108 | global gdb_prompt | |
109 | global testfile | |
110 | global srcdir | |
a0b3c4fd | 111 | global hp_aCC_compiler |
c906108c | 112 | |
b598bfda | 113 | gdb_test_multiple "break T5<int>::T5" "constructor breakpoint" { |
f8eba3c6 | 114 | -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 | 115 | gdb_test "0" \ |
a9e2e984 | 116 | "canceled" \ |
c906108c SS |
117 | "constructor breakpoint" |
118 | } | |
5330f2db DC |
119 | -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5 at .*\[\r\n\]*.3. T5 at .*\[\r\n\]*> $" { |
120 | setup_kfail "gdb/1062" "*-*-*" | |
121 | gdb_test "0" \ | |
122 | "nonsense intended to insure that this test fails" \ | |
123 | "constructor breakpoint" | |
124 | } | |
760f6330 MS |
125 | -re ".*\n> $" { |
126 | gdb_test "0" \ | |
127 | "nonsense intended to insure that this test fails" \ | |
128 | "constructor breakpoint (bad menu choices)" | |
129 | } | |
c906108c SS |
130 | } |
131 | ||
a0b3c4fd JM |
132 | # See CLLbs14792 |
133 | if {$hp_aCC_compiler} {setup_xfail hppa*-*-* CLLbs14792} | |
5330f2db DC |
134 | |
135 | gdb_test_multiple "break T5<int>::~T5" "destructor_breakpoint" { | |
136 | -re "Breakpoint.*at.* file .*${testfile}.cc, line.*$gdb_prompt $" | |
137 | { | |
138 | pass "destructor breakpoint" | |
139 | } | |
140 | -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 $" | |
141 | { | |
142 | kfail "gdb/1112" "destructor breakpoint" | |
143 | } | |
144 | } | |
c906108c SS |
145 | |
146 | gdb_test "break T5<int>::value" \ | |
147 | "Breakpoint.*at.* file .*${testfile}.cc, line.*" \ | |
148 | "value method breakpoint" | |
149 | ||
945a118d JG |
150 | set bp_location [gdb_get_line_number \ |
151 | "set breakpoint on a line with no real code"] | |
f8eba3c6 TT |
152 | |
153 | gdb_test_multiple "break ${testfile}.cc:${bp_location}" \ | |
154 | "breakpoint on a line with no real code" { | |
155 | -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\]*> $" { | |
156 | gdb_test "0" \ | |
157 | "canceled" \ | |
158 | "breakpoint on a line with no real code" | |
159 | } | |
160 | -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2.*\[\r\n\]*.3.*\[\r\n\]*> $" { | |
161 | gdb_test "0" \ | |
162 | "nonsense intended to insure that this test fails" \ | |
163 | "breakpoint on a line with no real code" | |
164 | } | |
165 | -re ".*\n> $" { | |
166 | gdb_test "0" \ | |
167 | "nonsense intended to insure that this test fails" \ | |
168 | "breakpoint on a line with no real code" | |
169 | } | |
170 | } | |
171 | ||
c906108c SS |
172 | delete_breakpoints |
173 | } | |
174 | ||
175 | # | |
176 | # Test calling of template methods. | |
177 | # | |
178 | ||
179 | proc test_template_calls {} { | |
180 | global gdb_prompt | |
a0b3c4fd | 181 | global hp_aCC_compiler |
c906108c SS |
182 | |
183 | if [target_info exists gdb,cannot_call_functions] { | |
184 | setup_xfail "*-*-*" 2416 | |
185 | fail "This target can not call functions" | |
186 | return | |
187 | } | |
188 | ||
a0b3c4fd | 189 | if {!$hp_aCC_compiler} {setup_xfail hppa*-*-*} |
f8d3bf8f MS |
190 | gdb_test_multiple "print t5i.value()" "print t5i.value()" { |
191 | -re ".* = 2\[\r\n\]*$gdb_prompt $" { | |
192 | pass "print t5i.value()" | |
193 | } | |
c906108c SS |
194 | -re "Cannot invoke functions on this machine.*$gdb_prompt $" { |
195 | fail "print t5i.value()" | |
196 | } | |
a0b3c4fd JM |
197 | -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { |
198 | setup_xfail hppa*-*-* CLLbs16899 | |
199 | xfail "print t5i.value" | |
200 | } | |
c906108c SS |
201 | } |
202 | } | |
203 | ||
3fe8f3b3 | 204 | proc test_template_typedef {} { |
ae1a303e | 205 | global gdb_prompt |
3fe8f3b3 KS |
206 | |
207 | gdb_test "print intBazOne::baz" ".*baz\\(int, int\\)>" \ | |
208 | "print method of template typedef" | |
209 | ||
ae1a303e JK |
210 | set test "print destructor of template typedef" |
211 | gdb_test_multiple "print intBazOne::~Baz" $test { | |
212 | -re "~Baz(\\(\\))?>\r\n$gdb_prompt $" { | |
213 | pass $test | |
214 | } | |
215 | -re "There is no field named ~Baz\r\n$gdb_prompt $" { | |
216 | set test2 "verify GCC PR debug/51668" | |
217 | gdb_test_multiple "whatis intBazOne" $test2 { | |
218 | -re "type = Baz<int, \\(char\\)'\\\\001'>\r\n$gdb_prompt $" { | |
219 | setup_xfail gcc/51668 "*-*-*" | |
220 | xfail $test | |
221 | pass $test2 | |
222 | } | |
223 | -re "\r\n$gdb_prompt $" { | |
224 | # Some unexpected response. | |
225 | fail $test | |
226 | fail $test2 | |
227 | } | |
228 | } | |
229 | } | |
230 | } | |
3fe8f3b3 | 231 | } |
c906108c | 232 | |
c767944b DJ |
233 | proc test_template_args {} { |
234 | ||
235 | set empty_re "Empty *<void *\\(FunctionArg *<int>\\)>" | |
236 | gdb_test "ptype empty" \ | |
5e1617b1 | 237 | "type = (struct|class) $empty_re {.*<no data fields>.*}" |
c767944b DJ |
238 | |
239 | gdb_test "ptype arg" \ | |
5e1617b1 | 240 | "type = (struct|class) FunctionArg<int> {.*int method\\($empty_re \\&\\);.*}" |
c767944b DJ |
241 | } |
242 | ||
c906108c | 243 | proc do_tests {} { |
c906108c SS |
244 | global subdir |
245 | global objdir | |
246 | global srcdir | |
247 | global binfile | |
248 | global gdb_prompt | |
c906108c | 249 | |
c906108c SS |
250 | |
251 | # Start with a fresh gdb. | |
252 | ||
253 | gdb_exit | |
254 | gdb_start | |
255 | gdb_reinitialize_dir $srcdir/$subdir | |
256 | gdb_load $binfile | |
257 | ||
eae06beb JB |
258 | # Change multiple-symbols to "ask" in order to get the multiple-choice |
259 | # menu when breaking on overloaded methods. | |
a8d52276 | 260 | gdb_test_no_output "set multiple-symbols ask" |
eae06beb | 261 | |
40f235b7 | 262 | runto_main |
c906108c SS |
263 | |
264 | test_ptype_of_templates | |
265 | test_template_breakpoints | |
3fe8f3b3 | 266 | test_template_typedef |
c767944b | 267 | test_template_args |
c906108c SS |
268 | |
269 | if [ runto_main] { | |
270 | test_template_calls | |
271 | } | |
272 | } | |
273 | ||
274 | do_tests | |
275 | ||
a0b3c4fd JM |
276 | |
277 | # More tests for different kinds of template parameters, | |
278 | # templates with partial specializations, nested templates, etc. | |
279 | # These have been tested only with HP aCC. They probably won't | |
280 | # work with other compilers because of differences in mangling | |
281 | # schemes. | |
282 | # Added by Satish Pai <[email protected]> 1997-09-25 | |
e6d71bf3 DB |
283 | # As of 2000-06-03, C++ support has been improved to the point that g++ can |
284 | # pass all of theses, excluding what appears to be one that exposes a stabs bug. - djb | |
a0b3c4fd | 285 | |
e6d71bf3 DB |
286 | # I don't know how HP could be passing these tests without this. They |
287 | # weren't breakpointing past a point where the below expressions were | |
288 | # initialized in the actual source. - djb | |
289 | ||
f8d3bf8f MS |
290 | gdb_test "b 770" \ |
291 | "Breakpoint .* at .*, line 770." | |
a0b3c4fd | 292 | |
f8d3bf8f MS |
293 | gdb_test "c" \ |
294 | "Continuing.*Breakpoint .*" \ | |
295 | "continue to line 770" | |
296 | ||
297 | gdb_test "print fint" \ | |
298 | "\\$\[0-9\]* = \\{x = 0, t = 0\\}" | |
299 | ||
300 | gdb_test "print fvpchar" \ | |
301 | "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}" | |
a0b3c4fd JM |
302 | |
303 | # Template Foo<T> | |
304 | ||
dd14ab43 DC |
305 | # Neither stabs nor DWARF-2 contains type information about templates |
306 | # (as opposed to instantiations of templates), so in those | |
307 | # circumstances we expect GDB to not find a symbol. HP has a debug | |
308 | # format that contains more info, though, so it's also correct to | |
309 | # print out template info. (This affects several subsequent tests as | |
310 | # well.) | |
311 | ||
312 | # NOTE: carlton/2003-02-26: However, because of a bug in the way GDB | |
313 | # handles nested types, we don't get this right in the DWARF-2 case. | |
314 | ||
f8d3bf8f MS |
315 | gdb_test_multiple "ptype Foo" "ptype Foo" { |
316 | -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 $" { | |
317 | pass "ptype Foo" | |
318 | } | |
319 | -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 $" { | |
320 | xfail "ptype Foo" | |
321 | } | |
322 | -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 $" { | |
323 | # GCC 3.1, DWARF-2 output. | |
324 | kfail "gdb/57" "ptype Foo" | |
325 | } | |
326 | -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" { | |
327 | # GCC 2.95.3, stabs+ output. | |
328 | pass "ptype Foo" | |
329 | } | |
a0b3c4fd | 330 | } |
f8d3bf8f | 331 | |
dd14ab43 | 332 | # -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 |
333 | |
334 | # ptype Foo<int> | |
335 | ||
f8d3bf8f MS |
336 | gdb_test_multiple "ptype fint" "ptype fint" { |
337 | -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 $" { | |
338 | pass "ptype fint" | |
339 | } | |
340 | -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 $" { | |
341 | pass "ptype fint" | |
342 | } | |
a0b3c4fd JM |
343 | } |
344 | ||
345 | # ptype Foo<char> | |
346 | ||
f8d3bf8f MS |
347 | gdb_test_multiple "ptype fchar" "ptype fchar" { |
348 | -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 $" { | |
349 | pass "ptype fchar" | |
350 | } | |
351 | -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 $" { | |
352 | pass "ptype fchar" | |
353 | } | |
a0b3c4fd JM |
354 | } |
355 | ||
356 | # ptype Foo<volatile char *> | |
357 | ||
f8d3bf8f MS |
358 | gdb_test_multiple "ptype fvpchar" "ptype fvpchar" { |
359 | -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 $" { | |
360 | pass "ptype fvpchar" | |
361 | } | |
362 | -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 $" { | |
363 | pass "ptype fvpchar" | |
364 | } | |
365 | -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 $" { | |
366 | kfail "gdb/1512" "ptype fvpchar" | |
367 | } | |
a0b3c4fd JM |
368 | } |
369 | ||
370 | # print a function from Foo<volatile char *> | |
371 | ||
0b71dc91 DC |
372 | # This test is sensitive to whitespace matching, so we'll do it twice, |
373 | # varying the spacing, because of PR gdb/33. | |
374 | ||
f8d3bf8f MS |
375 | gdb_test_multiple "print Foo<volatile char *>::foo" "print Foo<volatile char *>::foo" { |
376 | -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { | |
377 | pass "print Foo<volatile char *>::foo" | |
378 | } | |
379 | -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $" { | |
71c25dea TT |
380 | # This used to be a kfail gdb/33 and then kfail gdb/931. |
381 | fail "print Foo<volatile char *>::foo" | |
85ca1584 | 382 | } |
0b71dc91 DC |
383 | } |
384 | ||
f8d3bf8f MS |
385 | gdb_test_multiple "print Foo<volatile char*>::foo" "print Foo<volatile char*>::foo" { |
386 | -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { | |
387 | pass "print Foo<volatile char*>::foo" | |
388 | } | |
389 | -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $" { | |
71c25dea TT |
390 | # This used to be a kfail gdb/33 and then kfail gdb/931. |
391 | fail "print Foo<volatile char*>::foo" | |
85ca1584 | 392 | } |
a0b3c4fd JM |
393 | } |
394 | ||
395 | # Template Bar<T, int> | |
396 | ||
e6d71bf3 | 397 | # same as Foo for g++ |
f8d3bf8f MS |
398 | gdb_test_multiple "ptype Bar" "ptype Bar" { |
399 | -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 $" { | |
400 | pass "ptype Bar" | |
401 | } | |
402 | -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 $" { | |
403 | xfail "ptype Bar" | |
404 | } | |
405 | -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 $" { | |
406 | # GCC 3.1, DWARF-2 output. | |
407 | kfail "gdb/57" "ptype Bar" | |
408 | } | |
409 | -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $" { | |
410 | # GCC 2.95.3, stabs+ output. | |
411 | pass "ptype Bar" | |
412 | } | |
a0b3c4fd JM |
413 | } |
414 | ||
415 | ||
416 | # ptype Bar<int,33> | |
5a2a0a20 | 417 | |
f8d3bf8f MS |
418 | gdb_test_multiple "ptype bint" "ptype bint" { |
419 | -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 $" { | |
420 | pass "ptype bint" | |
421 | } | |
422 | -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 $" { | |
423 | pass "ptype bint" | |
424 | } | |
a0b3c4fd JM |
425 | } |
426 | ||
427 | # ptype Bar<int, (4>3)> | |
428 | ||
f8d3bf8f MS |
429 | gdb_test_multiple "ptype bint2" "ptype bint2" { |
430 | -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 $" { | |
431 | pass "ptype bint2" | |
432 | } | |
433 | -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 $" { | |
434 | pass "ptype bint2" | |
435 | } | |
a0b3c4fd JM |
436 | } |
437 | ||
438 | # Template Baz<T, char> | |
439 | ||
e6d71bf3 | 440 | # Same as Foo, for g++ |
f8d3bf8f MS |
441 | gdb_test_multiple "ptype Baz" "ptype Baz" { |
442 | -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 $" { | |
443 | pass "ptype Baz" | |
444 | } | |
445 | -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 $" { | |
446 | xfail "ptype Baz" | |
447 | } | |
448 | -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 $" { | |
449 | # GCC 3.1, DWARF-2 output. | |
450 | kfail "gdb/57" "ptype Baz" | |
451 | } | |
452 | -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 $" { | |
453 | # GCC 3.x, DWARF-2 output, running into gdb/57 and gdb/1512. | |
454 | kfail "gdb/57" "ptype Baz" | |
455 | } | |
456 | -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $" { | |
457 | # GCC 2.95.3, stabs+ output. | |
458 | pass "ptype Baz" | |
459 | } | |
a0b3c4fd JM |
460 | } |
461 | ||
462 | ||
463 | # ptype Baz<int, 's'> | |
464 | ||
f8d3bf8f MS |
465 | gdb_test_multiple "ptype bazint" "ptype bazint" { |
466 | -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 $" { | |
467 | pass "ptype bazint" | |
468 | } | |
469 | -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 $" { | |
470 | pass "ptype bazint" | |
471 | } | |
a0b3c4fd JM |
472 | } |
473 | ||
474 | # ptype Baz<char, 'a'> | |
475 | ||
f8d3bf8f MS |
476 | gdb_test_multiple "ptype bazint2" "ptype bazint2" { |
477 | -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 $" { | |
478 | pass "ptype bazint2" | |
479 | } | |
480 | -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 $" { | |
481 | pass "ptype bazint2" | |
482 | } | |
a0b3c4fd JM |
483 | } |
484 | ||
485 | # Template Qux<T, int (*f)(int) > | |
e6d71bf3 | 486 | # Same as Foo for g++ |
f8d3bf8f MS |
487 | gdb_test_multiple "ptype Qux" "ptype Qux" { |
488 | -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 $" { | |
489 | pass "ptype Qux" | |
490 | } | |
491 | -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 $" { | |
492 | pass "ptype Qux" | |
493 | } | |
494 | -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 $" { | |
495 | # GCC 3.1, DWARF-2 output. | |
496 | kfail "gdb/57" "ptype Qux" | |
497 | } | |
498 | -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 $" { | |
499 | # GCC 3.x, DWARF-2 output; gdb/57 + gdb/1512. | |
500 | kfail "gdb/57" "ptype Qux" | |
501 | } | |
502 | -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $" { | |
503 | # GCC 2.95.3, stabs+ output. | |
504 | pass "ptype Qux" | |
505 | } | |
a0b3c4fd JM |
506 | } |
507 | ||
508 | # pt Qux<int,&string> | |
509 | ||
f8d3bf8f MS |
510 | gdb_test_multiple "ptype quxint" "ptype quxint" { |
511 | -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 $" { | |
512 | pass "ptype quxint" | |
513 | } | |
514 | -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 $" { | |
515 | pass "ptype quxint" | |
516 | } | |
517 | -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 $" { | |
518 | pass "ptype quxint" | |
519 | } | |
520 | -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 $" { | |
521 | kfail "gdb/1512" "ptype quxint" | |
522 | } | |
a0b3c4fd JM |
523 | } |
524 | ||
a0b3c4fd JM |
525 | |
526 | # Template Spec<T1, T2> | |
527 | ||
e6d71bf3 | 528 | # Same as Foo for g++ |
f8d3bf8f MS |
529 | gdb_test_multiple "ptype Spec" "ptype Spec" { |
530 | -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 $" { | |
531 | pass "ptype Spec" | |
532 | } | |
533 | -re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { | |
534 | xfail "ptype Spec" | |
535 | } | |
536 | -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 $" { | |
537 | # GCC 3.1, DWARF-2 output. | |
538 | kfail "gdb/57" "ptype Spec" | |
539 | } | |
540 | -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $" { | |
541 | # GCC 2.95.3, stabs+ output. | |
542 | pass "ptype Spec" | |
543 | } | |
a0b3c4fd JM |
544 | } |
545 | ||
546 | # pt Spec<char,0> | |
547 | ||
f8d3bf8f MS |
548 | gdb_test_multiple "ptype siip" "ptype siip" { |
549 | -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 $" { | |
550 | pass "ptype siip" | |
551 | } | |
552 | -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 $" { | |
553 | pass "ptype siip" | |
554 | } | |
a0b3c4fd JM |
555 | } |
556 | ||
557 | # pt Garply<int> | |
558 | ||
f8d3bf8f MS |
559 | gdb_test_multiple "ptype Garply<int>" "ptype Garply<int>" { |
560 | -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 $" { | |
561 | pass "ptype Garply<int>" | |
562 | } | |
563 | -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 $" { | |
564 | pass "ptype Garply<int>" | |
565 | } | |
a0b3c4fd JM |
566 | } |
567 | ||
568 | # ptype of nested template name | |
569 | ||
f8d3bf8f MS |
570 | gdb_test_multiple "ptype Garply<Garply<char> >" "ptype Garply<Garply<char> >" { |
571 | -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 $" { | |
572 | pass "ptype Garply<Garply<char> >" | |
573 | } | |
574 | -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 $" { | |
575 | pass "ptype Garply<Garply<char> >" | |
576 | } | |
a0b3c4fd JM |
577 | } |
578 | ||
579 | # print out a function from a nested template name | |
580 | ||
f8d3bf8f MS |
581 | gdb_test "print Garply<Garply<char> >::garply" \ |
582 | "\\$\[0-9\]* = \\{(class |)Garply<char> \\((class |)Garply<Garply<char> > \\*(| const), int, (class |)Garply<char>\\)\\} $hex <Garply<Garply<char>\[ \t\]*>::garply\\(int, (class |)Garply<char>\\)>" \ | |
583 | "print Garply<Garply<char> >::garply" | |
a0b3c4fd | 584 | |
e6d71bf3 DB |
585 | # djb - 06-03-2000 |
586 | # Now should work fine | |
b598bfda DJ |
587 | gdb_test "break Garply<Garply<char> >::garply" \ |
588 | "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*" |