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