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