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