1 |
1181 |
sfurman |
# Copyright 1992, 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
|
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
|
5 |
|
|
# the Free Software Foundation; either version 2 of the License, or
|
6 |
|
|
# (at your option) any later version.
|
7 |
|
|
#
|
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.
|
12 |
|
|
#
|
13 |
|
|
# You should have received a copy of the GNU General Public License
|
14 |
|
|
# along with this program; if not, write to the Free Software
|
15 |
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
|
|
|
17 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
18 |
|
|
# bug-gdb@prep.ai.mit.edu
|
19 |
|
|
|
20 |
|
|
# This file was written by Fred Fish. (fnf@cygnus.com)
|
21 |
|
|
# Adapted for g++ 3.0 ABI by Michael Chastain. (chastain@redhat.com)
|
22 |
|
|
|
23 |
|
|
if $tracelevel then {
|
24 |
|
|
strace $tracelevel
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
if { [skip_cplus_tests] } { continue }
|
28 |
|
|
|
29 |
|
|
set testfile "cplusfuncs"
|
30 |
|
|
set srcfile ${testfile}.cc
|
31 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
32 |
|
|
|
33 |
|
|
if { [get_compiler_info $binfile "c++"] } {
|
34 |
|
|
return -1
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
|
38 |
|
|
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
#
|
42 |
|
|
# g++ changed its ABI between 2.95 and 3.0. gdb has two demanglers
|
43 |
|
|
# for the two different styles. The two demanglers have some subtle
|
44 |
|
|
# discrepancies in their output.
|
45 |
|
|
#
|
46 |
|
|
# old demangler new demangler
|
47 |
|
|
# --- --------- --- ---------
|
48 |
|
|
# "operator, " "operator,"
|
49 |
|
|
# "char *" "char*"
|
50 |
|
|
# "int *" "int*"
|
51 |
|
|
# "long *" "long*"
|
52 |
|
|
# "void *" "void*"
|
53 |
|
|
# "foo &" "foo&"
|
54 |
|
|
# "unsigned int" "unsigned"
|
55 |
|
|
# "void" ""
|
56 |
|
|
#
|
57 |
|
|
# I probe for the forms in use.
|
58 |
|
|
# The defaults are for the v3 demangler (as of 2001-02-13).
|
59 |
|
|
#
|
60 |
|
|
|
61 |
|
|
set dm_operator_comma ","
|
62 |
|
|
set dm_type_char_star "char*"
|
63 |
|
|
set dm_type_char_star_quoted "char\\*"
|
64 |
|
|
set dm_type_foo_ref "foo&"
|
65 |
|
|
set dm_type_int_star "int*"
|
66 |
|
|
set dm_type_long_star "long*"
|
67 |
|
|
set dm_type_unsigned_int "unsigned"
|
68 |
|
|
set dm_type_void ""
|
69 |
|
|
set dm_type_void_star "void*"
|
70 |
|
|
|
71 |
|
|
proc probe_demangler { } {
|
72 |
|
|
global gdb_prompt
|
73 |
|
|
global dm_operator_comma
|
74 |
|
|
global dm_type_char_star
|
75 |
|
|
global dm_type_char_star_quoted
|
76 |
|
|
global dm_type_foo_ref
|
77 |
|
|
global dm_type_int_star
|
78 |
|
|
global dm_type_long_star
|
79 |
|
|
global dm_type_unsigned_int
|
80 |
|
|
global dm_type_void
|
81 |
|
|
global dm_type_void_star
|
82 |
|
|
|
83 |
|
|
send_gdb "print &'foo::operator,(foo&)'\n"
|
84 |
|
|
gdb_expect {
|
85 |
|
|
-re ".*foo::operator, \\(.*foo.*&.*\\).*\r\n$gdb_prompt $" {
|
86 |
|
|
# v2 demangler
|
87 |
|
|
set dm_operator_comma ", "
|
88 |
|
|
pass "detect dm_operator_comma"
|
89 |
|
|
}
|
90 |
|
|
-re ".*foo::operator,\\(.*foo.*&.*\\).*\r\n$gdb_prompt $" {
|
91 |
|
|
# v3 demangler
|
92 |
|
|
pass "detect dm_operator_comma"
|
93 |
|
|
}
|
94 |
|
|
-re ".*$gdb_prompt $" {
|
95 |
|
|
fail "detect dm_operator_comma"
|
96 |
|
|
}
|
97 |
|
|
timeout {
|
98 |
|
|
fail "detect dm_operator_comma"
|
99 |
|
|
}
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
send_gdb "print &'dm_type_char_star'\n"
|
103 |
|
|
gdb_expect {
|
104 |
|
|
-re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" {
|
105 |
|
|
# v2 demangler
|
106 |
|
|
set dm_type_char_star "char *"
|
107 |
|
|
set dm_type_char_star_quoted "char \\*"
|
108 |
|
|
pass "detect dm_type_char_star"
|
109 |
|
|
}
|
110 |
|
|
-re ".*dm_type_char_star\\(char\\*\\).*\r\n$gdb_prompt $" {
|
111 |
|
|
# v3 demangler
|
112 |
|
|
pass "detect dm_type_char_star"
|
113 |
|
|
}
|
114 |
|
|
-re ".*$gdb_prompt $" {
|
115 |
|
|
fail "detect dm_type_char_star"
|
116 |
|
|
}
|
117 |
|
|
timeout {
|
118 |
|
|
fail "detect dm_type_char_star (timeout)"
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
send_gdb "print &'dm_type_foo_ref'\n"
|
123 |
|
|
gdb_expect {
|
124 |
|
|
-re ".*dm_type_foo_ref\\(foo &\\).*\r\n$gdb_prompt $" {
|
125 |
|
|
# v2 demangler
|
126 |
|
|
set dm_type_foo_ref "foo &"
|
127 |
|
|
pass "detect dm_type_foo_ref"
|
128 |
|
|
}
|
129 |
|
|
-re ".*dm_type_foo_ref\\(foo&\\).*\r\n$gdb_prompt $" {
|
130 |
|
|
# v3 demangler
|
131 |
|
|
pass "detect dm_type_foo_ref"
|
132 |
|
|
}
|
133 |
|
|
-re ".*$gdb_prompt $" {
|
134 |
|
|
fail "detect dm_type_foo_ref"
|
135 |
|
|
}
|
136 |
|
|
timeout {
|
137 |
|
|
fail "detect dm_type_foo_ref (timeout)"
|
138 |
|
|
}
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
send_gdb "print &'dm_type_int_star'\n"
|
142 |
|
|
gdb_expect {
|
143 |
|
|
-re ".*dm_type_int_star\\(int \\*\\).*\r\n$gdb_prompt $" {
|
144 |
|
|
# v2 demangler
|
145 |
|
|
set dm_type_int_star "int *"
|
146 |
|
|
pass "detect dm_type_int_star"
|
147 |
|
|
}
|
148 |
|
|
-re ".*dm_type_int_star\\(int\\*\\).*\r\n$gdb_prompt $" {
|
149 |
|
|
# v3 demangler
|
150 |
|
|
pass "detect dm_type_int_star"
|
151 |
|
|
}
|
152 |
|
|
-re ".*$gdb_prompt $" {
|
153 |
|
|
fail "detect dm_type_int_star"
|
154 |
|
|
}
|
155 |
|
|
timeout {
|
156 |
|
|
fail "detect dm_type_int_star (timeout)"
|
157 |
|
|
}
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
send_gdb "print &'dm_type_long_star'\n"
|
161 |
|
|
gdb_expect {
|
162 |
|
|
-re ".*dm_type_long_star\\(long \\*\\).*\r\n$gdb_prompt $" {
|
163 |
|
|
# v2 demangler
|
164 |
|
|
set dm_type_long_star "long *"
|
165 |
|
|
pass "detect dm_type_long_star"
|
166 |
|
|
}
|
167 |
|
|
-re ".*dm_type_long_star\\(long\\*\\).*\r\n$gdb_prompt $" {
|
168 |
|
|
# v3 demangler
|
169 |
|
|
pass "detect dm_type_long_star"
|
170 |
|
|
}
|
171 |
|
|
-re ".*$gdb_prompt $" {
|
172 |
|
|
fail "detect dm_type_long_star"
|
173 |
|
|
}
|
174 |
|
|
timeout {
|
175 |
|
|
fail "detect dm_type_long_star (timeout)"
|
176 |
|
|
}
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
send_gdb "print &'dm_type_unsigned_int'\n"
|
180 |
|
|
gdb_expect {
|
181 |
|
|
-re ".*dm_type_unsigned_int\\(unsigned int\\).*\r\n$gdb_prompt $" {
|
182 |
|
|
# v2 demangler
|
183 |
|
|
set dm_type_unsigned_int "unsigned int"
|
184 |
|
|
pass "detect dm_type_unsigned_int"
|
185 |
|
|
}
|
186 |
|
|
-re ".*dm_type_unsigned_int\\(unsigned\\).*\r\n$gdb_prompt $" {
|
187 |
|
|
# v3 demangler
|
188 |
|
|
pass "detect dm_type_unsigned_int"
|
189 |
|
|
}
|
190 |
|
|
-re ".*$gdb_prompt $" {
|
191 |
|
|
fail "detect dm_type_unsigned_int"
|
192 |
|
|
}
|
193 |
|
|
timeout {
|
194 |
|
|
fail "detect dm_unsigned int (timeout)"
|
195 |
|
|
}
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
send_gdb "print &'dm_type_void'\n"
|
199 |
|
|
gdb_expect {
|
200 |
|
|
-re ".*dm_type_void\\(void\\).*\r\n$gdb_prompt $" {
|
201 |
|
|
# v2 demangler
|
202 |
|
|
set dm_type_void "void"
|
203 |
|
|
pass "detect dm_type_void"
|
204 |
|
|
}
|
205 |
|
|
-re ".*dm_type_void\\(\\).*\r\n$gdb_prompt $" {
|
206 |
|
|
# v3 demangler
|
207 |
|
|
pass "detect dm_type_void"
|
208 |
|
|
}
|
209 |
|
|
-re ".*$gdb_prompt $" {
|
210 |
|
|
fail "detect dm_type_void"
|
211 |
|
|
}
|
212 |
|
|
timeout {
|
213 |
|
|
fail "detect dm_type_void (timeout)"
|
214 |
|
|
}
|
215 |
|
|
}
|
216 |
|
|
|
217 |
|
|
send_gdb "print &'dm_type_void_star'\n"
|
218 |
|
|
gdb_expect {
|
219 |
|
|
-re ".*dm_type_void_star\\(void \\*\\).*\r\n$gdb_prompt $" {
|
220 |
|
|
# v2 demangler
|
221 |
|
|
set dm_type_void_star "void *"
|
222 |
|
|
pass "detect dm_type_void_star"
|
223 |
|
|
}
|
224 |
|
|
-re ".*dm_type_void_star\\(void\\*\\).*\r\n$gdb_prompt $" {
|
225 |
|
|
# v3 demangler
|
226 |
|
|
pass "detect dm_type_void_star"
|
227 |
|
|
}
|
228 |
|
|
-re ".*$gdb_prompt $" {
|
229 |
|
|
fail "detect dm_type_void_star"
|
230 |
|
|
}
|
231 |
|
|
timeout {
|
232 |
|
|
fail "detect dm_type_void_star (timeout)"
|
233 |
|
|
}
|
234 |
|
|
}
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
#
|
238 |
|
|
# Lookup a specific C++ function and print the demangled type.
|
239 |
|
|
# This form accepts the demangled type as a regexp.
|
240 |
|
|
#
|
241 |
|
|
|
242 |
|
|
proc info_func_regexp { name demangled } {
|
243 |
|
|
global gdb_prompt
|
244 |
|
|
|
245 |
|
|
send_gdb "info function $name\n"
|
246 |
|
|
gdb_expect {
|
247 |
|
|
-re ".*File .*:\r\n(class |)$demangled\r\n.*$gdb_prompt $" {
|
248 |
|
|
pass "info function for \"$name\""
|
249 |
|
|
}
|
250 |
|
|
-re ".*$gdb_prompt $" {
|
251 |
|
|
fail "info function for \"$name\""
|
252 |
|
|
}
|
253 |
|
|
timeout {
|
254 |
|
|
fail "info function for \"$name\" (timeout)"
|
255 |
|
|
}
|
256 |
|
|
}
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
#
|
260 |
|
|
# Lookup a specific C++ function and print the demangled type.
|
261 |
|
|
# This form accepts the demangled type as a literal string.
|
262 |
|
|
#
|
263 |
|
|
|
264 |
|
|
proc info_func { name demangled } {
|
265 |
|
|
info_func_regexp "$name" [string_to_regexp "$demangled"]
|
266 |
|
|
}
|
267 |
|
|
|
268 |
|
|
#
|
269 |
|
|
# Print the address of a function.
|
270 |
|
|
# This checks that I can lookup a fully qualified C++ function.
|
271 |
|
|
# This also checks the argument types on the return string.
|
272 |
|
|
#
|
273 |
|
|
|
274 |
|
|
proc print_addr_2 { name good } {
|
275 |
|
|
global gdb_prompt
|
276 |
|
|
global hex
|
277 |
|
|
|
278 |
|
|
set good_pattern [string_to_regexp $good]
|
279 |
|
|
|
280 |
|
|
send_gdb "print &'$name'\n"
|
281 |
|
|
gdb_expect {
|
282 |
|
|
-re ".* = .* $hex <$good_pattern>\r\n$gdb_prompt $" {
|
283 |
|
|
pass "print &'$name'"
|
284 |
|
|
}
|
285 |
|
|
-re ".*$gdb_prompt $" {
|
286 |
|
|
fail "print &'$name'"
|
287 |
|
|
}
|
288 |
|
|
timeout {
|
289 |
|
|
fail "print &'$name' (timeout)"
|
290 |
|
|
}
|
291 |
|
|
}
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
#
|
295 |
|
|
# Simple interfaces to print_addr_2.
|
296 |
|
|
#
|
297 |
|
|
|
298 |
|
|
proc print_addr { name } {
|
299 |
|
|
print_addr_2 "$name" "$name"
|
300 |
|
|
}
|
301 |
|
|
|
302 |
|
|
#
|
303 |
|
|
# Test name demangling for operators.
|
304 |
|
|
#
|
305 |
|
|
# The '(' at the end of each regex input pattern is so that we match only
|
306 |
|
|
# the one we are looking for. I.E. "operator&" would match both
|
307 |
|
|
# "operator&(foo &)" and "operator&&(foo &)".
|
308 |
|
|
#
|
309 |
|
|
# gdb-gnats bug gdb/18:
|
310 |
|
|
# "gdb can't parse "info func operator*" or "info func operator\*".
|
311 |
|
|
# The star in "operator*" is interpreted as a regexp, but the "\*"
|
312 |
|
|
# in "operator\*" is not a legal operator.
|
313 |
|
|
#
|
314 |
|
|
|
315 |
|
|
proc test_lookup_operator_functions {} {
|
316 |
|
|
global dm_operator_comma
|
317 |
|
|
global dm_type_char_star
|
318 |
|
|
global dm_type_char_star_quoted
|
319 |
|
|
global dm_type_foo_ref
|
320 |
|
|
global dm_type_void
|
321 |
|
|
global dm_type_void_star
|
322 |
|
|
|
323 |
|
|
# operator* requires quoting so that GDB does not treat it as a regexp.
|
324 |
|
|
info_func "operator\\*(" "void foo::operator*($dm_type_foo_ref);"
|
325 |
|
|
info_func "operator%(" "void foo::operator%($dm_type_foo_ref);"
|
326 |
|
|
info_func "operator-(" "void foo::operator-($dm_type_foo_ref);"
|
327 |
|
|
info_func "operator>>(" "void foo::operator>>($dm_type_foo_ref);"
|
328 |
|
|
info_func "operator!=(" "void foo::operator!=($dm_type_foo_ref);"
|
329 |
|
|
info_func "operator>(" "void foo::operator>($dm_type_foo_ref);"
|
330 |
|
|
info_func "operator>=(" "void foo::operator>=($dm_type_foo_ref);"
|
331 |
|
|
info_func "operator|(" "void foo::operator|($dm_type_foo_ref);"
|
332 |
|
|
info_func "operator&&(" "void foo::operator&&($dm_type_foo_ref);"
|
333 |
|
|
info_func "operator!(" "void foo::operator!($dm_type_void);"
|
334 |
|
|
info_func "operator++(" "void foo::operator++(int);"
|
335 |
|
|
info_func "operator=(" "void foo::operator=($dm_type_foo_ref);"
|
336 |
|
|
info_func "operator+=(" "void foo::operator+=($dm_type_foo_ref);"
|
337 |
|
|
# operator*= requires quoting so that GDB does not treat it as a regexp.
|
338 |
|
|
info_func "operator\\*=(" "void foo::operator*=($dm_type_foo_ref);"
|
339 |
|
|
info_func "operator%=(" "void foo::operator%=($dm_type_foo_ref);"
|
340 |
|
|
info_func "operator>>=(" "void foo::operator>>=($dm_type_foo_ref);"
|
341 |
|
|
info_func "operator|=(" "void foo::operator|=($dm_type_foo_ref);"
|
342 |
|
|
info_func "operator$dm_operator_comma\(" \
|
343 |
|
|
"void foo::operator$dm_operator_comma\($dm_type_foo_ref);"
|
344 |
|
|
info_func "operator/(" "void foo::operator/($dm_type_foo_ref);"
|
345 |
|
|
info_func "operator+(" "void foo::operator+($dm_type_foo_ref);"
|
346 |
|
|
info_func "operator<<(" "void foo::operator<<($dm_type_foo_ref);"
|
347 |
|
|
info_func "operator==(" "void foo::operator==($dm_type_foo_ref);"
|
348 |
|
|
info_func "operator<(" "void foo::operator<($dm_type_foo_ref);"
|
349 |
|
|
info_func "operator<=(" "void foo::operator<=($dm_type_foo_ref);"
|
350 |
|
|
info_func "operator&(" "void foo::operator&($dm_type_foo_ref);"
|
351 |
|
|
info_func "operator^(" "void foo::operator^($dm_type_foo_ref);"
|
352 |
|
|
info_func "operator||(" "void foo::operator||($dm_type_foo_ref);"
|
353 |
|
|
info_func "operator~(" "void foo::operator~($dm_type_void);"
|
354 |
|
|
info_func "operator--(" "void foo::operator--(int);"
|
355 |
|
|
info_func "operator->(" "foo *foo::operator->($dm_type_void);"
|
356 |
|
|
info_func "operator-=(" "void foo::operator-=($dm_type_foo_ref);"
|
357 |
|
|
info_func "operator/=(" "void foo::operator/=($dm_type_foo_ref);"
|
358 |
|
|
info_func "operator<<=(" "void foo::operator<<=($dm_type_foo_ref);"
|
359 |
|
|
info_func "operator&=(" "void foo::operator&=($dm_type_foo_ref);"
|
360 |
|
|
info_func "operator^=(" "void foo::operator^=($dm_type_foo_ref);"
|
361 |
|
|
# operator->* requires quoting so that GDB does not treat it as a regexp.
|
362 |
|
|
info_func "operator->\\*(" "void foo::operator->*($dm_type_foo_ref);"
|
363 |
|
|
|
364 |
|
|
# operator[] needs double backslashes, so that a single backslash
|
365 |
|
|
# will be sent to GDB, preventing the square brackets from being
|
366 |
|
|
# evaluated as a regular expression.
|
367 |
|
|
info_func "operator\\\[\\\](" "void foo::operator\[\]($dm_type_foo_ref);"
|
368 |
|
|
|
369 |
|
|
# These are gnarly because they might end with 'static'.
|
370 |
|
|
set dm_type_void_star_regexp [string_to_regexp $dm_type_void_star]
|
371 |
|
|
info_func_regexp "operator new(" "void \\*foo::operator new\\(.*\\)(| static);"
|
372 |
|
|
info_func_regexp "operator delete(" "void foo::operator delete\\($dm_type_void_star_regexp\\)(| static);"
|
373 |
|
|
|
374 |
|
|
info_func "operator int(" "int foo::operator int($dm_type_void);"
|
375 |
|
|
info_func "operator()(" "void foo::operator()($dm_type_foo_ref);"
|
376 |
|
|
info_func "operator $dm_type_char_star_quoted\(" \
|
377 |
|
|
"char *foo::operator $dm_type_char_star\($dm_type_void);"
|
378 |
|
|
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
|
382 |
|
|
proc test_paddr_operator_functions {} {
|
383 |
|
|
global hex
|
384 |
|
|
global hp_aCC_compiler
|
385 |
|
|
global dm_operator_comma
|
386 |
|
|
global dm_type_char_star
|
387 |
|
|
global dm_type_foo_ref
|
388 |
|
|
global dm_type_long_star
|
389 |
|
|
global dm_type_unsigned_int
|
390 |
|
|
global dm_type_void
|
391 |
|
|
global dm_type_void_star
|
392 |
|
|
|
393 |
|
|
print_addr "foo::operator*($dm_type_foo_ref)"
|
394 |
|
|
print_addr "foo::operator%($dm_type_foo_ref)"
|
395 |
|
|
print_addr "foo::operator-($dm_type_foo_ref)"
|
396 |
|
|
print_addr "foo::operator>>($dm_type_foo_ref)"
|
397 |
|
|
print_addr "foo::operator!=($dm_type_foo_ref)"
|
398 |
|
|
print_addr "foo::operator>($dm_type_foo_ref)"
|
399 |
|
|
print_addr "foo::operator>=($dm_type_foo_ref)"
|
400 |
|
|
print_addr "foo::operator|($dm_type_foo_ref)"
|
401 |
|
|
print_addr "foo::operator&&($dm_type_foo_ref)"
|
402 |
|
|
print_addr "foo::operator!($dm_type_void)"
|
403 |
|
|
print_addr "foo::operator++(int)"
|
404 |
|
|
print_addr "foo::operator=($dm_type_foo_ref)"
|
405 |
|
|
print_addr "foo::operator+=($dm_type_foo_ref)"
|
406 |
|
|
print_addr "foo::operator*=($dm_type_foo_ref)"
|
407 |
|
|
print_addr "foo::operator%=($dm_type_foo_ref)"
|
408 |
|
|
print_addr "foo::operator>>=($dm_type_foo_ref)"
|
409 |
|
|
print_addr "foo::operator|=($dm_type_foo_ref)"
|
410 |
|
|
print_addr "foo::operator$dm_operator_comma\($dm_type_foo_ref)"
|
411 |
|
|
print_addr "foo::operator/($dm_type_foo_ref)"
|
412 |
|
|
print_addr "foo::operator+($dm_type_foo_ref)"
|
413 |
|
|
print_addr "foo::operator<<($dm_type_foo_ref)"
|
414 |
|
|
print_addr "foo::operator==($dm_type_foo_ref)"
|
415 |
|
|
print_addr "foo::operator<($dm_type_foo_ref)"
|
416 |
|
|
print_addr "foo::operator<=($dm_type_foo_ref)"
|
417 |
|
|
print_addr "foo::operator&($dm_type_foo_ref)"
|
418 |
|
|
print_addr "foo::operator^($dm_type_foo_ref)"
|
419 |
|
|
print_addr "foo::operator||($dm_type_foo_ref)"
|
420 |
|
|
print_addr "foo::operator~($dm_type_void)"
|
421 |
|
|
print_addr "foo::operator--(int)"
|
422 |
|
|
print_addr "foo::operator->($dm_type_void)"
|
423 |
|
|
print_addr "foo::operator-=($dm_type_foo_ref)"
|
424 |
|
|
print_addr "foo::operator/=($dm_type_foo_ref)"
|
425 |
|
|
print_addr "foo::operator<<=($dm_type_foo_ref)"
|
426 |
|
|
print_addr "foo::operator&=($dm_type_foo_ref)"
|
427 |
|
|
print_addr "foo::operator^=($dm_type_foo_ref)"
|
428 |
|
|
print_addr "foo::operator->*($dm_type_foo_ref)"
|
429 |
|
|
print_addr "foo::operator\[\]($dm_type_foo_ref)"
|
430 |
|
|
print_addr "foo::operator()($dm_type_foo_ref)"
|
431 |
|
|
|
432 |
|
|
gdb_test "print &'foo::operator new'" \
|
433 |
|
|
" = .* $hex "
|
434 |
|
|
if { !$hp_aCC_compiler } {
|
435 |
|
|
print_addr "foo::operator delete($dm_type_void_star)"
|
436 |
|
|
} else {
|
437 |
|
|
gdb_test "print &'foo::operator delete($dm_type_void_star) static'" \
|
438 |
|
|
" = .*(0x\[0-9a-f\]+|) "
|
439 |
|
|
}
|
440 |
|
|
|
441 |
|
|
print_addr "foo::operator int($dm_type_void)"
|
442 |
|
|
print_addr "foo::operator $dm_type_char_star\($dm_type_void)"
|
443 |
|
|
}
|
444 |
|
|
|
445 |
|
|
#
|
446 |
|
|
# Test overloaded functions (1 arg).
|
447 |
|
|
#
|
448 |
|
|
|
449 |
|
|
proc test_paddr_overloaded_functions {} {
|
450 |
|
|
global dm_type_unsigned_int
|
451 |
|
|
global dm_type_void
|
452 |
|
|
|
453 |
|
|
print_addr "overload1arg($dm_type_void)"
|
454 |
|
|
print_addr "overload1arg(char)"
|
455 |
|
|
print_addr "overload1arg(signed char)"
|
456 |
|
|
print_addr "overload1arg(unsigned char)"
|
457 |
|
|
print_addr "overload1arg(short)"
|
458 |
|
|
print_addr "overload1arg(unsigned short)"
|
459 |
|
|
print_addr "overload1arg(int)"
|
460 |
|
|
print_addr "overload1arg($dm_type_unsigned_int)"
|
461 |
|
|
print_addr "overload1arg(long)"
|
462 |
|
|
print_addr "overload1arg(unsigned long)"
|
463 |
|
|
print_addr "overload1arg(float)"
|
464 |
|
|
print_addr "overload1arg(double)"
|
465 |
|
|
|
466 |
|
|
print_addr "overloadargs(int)"
|
467 |
|
|
print_addr "overloadargs(int, int)"
|
468 |
|
|
print_addr "overloadargs(int, int, int)"
|
469 |
|
|
print_addr "overloadargs(int, int, int, int)"
|
470 |
|
|
print_addr "overloadargs(int, int, int, int, int)"
|
471 |
|
|
print_addr "overloadargs(int, int, int, int, int, int)"
|
472 |
|
|
print_addr "overloadargs(int, int, int, int, int, int, int)"
|
473 |
|
|
print_addr "overloadargs(int, int, int, int, int, int, int, int)"
|
474 |
|
|
print_addr "overloadargs(int, int, int, int, int, int, int, int, int)"
|
475 |
|
|
print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int)"
|
476 |
|
|
print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int, int)"
|
477 |
|
|
}
|
478 |
|
|
|
479 |
|
|
proc test_paddr_hairy_functions {} {
|
480 |
|
|
global gdb_prompt
|
481 |
|
|
global hex
|
482 |
|
|
global dm_type_char_star
|
483 |
|
|
global dm_type_int_star
|
484 |
|
|
global dm_type_long_star
|
485 |
|
|
|
486 |
|
|
print_addr_2 "hairyfunc1" "hairyfunc1(int)"
|
487 |
|
|
print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))"
|
488 |
|
|
print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))"
|
489 |
|
|
print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))"
|
490 |
|
|
|
491 |
|
|
# gdb-gnats bug gdb/19:
|
492 |
|
|
# "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
|
493 |
|
|
print_addr_2 "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))"
|
494 |
|
|
print_addr_2 "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))"
|
495 |
|
|
print_addr_2 "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))"
|
496 |
|
|
}
|
497 |
|
|
|
498 |
|
|
proc do_tests {} {
|
499 |
|
|
global prms_id
|
500 |
|
|
global bug_id
|
501 |
|
|
global subdir
|
502 |
|
|
global objdir
|
503 |
|
|
global srcdir
|
504 |
|
|
global binfile
|
505 |
|
|
global gdb_prompt
|
506 |
|
|
|
507 |
|
|
set prms_id 0
|
508 |
|
|
set bug_id 0
|
509 |
|
|
|
510 |
|
|
# Start with a fresh gdb.
|
511 |
|
|
|
512 |
|
|
gdb_exit
|
513 |
|
|
gdb_start
|
514 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
515 |
|
|
gdb_load $binfile
|
516 |
|
|
|
517 |
|
|
send_gdb "set language c++\n"
|
518 |
|
|
gdb_expect -re "$gdb_prompt $"
|
519 |
|
|
send_gdb "set width 0\n"
|
520 |
|
|
gdb_expect -re "$gdb_prompt $"
|
521 |
|
|
|
522 |
|
|
# Get the debug format for the compiled test case. If that
|
523 |
|
|
# format is DWARF 1 then just skip all the tests since none of
|
524 |
|
|
# them will pass.
|
525 |
|
|
|
526 |
|
|
if [ runto_main] then {
|
527 |
|
|
get_debug_format
|
528 |
|
|
if [ setup_xfail_format "DWARF 1" ] then {
|
529 |
|
|
fail "C++ tests skipped due to limited C++ support in DWARF 1 debug format"
|
530 |
|
|
return
|
531 |
|
|
}
|
532 |
|
|
clear_xfail "*-*-*"
|
533 |
|
|
}
|
534 |
|
|
|
535 |
|
|
probe_demangler
|
536 |
|
|
test_paddr_overloaded_functions
|
537 |
|
|
test_paddr_operator_functions
|
538 |
|
|
test_paddr_hairy_functions
|
539 |
|
|
test_lookup_operator_functions
|
540 |
|
|
}
|
541 |
|
|
|
542 |
|
|
do_tests
|