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