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