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