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