ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / testsuite / gdb.cp / templates.exp
blob6808062e8675756fd3a029c61571263bb8fad7dd
1 # Copyright 1992-2015 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This file was written by Fred Fish. (fnf@cygnus.com)
18 set ws "\[\r\n\t \]+"
20 if { [skip_cplus_tests] } { continue }
22 standard_testfile .cc
24 # Create and source the file that provides information about the compiler
25 # used to compile the test case.
26 if [get_compiler_info "c++"] {
27 return -1
30 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
31 return -1
35 # Test printing of the types of templates.
38 proc test_ptype_of_templates {} {
39 global gdb_prompt
40 global ws
42 gdb_test_multiple "ptype/r T5<int>" "ptype T5<int>" {
43 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
44 xfail "ptype T5<int> -- new without size_t"
46 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}\}\r\n$gdb_prompt $" {
47 xfail "ptype T5<int> -- new without size_t"
49 -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}${ws}$gdb_prompt $" {
50 xfail "ptype T5<int> -- new with unsigned int"
52 -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 $" {
53 xfail "ptype T5<int> -- new with unsigned long"
55 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\((T5<int> const|const T5<int>) ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" {
56 xfail "ptype T5<int> (obsolescent gcc or gdb)"
58 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(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 $" {
59 # This also triggers gdb/1113...
60 kfail "gdb/1111" "ptype T5<int>"
61 # Add here a PASS case when PR gdb/1111 gets fixed.
62 # These are really:
63 # http://sourceware.org/bugzilla/show_bug.cgi?id=8216
64 # http://sourceware.org/bugzilla/show_bug.cgi?id=8218
66 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
67 # http://sourceware.org/bugzilla/show_bug.cgi?id=8218
68 # The destructor has an argument type.
69 kfail "gdb/8218" "ptype T5<int>"
73 gdb_test_multiple "ptype/r 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 $" {
75 xfail "ptype T5<int> -- with several fixes from 4.17 -- without size_t"
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 $" {
78 xfail "ptype t5i<int> -- new with unsigned int -- without size_t"
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 $" {
81 xfail "ptype t5i<int> -- new with unsigned long -- without size_t"
83 -re "type = class T5<int> \{.*public:.*static int X;.*int x;.*int val;.*.*T5 \\(int\\);.*.*void ~T5 \\(int\\).*.*.*int value \\((void|)\\);.*\}.*$gdb_prompt $" {
84 xfail "ptype t5i -- without size_t"
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 $" {
87 xfail "ptype t5i -- without size_t"
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 $" {
90 xfail "ptype t5i -- without size_t"
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 $" {
93 xfail "ptype t5i (obsolescent gcc or gdb) -- without size_t"
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 $" {
96 # This also triggers gdb/1113...
97 kfail "gdb/1111" "ptype T5<int>"
98 # Add here a PASS case when PR gdb/1111 gets fixed.
99 # These are really:
100 # http://sourceware.org/bugzilla/show_bug.cgi?id=8216
101 # http://sourceware.org/bugzilla/show_bug.cgi?id=8218
103 -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 $" {
104 # http://sourceware.org/bugzilla/show_bug.cgi?id=8218
105 # The destructor has an argument type.
106 kfail "gdb/8218" "ptype T5<int>"
112 # Test breakpoint setting on template methods.
115 proc test_template_breakpoints {} {
116 global gdb_prompt
117 global testfile
118 global srcdir
119 global hp_aCC_compiler
121 gdb_test_multiple "break T5<int>::T5" "constructor breakpoint" {
122 -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\]*> $" {
123 gdb_test "0" \
124 "canceled" \
125 "constructor breakpoint"
127 -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5 at .*\[\r\n\]*.3. T5 at .*\[\r\n\]*> $" {
128 setup_kfail "gdb/1062" "*-*-*"
129 gdb_test "0" \
130 "nonsense intended to insure that this test fails" \
131 "constructor breakpoint"
133 -re ".*\n> $" {
134 gdb_test "0" \
135 "nonsense intended to insure that this test fails" \
136 "constructor breakpoint (bad menu choices)"
140 # See CLLbs14792
141 if {$hp_aCC_compiler} {setup_xfail hppa*-*-* CLLbs14792}
143 gdb_test_multiple "break T5<int>::~T5" "destructor_breakpoint" {
144 -re "Breakpoint.*at.* file .*${testfile}.cc, line.*$gdb_prompt $"
146 pass "destructor breakpoint"
148 -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 $"
150 kfail "gdb/1112" "destructor breakpoint"
154 gdb_test "break T5<int>::value" \
155 "Breakpoint.*at.* file .*${testfile}.cc, line.*" \
156 "value method breakpoint"
158 set bp_location [gdb_get_line_number \
159 "set breakpoint on a line with no real code"]
161 gdb_test_multiple "break ${testfile}.cc:${bp_location}" \
162 "breakpoint on a line with no real code" {
163 -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\]*> $" {
164 gdb_test "0" \
165 "canceled" \
166 "breakpoint on a line with no real code"
168 -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2.*\[\r\n\]*.3.*\[\r\n\]*> $" {
169 gdb_test "0" \
170 "nonsense intended to insure that this test fails" \
171 "breakpoint on a line with no real code"
173 -re ".*\n> $" {
174 gdb_test "0" \
175 "nonsense intended to insure that this test fails" \
176 "breakpoint on a line with no real code"
180 delete_breakpoints
184 # Test calling of template methods.
187 proc test_template_calls {} {
188 global gdb_prompt
189 global hp_aCC_compiler
191 if [target_info exists gdb,cannot_call_functions] {
192 setup_xfail "*-*-*" 2416
193 fail "This target can not call functions"
194 return
197 if {!$hp_aCC_compiler} {setup_xfail hppa*-*-*}
198 gdb_test_multiple "print t5i.value()" "print t5i.value()" {
199 -re ".* = 2\[\r\n\]*$gdb_prompt $" {
200 pass "print t5i.value()"
202 -re "Cannot invoke functions on this machine.*$gdb_prompt $" {
203 fail "print t5i.value()"
205 -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
206 setup_xfail hppa*-*-* CLLbs16899
207 xfail "print t5i.value"
212 proc test_template_typedef {} {
213 global gdb_prompt
215 gdb_test "print intBazOne::baz" ".*baz\\(int, int\\)>" \
216 "print method of template typedef"
218 set test "print destructor of template typedef"
219 gdb_test_multiple "print intBazOne::~Baz" $test {
220 -re "~Baz(\\(\\))?>\r\n$gdb_prompt $" {
221 pass $test
223 -re "There is no field named ~Baz\r\n$gdb_prompt $" {
224 set test2 "verify GCC PR debug/51668"
225 gdb_test_multiple "whatis intBazOne" $test2 {
226 -re "type = Baz<int, \\(char\\)'\\\\001'>\r\n$gdb_prompt $" {
227 setup_xfail gcc/51668 "*-*-*"
228 xfail $test
229 pass $test2
231 -re "\r\n$gdb_prompt $" {
232 # Some unexpected response.
233 fail $test
234 fail $test2
241 proc test_template_args {} {
243 set empty_re "Empty *<void *\\(FunctionArg *<int>\\)>"
244 gdb_test "ptype/r empty" \
245 "type = (struct|class) $empty_re {.*<no data fields>.*}" \
246 "ptype empty"
248 gdb_test "ptype/r arg" \
249 "type = (struct|class) FunctionArg<int> {.*int method\\($empty_re \\&\\);.*}" \
250 "ptype arg"
253 proc do_tests {} {
254 # Change multiple-symbols to "ask" in order to get the multiple-choice
255 # menu when breaking on overloaded methods.
256 gdb_test_no_output "set multiple-symbols ask"
258 runto_main
260 test_ptype_of_templates
261 test_template_breakpoints
262 test_template_typedef
263 test_template_args
265 if [ runto_main] {
266 test_template_calls
270 do_tests
273 # More tests for different kinds of template parameters,
274 # templates with partial specializations, nested templates, etc.
275 # These have been tested only with HP aCC. They probably won't
276 # work with other compilers because of differences in mangling
277 # schemes.
278 # Added by Satish Pai <pai@apollo.hp.com> 1997-09-25
279 # As of 2000-06-03, C++ support has been improved to the point that g++ can
280 # pass all of theses, excluding what appears to be one that exposes a stabs bug. - djb
282 # I don't know how HP could be passing these tests without this. They
283 # weren't breakpointing past a point where the below expressions were
284 # initialized in the actual source. - djb
286 gdb_test "b 770" \
287 "Breakpoint .* at .*, line 770."
289 gdb_test "c" \
290 "Continuing.*Breakpoint .*" \
291 "continue to line 770"
293 gdb_test "print fint" \
294 "\\$\[0-9\]* = \\{x = 0, t = 0\\}"
296 # Prevent symbol on address 0x0 being printed.
297 gdb_test_no_output "set print symbol off"
298 gdb_test "print fvpchar" \
299 "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}"
301 # Template Foo<T>
303 # Neither stabs nor DWARF-2 contains type information about templates
304 # (as opposed to instantiations of templates), so in those
305 # circumstances we expect GDB to not find a symbol. HP has a debug
306 # format that contains more info, though, so it's also correct to
307 # print out template info. (This affects several subsequent tests as
308 # well.)
310 # NOTE: carlton/2003-02-26: However, because of a bug in the way GDB
311 # handles nested types, we don't get this right in the DWARF-2 case.
313 gdb_test_multiple "ptype/r Foo" "ptype Foo" {
314 -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 $" {
315 pass "ptype Foo"
317 -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 $" {
318 xfail "ptype Foo"
320 -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 $" {
321 # GCC 3.1, DWARF-2 output.
322 kfail "gdb/57" "ptype Foo"
324 -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" {
325 # GCC 2.95.3, stabs+ output.
326 pass "ptype Foo"
330 # -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 $"
332 # ptype Foo<int>
334 gdb_test_multiple "ptype/r fint" "ptype fint" {
335 -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 $" {
336 pass "ptype fint"
338 -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 $" {
339 pass "ptype fint"
343 # ptype Foo<char>
345 gdb_test_multiple "ptype/r fchar" "ptype fchar" {
346 -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 $" {
347 pass "ptype fchar"
349 -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 $" {
350 pass "ptype fchar"
354 # ptype Foo<volatile char *>
356 gdb_test_multiple "ptype/r fvpchar" "ptype fvpchar" {
357 -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 $" {
358 pass "ptype fvpchar"
360 -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 $" {
361 pass "ptype fvpchar"
363 -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 $" {
364 kfail "gdb/1512" "ptype fvpchar"
368 # print a function from Foo<volatile char *>
370 # This test is sensitive to whitespace matching, so we'll do it twice,
371 # varying the spacing, because of PR gdb/33.
373 gdb_test_multiple "print Foo<volatile char *>::foo" "print Foo<volatile char *>::foo" {
374 -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" {
375 pass "print Foo<volatile char *>::foo"
377 -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $" {
378 # This used to be a kfail gdb/33 and then kfail gdb/931.
379 fail "print Foo<volatile char *>::foo"
383 gdb_test_multiple "print Foo<volatile char*>::foo" "print Foo<volatile char*>::foo" {
384 -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" {
385 pass "print Foo<volatile char*>::foo"
387 -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $" {
388 # This used to be a kfail gdb/33 and then kfail gdb/931.
389 fail "print Foo<volatile char*>::foo"
393 # Template Bar<T, int>
395 # same as Foo for g++
396 gdb_test_multiple "ptype/r Bar" "ptype Bar" {
397 -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 $" {
398 pass "ptype Bar"
400 -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 $" {
401 xfail "ptype Bar"
403 -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 $" {
404 # GCC 3.1, DWARF-2 output.
405 kfail "gdb/57" "ptype Bar"
407 -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $" {
408 # GCC 2.95.3, stabs+ output.
409 pass "ptype Bar"
414 # ptype Bar<int,33>
416 gdb_test_multiple "ptype/r bint" "ptype bint" {
417 -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 $" {
418 pass "ptype bint"
420 -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 $" {
421 pass "ptype bint"
425 # ptype Bar<int, (4>3)>
427 gdb_test_multiple "ptype/r bint2" "ptype bint2" {
428 -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 $" {
429 pass "ptype bint2"
431 -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 $" {
432 pass "ptype bint2"
436 # Template Baz<T, char>
438 # Same as Foo, for g++
439 gdb_test_multiple "ptype/r Baz" "ptype Baz" {
440 -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 $" {
441 pass "ptype Baz"
443 -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 $" {
444 xfail "ptype Baz"
446 -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 $" {
447 # GCC 3.1, DWARF-2 output.
448 kfail "gdb/57" "ptype Baz"
450 -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 $" {
451 # GCC 3.x, DWARF-2 output, running into gdb/57 and gdb/1512.
452 kfail "gdb/57" "ptype Baz"
454 -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $" {
455 # GCC 2.95.3, stabs+ output.
456 pass "ptype Baz"
461 # ptype Baz<int, 's'>
463 gdb_test_multiple "ptype/r bazint" "ptype bazint" {
464 -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 $" {
465 pass "ptype bazint"
467 -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 $" {
468 pass "ptype bazint"
472 # ptype Baz<char, 'a'>
474 gdb_test_multiple "ptype/r bazint2" "ptype bazint2" {
475 -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 $" {
476 pass "ptype bazint2"
478 -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 $" {
479 pass "ptype bazint2"
483 # Template Qux<T, int (*f)(int) >
484 # Same as Foo for g++
485 gdb_test_multiple "ptype/r Qux" "ptype Qux" {
486 -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 $" {
487 pass "ptype Qux"
489 -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 $" {
490 pass "ptype Qux"
492 -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 $" {
493 # GCC 3.1, DWARF-2 output.
494 kfail "gdb/57" "ptype Qux"
496 -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 $" {
497 # GCC 3.x, DWARF-2 output; gdb/57 + gdb/1512.
498 kfail "gdb/57" "ptype Qux"
500 -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $" {
501 # GCC 2.95.3, stabs+ output.
502 pass "ptype Qux"
506 # pt Qux<int,&string>
508 gdb_test_multiple "ptype/r quxint" "ptype quxint" {
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 pass "ptype quxint"
512 -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 $" {
513 pass "ptype quxint"
515 -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 $" {
516 pass "ptype quxint"
518 -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 $" {
519 kfail "gdb/1512" "ptype quxint"
524 # Template Spec<T1, T2>
526 # Same as Foo for g++
527 gdb_test_multiple "ptype/r Spec" "ptype Spec" {
528 -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 $" {
529 pass "ptype Spec"
531 -re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" {
532 xfail "ptype Spec"
534 -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 $" {
535 # GCC 3.1, DWARF-2 output.
536 kfail "gdb/57" "ptype Spec"
538 -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $" {
539 # GCC 2.95.3, stabs+ output.
540 pass "ptype Spec"
544 # pt Spec<char,0>
546 gdb_test_multiple "ptype/r siip" "ptype siip" {
547 -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 $" {
548 pass "ptype siip"
550 -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 $" {
551 pass "ptype siip"
555 # pt Garply<int>
557 gdb_test_multiple "ptype/r Garply<int>" "ptype Garply<int>" {
558 -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 $" {
559 pass "ptype Garply<int>"
561 -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 $" {
562 pass "ptype Garply<int>"
566 # ptype of nested template name
568 gdb_test_multiple "ptype/r Garply<Garply<char> >" "ptype Garply<Garply<char> >" {
569 -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 $" {
570 pass "ptype Garply<Garply<char> >"
572 -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 $" {
573 pass "ptype Garply<Garply<char> >"
577 # print out a function from a nested template name
579 gdb_test "print Garply<Garply<char> >::garply" \
580 "\\$\[0-9\]* = \\{(class |)Garply<char> \\((class |)Garply<Garply<char> > \\*(| const), int, (class |)Garply<char>\\)\\} $hex <Garply<Garply<char>\[ \t\]*>::garply\\(int, (class |)Garply<char>\\)>" \
581 "print Garply<Garply<char> >::garply"
583 # djb - 06-03-2000
584 # Now should work fine
585 gdb_test "break Garply<Garply<char> >::garply" \
586 "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*"