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