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