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