diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6dd99413df..5d72c34b60 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,17 @@ +2011-03-16 Keith Seitz + + PR c++/12273 + * gdb.cp/cmpd-minsyms.exp: New test. + * gdb.cp/cmpd-minsyms.cc: New file. + + PR c++/11734 + * gdb.cp/ovsrch.exp: New test. + * gdb.cp/ovsrch.h: New file. + * gdb.cp/ovsrch1.cc: New file. + * gdb.cp/ovsrch2.cc: New file. + * gdb.cp/ovsrch3.cc: New file. + * gdb.cp/ovsrch4.cc: New file. + 2011-03-16 Paul Pluzhnikov PR gdb/12528 diff --git a/gdb/testsuite/gdb.cp/cmpd-minsyms.cc b/gdb/testsuite/gdb.cp/cmpd-minsyms.cc new file mode 100644 index 0000000000..21d5c4e4db --- /dev/null +++ b/gdb/testsuite/gdb.cp/cmpd-minsyms.cc @@ -0,0 +1,37 @@ +/* This test case is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + 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 . */ + +template +class GDB +{ + public: + static int simple (void) { return 0; } + static int harder (T a) { return 1; } + template + static X even_harder (T a) { return static_cast (a); } + int operator == (GDB const& other) + { return 1; } +}; + +int main(int argc, char **argv) +{ + GDB a, b; + if (a == b) + return GDB::harder('a') + GDB::harder(3) + + GDB::even_harder ('a'); + return GDB::simple (); +} diff --git a/gdb/testsuite/gdb.cp/cmpd-minsyms.exp b/gdb/testsuite/gdb.cp/cmpd-minsyms.exp new file mode 100644 index 0000000000..36176fc356 --- /dev/null +++ b/gdb/testsuite/gdb.cp/cmpd-minsyms.exp @@ -0,0 +1,50 @@ +# Copyright 2011 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. + +if {[skip_cplus_tests]} { continue } + +# Test for c++/12273 +set testfile "cmpd-minsyms" +# Do NOT compile with debug flag. +if {[prepare_for_testing $testfile $testfile $testfile.cc {c++}]} { + return -1 +} + +gdb_test_no_output "set language c++" + +# A list of minimal symbol names to check. +# Note that GDB::even_harder(char) is quoted and includes +# the return type. This is necessary because this is the demangled name +# of the minimal symbol. +set min_syms [list \ + "GDB::operator ==" \ + "GDB::operator==(GDB const&)" \ + "GDB::harder(char)" \ + "GDB::harder(int)" \ + {"int GDB::even_harder(char)"} \ + "GDB::simple()"] + +foreach sym $min_syms { + set tst "setting breakpoint at $sym" + if {[gdb_breakpoint $sym]} { + pass $tst + } +} + +gdb_exit diff --git a/gdb/testsuite/gdb.cp/ovsrch.exp b/gdb/testsuite/gdb.cp/ovsrch.exp new file mode 100644 index 0000000000..b509a2519d --- /dev/null +++ b/gdb/testsuite/gdb.cp/ovsrch.exp @@ -0,0 +1,100 @@ +# Copyright 2011 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. + +proc test_class {class} { + + # An array holding the overload types for the methods A::outer::foo + # and A::B::inner::foo. The first element is the overloaded method + # parameter. The second element is the expected source file number, + # e.g. "ovsrch?.cc". + array set tests { + "char*" 4 + "int" 3 + "void" 2 + } + + # Test each overload instance twice: once quoted, once unquoted + set conditional1 "if (a == 3)" + set conditional2 "if (A::outer::func ())" + foreach ovld [array names tests] { + set method "${class}::foo ($ovld) const" + set result "Breakpoint (\[0-9\]).*file .*/ovsrch$tests($ovld).*" + gdb_test "break $method" $result + gdb_test "break '$method'" $result + + # Also test with a conditional tacked onto the end. + if {[string compare $ovld "void"] != 0} { + gdb_test "break $method $conditional1" $result + gdb_test "break '$method' $conditional1" $result + gdb_test "break $method $conditional2" $result + gdb_test "break '$method' $conditional2" $result + } + } + + # Test whether open parentheses are correctly identified as overload + # information or conditional. + gdb_test "break ${class}::foo if (a == 3)" "Breakpoint (\[0-9\]).*" +} + +if { [skip_cplus_tests] } { continue } + +# Test for c++/11734 +set testfile "ovsrch" +set binfile [file join $objdir $subdir $testfile] + +set srcfiles {} +for {set i 1} {$i < 5} {incr i} { + lappend srcfiles $testfile$i.cc +} + +if {[prepare_for_testing $testfile $testfile $srcfiles {c++ debug}]} { + return -1 +} + +if {![runto_main]} { + perror "couldn't run to breakpoint" + continue +} + +# Break in A::stop_here and run tests. +if {[gdb_breakpoint "stop_here"]} { + pass "break stop_here" +} + +if {[gdb_breakpoint "'stop_here'"]} { + pass "break 'stop_here'" +} + +gdb_continue_to_breakpoint "stop_here" +test_class outer + +# Break in A::B::stop_here_too and run tests. +if {[gdb_breakpoint "B::stop_here_too"]} { + pass "break B::stop_here_too" +} + +if {[gdb_breakpoint "'B::stop_here_too'"]} { + pass "break 'B::stop_here_too'" +} + +gdb_continue_to_breakpoint "stop_here_too" +test_class inner + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/ovsrch.h b/gdb/testsuite/gdb.cp/ovsrch.h new file mode 100644 index 0000000000..b2e518d2a2 --- /dev/null +++ b/gdb/testsuite/gdb.cp/ovsrch.h @@ -0,0 +1,39 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + 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 . */ + +namespace A +{ + class outer + { + public: + void foo (void) const; + void foo (int) const; + void foo (char *) const; + bool func (void) { return true; } + }; + + namespace B + { + class inner + { + public: + void foo (void) const; + void foo (int) const; + void foo (char *) const; + }; + } +} diff --git a/gdb/testsuite/gdb.cp/ovsrch1.cc b/gdb/testsuite/gdb.cp/ovsrch1.cc new file mode 100644 index 0000000000..ce25e5cc8e --- /dev/null +++ b/gdb/testsuite/gdb.cp/ovsrch1.cc @@ -0,0 +1,41 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + 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 . */ + +#include "ovsrch.h" + +namespace A +{ + void stop_here (void) { } + + namespace B + { + void stop_here_too (void) { } + } +} + +using namespace A; + +int +main () +{ + outer *p = new outer; + stop_here (); + B::stop_here_too (); + p->foo (); + return 0; +} + diff --git a/gdb/testsuite/gdb.cp/ovsrch2.cc b/gdb/testsuite/gdb.cp/ovsrch2.cc new file mode 100644 index 0000000000..54a219b33f --- /dev/null +++ b/gdb/testsuite/gdb.cp/ovsrch2.cc @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + 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 . */ + +#include "ovsrch.h" + +void +A::outer::foo (void) const +{ +} + +void +A::B::inner::foo (void) const +{ +} diff --git a/gdb/testsuite/gdb.cp/ovsrch3.cc b/gdb/testsuite/gdb.cp/ovsrch3.cc new file mode 100644 index 0000000000..e6e38a4507 --- /dev/null +++ b/gdb/testsuite/gdb.cp/ovsrch3.cc @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + 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 . */ + +#include "ovsrch.h" + +void +A::outer::foo (int a) const +{ +} + +void +A::B::inner::foo (int a) const +{ +} diff --git a/gdb/testsuite/gdb.cp/ovsrch4.cc b/gdb/testsuite/gdb.cp/ovsrch4.cc new file mode 100644 index 0000000000..2f0c1a62a0 --- /dev/null +++ b/gdb/testsuite/gdb.cp/ovsrch4.cc @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + 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 . */ + +#include "ovsrch.h" + +void +A::outer::foo (char *a) const +{ +} + +void +A::B::inner::foo (char *a) const +{ +}