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