diff options
author | Keith Seitz <keiths@redhat.com> | 2011-03-16 21:08:57 +0000 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2011-03-16 21:08:57 +0000 |
commit | 598997c828bff87692dc5addca8b7961f227918b (patch) | |
tree | 1ceb05e0da46c28cd8257653485f0795dce7eff8 /gdb/testsuite/gdb.cp | |
parent | c91513d8bcbfd180dbefdb84841661abead0e9c3 (diff) | |
download | binutils-gdb-598997c828bff87692dc5addca8b7961f227918b.tar.gz |
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.
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r-- | gdb/testsuite/gdb.cp/cmpd-minsyms.cc | 37 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/cmpd-minsyms.exp | 50 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/ovsrch.exp | 100 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/ovsrch.h | 39 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/ovsrch1.cc | 41 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/ovsrch2.cc | 28 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/ovsrch3.cc | 28 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/ovsrch4.cc | 28 |
8 files changed, 351 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/cmpd-minsyms.cc b/gdb/testsuite/gdb.cp/cmpd-minsyms.cc new file mode 100644 index 00000000000..21d5c4e4db8 --- /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 <http://www.gnu.org/licenses/>. */ + +template <typename T> +class GDB +{ + public: + static int simple (void) { return 0; } + static int harder (T a) { return 1; } + template <typename X> + static X even_harder (T a) { return static_cast<X> (a); } + int operator == (GDB const& other) + { return 1; } +}; + +int main(int argc, char **argv) +{ + GDB<int> a, b; + if (a == b) + return GDB<char>::harder('a') + GDB<int>::harder(3) + + GDB<char>::even_harder<int> ('a'); + return GDB<int>::simple (); +} diff --git a/gdb/testsuite/gdb.cp/cmpd-minsyms.exp b/gdb/testsuite/gdb.cp/cmpd-minsyms.exp new file mode 100644 index 00000000000..36176fc356c --- /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 <http://www.gnu.org/licenses/>. + +# 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<char>::even_harder<int>(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<int>::operator ==" \ + "GDB<int>::operator==(GDB<int> const&)" \ + "GDB<char>::harder(char)" \ + "GDB<int>::harder(int)" \ + {"int GDB<char>::even_harder<int>(char)"} \ + "GDB<int>::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 00000000000..b509a2519d8 --- /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 <http://www.gnu.org/licenses/>. + +# 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 00000000000..b2e518d2a21 --- /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 <http://www.gnu.org/licenses/>. */ + +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 00000000000..ce25e5cc8e6 --- /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 <http://www.gnu.org/licenses/>. */ + +#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 00000000000..54a219b33fb --- /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 <http://www.gnu.org/licenses/>. */ + +#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 00000000000..e6e38a4507b --- /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 <http://www.gnu.org/licenses/>. */ + +#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 00000000000..2f0c1a62a07 --- /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 <http://www.gnu.org/licenses/>. */ + +#include "ovsrch.h" + +void +A::outer::foo (char *a) const +{ +} + +void +A::B::inner::foo (char *a) const +{ +} |