Commit | Line | Data |
---|---|---|
9b254dd1 | 1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2007, |
4c38e0a4 | 2 | # 2008, 2009, 2010 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 {} { | |
c906108c SS |
205 | global subdir |
206 | global objdir | |
207 | global srcdir | |
208 | global binfile | |
209 | global gdb_prompt | |
c906108c | 210 | |
c906108c SS |
211 | |
212 | # Start with a fresh gdb. | |
213 | ||
214 | gdb_exit | |
215 | gdb_start | |
216 | gdb_reinitialize_dir $srcdir/$subdir | |
217 | gdb_load $binfile | |
218 | ||
eae06beb JB |
219 | # Change multiple-symbols to "ask" in order to get the multiple-choice |
220 | # menu when breaking on overloaded methods. | |
221 | gdb_test "set multiple-symbols ask" "" | |
222 | ||
40f235b7 | 223 | runto_main |
c906108c SS |
224 | |
225 | test_ptype_of_templates | |
226 | test_template_breakpoints | |
3fe8f3b3 | 227 | test_template_typedef |
c906108c SS |
228 | |
229 | if [ runto_main] { | |
230 | test_template_calls | |
231 | } | |
232 | } | |
233 | ||
234 | do_tests | |
235 | ||
a0b3c4fd JM |
236 | |
237 | # More tests for different kinds of template parameters, | |
238 | # templates with partial specializations, nested templates, etc. | |
239 | # These have been tested only with HP aCC. They probably won't | |
240 | # work with other compilers because of differences in mangling | |
241 | # schemes. | |
242 | # Added by Satish Pai <pai@apollo.hp.com> 1997-09-25 | |
e6d71bf3 DB |
243 | # As of 2000-06-03, C++ support has been improved to the point that g++ can |
244 | # pass all of theses, excluding what appears to be one that exposes a stabs bug. - djb | |
a0b3c4fd | 245 | |
e6d71bf3 DB |
246 | # I don't know how HP could be passing these tests without this. They |
247 | # weren't breakpointing past a point where the below expressions were | |
248 | # initialized in the actual source. - djb | |
249 | ||
250 | send_gdb "b 770\n" | |
251 | gdb_expect { | |
252 | -re ".*$gdb_prompt $" | |
253 | } | |
254 | send_gdb "c\n" | |
255 | gdb_expect { | |
256 | -re ".*$gdb_prompt $" | |
257 | } | |
a0b3c4fd JM |
258 | send_gdb "print fint\n" |
259 | gdb_expect { | |
260 | -re "\\$\[0-9\]* = \\{x = 0, t = 0\\}\r\n$gdb_prompt $" { pass "print fint" } | |
261 | -re "$gdb_prompt $" { fail "print fint" } | |
262 | timeout { fail "(timeout) print fint" } | |
263 | } | |
264 | ||
265 | send_gdb "print fvpchar\n" | |
266 | gdb_expect { | |
267 | -re "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}\r\n$gdb_prompt $" { pass "print fvpchar" } | |
268 | -re "$gdb_prompt $" { fail "print fvpchar" } | |
269 | timeout { fail "(timeout) print fvpchar" } | |
270 | } | |
271 | ||
272 | # Template Foo<T> | |
273 | ||
dd14ab43 DC |
274 | # Neither stabs nor DWARF-2 contains type information about templates |
275 | # (as opposed to instantiations of templates), so in those | |
276 | # circumstances we expect GDB to not find a symbol. HP has a debug | |
277 | # format that contains more info, though, so it's also correct to | |
278 | # print out template info. (This affects several subsequent tests as | |
279 | # well.) | |
280 | ||
281 | # NOTE: carlton/2003-02-26: However, because of a bug in the way GDB | |
282 | # handles nested types, we don't get this right in the DWARF-2 case. | |
283 | ||
a0b3c4fd JM |
284 | send_gdb "ptype Foo\n" |
285 | gdb_expect { | |
dd14ab43 DC |
286 | -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" } |
287 | -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" } | |
288 | -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 $" | |
289 | { # GCC 3.1, DWARF-2 output. | |
290 | kfail "gdb/57" "ptype Foo" } | |
291 | -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" | |
292 | { # GCC 2.95.3, stabs+ output. | |
293 | pass "ptype Foo" } | |
294 | -re "$gdb_prompt $" { fail "ptype Foo" } | |
295 | timeout { fail "(timeout) ptype Foo" } | |
a0b3c4fd | 296 | } |
dd14ab43 | 297 | # -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 |
298 | |
299 | # ptype Foo<int> | |
300 | ||
301 | send_gdb "ptype fint\n" | |
302 | gdb_expect { | |
e6d71bf3 | 303 | -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 | 304 | -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 |
305 | -re "$gdb_prompt $" { fail "ptype fint" } |
306 | timeout { fail "(timeout) ptype fint" } | |
307 | } | |
308 | ||
309 | # ptype Foo<char> | |
310 | ||
311 | send_gdb "ptype fchar\n" | |
312 | gdb_expect { | |
e6d71bf3 | 313 | -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 | 314 | -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 |
315 | -re "$gdb_prompt $" { fail "ptype fchar" } |
316 | timeout { fail "(timeout) ptype fchar" } | |
317 | } | |
318 | ||
319 | # ptype Foo<volatile char *> | |
320 | ||
321 | send_gdb "ptype fvpchar\n" | |
322 | gdb_expect { | |
5178b9d6 | 323 | -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 | 324 | -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 |
325 | -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 $" { |
326 | kfail "gdb/1512" "ptype fvpchar" | |
327 | } | |
a0b3c4fd JM |
328 | -re "$gdb_prompt $" { fail "ptype fvpchar" } |
329 | timeout { fail "(timeout) ptype fvpchar" } | |
330 | } | |
331 | ||
332 | # print a function from Foo<volatile char *> | |
333 | ||
0b71dc91 DC |
334 | # This test is sensitive to whitespace matching, so we'll do it twice, |
335 | # varying the spacing, because of PR gdb/33. | |
336 | ||
a0b3c4fd JM |
337 | send_gdb "print Foo<volatile char *>::foo\n" |
338 | gdb_expect { | |
71c25dea | 339 | -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 | 340 | -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $" |
85ca1584 | 341 | { |
71c25dea TT |
342 | # This used to be a kfail gdb/33 and then kfail gdb/931. |
343 | fail "print Foo<volatile char *>::foo" | |
85ca1584 | 344 | } |
0b71dc91 DC |
345 | -re "$gdb_prompt $" { fail "print Foo<volatile char *>::foo" } |
346 | timeout { fail "(timeout) print Foo<volatile char *>::foo" } | |
347 | } | |
348 | ||
349 | send_gdb "print Foo<volatile char*>::foo\n" | |
350 | gdb_expect { | |
71c25dea | 351 | -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 | 352 | -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $" |
85ca1584 | 353 | { |
71c25dea TT |
354 | # This used to be a kfail gdb/33 and then kfail gdb/931. |
355 | fail "print Foo<volatile char*>::foo" | |
85ca1584 | 356 | } |
0b71dc91 DC |
357 | -re "$gdb_prompt $" { fail "print Foo<volatile char*>::foo" } |
358 | timeout { fail "(timeout) print Foo<volatile char*>::foo" } | |
a0b3c4fd JM |
359 | } |
360 | ||
361 | # Template Bar<T, int> | |
362 | ||
e6d71bf3 | 363 | # same as Foo for g++ |
a0b3c4fd JM |
364 | send_gdb "ptype Bar\n" |
365 | gdb_expect { | |
dd14ab43 DC |
366 | -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" } |
367 | -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 | 368 | -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 |
369 | { # GCC 3.1, DWARF-2 output. |
370 | kfail "gdb/57" "ptype Bar" } | |
371 | -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $" | |
372 | { # GCC 2.95.3, stabs+ output. | |
373 | pass "ptype Bar" } | |
374 | -re "$gdb_prompt $" { fail "ptype Bar" } | |
375 | timeout { fail "(timeout) ptype Bar" } | |
a0b3c4fd JM |
376 | } |
377 | ||
378 | ||
379 | # ptype Bar<int,33> | |
5a2a0a20 | 380 | |
a0b3c4fd JM |
381 | send_gdb "ptype bint\n" |
382 | gdb_expect { | |
3e5fc8d2 | 383 | -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 | 384 | -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 |
385 | -re "$gdb_prompt $" { fail "ptype bint" } |
386 | timeout { fail "(timeout) ptype bint" } | |
387 | } | |
388 | ||
389 | # ptype Bar<int, (4>3)> | |
390 | ||
391 | send_gdb "ptype bint2\n" | |
392 | gdb_expect { | |
3e5fc8d2 | 393 | -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 | 394 | -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 |
395 | -re "$gdb_prompt $" { fail "ptype bint2" } |
396 | timeout { fail "(timeout) ptype bint2" } | |
397 | } | |
398 | ||
399 | # Template Baz<T, char> | |
400 | ||
e6d71bf3 | 401 | # Same as Foo, for g++ |
a0b3c4fd JM |
402 | send_gdb "ptype Baz\n" |
403 | gdb_expect { | |
32c70722 MC |
404 | -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" } |
405 | -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" } | |
406 | -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 |
407 | { # GCC 3.1, DWARF-2 output. |
408 | kfail "gdb/57" "ptype Baz" } | |
54d90d35 | 409 | -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 |
410 | { # GCC 3.x, DWARF-2 output, running into gdb/57 and gdb/1512. |
411 | kfail "gdb/57" "ptype Baz" } | |
dd14ab43 DC |
412 | -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $" |
413 | { # GCC 2.95.3, stabs+ output. | |
414 | pass "ptype Baz" } | |
415 | -re "$gdb_prompt $" { fail "ptype Baz" } | |
416 | timeout { fail "(timeout) ptype Baz" } | |
a0b3c4fd JM |
417 | } |
418 | ||
419 | ||
420 | # ptype Baz<int, 's'> | |
421 | ||
422 | send_gdb "ptype bazint\n" | |
423 | gdb_expect { | |
3e5fc8d2 | 424 | -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 | 425 | -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 |
426 | -re "$gdb_prompt $" { fail "ptype bazint" } |
427 | timeout { fail "(timeout) ptype bazint" } | |
428 | } | |
429 | ||
430 | # ptype Baz<char, 'a'> | |
431 | ||
432 | send_gdb "ptype bazint2\n" | |
433 | gdb_expect { | |
3e5fc8d2 | 434 | -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 | 435 | -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 |
436 | -re "$gdb_prompt $" { fail "ptype bazint2" } |
437 | timeout { fail "(timeout) ptype bazint2" } | |
438 | } | |
439 | ||
440 | # Template Qux<T, int (*f)(int) > | |
e6d71bf3 | 441 | # Same as Foo for g++ |
a0b3c4fd JM |
442 | send_gdb "ptype Qux\n" |
443 | gdb_expect { | |
32c70722 MC |
444 | -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" } |
445 | -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" } | |
446 | -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 |
447 | { # GCC 3.1, DWARF-2 output. |
448 | kfail "gdb/57" "ptype Qux" } | |
3e5fc8d2 DC |
449 | -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 $" |
450 | { # GCC 3.x, DWARF-2 output; gdb/57 + gdb/1512. | |
451 | kfail "gdb/57" "ptype Qux" } | |
dd14ab43 DC |
452 | -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $" |
453 | { # GCC 2.95.3, stabs+ output. | |
454 | pass "ptype Qux" } | |
455 | -re "$gdb_prompt $" { fail "ptype Qux" } | |
456 | timeout { fail "(timeout) ptype Qux" } | |
a0b3c4fd JM |
457 | } |
458 | ||
459 | # pt Qux<int,&string> | |
460 | ||
461 | send_gdb "ptype quxint\n" | |
462 | gdb_expect { | |
44ae2f6a MC |
463 | -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" } |
464 | -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 | 465 | -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 | 466 | -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 |
467 | kfail "gdb/1512" "ptype quxint" |
468 | } | |
a0b3c4fd JM |
469 | -re "$gdb_prompt $" { fail "ptype quxint" } |
470 | timeout { fail "(timeout) ptype quxint" } | |
471 | } | |
472 | ||
473 | # pt Qux<char,0> | |
474 | ||
475 | # commented out this as quxint2 declaration was commented out in | |
476 | # templates.exp -- ovidiu | |
477 | # send_gdb "ptype quxint2\n" | |
478 | # gdb_expect { | |
479 | # -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" } | |
480 | # -re "$gdb_prompt $" { fail "ptype quxint2" } | |
481 | # timeout { fail "(timeout) ptype quxint2" } | |
482 | # } | |
483 | ||
484 | # Template Spec<T1, T2> | |
485 | ||
e6d71bf3 | 486 | # Same as Foo for g++ |
a0b3c4fd JM |
487 | send_gdb "ptype Spec\n" |
488 | gdb_expect { | |
dd14ab43 DC |
489 | -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" } |
490 | -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 | 491 | -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 |
492 | { # GCC 3.1, DWARF-2 output. |
493 | kfail "gdb/57" "ptype Spec" } | |
494 | -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $" | |
495 | { # GCC 2.95.3, stabs+ output. | |
496 | pass "ptype Spec" } | |
497 | -re "$gdb_prompt $" { fail "ptype Spec" } | |
498 | timeout { fail "(timeout) ptype Spec" } | |
a0b3c4fd JM |
499 | } |
500 | ||
501 | # pt Spec<char,0> | |
502 | ||
503 | send_gdb "ptype siip\n" | |
504 | gdb_expect { | |
3e5fc8d2 | 505 | -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 | 506 | -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 |
507 | -re "$gdb_prompt $" { fail "ptype siip" } |
508 | timeout { fail "(timeout) ptype siip" } | |
509 | } | |
510 | ||
511 | # pt Garply<int> | |
512 | ||
513 | send_gdb "ptype Garply<int>\n" | |
514 | gdb_expect { | |
e6d71bf3 | 515 | -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 | 516 | -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 |
517 | -re "$gdb_prompt $" { fail "ptype Garply<int>" } |
518 | timeout { fail "(timeout) ptype Garply<int>" } | |
519 | } | |
520 | ||
521 | # ptype of nested template name | |
522 | ||
523 | send_gdb "ptype Garply<Garply<char> >\n" | |
524 | gdb_expect { | |
e6d71bf3 | 525 | -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 | 526 | -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 |
527 | -re "$gdb_prompt $" { fail "ptype Garply<Garply<char> >" } |
528 | timeout { fail "(timeout) ptype Garply<Garply<char> >" } | |
529 | } | |
530 | ||
531 | # print out a function from a nested template name | |
532 | ||
533 | send_gdb "print Garply<Garply<char> >::garply\n" | |
534 | gdb_expect { | |
5330f2db | 535 | -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 |
536 | -re ".*$gdb_prompt $" { fail "print Garply<Garply<char> >::garply" } |
537 | timeout { fail "print Garply<Garply<char> >::garply (timeout)" } | |
538 | } | |
539 | ||
e6d71bf3 DB |
540 | # djb - 06-03-2000 |
541 | # Now should work fine | |
b598bfda DJ |
542 | gdb_test "break Garply<Garply<char> >::garply" \ |
543 | "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*" |