From: Keith Seitz Date: Tue, 9 Mar 2010 18:08:05 +0000 (+0000) Subject: * gdb.cp/cp-relocate.exp: Remove single-quoting of C++ methods. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cec808ecec654eb5c43ca6281ee5e08aca3f2a7b;p=binutils-gdb.git * gdb.cp/cp-relocate.exp: Remove single-quoting of C++ methods. * gdb.cp/cplusfuncs.cc (dm_type_short): New function. (dm_type_long): New function. (dm_type_unsigned_short): New function. (dm_type_unsigned_long): New function. (myint): New typedef. * gdb.cp/cplusfuncs.exp (probe_demangler): Add tests for short, long, unsigned shor and long, operator char*, and typedef. (test_lookup_operator_functions): Add operator char* test. (test_paddr_operator_functions): Likewise. (test_paddr_overloaded_functions): Use probe values for short, long, and unsigned short and long. (test_paddr_hairy_functions): If the demangler probe detected gdb type printers, "expect" them. Otherwise "expect" the v2 or v3 demangler. * gdb.cp/expand-sals.exp: Backtrace may contain class names. * gdb.cp/member-ptr.exp: Refine expected result for "print pmf" and "print null_pmf". Add test "ptype a.*pmf". * gdb.cp/overload.exp: Allow optional "int" to appear with "short" and "long". * gdb.cp/ovldbreak.exp: Use append to construct super-duper long expect value for men_overload1arg. Allow "int" to appear with "short" and "long". When testing "info break", add argument for main (void). Also allow "int" to appear with "short" and "long". Ditto with "unsigned" and "long long". * gdb.java/jmain.exp: Do not enclose methods names in single quotes. * gdb.java/jmisc.exp: Likewise. * gdb.java/jprint.exp: Likewise. * gdb.python/py-symbol.exp: Update expected "linkage_name" value. From Jan Kratochvil : * gdb.cp/exception.exp (backtrace after first throw) (backtrace after second throw): Allow a namespace before __cxa_throw. (backtrace after first catch, backtrace after second catch): Allow a namespace before __cxa_begin_catch. * gdb.cp/cpexprs.exp: New file. * gdb.cp/cpexprs.cc: New file. From Daniel Jacobowitz * gdb.cp/cpexprs.exp (escape): Delete. Change all callers to use string_to_regexp. (ctor, dtor): New functions. Use them to match constructor and destructor function types. (Top level): Use runto_main. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 3efd2be14f1..baba6eb79f7 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,54 @@ +2010-03-08 Keith Seitz + + * gdb.cp/cp-relocate.exp: Remove single-quoting of C++ methods. + * gdb.cp/cplusfuncs.cc (dm_type_short): New function. + (dm_type_long): New function. + (dm_type_unsigned_short): New function. + (dm_type_unsigned_long): New function. + (myint): New typedef. + * gdb.cp/cplusfuncs.exp (probe_demangler): Add tests for short, + long, unsigned shor and long, operator char*, and typedef. + (test_lookup_operator_functions): Add operator char* test. + (test_paddr_operator_functions): Likewise. + (test_paddr_overloaded_functions): Use probe values for + short, long, and unsigned short and long. + (test_paddr_hairy_functions): If the demangler probe detected + gdb type printers, "expect" them. Otherwise "expect" the v2 or v3 + demangler. + * gdb.cp/expand-sals.exp: Backtrace may contain class names. + * gdb.cp/member-ptr.exp: Refine expected result for "print pmf" + and "print null_pmf". + Add test "ptype a.*pmf". + * gdb.cp/overload.exp: Allow optional "int" to appear with + "short" and "long". + * gdb.cp/ovldbreak.exp: Use append to construct super-duper + long expect value for men_overload1arg. + Allow "int" to appear with "short" and "long". + When testing "info break", add argument for main (void). + Also allow "int" to appear with "short" and "long". + Ditto with "unsigned" and "long long". + * gdb.java/jmain.exp: Do not enclose methods names in single + quotes. + * gdb.java/jmisc.exp: Likewise. + * gdb.java/jprint.exp: Likewise. + * gdb.python/py-symbol.exp: Update expected "linkage_name" value. + + From Jan Kratochvil : + * gdb.cp/exception.exp (backtrace after first throw) + (backtrace after second throw): Allow a namespace before __cxa_throw. + (backtrace after first catch, backtrace after second catch): Allow + a namespace before __cxa_begin_catch. + + * gdb.cp/cpexprs.exp: New file. + * gdb.cp/cpexprs.cc: New file. + + From Daniel Jacobowitz + * gdb.cp/cpexprs.exp (escape): Delete. Change all callers + to use string_to_regexp. + (ctor, dtor): New functions. Use them to match constructor + and destructor function types. + (Top level): Use runto_main. + 2010-03-05 Tom Tromey * gdb.python/py-prettyprint.py (pp_nullstr.to_string): Use diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp index f81a21207c0..30d362af85d 100644 --- a/gdb/testsuite/gdb.cp/cp-relocate.exp +++ b/gdb/testsuite/gdb.cp/cp-relocate.exp @@ -30,7 +30,7 @@ proc get_func_address { func } { global gdb_prompt hex set rfunc [string_to_regexp $func] - gdb_test_multiple "print '${func}'" "get address of ${func}" { + gdb_test_multiple "print ${func}" "get address of ${func}" { -re "\\\$\[0-9\]+ = \\{.*\\} (0|($hex) <${rfunc}>)\[\r\n\]+${gdb_prompt} $" { # $1 = {int ()} 0x24 # But if the function is at zero, the name may be omitted. @@ -130,7 +130,7 @@ gdb_test "add-symbol-file ${binfile} 0 -s ${func1_sec} 0x10000 -s ${func2_sec} 0 "y" # Make sure the function addresses were updated. -gdb_test "break *'$func1_name'" \ +gdb_test "break *$func1_name" \ "Breakpoint $decimal at 0x1....: file .*" -gdb_test "break *'$func2_name'" \ +gdb_test "break *$func2_name" \ "Breakpoint $decimal at 0x2....: file .*" diff --git a/gdb/testsuite/gdb.cp/cpexprs.cc b/gdb/testsuite/gdb.cp/cpexprs.cc new file mode 100644 index 00000000000..2bca4cd73ac --- /dev/null +++ b/gdb/testsuite/gdb.cp/cpexprs.cc @@ -0,0 +1,431 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + + Contributed by Red Hat, originally written by Keith Seitz. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include +#include + +// Forward decls +class base; +class derived; + +// A simple template with specializations +template +class tclass +{ +public: + void do_something () { } // tclass::do_something +}; + +template <> +void tclass::do_something () { } // tclass::do_something + +template <> +void tclass::do_something () { } // tclass::do_something + +template<> +void tclass::do_something () { } // tclass::do_something + +template<> +void tclass::do_something () { } // tclass::do_something + +// A simple template with multiple template parameters +template +void flubber (void) // flubber +{ + A a; + B b; + C c; + D d; + E e; + + ++a; + ++b; + ++c; + ++d; + ++e; +} + +// Some contrived policies +template +struct operation_1 +{ + static void function (void) { } // operation_1::function +}; + +template +struct operation_2 +{ + static void function (void) { } // operation_2::function +}; + +template +struct operation_3 +{ + static void function (void) { } // operation_3::function +}; + +template +struct operation_4 +{ + static void function (void) { } // operation_4::function +}; + +// A policy-based class w/ and w/o default policy +template +class policy : public Policy +{ +public: + policy (T obj) : obj_ (obj) { } // policy::policy + +private: + T obj_; +}; + +template > +class policyd : public Policy +{ +public: + policyd (T obj) : obj_ (obj) { } // policyd::policyd + ~policyd (void) { } // policyd::~policyd + +private: + T obj_; +}; + +typedef policy > policy1; +typedef policy > policy2; +typedef policy > policy3; +typedef policy > policy4; + +typedef policyd policyd1; +typedef policyd policyd2; +typedef policyd policyd3; +typedef policyd policyd4; +typedef policyd > policyd5; + +class fluff { }; +static fluff *g_fluff = new fluff (); + +class base +{ +protected: + int foo_; + +public: + base (void) : foo_ (42) { } // base::base(void) + base (int foo) : foo_ (foo) { } // base::base(int) + ~base (void) { } // base::~base + + // Some overloaded methods + int overload (void) const { return 0; } // base::overload(void) const + int overload (int i) const { return 1; } // base::overload(int) const + int overload (short s) const { return 2; } // base::overload(short) const + int overload (long l) const { return 3; } // base::overload(long) const + int overload (char* a) const { return 4; } // base::overload(char*) const + int overload (base& b) const { return 5; } // base::overload(base&) const + + // Operators + int operator+ (base const& o) const // base::operator+ + { return foo_ + o.foo_; } + + base operator++ (void) // base::operator++ + { ++foo_; return *this; } + + base operator+=(base const& o) // base::operator+= + { foo_ += o.foo_; return *this; } + + int operator- (base const& o) const // base::operator- + { return foo_ - o.foo_; } + + base operator-- (void) // base::operator-- + { --foo_; return *this; } + + base operator-= (base const& o) // base::operator-= + { foo_ -= o.foo_; return *this; } + + int operator* (base const& o) const // base::operator* + { return foo_ * o.foo_; } + + base operator*= (base const& o) // base::operator*= + { foo_ *= o.foo_; return *this; } + + int operator/ (base const& o) const // base::operator/ + { return foo_ / o.foo_; } + + base operator/= (base const& o) // base::operator/= + { foo_ /= o.foo_; return *this; } + + int operator% (base const& o) const // base::operator% + { return foo_ % o.foo_; } + + base operator%= (base const& o) // base::operator%= + { foo_ %= o.foo_; return *this; } + + bool operator< (base const& o) const // base::operator< + { return foo_ < o.foo_; } + + bool operator<= (base const& o) const // base::operator<= + { return foo_ <= o.foo_; } + + bool operator> (base const& o) const // base::operator> + { return foo_ > o.foo_; } + + bool operator>= (base const& o) const // base::operator>= + { return foo_ >= o.foo_; } + + bool operator!= (base const& o) const // base::operator!= + { return foo_ != o.foo_; } + + bool operator== (base const& o) const // base::operator== + { return foo_ == o.foo_; } + + bool operator! (void) const // base::operator! + { return !foo_; } + + bool operator&& (base const& o) const // base::operator&& + { return foo_ && o.foo_; } + + bool operator|| (base const& o) const // base::operator|| + { return foo_ || o.foo_; } + + int operator<< (int value) const // base::operator<< + { return foo_ << value; } + + base operator<<= (int value) // base::operator<<= + { foo_ <<= value; return *this; } + + int operator>> (int value) const // base::operator>> + { return foo_ >> value; } + + base operator>>= (int value) // base::operator>>= + { foo_ >>= value; return *this; } + + int operator~ (void) const // base::operator~ + { return ~foo_; } + + int operator& (base const& o) const // base::operator& + { return foo_ & o.foo_; } + + base operator&= (base const& o) // base::operator&= + { foo_ &= o.foo_; return *this; } + + int operator| (base const& o) const // base::operator| + { return foo_ | o.foo_; } + + base operator|= (base const& o) // base::operator|= + { foo_ |= o.foo_; return *this; } + + int operator^ (base const& o) const // base::operator^ + { return foo_ ^ o.foo_; } + + base operator^= (base const& o) // base::operator^= + { foo_ ^= o.foo_; return *this; } + + base operator= (base const& o) // base::operator= + { foo_ = o.foo_; return *this; } + + void operator() (void) const // base::operator() + { return; } + + int operator[] (int idx) const // base::operator[] + { return idx; } + + void* operator new (size_t size) throw () // base::operator new + { return malloc (size); } + + void operator delete (void* ptr) // base::operator delete + { free (ptr); } + + void* operator new[] (size_t size) throw () // base::operator new[] + { return malloc (size); } + + void operator delete[] (void* ptr) // base::operator delete[] + { free (ptr); } + + base const* operator-> (void) const // base::opeartor-> + { return this; } + + int operator->* (base const& b) const // base::operator->* + { return foo_ * b.foo_; } + + operator char* () const { return const_cast ("hello"); } // base::operator char* + operator int () const { return 21; } // base::operator int + operator fluff* () const { return new fluff (); } // base::operator fluff* + operator fluff** () const { return &g_fluff; } // base::operator fluff** +}; + +class base1 : public virtual base +{ +public: + base1 (void) : foo_ (21) { } // base1::base1(void) + base1 (int a) : foo_(a) { } // base1::base1(int) + void a_function (void) const { } // base1::a_function + +protected: + int foo_; +}; + +class base2 : public virtual base +{ +public: + base2 () : foo_ (3) { } // base2::base2 + +protected: + void a_function (void) const { } // base2::a_function + int foo_; +}; + +class derived : public base1, public base2 +{ + public: + derived(void) : foo_ (4) { } // derived::derived + void a_function (void) const // derived::a_function + { + this->base1::a_function (); + this->base2::a_function (); + } + + protected: + int foo_; +}; + +int +main (int argc, char* argv[]) // main +{ // main + derived d; + void (derived::*pfunc) (void) const = &derived::a_function; + (d.*pfunc) (); + + base a (1), b (3), c (8); + (void) a.overload (); + (void) a.overload (static_cast (0)); + (void) a.overload (static_cast (0)); + (void) a.overload (static_cast (0)); + (void) a.overload (static_cast (0)); + (void) a.overload (a); + + int r; + r = b + c; + ++a; + a += b; + r = b - c; + --a; + a -= b; + r = b * c; + a *= b; + r = b / c; + a /= b; + r = b % c; + a %= b; + bool x = (b < c); + x = (b <= c); + x = (b > c); + x = (b >= c); + x = (b != c); + x = (b == c); + x = (!b); + x = (b && c); + x = (b || c); + r = b << 2; + a <<= 1; + r = b >> 2; + a >>= 1; + r = ~b; + r = b & c; + a &= c; + r = b | c; + a |= c; + r = b ^ c; + a ^= c; + a = c; + a (); + int i = a[3]; + derived* f = new derived (); + derived* g = new derived[3]; + delete f; + delete[] g; + a->overload (); + r = a->*b; + + tclass char_tclass; + tclass int_tclass; + tclass short_tclass; + tclass long_tclass; + tclass base_tclass; + char_tclass.do_something (); + int_tclass.do_something (); + short_tclass.do_something (); + long_tclass.do_something (); + base_tclass.do_something (); + + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + + policy1 p1 (1); + p1.function (); + policy2 p2 (2); + p2.function (); + policy3 p3 (3); + p3.function (); + policy4 p4 (4); + p4.function (); + + policyd1 pd1 (5); + pd1.function (); + policyd2 pd2 (6); + pd2.function (); + policyd3 pd3 (7); + pd3.function (); + policyd4 pd4 (d); + pd4.function (); + policyd5 pd5 (int_tclass); + pd5.function (); + + base1 b1 (3); + + r = a; + char* str = a; + fluff* flp = a; + fluff** flpp = a; +} + diff --git a/gdb/testsuite/gdb.cp/cpexprs.exp b/gdb/testsuite/gdb.cp/cpexprs.exp new file mode 100644 index 00000000000..60747631138 --- /dev/null +++ b/gdb/testsuite/gdb.cp/cpexprs.exp @@ -0,0 +1,724 @@ +# cpexprs.exp - C++ expressions tests +# +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +# +# Contributed by Red Hat, originally written by Keith Seitz. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. + +# A helper proc which sets a breakpoint at FUNC and attempts to +# run to the breakpoint. +proc test_breakpoint {func} { + global DEC + + # Restart every time + if {![runto_main]} { + perror "could not run to main when attempting to break at $func" + } else { + gdb_breakpoint "$func" + set i [expr {[string last : $func] + 1}] + set efunc [string_to_regexp [string range $func $i end]] + gdb_test "continue" \ + "Continuing.\r\n\r\nBreakpoint $DEC+,.*$efunc.*" \ + "continue to $func" + } +} + +# Add a function to the list of tested functions +# FUNC is the name of the function (which will be passed to gdb commands) +# TYPE is the type of the function, as expected from the "print" command +# PRINT is the name of the function, as expected result of the print command +# *OR* "-", indicating that FUNC should be used (needed for virtual/inherited +# funcs) +# LST is either the expected result of the list command (the comment from +# the source code) *OR* "-", in which case FUNC will be used +# +# Usage: +# add NAME TYPE PRINT LST +# add NAME TYPE PRINT - +proc add {func type print lst} { + global all_functions CONVAR ADDR + + set all_functions($func,type) $type + if {$print == "-"} { + set print $func + } + + # An exception: since gdb canonicalizes C++ output, + # "(void)" must be mutated to "()". + regsub {\(void\)} $print {()} print + + set all_functions($func,print) \ + "$CONVAR = {[string_to_regexp $type]} $ADDR <[string_to_regexp $print].*>" + if {$lst == "-"} { + set lst "$func" + } + set all_functions($func,list) ".*// [string_to_regexp $lst]" +} + +proc get {func cmd} { + global all_functions + return $all_functions($func,$cmd) +} + +# Returns a list of function names for a given command +proc get_functions {cmd} { + global all_functions + set result {} + foreach i [array names all_functions *,$cmd] { + if {$all_functions($i) != ""} { + set idx [string last , $i] + if {$idx != -1} { + lappend result [string range $i 0 [expr {$idx - 1}]] + } + } + } + + return [lsort $result] +} + +# Some convenience variables for this test +set DEC {[0-9]}; # a decimal number +set HEX {[0-9a-fA-F]}; # a hexidecimal number +set CONVAR "\\\$$DEC+"; # convenience variable regexp +set ADDR "0x$HEX+"; # address + +# An array of functions/methods that we are testing... +# Each element consists is indexed by NAME,COMMAND, where +# NAME is the function name and COMMAND is the gdb command that +# we are testing. The value of the array for any index pair is +# the expected result of running COMMAND with the NAME as argument. + +# The array holding all functions/methods to test. Valid subindexes +# are (none need character escaping -- "add" will take care of that): + +# add name type print_name list +# NAME,type: value is type of function +# NAME,print: value is print name of function (careful w/inherited/virtual!) +# NAME,list: value is comment in source code on first line of function +# (without the leading "//") +array set all_functions {} + +# "Normal" functions/methods +add {main} \ + {int (int, char **)} \ + - \ + - +add {derived::a_function} \ + {void (const derived * const)} \ + - \ + - +add {base1::a_function} \ + {void (const base1 * const)} \ + - \ + - +add {base2::a_function} \ + {void (const base2 * const)} \ + - \ + - + +# Constructors + +# On targets using the ARM EABI, the constructor is expected to return +# "this". +proc ctor { type arglist } { + if { [istarget arm*-*eabi*] } { + set ret "$type *" + } else { + set ret "void " + } + if { $arglist != "" } { + set arglist ", $arglist" + } + return "${ret}($type * const$arglist)" +} + +add {derived::derived} \ + [ctor derived ""] \ + - \ + - +add {base1::base1(void)} \ + [ctor base1 "const void ** const"] \ + - \ + - +add {base1::base1(int)} \ + [ctor base1 "int"] \ + - \ + - +add {base2::base2} \ + [ctor base2 "const void ** const"] \ + - \ + - +add {base::base(void)} \ + [ctor base ""] \ + - \ + - +add {base::base(int)} \ + [ctor base "int"] \ + - \ + - + +# Destructors + +# On targets using the ARM EABI, some destructors are expected +# to return "this". Others are void. For internal reasons, +# GCC returns void * instead of $type *; RealView appears to do +# the same. +proc dtor { type } { + if { [istarget arm*-*eabi*] } { + set ret "void *" + } else { + set ret "void " + } + return "${ret}($type * const)" +} + +add {base::~base} \ + [dtor base] \ + - \ + - + +# Overloaded methods (all are const -- we try to use the void +# method with and without specifying "const") +add {base::overload(void)} \ + {int (const base * const)} \ + - \ + {base::overload(void) const} +add {base::overload(void) const} \ + {int (const base * const)} \ + - \ + {base::overload(void) const} +add {base::overload(int) const} \ + {int (const base * const, int)} \ + - \ + - +add {base::overload(short) const} \ + {int (const base * const, short)} \ + - \ + - +add {base::overload(long) const} \ + {int (const base * const, long)} \ + - \ + - +add {base::overload(char*) const} \ + {int (const base * const, char *)} \ + - \ + - +add {base::overload(base&) const} \ + {int (const base * const, base &)} \ + - \ + - + +# Operators +add {base::operator+} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator++} \ + {base (base * const)} \ + - \ + - +add {base::operator+=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator-} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator--} \ + {base (base * const)} \ + - \ + - +add {base::operator-=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator*} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator*=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator/} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator/=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator%} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator%=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator<} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator<=} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator>} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator>=} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator!=} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator==} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator!} \ + {bool (const base * const)} \ + - \ + - +add {base::operator&&} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator||} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator<<} \ + {int (const base * const, int)} \ + - \ + - +add {base::operator<<=} \ + {base (base * const, int)} \ + - \ + - +add {base::operator>>} \ + {int (const base * const, int)} \ + - \ + - +add {base::operator>>=} \ + {base (base * const, int)} \ + - \ + - +add {base::operator~} \ + {int (const base * const)} \ + - \ + - +add {base::operator&} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator&=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator|} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator|=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator^} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator^=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator()} \ + {void (const base * const)} \ + - \ + - +add {base::operator[]} \ + {int (const base * const, int)} \ + - \ + - +add {base::operator new} \ + {void *(size_t)} \ + - \ + - +add {base::operator delete} \ + {void (void *)} \ + - \ + - +add {base::operator new[]} \ + {void *(size_t)} \ + - \ + - +add {base::operator delete[]} \ + {void (void *)} \ + - \ + - +add {base::operator char*} \ + {char *(const base * const)} \ + - \ + - +add {base::operator fluff*} \ + {fluff *(const base * const)} \ + - \ + - +add {base::operator fluff**} \ + {fluff **(const base * const)} \ + - \ + - +add {base::operator int} \ + {int (const base * const)} \ + - \ + - + +# Templates +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + {tclass::do_something} +add {policy1::policy} \ + [ctor "policy >" "int"] \ + {policy >::policy} \ + {policy::policy} +add {policy2::policy} \ + [ctor "policy >" int] \ + {policy >::policy} \ + {policy::policy} +add {policy3::policy} \ + [ctor "policy >" "int"] \ + {policy >::policy} \ + {policy::policy} +add {policy4::policy} \ + [ctor "policy >" "int"] \ + {policy >::policy} \ + {policy::policy} +add {policy1::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policy2::function} \ + {void (void)} \ + {operation_2::function} \ + {operation_2::function} +add {policy3::function} \ + {void (void)} \ + {operation_3::function} \ + {operation_3::function} +add {policy4::function} \ + {void (void)} \ + {operation_4::function} \ + {operation_4::function} +add {policyd >::policyd} \ + [ctor "policyd >" "int"] \ + - \ + {policyd::policyd} +add {policyd1::policyd} \ + [ctor "policyd >" "int"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd1::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd >::policyd} \ + [ctor "policyd >" "long"] \ + - \ + {policyd::policyd} +add {policyd2::policyd} \ + [ctor "policyd >" "long"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd2::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd >::policyd} \ + [ctor "policyd >" "char"] \ + - \ + {policyd::policyd} +add {policyd3::policyd} \ + [ctor "policyd >" "char"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd3::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd >::policyd} \ + [ctor "policyd >" "base"] \ + - \ + {policyd::policyd} +add {policyd4::policyd} \ + [ctor "policyd >" "base"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd4::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd, operation_1 > >::policyd} \ + [ctor "policyd, operation_1 > >" "tclass"] \ + - \ + {policyd::policyd} +add {policyd5::policyd} \ + [ctor "policyd, operation_1 > >" "tclass"] \ + {policyd, operation_1 > >::policyd} \ + {policyd::policyd} +add {policyd, operation_1 > >::~policyd} \ + [dtor "policyd, operation_1 > >"] \ + - \ + {policyd::~policyd} +add {policyd5::~policyd} \ + [dtor "policyd, operation_1 > >"] \ + {policyd, operation_1 > >::~policyd} \ + {policyd::~policyd} +add {policyd >::function} \ + {void (void)} \ + {operation_1::function}\ + {operation_1::function} +add {policyd1::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd2::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd >::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd3::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd >::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd4::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd, operation_1 > >::function} \ + {void (void)} \ + {operation_1 >::function} \ + {operation_1::function} +add {policyd5::function} \ + {void (void)} \ + {operation_1 >::function} \ + {operation_1::function} + +# Start the test +if {$tracelevel} { + strace $tracelevel +} + +if {[skip_cplus_tests]} { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "cpexprs" +set srcfile "${testfile}.cc" +set binfile [file join $objdir $subdir $testfile] + +if {[gdb_compile [file join $srcdir $subdir $srcfile] $binfile \ + executable {debug c++}] != "" } { + untested "$testfile.exp" + return -1 +} + +if {[get_compiler_info $binfile "c++"]} { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir [file join $srcdir $subdir] +gdb_load $binfile + +if {![runto_main]} { + perror "couldn't run to breakpoint" + continue +} + +# Set the listsize to one. This will help with testing "list". +gdb_test "set listsize 1" + +# "print METHOD" +foreach name [get_functions print] { + gdb_test "print $name" [get $name print] "print $name" +} + +# "list METHOD" +foreach name [get_functions list] { + gdb_test "list $name" [get $name list] "list $name" +} + +# Running to breakpoint -- use any function we can "list" +foreach name [get_functions list] { + # Skip "main", since test_breakpoint uses it + if {[string compare $name "main"] != 0} { + test_breakpoint $name + } +} + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.cc b/gdb/testsuite/gdb.cp/cplusfuncs.cc index f4f78a626e1..11dba0634ea 100644 --- a/gdb/testsuite/gdb.cp/cplusfuncs.cc +++ b/gdb/testsuite/gdb.cp/cplusfuncs.cc @@ -195,6 +195,12 @@ char * dm_type_char_star (char * p) { return p; } int dm_type_foo_ref (foo & foo) { return foo.ifoo; } int * dm_type_int_star (int * p) { return p; } long * dm_type_long_star (long * p) { return p; } +int dm_type_short (short i) { return i; } +int dm_type_long (long i) { return i; } int dm_type_unsigned_int (unsigned int i) { return i; } +int dm_type_unsigned_short (unsigned short i) { return i; } +int dm_type_unsigned_long (unsigned long i) { return i; } int dm_type_void (void) { return 0; } void * dm_type_void_star (void * p) { return p; } +typedef int myint; +int dm_type_typedef (myint i) { return i; } diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.exp b/gdb/testsuite/gdb.cp/cplusfuncs.exp index f322586c2c3..443af7a3b67 100644 --- a/gdb/testsuite/gdb.cp/cplusfuncs.exp +++ b/gdb/testsuite/gdb.cp/cplusfuncs.exp @@ -66,9 +66,25 @@ set dm_type_unsigned_int "unsigned" set dm_type_void "void" set dm_type_void_star "void*" +# Some other vagaries of GDB's type printing machinery. The integer types +# may have unsigned before or after their length, and may have "int" +# appended. The char* conversion operator may have name "char*" even if +# the type is "char *", because the name comes from the debug information +# and the type from GDB. Function types may not see through typedefs. + +set dm_type_short "short" +set dm_type_long "long" +set dm_type_unsigned_short "unsigned short" +set dm_type_unsigned_long "unsigned long" +set dm_operator_char_star "char*" +set dm_operator_char_star_quoted "char\\*" +set dm_type_typedef 0 + proc probe_demangler { } { global gdb_prompt global dm_operator_comma + global dm_operator_char_star + global dm_operator_char_star_quoted global dm_type_char_star global dm_type_char_star_quoted global dm_type_foo_ref @@ -77,6 +93,11 @@ proc probe_demangler { } { global dm_type_unsigned_int global dm_type_void global dm_type_void_star + global dm_type_short + global dm_type_unsigned_short + global dm_type_long + global dm_type_unsigned_long + global dm_type_typedef send_gdb "print &foo::operator,(foo&)\n" gdb_expect { @@ -97,6 +118,26 @@ proc probe_demangler { } { } } + send_gdb "print &foo::operator char*($dm_type_void)\n" + gdb_expect { + -re ".*foo::operator char \\*\\(void\\).*\r\n$gdb_prompt $" { + # v2 demangler or GDB type printer + set dm_operator_char_star "char *" + set dm_operator_char_star_quoted "char \\*" + pass "detect dm_operator_char_star" + } + -re ".*foo::operator char\\*\\(\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_operator_char_star" + } + -re ".*$gdb_prompt $" { + fail "detect dm_operator_char_star" + } + timeout { + fail "detect dm_operator_char_star" + } + } + send_gdb "print &dm_type_char_star\n" gdb_expect { -re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" { @@ -166,6 +207,11 @@ proc probe_demangler { } { # v3 demangler pass "detect dm_type_long_star" } + -re ".*dm_type_long_star\\(long int \\*\\).*\r\n$gdb_prompt $" { + # GCC v3 and GDB's type printer + set dm_type_long_star "long int *" + pass "detect dm_type_long_star" + } -re ".*$gdb_prompt $" { fail "detect dm_type_long_star" } @@ -230,6 +276,101 @@ proc probe_demangler { } { fail "detect dm_type_void_star (timeout)" } } + + send_gdb "print &dm_type_short\n" + gdb_expect { + -re ".*dm_type_short\\(short\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_short" + } + -re ".*dm_type_short\\(short int\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_short "short int" + pass "detect dm_type_short" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_short" + } + timeout { + fail "detect dm_type_short (timeout)" + } + } + + send_gdb "print &dm_type_unsigned_short\n" + gdb_expect { + -re ".*dm_type_unsigned_short\\(unsigned short\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_unsigned_short" + } + -re ".*dm_type_unsigned_short\\(short unsigned int\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_unsigned_short "short unsigned int" + pass "detect dm_type_unsigned_short" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_unsigned_short" + } + timeout { + fail "detect dm_type_unsigned_short (timeout)" + } + } + + send_gdb "print &dm_type_long\n" + gdb_expect { + -re ".*dm_type_long\\(long\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_long" + } + -re ".*dm_type_long\\(long int\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_long "long int" + pass "detect dm_type_long" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_long" + } + timeout { + fail "detect dm_type_long (timeout)" + } + } + + send_gdb "print &dm_type_unsigned_long\n" + gdb_expect { + -re ".*dm_type_unsigned_long\\(unsigned long\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_unsigned_long" + } + -re ".*dm_type_unsigned_long\\(long unsigned int\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_unsigned_long "long unsigned int" + pass "detect dm_type_unsigned_long" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_unsigned_long" + } + timeout { + fail "detect dm_type_unsigned_long (timeout)" + } + } + + send_gdb "print &dm_type_typedef\n" + gdb_expect { + -re ".*dm_type_typedef\\(int\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_typedef" + } + -re ".*dm_type_typedef\\(myint\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_typedef 1 + pass "detect dm_type_typedef" + } + -re ".*$gdb_prompt $" { + fail "detect dm_type_typedef" + } + timeout { + fail "detect dm_type_typedef (timeout)" + } + } } # @@ -351,8 +492,9 @@ proc print_addr { name } { proc test_lookup_operator_functions {} { global dm_operator_comma + global dm_operator_char_star global dm_type_char_star - global dm_type_char_star_quoted + global dm_operator_char_star_quoted global dm_type_foo_ref global dm_type_void global dm_type_void_star @@ -410,8 +552,8 @@ proc test_lookup_operator_functions {} { info_func "operator int(" "int foo::operator int($dm_type_void);" info_func "operator()(" "void foo::operator()($dm_type_foo_ref);" - info_func "operator $dm_type_char_star_quoted\(" \ - "char *foo::operator $dm_type_char_star\($dm_type_void);" + info_func "operator $dm_operator_char_star_quoted\(" \ + "char *foo::operator $dm_operator_char_star\($dm_type_void);" } @@ -426,6 +568,7 @@ proc test_paddr_operator_functions {} { global dm_type_unsigned_int global dm_type_void global dm_type_void_star + global dm_operator_char_star print_addr "foo::operator*($dm_type_foo_ref)" print_addr "foo::operator%($dm_type_foo_ref)" @@ -479,7 +622,7 @@ proc test_paddr_operator_functions {} { } print_addr "foo::operator int($dm_type_void)" - print_addr "foo::operator $dm_type_char_star\($dm_type_void)" + print_addr "foo::operator $dm_operator_char_star\($dm_type_void)" } # @@ -489,17 +632,21 @@ proc test_paddr_operator_functions {} { proc test_paddr_overloaded_functions {} { global dm_type_unsigned_int global dm_type_void + global dm_type_short + global dm_type_unsigned_short + global dm_type_long + global dm_type_unsigned_long print_addr "overload1arg($dm_type_void)" print_addr "overload1arg(char)" print_addr "overload1arg(signed char)" print_addr "overload1arg(unsigned char)" - print_addr "overload1arg(short)" - print_addr "overload1arg(unsigned short)" + print_addr "overload1arg($dm_type_short)" + print_addr "overload1arg($dm_type_unsigned_short)" print_addr "overload1arg(int)" print_addr "overload1arg($dm_type_unsigned_int)" - print_addr "overload1arg(long)" - print_addr "overload1arg(unsigned long)" + print_addr "overload1arg($dm_type_long)" + print_addr "overload1arg($dm_type_unsigned_long)" print_addr "overload1arg(float)" print_addr "overload1arg(double)" @@ -522,17 +669,31 @@ proc test_paddr_hairy_functions {} { global dm_type_char_star global dm_type_int_star global dm_type_long_star + global dm_type_typedef print_addr_2 "hairyfunc1" "hairyfunc1(int)" - print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))" - print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))" - print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))" - - # gdb-gnats bug gdb/19: - # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" - print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19" - print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19" - print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19" + + if {$dm_type_typedef == 0} { + print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))" + print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))" + print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))" + + # gdb-gnats bug gdb/19: + # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" + print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19" + print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19" + print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19" + } else { + print_addr_2 "hairyfunc2" "hairyfunc2(PFPc_i)" + print_addr_2 "hairyfunc3" "hairyfunc3(PFPFPl_s_i)" + print_addr_2 "hairyfunc4" "hairyfunc4(PFPFPc_s_i)" + + # gdb-gnats bug gdb/19: + # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" + print_addr_2 "hairyfunc5" "hairyfunc5(PFPc_PFl_i)" + print_addr_2 "hairyfunc6" "hairyfunc6(PFPi_PFl_i)" + print_addr_2 "hairyfunc7" "hairyfunc7(PFPFPc_i_PFl_i)" + } } proc do_tests {} { diff --git a/gdb/testsuite/gdb.cp/exception.exp b/gdb/testsuite/gdb.cp/exception.exp index 47890f17f66..03c884777a2 100644 --- a/gdb/testsuite/gdb.cp/exception.exp +++ b/gdb/testsuite/gdb.cp/exception.exp @@ -146,7 +146,9 @@ gdb_test_multiple "continue" $name { set name "backtrace after first throw" gdb_test_multiple "backtrace" $name { - -re ".*#\[0-9\]+${ws}($hex in |)__cxa_throw.*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" { + -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" { + # Either __cxxabiv1::__cxa_throw or __cxa_throw can be printed + # depending on debug info presence. pass $name } } @@ -168,7 +170,7 @@ gdb_test_multiple "continue" $name { set name "backtrace after first catch" gdb_test_multiple "backtrace" $name { - -re ".*#\[0-9\]+${ws}($hex in |)__cxa_begin_catch.*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" { + -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" { pass $name } } @@ -190,7 +192,7 @@ gdb_test_multiple "continue" $name { set name "backtrace after second throw" gdb_test_multiple "backtrace" $name { - -re ".*#\[0-9\]+${ws}($hex in |)__cxa_throw.*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" { + -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" { pass $name } } @@ -212,7 +214,7 @@ gdb_test_multiple "continue" $name { set name "backtrace after second catch" gdb_test_multiple "backtrace" $name { - -re ".*#\[0-9\]+${ws}($hex in |)__cxa_begin_catch.*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" { + -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" { pass $name } } diff --git a/gdb/testsuite/gdb.cp/expand-sals.exp b/gdb/testsuite/gdb.cp/expand-sals.exp index 25ec4a9d685..e4fd59b8ffe 100644 --- a/gdb/testsuite/gdb.cp/expand-sals.exp +++ b/gdb/testsuite/gdb.cp/expand-sals.exp @@ -46,7 +46,7 @@ gdb_continue_to_breakpoint "caller" ".*caller-line.*" # Test GDB caught this return call and not the next one through B::B() gdb_test "bt" \ - "#0 \[^\r\n\]* A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \ + "#0 \[^\r\n\]* (A::)?A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \ "bt from A" gdb_continue_to_breakpoint "next caller func" ".*func-line.*" diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp index 6832f3b6719..083a329fb2e 100644 --- a/gdb/testsuite/gdb.cp/member-ptr.exp +++ b/gdb/testsuite/gdb.cp/member-ptr.exp @@ -420,7 +420,7 @@ gdb_test_multiple "ptype pmf" $name { set name "print pmf" gdb_test_multiple "print pmf" $name { - -re "$vhn = $hex \r\n$gdb_prompt $" { + -re "$vhn = \\(int \\(A::\\*\\)\\(A \\*, int\\)\\) $hex \r\n$gdb_prompt $" { pass $name } -re "$vhn = .*not supported with HP aCC.*\r\n$gdb_prompt $" { @@ -608,6 +608,8 @@ gdb_test_multiple "print (a.*pmf)(3)" $name { } } +gdb_test "ptype a.*pmf" "type = int \\(A \\*, int\\)" + # Print out a pointer to data member which requires looking into # a base class. gdb_test "print diamond_pmi" "$vhn = &Base::x" @@ -658,5 +660,5 @@ gdb_test "print null_pmi = &A::j" "$vhn = &A::j" gdb_test "print null_pmi = 0" "$vhn = NULL" gdb_test "print null_pmf" "$vhn = NULL" -gdb_test "print null_pmf = &A::foo" "$vhn = $hex " +gdb_test "print null_pmf = &A::foo" "$vhn = \\(int \\(A::\\*\\)\\(A \\*, int\\)\\) $hex " gdb_test "print null_pmf = 0" "$vhn = NULL" diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp index c6d8bffe49f..f8796851712 100644 --- a/gdb/testsuite/gdb.cp/overload.exp +++ b/gdb/testsuite/gdb.cp/overload.exp @@ -74,12 +74,12 @@ set re_methods "${re_methods}${ws}int overload1arg\\((void|)\\);" set re_methods "${re_methods}${ws}int overload1arg\\(char\\);" set re_methods "${re_methods}${ws}int overload1arg\\(signed char\\);" set re_methods "${re_methods}${ws}int overload1arg\\(unsigned char\\);" -set re_methods "${re_methods}${ws}int overload1arg\\(short\\);" -set re_methods "${re_methods}${ws}int overload1arg\\(unsigned short\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(short( int)?\\);" +set re_methods "${re_methods}${ws}int overload1arg\\((unsigned short|short unsigned)( int)?\\);" set re_methods "${re_methods}${ws}int overload1arg\\(int\\);" set re_methods "${re_methods}${ws}int overload1arg\\(unsigned int\\);" -set re_methods "${re_methods}${ws}int overload1arg\\(long\\);" -set re_methods "${re_methods}${ws}int overload1arg\\(unsigned long\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(long( int)?\\);" +set re_methods "${re_methods}${ws}int overload1arg\\((unsigned long|long unsigned)( int)?\\);" set re_methods "${re_methods}${ws}int overload1arg\\(float\\);" set re_methods "${re_methods}${ws}int overload1arg\\(double\\);" set re_methods "${re_methods}${ws}int overloadfnarg\\((void|)\\);" diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp index 5b06b31a886..31ef63e65ee 100644 --- a/gdb/testsuite/gdb.cp/ovldbreak.exp +++ b/gdb/testsuite/gdb.cp/ovldbreak.exp @@ -23,7 +23,8 @@ # overloaded member functions # - +global timeout +set timeout 15 if $tracelevel then { strace $tracelevel } @@ -127,10 +128,24 @@ proc set_bp_overloaded {name expectedmenu mychoice bpnumber linenumber} { } # This is the expected menu for overload1arg. -# Note the arg type variations on lines 6 and 13. +# Note the arg type variations for void and integer types. # This accommodates different versions of g++. -set menu_overload1arg "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n\\\[4\\\] foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r\n\\\[5\\\] foo::overload1arg\\(long\\) at.*$srcfile:118\r\n\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n\\\[8\\\] foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r\n\\\[9\\\] foo::overload1arg\\(short\\) at.*$srcfile:114\r\n\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n> $" +set menu_overload1arg "\\\[0\\\] cancel\r\n" +append menu_overload1arg "\\\[1\\\] all\r\n" +append menu_overload1arg "\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n" +append menu_overload1arg "\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n" +append menu_overload1arg "\\\[4\\\] foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r\n" +append menu_overload1arg "\\\[5\\\] foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r\n" +append menu_overload1arg "\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n" +append menu_overload1arg "\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n" +append menu_overload1arg "\\\[8\\\] foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r\n" +append menu_overload1arg "\\\[9\\\] foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r\n" +append menu_overload1arg "\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n" +append menu_overload1arg "\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n" +append menu_overload1arg "\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n" +append menu_overload1arg "\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n" +append menu_overload1arg "> $" # Set multiple-symbols to "ask", to allow us to test the use # of the multiple-choice menu when breaking on an overloaded method. @@ -157,17 +172,17 @@ set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 13 13 110 gdb_test "info break" \ "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r \[\t \]+breakpoint already hit 1 time\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ @@ -215,17 +230,17 @@ gdb_expect { gdb_test "info break" \ "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r \[\t \]+breakpoint already hit 1 time\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ @@ -296,12 +311,12 @@ gdb_test "info break" \ "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r diff --git a/gdb/testsuite/gdb.java/jmain.exp b/gdb/testsuite/gdb.java/jmain.exp index ab952473a27..98149213457 100644 --- a/gdb/testsuite/gdb.java/jmain.exp +++ b/gdb/testsuite/gdb.java/jmain.exp @@ -65,7 +65,7 @@ gdb_test "break jmain.main" "${bpmain}" # Check that a fully qualified "main" works. gdb_load "${binfile}" -set cmd "break \'${testfile}.main(java.lang.String\[\])\'" +set cmd "break ${testfile}.main(java.lang.String\[\])" set msg $cmd gdb_test_multiple $cmd $msg { -re "${bpmain}\r\n$gdb_prompt $" { @@ -79,7 +79,7 @@ gdb_test_multiple $cmd $msg { gdb_test "n" "" "" # Check again with a method signature at the end. - set cmd "break \'${testfile}.main(java.lang.String\[\])void\'" + set cmd "break ${testfile}.main(java.lang.String\[\])void" set msg $cmd gdb_test_multiple $cmd $msg { -re "${bpmain}\r\n$gdb_prompt $" { diff --git a/gdb/testsuite/gdb.java/jmisc.exp b/gdb/testsuite/gdb.java/jmisc.exp index 6f7188dcfd1..e3ab6576e9f 100644 --- a/gdb/testsuite/gdb.java/jmisc.exp +++ b/gdb/testsuite/gdb.java/jmisc.exp @@ -71,8 +71,8 @@ if ![set_lang_java] then { # signature. runto_main set function "${testfile}.main(java.lang.String\[\])" - gdb_breakpoint "\'$function\'" { allow-pending } - gdb_breakpoint "\'${function}void\'" { allow-pending } + gdb_breakpoint "$function" { allow-pending } + gdb_breakpoint "${function}void" { allow-pending } gdb_continue_to_breakpoint $function send_gdb "ptype jmisc\n" diff --git a/gdb/testsuite/gdb.java/jprint.exp b/gdb/testsuite/gdb.java/jprint.exp index 29dbf4badee..447ca73495a 100644 --- a/gdb/testsuite/gdb.java/jprint.exp +++ b/gdb/testsuite/gdb.java/jprint.exp @@ -70,8 +70,8 @@ if ![set_lang_java] then { # signature. runto_main set function "${testfile}.main(java.lang.String\[\])" - gdb_breakpoint "\'$function\'" { allow-pending } - gdb_breakpoint "\'${function}void\'" { allow-pending } + gdb_breakpoint "$function" { allow-pending } + gdb_breakpoint "${function}void" { allow-pending } gdb_continue_to_breakpoint $function gdb_test "p jvclass.addprint(4,5,6)" "sum is 15\r\n.*" "unambiguous static call" diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp index 6eaa943a203..3ad978b6459 100644 --- a/gdb/testsuite/gdb.python/py-symbol.exp +++ b/gdb/testsuite/gdb.python/py-symbol.exp @@ -128,5 +128,5 @@ gdb_test "python print cplusfunc.is_argument" "False" "Test func.is_argument" gdb_test "python print cplusfunc.is_function" "True" "Test func.is_function" gdb_test "python print cplusfunc.name" "SimpleClass::valueofi().*" "Test func.name" gdb_test "python print cplusfunc.print_name" "SimpleClass::valueofi().*" "Test func.print_name" -gdb_test "python print cplusfunc.linkage_name" "_ZN11SimpleClass8valueofiEv" "Test func.linkage_name" +gdb_test "python print cplusfunc.linkage_name" "SimpleClass::valueofi().*" "Test func.linkage_name" gdb_test "python print cplusfunc.addr_class == gdb.SYMBOL_LOC_BLOCK" "True" "Test func.addr_class"