Index: linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.103 diff -u -p -r1.103 linespec.c --- linespec.c 14 May 2010 23:41:04 -0000 1.103 +++ linespec.c 22 Jun 2010 15:39:18 -0000 @@ -1217,6 +1217,19 @@ decode_compound (char **argptr, int funf struct type *t; char *saved_java_argptr = NULL; + /* Strip single quotes from SAVED_ARG. This interferes with this function + which might, e.g., later call strcmp_iw with SYMBOL_LINKAGE_NAME + (which never contains quotes). */ + if (*saved_arg == '\'') + { + char *close = strrchr (saved_arg, '\''); + if (close) + { + ++saved_arg; + *close = '\0'; + } + } + /* First check for "global" namespace specification, of the form "::foo". If found, skip over the colons and jump to normal symbol processing. I.e. the whole line specification starts with Index: psymtab.c =================================================================== RCS file: /cvs/src/src/gdb/psymtab.c,v retrieving revision 1.4 diff -u -p -r1.4 psymtab.c --- psymtab.c 16 May 2010 01:27:02 -0000 1.4 +++ psymtab.c 22 Jun 2010 15:39:20 -0000 @@ -432,6 +432,7 @@ lookup_partial_symbol (struct partial_sy struct partial_symbol **top, **real_top, **bottom, **center; int length = (global ? pst->n_global_syms : pst->n_static_syms); int do_linear_search = 1; + char *simple_name = NULL, *paren; if (length == 0) { @@ -441,6 +442,14 @@ lookup_partial_symbol (struct partial_sy pst->objfile->global_psymbols.list + pst->globals_offset : pst->objfile->static_psymbols.list + pst->statics_offset); + paren = strchr (name, '('); + if (paren) + { + simple_name = alloca (strlen (name)); + memcpy (simple_name, name, paren - name); + simple_name[name - paren] = '\0'; + } + if (global) /* This means we can use a binary search. */ { do_linear_search = 0; @@ -476,12 +485,32 @@ lookup_partial_symbol (struct partial_sy if (!(top == bottom)) internal_error (__FILE__, __LINE__, _("failed internal consistency check")); - while (top <= real_top - && SYMBOL_MATCHES_SEARCH_NAME (*top, name)) + while (top <= real_top) { - if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), - SYMBOL_DOMAIN (*top), domain)) - return (*top); + if (SYMBOL_MATCHES_SEARCH_NAME (*top, name)) + { + if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), + SYMBOL_DOMAIN (*top), domain)) + return (*top); + } + else + { + if (simple_name) + { + /* NAME has overload information. Partial symbols, however, + do not. This is a case of mistaken identity. + + Although hacky, this is fixed by expanding this psymtab, + which will allow any subsequent symtab search to succeed. + + For more details/test case, please refer to c++/11734. */ + + if (SYMBOL_MATCHES_SEARCH_NAME (*top, simple_name)) + PSYMTAB_TO_SYMTAB (pst); + } + else + break; + } top++; } } @@ -497,6 +526,11 @@ lookup_partial_symbol (struct partial_sy SYMBOL_DOMAIN (*psym), domain) && SYMBOL_MATCHES_SEARCH_NAME (*psym, name)) return (*psym); + else if (simple_name && SYMBOL_MATCHES_SEARCH_NAME (*psym, simple_name)) + { + PSYMTAB_TO_SYMTAB (pst); + break; + } } } Index: testsuite/gdb.cp/pr11734-1.cc =================================================================== RCS file: testsuite/gdb.cp/pr11734-1.cc diff -N testsuite/gdb.cp/pr11734-1.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734-1.cc 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,30 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include "pr11734.h" + +int +main () +{ + pr11734 *p = new pr11734; + p->foo (); + return 0; +} + Index: testsuite/gdb.cp/pr11734-2.cc =================================================================== RCS file: testsuite/gdb.cp/pr11734-2.cc diff -N testsuite/gdb.cp/pr11734-2.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734-2.cc 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include "pr11734.h" + +void +pr11734::foo(void) +{ +} + Index: testsuite/gdb.cp/pr11734-3.cc =================================================================== RCS file: testsuite/gdb.cp/pr11734-3.cc diff -N testsuite/gdb.cp/pr11734-3.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734-3.cc 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include "pr11734.h" + +void +pr11734::foo (int a) +{ +} + Index: testsuite/gdb.cp/pr11734-4.cc =================================================================== RCS file: testsuite/gdb.cp/pr11734-4.cc diff -N testsuite/gdb.cp/pr11734-4.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734-4.cc 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include "pr11734.h" + +void +pr11734::foo (char *a) +{ +} + Index: testsuite/gdb.cp/pr11734.exp =================================================================== RCS file: testsuite/gdb.cp/pr11734.exp diff -N testsuite/gdb.cp/pr11734.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734.exp 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,67 @@ +# Copyright 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. + +if { [skip_cplus_tests] } { continue } + +set testfile "pr11734" +set class $testfile +set binfile [file join $objdir $subdir $testfile] + +set srcfiles {} +for {set i 1} {$i < 5} {incr i} { + lappend srcfiles [file join $srcdir $subdir $testfile-$i.cc] +} +if {[gdb_compile $srcfiles $binfile executable {debug c++}] != "" } { + untested pr11734.exp + return -1 +} + +if {[get_compiler_info $binfile "c++"]} { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load $binfile + +if {![runto_main]} { + perror "couldn't run to breakpoint" + continue +} + +# An array holding the overload types for the method pr11734::foo. The +# first element is the overloaded method parameter. The second element +# is the expected source file number, e.g. "pr11734-?.cc". +array set tests { + "char*" 4 + "int" 3 + "" 2 +} + +# Test each overload instance twice: once quoted, once unquoted +foreach ovld [array names tests] { + set method "${class}::foo\($ovld\)" + set result "Breakpoint (\[0-9\]).*file .*/$class-$tests($ovld).*" + gdb_test "break $method" $result + gdb_test "break '$method'" $result +} + +gdb_exit +return 0 Index: testsuite/gdb.cp/pr11734.h =================================================================== RCS file: testsuite/gdb.cp/pr11734.h diff -N testsuite/gdb.cp/pr11734.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.cp/pr11734.h 22 Jun 2010 15:39:25 -0000 @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +class pr11734 +{ + public: + void foo (); + void foo (int); + void foo (char *); +}; +