gdb
PR c++/9946: * symfile.c (reread_symbols): Clear template_symbols. * symtab.h (struct symbol) <is_cplus_template_function>: New field. (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION): New macro. (struct template_symbol): New. * symtab.c (lookup_symbol_aux_local): Use cp_lookup_symbol_imports_or_template. * objfiles.h (struct objfile) <template_symbols>: New field. * objfiles.c (relocate_one_symbol): New function. (objfile_relocate1): Use it. Relocate isolated symbols. * gdbtypes.h (struct cplus_struct_type) <n_template_arguments, template_arguments>: New fields. (TYPE_N_TEMPLATE_ARGUMENTS): New macro. (TYPE_TEMPLATE_ARGUMENTS): Likewise. (TYPE_TEMPLATE_ARGUMENT): Likewise. (lookup_typename): Update. * gdbtypes.c (lookup_typename): Constify "block" argument. * dwarf2read.c: Include vec.h. (symbolp): New typedef. (read_func_scope): Read template arguments. Allocate a template_symbol when needed. (read_structure_type): Read template arguments. (new_symbol_full): New function, from new_symbol. Handle DW_TAG_template_type_param and DW_TAG_template_value_param. (new_symbol): Rewrite as wrapper. * cp-support.h (cp_lookup_symbol_imports_or_template): Declare. * cp-namespace.c: Include language.h. (search_symbol_list): New function. (cp_lookup_symbol_imports_or_template): Likewise. gdb/testsuite PR c++/9946: * gdb.cp/temargs.exp: New file. * gdb.cp/temargs.cc: New file.
This commit is contained in:
parent
75bc1f8113
commit
34eaf5422c
14 changed files with 532 additions and 40 deletions
|
@ -32,6 +32,7 @@
|
|||
#include "command.h"
|
||||
#include "frame.h"
|
||||
#include "buildsym.h"
|
||||
#include "language.h"
|
||||
|
||||
static struct symbol *lookup_namespace_scope (const char *name,
|
||||
const struct block *block,
|
||||
|
@ -412,6 +413,95 @@ cp_lookup_symbol_imports (const char *scope,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Helper function that searches an array of symbols for one named
|
||||
NAME. */
|
||||
|
||||
static struct symbol *
|
||||
search_symbol_list (const char *name, int num, struct symbol **syms)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Maybe we should store a dictionary in here instead. */
|
||||
for (i = 0; i < num; ++i)
|
||||
{
|
||||
if (strcmp (name, SYMBOL_NATURAL_NAME (syms[i])) == 0)
|
||||
return syms[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Like cp_lookup_symbol_imports, but if BLOCK is a function, it
|
||||
searches through the template parameters of the function and the
|
||||
function's type. */
|
||||
|
||||
struct symbol *
|
||||
cp_lookup_symbol_imports_or_template (const char *scope,
|
||||
const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain)
|
||||
{
|
||||
struct symbol *function = BLOCK_FUNCTION (block);
|
||||
|
||||
if (function != NULL && SYMBOL_LANGUAGE (function) == language_cplus)
|
||||
{
|
||||
int i;
|
||||
struct cplus_specific *cps
|
||||
= function->ginfo.language_specific.cplus_specific;
|
||||
|
||||
/* Search the function's template parameters. */
|
||||
if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function))
|
||||
{
|
||||
struct template_symbol *templ = (struct template_symbol *) function;
|
||||
struct symbol *result;
|
||||
|
||||
result = search_symbol_list (name,
|
||||
templ->n_template_arguments,
|
||||
templ->template_arguments);
|
||||
if (result != NULL)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Search the template parameters of the function's defining
|
||||
context. */
|
||||
if (SYMBOL_NATURAL_NAME (function))
|
||||
{
|
||||
struct type *context;
|
||||
char *name_copy = xstrdup (SYMBOL_NATURAL_NAME (function));
|
||||
struct cleanup *cleanups = make_cleanup (xfree, name_copy);
|
||||
const struct language_defn *lang = language_def (language_cplus);
|
||||
struct gdbarch *arch = SYMBOL_SYMTAB (function)->objfile->gdbarch;
|
||||
const struct block *parent = BLOCK_SUPERBLOCK (block);
|
||||
|
||||
while (1)
|
||||
{
|
||||
struct symbol *result;
|
||||
unsigned int prefix_len = cp_entire_prefix_len (name_copy);
|
||||
|
||||
if (prefix_len == 0)
|
||||
context = NULL;
|
||||
else
|
||||
{
|
||||
name_copy[prefix_len] = '\0';
|
||||
context = lookup_typename (lang, arch, name_copy, parent, 1);
|
||||
}
|
||||
|
||||
if (context == NULL)
|
||||
break;
|
||||
|
||||
result = search_symbol_list (name,
|
||||
TYPE_N_TEMPLATE_ARGUMENTS (context),
|
||||
TYPE_TEMPLATE_ARGUMENTS (context));
|
||||
if (result != NULL)
|
||||
return result;
|
||||
}
|
||||
|
||||
do_cleanups (cleanups);
|
||||
}
|
||||
}
|
||||
|
||||
return cp_lookup_symbol_imports (scope, name, block, domain, 1, 1);
|
||||
}
|
||||
|
||||
/* Searches for NAME in the current namespace, and by applying relevant import
|
||||
statements belonging to BLOCK and its parents. SCOPE is the namespace scope
|
||||
of the context in which the search is being evaluated. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue