OSDN Git Service

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