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.
This commit is contained in:
Keith Seitz 2011-03-16 21:08:57 +00:00
parent c91513d8bc
commit 598997c828
9 changed files with 365 additions and 0 deletions

View File

@ -1,3 +1,17 @@
2011-03-16 Keith Seitz <keiths@redhat.com>
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 <ppluzhnikov@google.com>
PR gdb/12528

View File

@ -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 ();
}

View File

@ -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

View File

@ -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

View File

@ -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;
};
}
}

View File

@ -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;
}

View File

@ -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
{
}

View File

@ -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
{
}

View File

@ -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
{
}