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