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