- Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz).

This commit is contained in:
Jan Kratochvil 2011-02-06 23:48:08 +01:00
parent cb641a7fa4
commit e266c66da6
4 changed files with 857 additions and 2 deletions

View File

@ -0,0 +1,619 @@
http://sourceware.org/ml/gdb-patches/2010-12/msg00263.html
Index: gdb-7.2.50.20110206/gdb/cp-support.c
===================================================================
--- gdb-7.2.50.20110206.orig/gdb/cp-support.c 2011-02-06 23:12:16.000000000 +0100
+++ gdb-7.2.50.20110206/gdb/cp-support.c 2011-02-06 23:12:22.000000000 +0100
@@ -35,6 +35,7 @@
#include "exceptions.h"
#include "expression.h"
#include "value.h"
+#include "language.h"
#include "safe-ctype.h"
@@ -936,7 +937,8 @@ make_symbol_overload_list_qualified (con
ALL_OBJFILES (objfile)
{
if (objfile->sf)
- objfile->sf->qf->expand_symtabs_for_function (objfile, func_name);
+ objfile->sf->qf->expand_symtabs_for_function (objfile, func_name,
+ language_cplus);
}
/* Search upwards from currently selected frame (so that we can
Index: gdb-7.2.50.20110206/gdb/dwarf2read.c
===================================================================
--- gdb-7.2.50.20110206.orig/gdb/dwarf2read.c 2011-02-06 23:12:22.000000000 +0100
+++ gdb-7.2.50.20110206/gdb/dwarf2read.c 2011-02-06 23:12:22.000000000 +0100
@@ -2373,7 +2373,8 @@ dw2_lookup_symtab (struct objfile *objfi
static struct symtab *
dw2_lookup_symbol (struct objfile *objfile, int block_index,
- const char *name, domain_enum domain)
+ const char *name, domain_enum domain,
+ enum language language)
{
/* We do all the work in the pre_expand_symtabs_matching hook
instead. */
@@ -2449,7 +2450,8 @@ dw2_relocate (struct objfile *objfile, s
static void
dw2_expand_symtabs_for_function (struct objfile *objfile,
- const char *func_name)
+ const char *func_name,
+ enum language language)
{
dw2_do_expand_symtabs_matching (objfile, func_name);
}
@@ -2509,7 +2511,8 @@ dw2_expand_symtabs_with_filename (struct
}
static const char *
-dw2_find_symbol_file (struct objfile *objfile, const char *name)
+dw2_find_symbol_file (struct objfile *objfile, const char *name,
+ enum language language)
{
struct dwarf2_per_cu_data *per_cu;
offset_type *vec;
Index: gdb-7.2.50.20110206/gdb/linespec.c
===================================================================
--- gdb-7.2.50.20110206.orig/gdb/linespec.c 2011-02-06 23:12:16.000000000 +0100
+++ gdb-7.2.50.20110206/gdb/linespec.c 2011-02-06 23:12:26.000000000 +0100
@@ -1226,7 +1226,7 @@ decode_objc (char **argptr, int funfirst
static struct symtabs_and_lines
decode_compound (char **argptr, int funfirstline, char ***canonical,
- char *saved_arg, char *p, int *not_found_ptr)
+ char *the_real_saved_arg, char *p, int *not_found_ptr)
{
struct symtabs_and_lines values;
char *p2;
@@ -1237,7 +1237,23 @@ decode_compound (char **argptr, int funf
struct symbol *sym_class;
struct type *t;
char *saved_java_argptr = NULL;
+ char *saved_arg;
+ /* THE_REAL_SAVED_ARG cannot be altered, so make a copy that can be. */
+ saved_arg = alloca (strlen (the_real_saved_arg) + 1);
+ strcpy (saved_arg, the_real_saved_arg);
+
+ /* If the user specified "'foo::bar(baz)'" (note the quotes -- often
+ added to workaround completer issues) -- saved_arg will be
+ encapsulated in single-quotes. They are superfluous, so just strip
+ them off. */
+ if (*saved_arg == '\'')
+ {
+ char *end = skip_quoted (saved_arg);
+ memmove (saved_arg, saved_arg + 1, end - saved_arg);
+ memmove (end - 2, end, strlen (saved_arg) + 1);
+ }
+
/* 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
@@ -1489,7 +1505,7 @@ decode_compound (char **argptr, int funf
up. The quotes are important if copy is empty. */
if (not_found_ptr)
*not_found_ptr = 1;
- cplusplus_error (saved_arg,
+ cplusplus_error (the_real_saved_arg,
"Can't find member of namespace, "
"class, struct, or union named \"%s\"\n",
copy);
Index: gdb-7.2.50.20110206/gdb/psymtab.c
===================================================================
--- gdb-7.2.50.20110206.orig/gdb/psymtab.c 2011-02-06 23:12:16.000000000 +0100
+++ gdb-7.2.50.20110206/gdb/psymtab.c 2011-02-06 23:12:54.000000000 +0100
@@ -33,6 +33,8 @@
#include "readline/readline.h"
#include "gdb_regex.h"
#include "dictionary.h"
+#include "language.h"
+#include "cp-support.h"
#ifndef DEV_TTY
#define DEV_TTY "/dev/tty"
@@ -55,7 +57,8 @@ static struct partial_symbol *match_part
static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
const char *, int,
- domain_enum);
+ domain_enum,
+ enum language);
static char *psymtab_to_fullname (struct partial_symtab *ps);
@@ -418,15 +421,35 @@ fixup_psymbol_section (struct partial_sy
static struct symtab *
lookup_symbol_aux_psymtabs (struct objfile *objfile,
int block_index, const char *name,
- const domain_enum domain)
+ const domain_enum domain, enum language language)
{
struct partial_symtab *ps;
const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
ALL_OBJFILE_PSYMTABS (objfile, ps)
{
- if (!ps->readin && lookup_partial_symbol (ps, name, psymtab_index, domain))
- return PSYMTAB_TO_SYMTAB (ps);
+ if (!ps->readin
+ && lookup_partial_symbol (ps, name, psymtab_index, domain, language))
+ {
+ struct symbol *sym;
+ struct symtab *stab = PSYMTAB_TO_SYMTAB (ps);
+ sym = NULL;
+
+ /* Some caution must be observed with overloaded functions
+ and methods, since the psymtab will not contain any overload
+ information (but NAME might contain it). */
+ if (stab->primary)
+ {
+ struct blockvector *bv = BLOCKVECTOR (stab);
+ struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
+ sym = lookup_block_symbol (block, name, domain);
+ }
+
+ if (sym && strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0)
+ return stab;
+
+ /* Keep looking through other psymtabs. */
+ }
}
return NULL;
@@ -519,22 +542,58 @@ pre_expand_symtabs_matching_psymtabs (st
/* Nothing. */
}
+/* Returns the name used to search psymtabs. Unlike symtabs, psymtabs do
+ not contain any method/function instance information (since this would
+ force reading type information while reading psymtabs). Therefore,
+ if NAME contains overload information, it must be stripped before searching
+ psymtabs.
+
+ The caller is responsible for freeing the return result. */
+
+static const char *
+psymtab_search_name (const char *name, enum language language)
+{
+ switch (language)
+ {
+ case language_cplus:
+ case language_java:
+ {
+ if (strchr (name, '('))
+ {
+ char *ret = cp_remove_params (name);
+ if (ret)
+ return ret;
+ }
+ }
+
+ default:
+ break;
+ }
+
+ return xstrdup (name);
+}
+
/* Look, in partial_symtab PST, for symbol whose natural name is NAME.
Check the global symbols if GLOBAL, the static symbols if not. */
static struct partial_symbol *
lookup_partial_symbol (struct partial_symtab *pst, const char *name,
- int global, domain_enum domain)
+ int global, domain_enum domain, enum language language)
{
struct partial_symbol **start, **psym;
struct partial_symbol **top, **real_top, **bottom, **center;
int length = (global ? pst->n_global_syms : pst->n_static_syms);
int do_linear_search = 1;
+ const char *search_name;
+ struct cleanup *cleanup;
if (length == 0)
{
return (NULL);
}
+
+ search_name = psymtab_search_name (name, language);
+ cleanup = make_cleanup (xfree, (void *) search_name);
start = (global ?
pst->objfile->global_psymbols.list + pst->globals_offset :
pst->objfile->static_psymbols.list + pst->statics_offset);
@@ -563,7 +622,8 @@ lookup_partial_symbol (struct partial_sy
{
do_linear_search = 1;
}
- if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center), name) >= 0)
+ if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center),
+ search_name) >= 0)
{
top = center;
}
@@ -577,11 +637,14 @@ lookup_partial_symbol (struct partial_sy
_("failed internal consistency check"));
while (top <= real_top
- && SYMBOL_MATCHES_SEARCH_NAME (*top, name))
+ && SYMBOL_MATCHES_SEARCH_NAME (*top, search_name))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
SYMBOL_DOMAIN (*top), domain))
- return (*top);
+ {
+ do_cleanups (cleanup);
+ return (*top);
+ }
top++;
}
}
@@ -595,11 +658,15 @@ lookup_partial_symbol (struct partial_sy
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
SYMBOL_DOMAIN (*psym), domain)
- && SYMBOL_MATCHES_SEARCH_NAME (*psym, name))
- return (*psym);
+ && SYMBOL_MATCHES_SEARCH_NAME (*psym, search_name))
+ {
+ do_cleanups (cleanup);
+ return (*psym);
+ }
}
}
+ do_cleanups (cleanup);
return (NULL);
}
@@ -911,7 +978,8 @@ dump_psymtabs_for_objfile (struct objfil
by matching FUNC_NAME. Make sure we read that symbol table in. */
static void
-read_symtabs_for_function (struct objfile *objfile, const char *func_name)
+read_symtabs_for_function (struct objfile *objfile, const char *func_name,
+ enum language language)
{
struct partial_symtab *ps;
@@ -920,9 +988,9 @@ read_symtabs_for_function (struct objfil
if (ps->readin)
continue;
- if ((lookup_partial_symbol (ps, func_name, 1, VAR_DOMAIN)
+ if ((lookup_partial_symbol (ps, func_name, 1, VAR_DOMAIN, language)
!= NULL)
- || (lookup_partial_symbol (ps, func_name, 0, VAR_DOMAIN)
+ || (lookup_partial_symbol (ps, func_name, 0, VAR_DOMAIN, language)
!= NULL))
psymtab_to_symtab (ps);
}
@@ -1042,13 +1110,14 @@ psymtab_to_fullname (struct partial_symt
}
static const char *
-find_symbol_file_from_partial (struct objfile *objfile, const char *name)
+find_symbol_file_from_partial (struct objfile *objfile, const char *name,
+ enum language language)
{
struct partial_symtab *pst;
ALL_OBJFILE_PSYMTABS (objfile, pst)
{
- if (lookup_partial_symbol (pst, name, 1, VAR_DOMAIN))
+ if (lookup_partial_symbol (pst, name, 1, VAR_DOMAIN, language))
return pst->filename;
}
return NULL;
Index: gdb-7.2.50.20110206/gdb/symfile.h
===================================================================
--- gdb-7.2.50.20110206.orig/gdb/symfile.h 2011-02-06 23:12:16.000000000 +0100
+++ gdb-7.2.50.20110206/gdb/symfile.h 2011-02-06 23:12:22.000000000 +0100
@@ -167,14 +167,15 @@ struct quick_symbol_functions
/* Check to see if the symbol is defined in a "partial" symbol table
of OBJFILE. KIND should be either GLOBAL_BLOCK or STATIC_BLOCK,
depending on whether we want to search global symbols or static
- symbols. NAME is the name of the symbol to look for. DOMAIN
- indicates what sort of symbol to search for.
+ symbols. NAME (valid in LANGUAGE) is the name of the symbol to look for.
+ DOMAIN indicates what sort of symbol to search for.
Returns the newly-expanded symbol table in which the symbol is
defined, or NULL if no such symbol table exists. */
struct symtab *(*lookup_symbol) (struct objfile *objfile,
int kind, const char *name,
- domain_enum domain);
+ domain_enum domain,
+ enum language language);
/* This is called to expand symbol tables before looking up a
symbol. A backend can choose to implement this and then have its
@@ -200,10 +201,11 @@ struct quick_symbol_functions
struct section_offsets *new_offsets,
struct section_offsets *delta);
- /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
- the corresponding symbol tables are loaded. */
+ /* Find all the symbols in OBJFILE named FUNC_NAME (valid in LANGUAGE),
+ and ensure that the corresponding symbol tables are loaded. */
void (*expand_symtabs_for_function) (struct objfile *objfile,
- const char *func_name);
+ const char *func_name,
+ enum language language);
/* Read all symbol tables associated with OBJFILE. */
void (*expand_all_symtabs) (struct objfile *objfile);
@@ -217,8 +219,10 @@ struct quick_symbol_functions
const char *filename);
/* Return the file name of the file holding the symbol in OBJFILE
- named NAME. If no such symbol exists in OBJFILE, return NULL. */
- const char *(*find_symbol_file) (struct objfile *objfile, const char *name);
+ named NAME (valid in LANGUAGE). If no such symbol exists in OBJFILE,
+ return NULL. */
+ const char *(*find_symbol_file) (struct objfile *objfile, const char *name,
+ enum language language);
/* Find global or static symbols in all tables that are in NAMESPACE
and for which MATCH (symbol name, NAME) == 0, passing each to
Index: gdb-7.2.50.20110206/gdb/symtab.c
===================================================================
--- gdb-7.2.50.20110206.orig/gdb/symtab.c 2011-02-06 23:12:16.000000000 +0100
+++ gdb-7.2.50.20110206/gdb/symtab.c 2011-02-06 23:12:22.000000000 +0100
@@ -1380,7 +1380,8 @@ lookup_symbol_aux_quick (struct objfile
if (!objfile->sf)
return NULL;
- symtab = objfile->sf->qf->lookup_symbol (objfile, kind, name, domain);
+ symtab = objfile->sf->qf->lookup_symbol (objfile, kind, name, domain,
+ current_language->la_language);
if (!symtab)
return NULL;
@@ -1554,7 +1555,8 @@ basic_lookup_transparent_type_quick (str
if (!objfile->sf)
return NULL;
- symtab = objfile->sf->qf->lookup_symbol (objfile, kind, name, STRUCT_DOMAIN);
+ symtab = objfile->sf->qf->lookup_symbol (objfile, kind, name, STRUCT_DOMAIN,
+ current_language->la_language);
if (!symtab)
return NULL;
@@ -1686,7 +1688,8 @@ find_main_filename (void)
if (!objfile->sf)
continue;
- result = objfile->sf->qf->find_symbol_file (objfile, name);
+ result = objfile->sf->qf->find_symbol_file (objfile, name,
+ current_language->la_language);
if (result)
return result;
}
Index: gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734-1.cc
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734-1.cc 2011-02-06 23:12:22.000000000 +0100
@@ -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 <http://www.gnu.org/licenses/>.
+
+ 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: gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734-2.cc
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734-2.cc 2011-02-06 23:12:22.000000000 +0100
@@ -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 <http://www.gnu.org/licenses/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@gnu.org */
+
+#include "pr11734.h"
+
+void
+pr11734::foo(void)
+{
+}
+
Index: gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734-3.cc
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734-3.cc 2011-02-06 23:12:22.000000000 +0100
@@ -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 <http://www.gnu.org/licenses/>.
+
+ 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: gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734-4.cc
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734-4.cc 2011-02-06 23:12:22.000000000 +0100
@@ -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 <http://www.gnu.org/licenses/>.
+
+ 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: gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734.exp 2011-02-06 23:12:22.000000000 +0100
@@ -0,0 +1,55 @@
+# 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 <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite.
+
+if { [skip_cplus_tests] } { continue }
+
+set testfile "pr11734"
+set class $testfile
+
+set srcfiles {}
+for {set i 1} {$i < 5} {incr i} {
+ lappend srcfiles $testfile-$i.cc
+}
+
+prepare_for_testing pr11734 $testfile $srcfiles {c++ debug}
+
+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: gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr11734.h 2011-02-06 23:12:22.000000000 +0100
@@ -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 <http://www.gnu.org/licenses/>.
+
+ 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 *);
+};
+

View File

@ -0,0 +1,18 @@
http://sourceware.org/ml/gdb-patches/2011-01/msg00460.html
Index: gdb-7.2/gdb/linespec.c
===================================================================
--- gdb-7.2.orig/gdb/linespec.c 2011-02-03 22:59:46.000000000 +0100
+++ gdb-7.2/gdb/linespec.c 2011-02-03 23:03:28.000000000 +0100
@@ -1230,7 +1230,10 @@ decode_compound (char **argptr, int funf
{
char *end = skip_quoted (saved_arg);
memmove (saved_arg, saved_arg + 1, end - saved_arg);
- memmove (end - 2, end, strlen (saved_arg) + 1);
+ if (&end[-2] >= saved_arg && end[-2] == '\'')
+ memmove (end - 2, end, strlen (end) + 1);
+ else
+ memmove (end - 1, end, strlen (end) + 1);
}
/* First check for "global" namespace specification, of the form

207
gdb-physname-pr12273.patch Normal file
View File

@ -0,0 +1,207 @@
http://sourceware.org/ml/gdb-patches/2010-12/msg00264.html
Index: gdb-7.2.50.20110206/gdb/linespec.c
===================================================================
--- gdb-7.2.50.20110206.orig/gdb/linespec.c 2011-02-06 23:06:26.000000000 +0100
+++ gdb-7.2.50.20110206/gdb/linespec.c 2011-02-06 23:08:23.000000000 +0100
@@ -1057,6 +1057,10 @@ locate_first_half (char **argptr, int *i
error (_("malformed template specification in command"));
p = temp_end;
}
+
+ if (p[0] == '(')
+ p = find_method_overload_end (p);
+
/* Check for a colon and a plus or minus and a [ (which
indicates an Objective-C method). */
if (is_objc_method_format (p))
@@ -1272,8 +1276,10 @@ decode_compound (char **argptr, int funf
find_method.
2) AAA::inA isn't the name of a class. In that case, either the
- user made a typo or AAA::inA is the name of a namespace.
- Either way, we just look up AAA::inA::fun with lookup_symbol.
+ user made a typo, AAA::inA is the name of a namespace, or it is
+ the name of a minimal symbol.
+ We just look up AAA::inA::fun with lookup_symbol. If that fails,
+ try lookup_minimal_symbol.
Thus, our first task is to find everything before the last set of
double-colons and figure out if it's the name of a class. So we
@@ -1294,6 +1300,8 @@ decode_compound (char **argptr, int funf
while (1)
{
+ static char *break_characters = " \t\'(";
+
/* Move pointer up to next possible class/namespace token. */
p = p2 + 1; /* Restart with old value +1. */
@@ -1304,8 +1312,7 @@ decode_compound (char **argptr, int funf
/* PASS2: p2->"::fun", p->":fun" */
/* Move pointer ahead to next double-colon. */
- while (*p && (p[0] != ' ') && (p[0] != '\t') && (p[0] != '\'')
- && (*p != '('))
+ while (*p && strchr (break_characters, *p) == NULL)
{
if (current_language->la_language == language_cplus)
p += cp_validate_operator (p);
@@ -1329,9 +1336,12 @@ decode_compound (char **argptr, int funf
else if ((p[0] == ':') && (p[1] == ':'))
break; /* Found double-colon. */
else
- /* PASS2: We'll keep getting here, until p->"", at which point
- we exit this loop. */
- p++;
+ {
+ /* PASS2: We'll keep getting here, until P points to one of the
+ break characters, at which point we exit this loop. */
+ if (strchr (break_characters, *p) == NULL)
+ p++;
+ }
}
if (*p != ':')
@@ -1340,7 +1350,7 @@ decode_compound (char **argptr, int funf
unsuccessfully all the components of the
string, and p->""(PASS2). */
- /* We get here if p points to ' ', '\t', '\'', "::" or ""(i.e
+ /* We get here if p points to one of the break characters or ""(i.e
string ended). */
/* Save restart for next time around. */
p2 = p;
@@ -1491,6 +1501,18 @@ decode_compound (char **argptr, int funf
/* We couldn't find a class, so we're in case 2 above. We check the
entire name as a symbol instead. */
+ if (current_language->la_language == language_cplus
+ || current_language->la_language == language_java)
+ {
+ char *paren = strchr (p, '(');
+ if (paren != NULL)
+ p = find_method_overload_end (paren);
+
+ /* Make sure we keep important kewords like "const" */
+ if (strncmp (p, " const", 6) == 0)
+ p += 6;
+ }
+
copy = (char *) alloca (p - saved_arg2 + 1);
memcpy (copy, saved_arg2, p - saved_arg2);
/* Note: if is_quoted should be true, we snuff out quote here
@@ -1503,9 +1525,18 @@ decode_compound (char **argptr, int funf
sym = lookup_symbol (copy, 0, VAR_DOMAIN, 0);
if (sym)
return symbol_found (funfirstline, canonical, copy, sym, NULL);
+ else
+ {
+ struct minimal_symbol *msym;
+
+ /* Couldn't find any interpretation as classes/namespaces. As a last
+ resort, try the minimal symbol tables. */
+ msym = lookup_minimal_symbol (copy, NULL, NULL);
+ if (msym != NULL)
+ return minsym_found (funfirstline, msym);
+ }
- /* Couldn't find any interpretation as classes/namespaces, so give
- up. The quotes are important if copy is empty. */
+ /* Couldn't find a minimal symbol, either, so give up. */
if (not_found_ptr)
*not_found_ptr = 1;
cplusplus_error (the_real_saved_arg,
Index: gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr12273.cc
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr12273.cc 2011-02-06 23:07:19.000000000 +0100
@@ -0,0 +1,37 @@
+/* This test case 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 <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 ();
+}
Index: gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr12273.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.2.50.20110206/gdb/testsuite/gdb.cp/pr12273.exp 2011-02-06 23:07:19.000000000 +0100
@@ -0,0 +1,46 @@
+# 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 <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite.
+
+if {[skip_cplus_tests]} { continue }
+
+set testfile "pr12273"
+# Do NOT compile with debug flag.
+prepare_for_testing pr12273 $testfile $testfile.cc {c++}
+
+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 {
+ if {[gdb_breakpoint $sym]} {
+ pass "setting breakpoint at $sym"
+ }
+}
+
+gdb_exit

View File

@ -27,7 +27,7 @@ Version: 7.2.50.20110206
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 17%{?_with_upstream:.upstream}%{?dist}
Release: 18%{?_with_upstream:.upstream}%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
Group: Development/Debuggers
@ -552,6 +552,11 @@ Patch556: gdb-gcc46-stdarg-prologue.patch
# =push
Patch557: gdb-python-newbacktrace.patch
# Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz).
Patch565: gdb-physname-pr11734-1of2.patch
Patch566: gdb-physname-pr11734-2of2.patch
Patch567: gdb-physname-pr12273.patch
BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
Requires: readline%{?_isa}
BuildRequires: readline-devel%{?_isa}
@ -805,6 +810,9 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch555 -p1
%patch556 -p1
%patch557 -p1
%patch565 -p1
%patch566 -p1
%patch567 -p1
%patch390 -p1
%patch393 -p1
@ -1211,7 +1219,10 @@ fi
%endif
%changelog
* Thu Jan 27 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.2.50.20110206-17.fc15
* Sun Feb 6 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.2.50.20110206-18.fc15
- Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz).
* Sun Feb 6 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.2.50.20110206-17.fc15
- Rebase to FSF GDB 7.2.50.20110206 (which is a 7.3 pre-release).
* Thu Jan 27 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.2.50.20110125-16.fc15