* gdb.cp/abstract-origin.exp: Use standard_testfile.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / cplusfuncs.exp
CommitLineData
0b302171
JB
1# Copyright 1992, 1997, 1999, 2001-2004, 2007-2012 Free Software
2# 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 17# This file was written by Fred Fish. (fnf@cygnus.com)
99f78f56 18# Adapted for g++ 3.0 ABI by Michael Chastain. (chastain@redhat.com)
c906108c 19
d4f3574e 20if { [skip_cplus_tests] } { continue }
c906108c 21
f5f3a911 22standard_testfile .cc
c906108c 23
4c93b1db 24if { [get_compiler_info "c++"] } {
a0b3c4fd
JM
25 return -1
26}
27
f5f3a911
TT
28if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
29 return -1
d4f3574e
SS
30}
31
c906108c 32#
99f78f56
MC
33# g++ changed its ABI between 2.95 and 3.0. gdb has two demanglers
34# for the two different styles. The two demanglers have some subtle
35# discrepancies in their output.
36#
37# old demangler new demangler
38# --- --------- --- ---------
39# "operator, " "operator,"
40# "char *" "char*"
41# "int *" "int*"
42# "long *" "long*"
43# "void *" "void*"
44# "foo &" "foo&"
45# "unsigned int" "unsigned"
46# "void" ""
47#
48# I probe for the forms in use.
49# The defaults are for the v3 demangler (as of 2001-02-13).
c906108c
SS
50#
51
99f78f56
MC
52set dm_operator_comma ","
53set dm_type_char_star "char*"
3f08ced9 54set dm_type_char_star_quoted "char\\*"
99f78f56
MC
55set dm_type_foo_ref "foo&"
56set dm_type_int_star "int*"
57set dm_type_long_star "long*"
58set dm_type_unsigned_int "unsigned"
a4216f37 59set dm_type_void "void"
99f78f56
MC
60set dm_type_void_star "void*"
61
cec808ec
KS
62# Some other vagaries of GDB's type printing machinery. The integer types
63# may have unsigned before or after their length, and may have "int"
64# appended. The char* conversion operator may have name "char*" even if
65# the type is "char *", because the name comes from the debug information
66# and the type from GDB. Function types may not see through typedefs.
67
68set dm_type_short "short"
69set dm_type_long "long"
70set dm_type_unsigned_short "unsigned short"
71set dm_type_unsigned_long "unsigned long"
72set dm_operator_char_star "char*"
73set dm_operator_char_star_quoted "char\\*"
74set dm_type_typedef 0
75
99f78f56 76proc probe_demangler { } {
c906108c 77 global gdb_prompt
99f78f56 78 global dm_operator_comma
cec808ec
KS
79 global dm_operator_char_star
80 global dm_operator_char_star_quoted
99f78f56 81 global dm_type_char_star
3f08ced9 82 global dm_type_char_star_quoted
99f78f56
MC
83 global dm_type_foo_ref
84 global dm_type_int_star
85 global dm_type_long_star
86 global dm_type_unsigned_int
87 global dm_type_void
88 global dm_type_void_star
cec808ec
KS
89 global dm_type_short
90 global dm_type_unsigned_short
91 global dm_type_long
92 global dm_type_unsigned_long
93 global dm_type_typedef
99f78f56 94
f8d3bf8f
MS
95 gdb_test_multiple "print &foo::operator,(foo&)" \
96 "detect dm_operator_comma" {
97 -re ".*foo::operator, \\(.*foo.*&.*\\).*\r\n$gdb_prompt $" {
98 # v2 demangler
99 set dm_operator_comma ", "
100 pass "detect dm_operator_comma"
101 }
102 -re ".*foo::operator,\\(.*foo.*&.*\\).*\r\n$gdb_prompt $" {
103 # v3 demangler
104 pass "detect dm_operator_comma"
105 }
106 }
107
108 gdb_test_multiple "print &foo::operator char*($dm_type_void)" \
109 "detect dm_operator_char_star" {
110 -re ".*foo::operator char \\*\\(void\\).*\r\n$gdb_prompt $" {
111 # v2 demangler or GDB type printer
112 set dm_operator_char_star "char *"
113 set dm_operator_char_star_quoted "char \\*"
114 pass "detect dm_operator_char_star"
115 }
116 -re ".*foo::operator char\\*\\(\\).*\r\n$gdb_prompt $" {
117 # v3 demangler
118 pass "detect dm_operator_char_star"
119 }
120 }
121
122 gdb_test_multiple "print &dm_type_char_star" \
123 "detect dm_type_char_star" {
124 -re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" {
125 # v2 demangler
126 set dm_type_char_star "char *"
127 set dm_type_char_star_quoted "char \\*"
128 pass "detect dm_type_char_star"
129 }
130 -re ".*dm_type_char_star\\(char\\*\\).*\r\n$gdb_prompt $" {
131 # v3 demangler
132 pass "detect dm_type_char_star"
133 }
134 }
135
136 gdb_test_multiple "print &dm_type_foo_ref" \
137 "detect dm_type_foo_ref" {
138 -re ".*dm_type_foo_ref\\(foo &\\).*\r\n$gdb_prompt $" {
139 # v2 demangler
140 set dm_type_foo_ref "foo &"
141 pass "detect dm_type_foo_ref"
142 }
143 -re ".*dm_type_foo_ref\\(foo&\\).*\r\n$gdb_prompt $" {
144 # v3 demangler
145 pass "detect dm_type_foo_ref"
146 }
147 }
148
149 gdb_test_multiple "print &dm_type_int_star" \
150 "detect dm_type_int_star" {
151 -re ".*dm_type_int_star\\(int \\*\\).*\r\n$gdb_prompt $" {
152 # v2 demangler
153 set dm_type_int_star "int *"
154 pass "detect dm_type_int_star"
155 }
156 -re ".*dm_type_int_star\\(int\\*\\).*\r\n$gdb_prompt $" {
157 # v3 demangler
158 pass "detect dm_type_int_star"
159 }
160 }
161
162 gdb_test_multiple "print &dm_type_long_star" \
163 "detect dm_type_long_star" {
164 -re ".*dm_type_long_star\\(long \\*\\).*\r\n$gdb_prompt $" {
165 # v2 demangler
166 set dm_type_long_star "long *"
167 pass "detect dm_type_long_star"
168 }
169 -re ".*dm_type_long_star\\(long\\*\\).*\r\n$gdb_prompt $" {
170 # v3 demangler
171 pass "detect dm_type_long_star"
172 }
173 -re ".*dm_type_long_star\\(long int \\*\\).*\r\n$gdb_prompt $" {
174 # GCC v3 and GDB's type printer
175 set dm_type_long_star "long int *"
176 pass "detect dm_type_long_star"
177 }
178 }
179
180 gdb_test_multiple "print &dm_type_unsigned_int" \
181 "detect dm_type_unsigned_int" {
182 -re ".*dm_type_unsigned_int\\(unsigned int\\).*\r\n$gdb_prompt $" {
183 # v2 demangler
184 set dm_type_unsigned_int "unsigned int"
185 pass "detect dm_type_unsigned_int"
186 }
187 -re ".*dm_type_unsigned_int\\(unsigned\\).*\r\n$gdb_prompt $" {
188 # v3 demangler
189 pass "detect dm_type_unsigned_int"
190 }
191 }
192
193 gdb_test_multiple "print &dm_type_void" \
194 "detect dm_type_void" {
195 -re ".*dm_type_void\\(void\\).*\r\n$gdb_prompt $" {
196 # v2 demangler
197 set dm_type_void "void"
198 pass "detect dm_type_void"
199 }
200 -re ".*dm_type_void\\(\\).*\r\n$gdb_prompt $" {
201 # v3 demangler
202 pass "detect dm_type_void"
203 }
204 }
205
206 gdb_test_multiple "print &dm_type_void_star" \
207 "detect dm_type_void_star" {
208 -re ".*dm_type_void_star\\(void \\*\\).*\r\n$gdb_prompt $" {
209 # v2 demangler
210 set dm_type_void_star "void *"
211 pass "detect dm_type_void_star"
212 }
213 -re ".*dm_type_void_star\\(void\\*\\).*\r\n$gdb_prompt $" {
214 # v3 demangler
215 pass "detect dm_type_void_star"
216 }
217 }
218
219 gdb_test_multiple "print &dm_type_short" \
220 "detect dm_type_short" {
221 -re ".*dm_type_short\\(short\\).*\r\n$gdb_prompt $" {
222 # v2 and v3 demanglers
223 pass "detect dm_type_short"
224 }
225 -re ".*dm_type_short\\(short int\\).*\r\n$gdb_prompt $" {
226 # GDB type printer
227 set dm_type_short "short int"
228 pass "detect dm_type_short"
229 }
230 }
231
232 gdb_test_multiple "print &dm_type_unsigned_short" \
233 "detect dm_type_unsigned_short" {
234 -re ".*dm_type_unsigned_short\\(unsigned short\\).*\r\n$gdb_prompt $" {
235 # v2 and v3 demanglers
236 pass "detect dm_type_unsigned_short"
237 }
238 -re ".*dm_type_unsigned_short\\(short unsigned int\\).*\r\n$gdb_prompt $" {
239 # GDB type printer
240 set dm_type_unsigned_short "short unsigned int"
241 pass "detect dm_type_unsigned_short"
242 }
243 }
244
245 gdb_test_multiple "print &dm_type_long" \
246 "detect dm_type_long" {
247 -re ".*dm_type_long\\(long\\).*\r\n$gdb_prompt $" {
248 # v2 and v3 demanglers
249 pass "detect dm_type_long"
250 }
251 -re ".*dm_type_long\\(long int\\).*\r\n$gdb_prompt $" {
252 # GDB type printer
253 set dm_type_long "long int"
254 pass "detect dm_type_long"
255 }
256 }
257
258 gdb_test_multiple "print &dm_type_unsigned_long" \
259 "detect dm_type_unsigned_long" {
260 -re ".*dm_type_unsigned_long\\(unsigned long\\).*\r\n$gdb_prompt $" {
261 # v2 and v3 demanglers
262 pass "detect dm_type_unsigned_long"
263 }
264 -re ".*dm_type_unsigned_long\\(long unsigned int\\).*\r\n$gdb_prompt $" {
265 # GDB type printer
266 set dm_type_unsigned_long "long unsigned int"
267 pass "detect dm_type_unsigned_long"
268 }
269 }
270
271 gdb_test_multiple "print &dm_type_typedef" \
272 "detect dm_type_typedef" {
273 -re ".*dm_type_typedef\\(int\\).*\r\n$gdb_prompt $" {
274 # v2 and v3 demanglers
275 pass "detect dm_type_typedef"
276 }
277 -re ".*dm_type_typedef\\(myint\\).*\r\n$gdb_prompt $" {
278 # GDB type printer
279 set dm_type_typedef 1
280 pass "detect dm_type_typedef"
281 }
99f78f56 282 }
99f78f56
MC
283}
284
285#
286# Lookup a specific C++ function and print the demangled type.
287# This form accepts the demangled type as a regexp.
288#
289
290proc info_func_regexp { name demangled } {
291 global gdb_prompt
292
8c2fb5de 293 regsub {\\\(void\\\)} $demangled {\(\)} demangled
f8d3bf8f
MS
294
295 gdb_test "info function $name" \
296 "File .*:\r\n(class|)${demangled}.*" \
297 "info function for \"$name\""
c906108c
SS
298}
299
300#
99f78f56
MC
301# Lookup a specific C++ function and print the demangled type.
302# This form accepts the demangled type as a literal string.
c906108c
SS
303#
304
99f78f56
MC
305proc info_func { name demangled } {
306 info_func_regexp "$name" [string_to_regexp "$demangled"]
307}
308
309#
310# Print the address of a function.
311# This checks that I can lookup a fully qualified C++ function.
312# This also checks the argument types on the return string.
d2b29e01
DC
313
314# Note: carlton/2003-01-16: If you modify this, make a corresponding
315# modification to print_addr_2_kfail.
99f78f56
MC
316
317proc print_addr_2 { name good } {
c906108c
SS
318 global gdb_prompt
319 global hex
320
99f78f56
MC
321 set good_pattern [string_to_regexp $good]
322
f8d3bf8f
MS
323 gdb_test "print &$name" \
324 ".* = .* $hex <$good_pattern>"
c906108c
SS
325}
326
d2b29e01
DC
327# NOTE: carlton/2003-01-16: hairyfunc5-6 fail on GCC 3.x (for at least
328# x=1 and x=2.1). So I'm modifying print_addr_2 to accept a failure
329# condition. FIXME: It would be nice if the failure condition were
330# conditional on the compiler version, but I'm not sufficiently
331# motivated. I did hardwire in the versions of char * and int *,
332# which will give some compiler-specificity to the failure.
333
334proc print_addr_2_kfail { name good bad bugid } {
335 global gdb_prompt
336 global hex
337
338 set good_pattern [string_to_regexp $good]
339 set bad_pattern [string_to_regexp $bad]
340
f8d3bf8f 341 gdb_test_multiple "print &$name" "print &$name" {
d2b29e01 342 -re ".* = .* $hex <$good_pattern>\r\n$gdb_prompt $" {
a4216f37 343 pass "print &$name"
d2b29e01
DC
344 }
345 -re ".* = .* $hex <$bad_pattern>\r\n$gdb_prompt $" {
a4216f37 346 kfail $bugid "print &$name"
d2b29e01 347 }
d2b29e01
DC
348 }
349}
350
99f78f56
MC
351#
352# Simple interfaces to print_addr_2.
353#
354
355proc print_addr { name } {
8c2fb5de 356 regsub {\(void\)} $name {()} expected
a4216f37
KS
357 if {[string first "::" $name] == -1} {
358 # C function -- must be qutoed
359 set name "'$name'"
360 }
361 print_addr_2 "$name" $expected
99f78f56
MC
362}
363
c906108c
SS
364#
365# Test name demangling for operators.
366#
367# The '(' at the end of each regex input pattern is so that we match only
368# the one we are looking for. I.E. "operator&" would match both
369# "operator&(foo &)" and "operator&&(foo &)".
370#
99f78f56
MC
371# gdb-gnats bug gdb/18:
372# "gdb can't parse "info func operator*" or "info func operator\*".
373# The star in "operator*" is interpreted as a regexp, but the "\*"
374# in "operator\*" is not a legal operator.
375#
c906108c
SS
376
377proc test_lookup_operator_functions {} {
99f78f56 378 global dm_operator_comma
cec808ec 379 global dm_operator_char_star
99f78f56 380 global dm_type_char_star
cec808ec 381 global dm_operator_char_star_quoted
99f78f56
MC
382 global dm_type_foo_ref
383 global dm_type_void
384 global dm_type_void_star
c906108c 385
3f08ced9
MS
386 # operator* requires quoting so that GDB does not treat it as a regexp.
387 info_func "operator\\*(" "void foo::operator*($dm_type_foo_ref);"
99f78f56
MC
388 info_func "operator%(" "void foo::operator%($dm_type_foo_ref);"
389 info_func "operator-(" "void foo::operator-($dm_type_foo_ref);"
390 info_func "operator>>(" "void foo::operator>>($dm_type_foo_ref);"
391 info_func "operator!=(" "void foo::operator!=($dm_type_foo_ref);"
392 info_func "operator>(" "void foo::operator>($dm_type_foo_ref);"
393 info_func "operator>=(" "void foo::operator>=($dm_type_foo_ref);"
394 info_func "operator|(" "void foo::operator|($dm_type_foo_ref);"
395 info_func "operator&&(" "void foo::operator&&($dm_type_foo_ref);"
396 info_func "operator!(" "void foo::operator!($dm_type_void);"
397 info_func "operator++(" "void foo::operator++(int);"
398 info_func "operator=(" "void foo::operator=($dm_type_foo_ref);"
399 info_func "operator+=(" "void foo::operator+=($dm_type_foo_ref);"
3f08ced9
MS
400 # operator*= requires quoting so that GDB does not treat it as a regexp.
401 info_func "operator\\*=(" "void foo::operator*=($dm_type_foo_ref);"
99f78f56
MC
402 info_func "operator%=(" "void foo::operator%=($dm_type_foo_ref);"
403 info_func "operator>>=(" "void foo::operator>>=($dm_type_foo_ref);"
404 info_func "operator|=(" "void foo::operator|=($dm_type_foo_ref);"
405 info_func "operator$dm_operator_comma\(" \
406 "void foo::operator$dm_operator_comma\($dm_type_foo_ref);"
407 info_func "operator/(" "void foo::operator/($dm_type_foo_ref);"
408 info_func "operator+(" "void foo::operator+($dm_type_foo_ref);"
409 info_func "operator<<(" "void foo::operator<<($dm_type_foo_ref);"
410 info_func "operator==(" "void foo::operator==($dm_type_foo_ref);"
411 info_func "operator<(" "void foo::operator<($dm_type_foo_ref);"
412 info_func "operator<=(" "void foo::operator<=($dm_type_foo_ref);"
413 info_func "operator&(" "void foo::operator&($dm_type_foo_ref);"
414 info_func "operator^(" "void foo::operator^($dm_type_foo_ref);"
415 info_func "operator||(" "void foo::operator||($dm_type_foo_ref);"
416 info_func "operator~(" "void foo::operator~($dm_type_void);"
417 info_func "operator--(" "void foo::operator--(int);"
418 info_func "operator->(" "foo *foo::operator->($dm_type_void);"
419 info_func "operator-=(" "void foo::operator-=($dm_type_foo_ref);"
420 info_func "operator/=(" "void foo::operator/=($dm_type_foo_ref);"
421 info_func "operator<<=(" "void foo::operator<<=($dm_type_foo_ref);"
422 info_func "operator&=(" "void foo::operator&=($dm_type_foo_ref);"
423 info_func "operator^=(" "void foo::operator^=($dm_type_foo_ref);"
3f08ced9
MS
424 # operator->* requires quoting so that GDB does not treat it as a regexp.
425 info_func "operator->\\*(" "void foo::operator->*($dm_type_foo_ref);"
99f78f56 426
3f08ced9
MS
427 # operator[] needs double backslashes, so that a single backslash
428 # will be sent to GDB, preventing the square brackets from being
429 # evaluated as a regular expression.
430 info_func "operator\\\[\\\](" "void foo::operator\[\]($dm_type_foo_ref);"
99f78f56
MC
431
432 # These are gnarly because they might end with 'static'.
433 set dm_type_void_star_regexp [string_to_regexp $dm_type_void_star]
434 info_func_regexp "operator new(" "void \\*foo::operator new\\(.*\\)(| static);"
435 info_func_regexp "operator delete(" "void foo::operator delete\\($dm_type_void_star_regexp\\)(| static);"
436
437 info_func "operator int(" "int foo::operator int($dm_type_void);"
438 info_func "operator()(" "void foo::operator()($dm_type_foo_ref);"
cec808ec
KS
439 info_func "operator $dm_operator_char_star_quoted\(" \
440 "char *foo::operator $dm_operator_char_star\($dm_type_void);"
99f78f56 441
c906108c
SS
442}
443
444
445proc test_paddr_operator_functions {} {
446 global hex
a0b3c4fd 447 global hp_aCC_compiler
99f78f56
MC
448 global dm_operator_comma
449 global dm_type_char_star
450 global dm_type_foo_ref
451 global dm_type_long_star
452 global dm_type_unsigned_int
453 global dm_type_void
454 global dm_type_void_star
cec808ec 455 global dm_operator_char_star
99f78f56
MC
456
457 print_addr "foo::operator*($dm_type_foo_ref)"
458 print_addr "foo::operator%($dm_type_foo_ref)"
459 print_addr "foo::operator-($dm_type_foo_ref)"
460 print_addr "foo::operator>>($dm_type_foo_ref)"
461 print_addr "foo::operator!=($dm_type_foo_ref)"
462 print_addr "foo::operator>($dm_type_foo_ref)"
463 print_addr "foo::operator>=($dm_type_foo_ref)"
464 print_addr "foo::operator|($dm_type_foo_ref)"
465 print_addr "foo::operator&&($dm_type_foo_ref)"
466 print_addr "foo::operator!($dm_type_void)"
467 print_addr "foo::operator++(int)"
468 print_addr "foo::operator=($dm_type_foo_ref)"
469 print_addr "foo::operator+=($dm_type_foo_ref)"
470 print_addr "foo::operator*=($dm_type_foo_ref)"
471 print_addr "foo::operator%=($dm_type_foo_ref)"
472 print_addr "foo::operator>>=($dm_type_foo_ref)"
473 print_addr "foo::operator|=($dm_type_foo_ref)"
474 print_addr "foo::operator$dm_operator_comma\($dm_type_foo_ref)"
475 print_addr "foo::operator/($dm_type_foo_ref)"
476 print_addr "foo::operator+($dm_type_foo_ref)"
477 print_addr "foo::operator<<($dm_type_foo_ref)"
478 print_addr "foo::operator==($dm_type_foo_ref)"
479 print_addr "foo::operator<($dm_type_foo_ref)"
480 print_addr "foo::operator<=($dm_type_foo_ref)"
481 print_addr "foo::operator&($dm_type_foo_ref)"
482 print_addr "foo::operator^($dm_type_foo_ref)"
483 print_addr "foo::operator||($dm_type_foo_ref)"
484 print_addr "foo::operator~($dm_type_void)"
485 print_addr "foo::operator--(int)"
486 print_addr "foo::operator->($dm_type_void)"
487 print_addr "foo::operator-=($dm_type_foo_ref)"
488 print_addr "foo::operator/=($dm_type_foo_ref)"
489 print_addr "foo::operator<<=($dm_type_foo_ref)"
490 print_addr "foo::operator&=($dm_type_foo_ref)"
491 print_addr "foo::operator^=($dm_type_foo_ref)"
492 print_addr "foo::operator->*($dm_type_foo_ref)"
493 print_addr "foo::operator\[\]($dm_type_foo_ref)"
494 print_addr "foo::operator()($dm_type_foo_ref)"
c906108c 495
a4216f37 496 gdb_test "print &foo::operator new" \
99f78f56 497 " = .* $hex <foo::operator new\\(.*\\)(| static)>"
a4216f37
KS
498 gdb_test "print &foo::operator new\[\]" \
499 " = .* $hex <foo::operator new\\\[\\\]\\(.*\\)(| static)>"
a0b3c4fd 500 if { !$hp_aCC_compiler } {
99f78f56 501 print_addr "foo::operator delete($dm_type_void_star)"
a4216f37 502 print_addr "foo::operator delete[]($dm_type_void_star)"
a0b3c4fd 503 } else {
99f78f56 504 gdb_test "print &'foo::operator delete($dm_type_void_star) static'" \
a0b3c4fd
JM
505 " = .*(0x\[0-9a-f\]+|) <foo::operator delete.*>"
506 }
99f78f56
MC
507
508 print_addr "foo::operator int($dm_type_void)"
cec808ec 509 print_addr "foo::operator $dm_operator_char_star\($dm_type_void)"
c906108c
SS
510}
511
512#
513# Test overloaded functions (1 arg).
514#
515
516proc test_paddr_overloaded_functions {} {
99f78f56
MC
517 global dm_type_unsigned_int
518 global dm_type_void
cec808ec
KS
519 global dm_type_short
520 global dm_type_unsigned_short
521 global dm_type_long
522 global dm_type_unsigned_long
99f78f56
MC
523
524 print_addr "overload1arg($dm_type_void)"
525 print_addr "overload1arg(char)"
526 print_addr "overload1arg(signed char)"
527 print_addr "overload1arg(unsigned char)"
cec808ec
KS
528 print_addr "overload1arg($dm_type_short)"
529 print_addr "overload1arg($dm_type_unsigned_short)"
99f78f56
MC
530 print_addr "overload1arg(int)"
531 print_addr "overload1arg($dm_type_unsigned_int)"
cec808ec
KS
532 print_addr "overload1arg($dm_type_long)"
533 print_addr "overload1arg($dm_type_unsigned_long)"
99f78f56
MC
534 print_addr "overload1arg(float)"
535 print_addr "overload1arg(double)"
536
537 print_addr "overloadargs(int)"
538 print_addr "overloadargs(int, int)"
539 print_addr "overloadargs(int, int, int)"
540 print_addr "overloadargs(int, int, int, int)"
541 print_addr "overloadargs(int, int, int, int, int)"
542 print_addr "overloadargs(int, int, int, int, int, int)"
543 print_addr "overloadargs(int, int, int, int, int, int, int)"
544 print_addr "overloadargs(int, int, int, int, int, int, int, int)"
545 print_addr "overloadargs(int, int, int, int, int, int, int, int, int)"
546 print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int)"
547 print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int, int)"
c906108c
SS
548}
549
550proc test_paddr_hairy_functions {} {
99f78f56
MC
551 global gdb_prompt
552 global hex
553 global dm_type_char_star
554 global dm_type_int_star
555 global dm_type_long_star
cec808ec 556 global dm_type_typedef
99f78f56
MC
557
558 print_addr_2 "hairyfunc1" "hairyfunc1(int)"
cec808ec
KS
559
560 if {$dm_type_typedef == 0} {
561 print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))"
562 print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))"
563 print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))"
564
565 # gdb-gnats bug gdb/19:
566 # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
567 print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19"
568 print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19"
569 print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19"
570 } else {
571 print_addr_2 "hairyfunc2" "hairyfunc2(PFPc_i)"
572 print_addr_2 "hairyfunc3" "hairyfunc3(PFPFPl_s_i)"
573 print_addr_2 "hairyfunc4" "hairyfunc4(PFPFPc_s_i)"
574
575 # gdb-gnats bug gdb/19:
576 # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
577 print_addr_2 "hairyfunc5" "hairyfunc5(PFPc_PFl_i)"
578 print_addr_2 "hairyfunc6" "hairyfunc6(PFPi_PFl_i)"
579 print_addr_2 "hairyfunc7" "hairyfunc7(PFPFPc_i_PFl_i)"
580 }
c906108c
SS
581}
582
583proc do_tests {} {
c906108c 584 global binfile
11ef0d76 585 global dm_type_int_star
c906108c 586
f5f3a911 587 clean_restart $binfile
c906108c 588
f8d3bf8f 589 gdb_test_no_output "set width 0"
c906108c 590
40f235b7 591 runto_main
c906108c 592
1cf0e11f 593 gdb_test_no_output "set language c++"
99f78f56 594 probe_demangler
c906108c
SS
595 test_paddr_overloaded_functions
596 test_paddr_operator_functions
597 test_paddr_hairy_functions
598 test_lookup_operator_functions
11ef0d76
KS
599
600 # A regression test on errors involving operators
601 gdb_test "list foo::operator $dm_type_int_star" \
dcf9f4ab 602 "Function \"foo::operator [string_to_regexp $dm_type_int_star]\" not defined\\."
c906108c
SS
603}
604
605do_tests
This page took 1.662859 seconds and 4 git commands to generate.