testsuite/
[deliverable/binutils-gdb.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 gdb_test_multiple "break T5<int>::T5" "constructor breakpoint" {
116 -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\]*> $" {
117 gdb_test "0" \
118 "canceled" \
119 "constructor breakpoint (obsolete format!)"
120 }
121 -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\]*> $" {
122 gdb_test "0" \
123 "canceled" \
124 "constructor breakpoint"
125 }
126 -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5 at .*\[\r\n\]*.3. T5 at .*\[\r\n\]*> $" {
127 setup_kfail "gdb/1062" "*-*-*"
128 gdb_test "0" \
129 "nonsense intended to insure that this test fails" \
130 "constructor breakpoint"
131 }
132 -re ".*\n> $" {
133 gdb_test "0" \
134 "nonsense intended to insure that this test fails" \
135 "constructor breakpoint (bad menu choices)"
136 }
137 }
138
139 # See CLLbs14792
140 if {$hp_aCC_compiler} {setup_xfail hppa*-*-* CLLbs14792}
141
142 gdb_test_multiple "break T5<int>::~T5" "destructor_breakpoint" {
143 -re "Breakpoint.*at.* file .*${testfile}.cc, line.*$gdb_prompt $"
144 {
145 pass "destructor breakpoint"
146 }
147 -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 $"
148 {
149 kfail "gdb/1112" "destructor breakpoint"
150 }
151 }
152
153 gdb_test "break T5<int>::value" \
154 "Breakpoint.*at.* file .*${testfile}.cc, line.*" \
155 "value method breakpoint"
156
157 set bp_location [gdb_get_line_number \
158 "set breakpoint on a line with no real code"]
159 gdb_test "break ${testfile}.cc:${bp_location}" \
160 "Breakpoint.*at.* file .*${testfile}.cc, line.*(2 locations).*" \
161 "breakpoint on a line with no real code"
162 delete_breakpoints
163 }
164
165 #
166 # Test calling of template methods.
167 #
168
169 proc test_template_calls {} {
170 global gdb_prompt
171 global hp_aCC_compiler
172
173 if [target_info exists gdb,cannot_call_functions] {
174 setup_xfail "*-*-*" 2416
175 fail "This target can not call functions"
176 return
177 }
178
179 if {!$hp_aCC_compiler} {setup_xfail hppa*-*-*}
180 send_gdb "print t5i.value()\n"
181 gdb_expect {
182 -re ".* = 2\[\r\n\]*$gdb_prompt $" { pass "print t5i.value()" }
183 -re "Cannot invoke functions on this machine.*$gdb_prompt $" {
184 fail "print t5i.value()"
185 }
186 -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
187 setup_xfail hppa*-*-* CLLbs16899
188 xfail "print t5i.value"
189 }
190 -re ".*$gdb_prompt $" { fail "print t5i.value()" }
191 timeout { fail "print t5i.value() (timeout)" }
192 }
193 }
194
195 proc test_template_typedef {} {
196
197 gdb_test "print intBazOne::baz" ".*baz\\(int, int\\)>" \
198 "print method of template typedef"
199
200 gdb_test "print intBazOne::~Baz" ".*~Baz(\\(\\))?>" \
201 "print destructor of template typedef"
202 }
203
204 proc do_tests {} {
205 global prms_id
206 global bug_id
207 global subdir
208 global objdir
209 global srcdir
210 global binfile
211 global gdb_prompt
212
213 set prms_id 0
214 set bug_id 0
215
216 # Start with a fresh gdb.
217
218 gdb_exit
219 gdb_start
220 gdb_reinitialize_dir $srcdir/$subdir
221 gdb_load $binfile
222
223 # Change multiple-symbols to "ask" in order to get the multiple-choice
224 # menu when breaking on overloaded methods.
225 gdb_test "set multiple-symbols ask" ""
226
227 runto_main
228
229 test_ptype_of_templates
230 test_template_breakpoints
231 test_template_typedef
232
233 if [ runto_main] {
234 test_template_calls
235 }
236 }
237
238 do_tests
239
240
241 # More tests for different kinds of template parameters,
242 # templates with partial specializations, nested templates, etc.
243 # These have been tested only with HP aCC. They probably won't
244 # work with other compilers because of differences in mangling
245 # schemes.
246 # Added by Satish Pai <pai@apollo.hp.com> 1997-09-25
247 # As of 2000-06-03, C++ support has been improved to the point that g++ can
248 # pass all of theses, excluding what appears to be one that exposes a stabs bug. - djb
249
250 # I don't know how HP could be passing these tests without this. They
251 # weren't breakpointing past a point where the below expressions were
252 # initialized in the actual source. - djb
253
254 send_gdb "b 770\n"
255 gdb_expect {
256 -re ".*$gdb_prompt $"
257 }
258 send_gdb "c\n"
259 gdb_expect {
260 -re ".*$gdb_prompt $"
261 }
262 send_gdb "print fint\n"
263 gdb_expect {
264 -re "\\$\[0-9\]* = \\{x = 0, t = 0\\}\r\n$gdb_prompt $" { pass "print fint" }
265 -re "$gdb_prompt $" { fail "print fint" }
266 timeout { fail "(timeout) print fint" }
267 }
268
269 send_gdb "print fvpchar\n"
270 gdb_expect {
271 -re "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}\r\n$gdb_prompt $" { pass "print fvpchar" }
272 -re "$gdb_prompt $" { fail "print fvpchar" }
273 timeout { fail "(timeout) print fvpchar" }
274 }
275
276 # Template Foo<T>
277
278 # Neither stabs nor DWARF-2 contains type information about templates
279 # (as opposed to instantiations of templates), so in those
280 # circumstances we expect GDB to not find a symbol. HP has a debug
281 # format that contains more info, though, so it's also correct to
282 # print out template info. (This affects several subsequent tests as
283 # well.)
284
285 # NOTE: carlton/2003-02-26: However, because of a bug in the way GDB
286 # handles nested types, we don't get this right in the DWARF-2 case.
287
288 send_gdb "ptype Foo\n"
289 gdb_expect {
290 -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" }
291 -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" }
292 -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 $"
293 { # GCC 3.1, DWARF-2 output.
294 kfail "gdb/57" "ptype Foo" }
295 -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $"
296 { # GCC 2.95.3, stabs+ output.
297 pass "ptype Foo" }
298 -re "$gdb_prompt $" { fail "ptype Foo" }
299 timeout { fail "(timeout) 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
303 # ptype Foo<int>
304
305 send_gdb "ptype fint\n"
306 gdb_expect {
307 -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" }
308 -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" }
309 -re "$gdb_prompt $" { fail "ptype fint" }
310 timeout { fail "(timeout) ptype fint" }
311 }
312
313 # ptype Foo<char>
314
315 send_gdb "ptype fchar\n"
316 gdb_expect {
317 -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" }
318 -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" }
319 -re "$gdb_prompt $" { fail "ptype fchar" }
320 timeout { fail "(timeout) ptype fchar" }
321 }
322
323 # ptype Foo<volatile char *>
324
325 send_gdb "ptype fvpchar\n"
326 gdb_expect {
327 -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" }
328 -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" }
329 -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 $" {
330 kfail "gdb/1512" "ptype fvpchar"
331 }
332 -re "$gdb_prompt $" { fail "ptype fvpchar" }
333 timeout { fail "(timeout) ptype fvpchar" }
334 }
335
336 # print a function from Foo<volatile char *>
337
338 # This test is sensitive to whitespace matching, so we'll do it twice,
339 # varying the spacing, because of PR gdb/33.
340
341 send_gdb "print Foo<volatile char *>::foo\n"
342 gdb_expect {
343 -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" }
344 -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $"
345 {
346 # This used to be a kfail gdb/33 and then kfail gdb/931.
347 fail "print Foo<volatile char *>::foo"
348 }
349 -re "$gdb_prompt $" { fail "print Foo<volatile char *>::foo" }
350 timeout { fail "(timeout) print Foo<volatile char *>::foo" }
351 }
352
353 send_gdb "print Foo<volatile char*>::foo\n"
354 gdb_expect {
355 -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" }
356 -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $"
357 {
358 # This used to be a kfail gdb/33 and then kfail gdb/931.
359 fail "print Foo<volatile char*>::foo"
360 }
361 -re "$gdb_prompt $" { fail "print Foo<volatile char*>::foo" }
362 timeout { fail "(timeout) print Foo<volatile char*>::foo" }
363 }
364
365 # Template Bar<T, int>
366
367 # same as Foo for g++
368 send_gdb "ptype Bar\n"
369 gdb_expect {
370 -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" }
371 -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" }
372 -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 $"
373 { # GCC 3.1, DWARF-2 output.
374 kfail "gdb/57" "ptype Bar" }
375 -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $"
376 { # GCC 2.95.3, stabs+ output.
377 pass "ptype Bar" }
378 -re "$gdb_prompt $" { fail "ptype Bar" }
379 timeout { fail "(timeout) ptype Bar" }
380 }
381
382
383 # ptype Bar<int,33>
384
385 send_gdb "ptype bint\n"
386 gdb_expect {
387 -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" }
388 -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" }
389 -re "$gdb_prompt $" { fail "ptype bint" }
390 timeout { fail "(timeout) ptype bint" }
391 }
392
393 # ptype Bar<int, (4>3)>
394
395 send_gdb "ptype bint2\n"
396 gdb_expect {
397 -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" }
398 -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" }
399 -re "$gdb_prompt $" { fail "ptype bint2" }
400 timeout { fail "(timeout) ptype bint2" }
401 }
402
403 # Template Baz<T, char>
404
405 # Same as Foo, for g++
406 send_gdb "ptype Baz\n"
407 gdb_expect {
408 -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" }
409 -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" }
410 -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 $"
411 { # GCC 3.1, DWARF-2 output.
412 kfail "gdb/57" "ptype Baz" }
413 -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 $"
414 { # GCC 3.x, DWARF-2 output, running into gdb/57 and gdb/1512.
415 kfail "gdb/57" "ptype Baz" }
416 -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $"
417 { # GCC 2.95.3, stabs+ output.
418 pass "ptype Baz" }
419 -re "$gdb_prompt $" { fail "ptype Baz" }
420 timeout { fail "(timeout) ptype Baz" }
421 }
422
423
424 # ptype Baz<int, 's'>
425
426 send_gdb "ptype bazint\n"
427 gdb_expect {
428 -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" }
429 -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" }
430 -re "$gdb_prompt $" { fail "ptype bazint" }
431 timeout { fail "(timeout) ptype bazint" }
432 }
433
434 # ptype Baz<char, 'a'>
435
436 send_gdb "ptype bazint2\n"
437 gdb_expect {
438 -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" }
439 -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" }
440 -re "$gdb_prompt $" { fail "ptype bazint2" }
441 timeout { fail "(timeout) ptype bazint2" }
442 }
443
444 # Template Qux<T, int (*f)(int) >
445 # Same as Foo for g++
446 send_gdb "ptype Qux\n"
447 gdb_expect {
448 -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" }
449 -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" }
450 -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 $"
451 { # GCC 3.1, DWARF-2 output.
452 kfail "gdb/57" "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.x, DWARF-2 output; gdb/57 + gdb/1512.
455 kfail "gdb/57" "ptype Qux" }
456 -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $"
457 { # GCC 2.95.3, stabs+ output.
458 pass "ptype Qux" }
459 -re "$gdb_prompt $" { fail "ptype Qux" }
460 timeout { fail "(timeout) ptype Qux" }
461 }
462
463 # pt Qux<int,&string>
464
465 send_gdb "ptype quxint\n"
466 gdb_expect {
467 -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" }
468 -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" }
469 -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" }
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 $" {
471 kfail "gdb/1512" "ptype quxint"
472 }
473 -re "$gdb_prompt $" { fail "ptype quxint" }
474 timeout { fail "(timeout) ptype quxint" }
475 }
476
477 # pt Qux<char,0>
478
479 # commented out this as quxint2 declaration was commented out in
480 # templates.exp -- ovidiu
481 # send_gdb "ptype quxint2\n"
482 # gdb_expect {
483 # -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" }
484 # -re "$gdb_prompt $" { fail "ptype quxint2" }
485 # timeout { fail "(timeout) ptype quxint2" }
486 # }
487
488 # Template Spec<T1, T2>
489
490 # Same as Foo for g++
491 send_gdb "ptype Spec\n"
492 gdb_expect {
493 -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" }
494 -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" }
495 -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 $"
496 { # GCC 3.1, DWARF-2 output.
497 kfail "gdb/57" "ptype Spec" }
498 -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $"
499 { # GCC 2.95.3, stabs+ output.
500 pass "ptype Spec" }
501 -re "$gdb_prompt $" { fail "ptype Spec" }
502 timeout { fail "(timeout) ptype Spec" }
503 }
504
505 # pt Spec<char,0>
506
507 send_gdb "ptype siip\n"
508 gdb_expect {
509 -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" }
510 -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" }
511 -re "$gdb_prompt $" { fail "ptype siip" }
512 timeout { fail "(timeout) ptype siip" }
513 }
514
515 # pt Garply<int>
516
517 send_gdb "ptype Garply<int>\n"
518 gdb_expect {
519 -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>" }
520 -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>" }
521 -re "$gdb_prompt $" { fail "ptype Garply<int>" }
522 timeout { fail "(timeout) ptype Garply<int>" }
523 }
524
525 # ptype of nested template name
526
527 send_gdb "ptype Garply<Garply<char> >\n"
528 gdb_expect {
529 -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> >" }
530 -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> >" }
531 -re "$gdb_prompt $" { fail "ptype Garply<Garply<char> >" }
532 timeout { fail "(timeout) ptype Garply<Garply<char> >" }
533 }
534
535 # print out a function from a nested template name
536
537 send_gdb "print Garply<Garply<char> >::garply\n"
538 gdb_expect {
539 -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" }
540 -re ".*$gdb_prompt $" { fail "print Garply<Garply<char> >::garply" }
541 timeout { fail "print Garply<Garply<char> >::garply (timeout)" }
542 }
543
544 # djb - 06-03-2000
545 # Now should work fine
546 gdb_test "break Garply<Garply<char> >::garply" \
547 "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*"
This page took 0.042899 seconds and 5 git commands to generate.