Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009,
- 2010 Free Software Foundation, Inc.
+ 2010, 2011 Free Software Foundation, Inc.
This file is part of GDB.
is_full_physname_constructor = is_constructor_name (physname);
- is_constructor =
- is_full_physname_constructor || (newname && strcmp (field_name, newname) == 0);
+ is_constructor = is_full_physname_constructor
+ || (newname && strcmp (field_name, newname) == 0);
if (!is_destructor)
is_destructor = (strncmp (physname, "__dt", 4) == 0);
return (mangled_name);
}
+/* Initialize the cplus_specific structure. 'cplus_specific' should
+ only be allocated for use with cplus symbols. */
+
+static void
+symbol_init_cplus_specific (struct general_symbol_info *gsymbol,
+ struct objfile *objfile)
+{
+ /* A language_specific structure should not have been previously
+ initialized. */
+ gdb_assert (gsymbol->language_specific.cplus_specific == NULL);
+ gdb_assert (objfile != NULL);
+
+ gsymbol->language_specific.cplus_specific =
+ OBSTACK_ZALLOC (&objfile->objfile_obstack, struct cplus_specific);
+}
+
+/* Set the demangled name of GSYMBOL to NAME. NAME must be already
+ correctly allocated. For C++ symbols a cplus_specific struct is
+ allocated so OBJFILE must not be NULL. If this is a non C++ symbol
+ OBJFILE can be NULL. */
+void
+symbol_set_demangled_name (struct general_symbol_info *gsymbol,
+ char *name,
+ struct objfile *objfile)
+{
+ if (gsymbol->language == language_cplus)
+ {
+ if (gsymbol->language_specific.cplus_specific == NULL)
+ symbol_init_cplus_specific (gsymbol, objfile);
+
+ gsymbol->language_specific.cplus_specific->demangled_name = name;
+ }
+ else
+ gsymbol->language_specific.mangled_lang.demangled_name = name;
+}
+
+/* Return the demangled name of GSYMBOL. */
+char *
+symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
+{
+ if (gsymbol->language == language_cplus)
+ {
+ if (gsymbol->language_specific.cplus_specific != NULL)
+ return gsymbol->language_specific.cplus_specific->demangled_name;
+ else
+ return NULL;
+ }
+ else
+ return gsymbol->language_specific.mangled_lang.demangled_name;
+}
+
\f
/* Initialize the language dependent portion of a symbol
depending upon the language for the symbol. */
void
-symbol_init_language_specific (struct general_symbol_info *gsymbol,
- enum language language)
+symbol_set_language (struct general_symbol_info *gsymbol,
+ enum language language)
{
gsymbol->language = language;
- if (gsymbol->language == language_cplus
- || gsymbol->language == language_d
+ if (gsymbol->language == language_d
|| gsymbol->language == language_java
|| gsymbol->language == language_objc
|| gsymbol->language == language_fortran)
{
- gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+ symbol_set_demangled_name (gsymbol, NULL, NULL);
}
+ else if (gsymbol->language == language_cplus)
+ gsymbol->language_specific.cplus_specific = NULL;
else
{
memset (&gsymbol->language_specific, 0,
memcpy (gsymbol->name, linkage_name, len);
gsymbol->name[len] = '\0';
}
- gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+ symbol_set_demangled_name (gsymbol, NULL, NULL);
return;
}
gsymbol->name = (*slot)->mangled + lookup_len - len;
if ((*slot)->demangled[0] != '\0')
- gsymbol->language_specific.cplus_specific.demangled_name
- = (*slot)->demangled;
+ symbol_set_demangled_name (gsymbol, (*slot)->demangled, objfile);
else
- gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+ symbol_set_demangled_name (gsymbol, NULL, objfile);
}
/* Return the source code name of a symbol. In languages where
case language_java:
case language_objc:
case language_fortran:
- if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
- return gsymbol->language_specific.cplus_specific.demangled_name;
+ if (symbol_get_demangled_name (gsymbol) != NULL)
+ return symbol_get_demangled_name (gsymbol);
break;
case language_ada:
- if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
- return gsymbol->language_specific.cplus_specific.demangled_name;
+ if (symbol_get_demangled_name (gsymbol) != NULL)
+ return symbol_get_demangled_name (gsymbol);
else
return ada_decode_symbol (gsymbol);
break;
case language_java:
case language_objc:
case language_fortran:
- if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
- return gsymbol->language_specific.cplus_specific.demangled_name;
+ if (symbol_get_demangled_name (gsymbol) != NULL)
+ return symbol_get_demangled_name (gsymbol);
break;
case language_ada:
- if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
- return gsymbol->language_specific.cplus_specific.demangled_name;
+ if (symbol_get_demangled_name (gsymbol) != NULL)
+ return symbol_get_demangled_name (gsymbol);
else
return ada_decode_symbol (gsymbol);
break;
if (language == language_cplus || language == language_fortran)
{
- sym = cp_lookup_symbol_imports (scope,
- name,
- block,
- domain,
- 1,
- 1);
+ sym = cp_lookup_symbol_imports_or_template (scope, name, block,
+ domain);
if (sym != NULL)
return sym;
}
const struct block *block;
struct symtab *s;
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_OBJFILES (objfile)
{
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, block_index);
- sym = lookup_block_symbol (block, name, domain);
- if (sym)
- {
- block_found = block;
- return fixup_symbol_section (sym, objfile);
- }
+ if (objfile->sf)
+ objfile->sf->qf->pre_expand_symtabs_matching (objfile,
+ block_index,
+ name, domain);
+
+ ALL_OBJFILE_SYMTABS (objfile, s)
+ if (s->primary)
+ {
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, block_index);
+ sym = lookup_block_symbol (block, name, domain);
+ if (sym)
+ {
+ block_found = block;
+ return fixup_symbol_section (sym, objfile);
+ }
+ }
}
return NULL;
STATIC_BLOCK : GLOBAL_BLOCK);
sym = lookup_block_symbol (block, name, domain);
if (!sym)
- error (_("Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s<type>)."),
+ error (_("\
+Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\
+%s may be an inlined function, or may be a template function\n\
+(if a template, try specifying an instantiation: %s<type>)."),
kind == GLOBAL_BLOCK ? "global" : "static",
name, symtab->filename, name, name);
}
sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
/* FIXME; error is wrong in one case */
- error (_("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
+ error (_("\
+Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
(if a template, try specifying an instantiation: %s<type>)."),
name, symtab->filename, name, name);
of the desired name as a global, then do psymtab-to-symtab
conversion on the fly and return the found symbol. */
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_OBJFILES (objfile)
{
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
- if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
- {
- return SYMBOL_TYPE (sym);
- }
+ if (objfile->sf)
+ objfile->sf->qf->pre_expand_symtabs_matching (objfile,
+ GLOBAL_BLOCK,
+ name, STRUCT_DOMAIN);
+
+ ALL_OBJFILE_SYMTABS (objfile, s)
+ if (s->primary)
+ {
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
+ if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+ {
+ return SYMBOL_TYPE (sym);
+ }
+ }
}
ALL_OBJFILES (objfile)
conversion on the fly and return the found symbol.
*/
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_OBJFILES (objfile)
{
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
- if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+ if (objfile->sf)
+ objfile->sf->qf->pre_expand_symtabs_matching (objfile, STATIC_BLOCK,
+ name, STRUCT_DOMAIN);
+
+ ALL_OBJFILE_SYMTABS (objfile, s)
{
- return SYMBOL_TYPE (sym);
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
+ if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+ {
+ return SYMBOL_TYPE (sym);
+ }
}
}
/* FIXME: What about languages without main() or specially linked
executables that have no main() ? */
-char *
+const char *
find_main_filename (void)
{
struct objfile *objfile;
- char *result, *name = main_name ();
+ char *name = main_name ();
ALL_OBJFILES (objfile)
{
+ const char *result;
+
if (!objfile->sf)
continue;
result = objfile->sf->qf->find_symbol_file (objfile, name);
* so of course we can't find the real func/line info,
* but the "break" still works, and the warning is annoying.
* So I commented out the warning. RT */
- /* warning ("In stub for %s; unable to find real function/line info", SYMBOL_LINKAGE_NAME (msymbol)) */ ;
+ /* warning ("In stub for %s; unable to find real function/line info",
+ SYMBOL_LINKAGE_NAME (msymbol)) */ ;
/* fall through */
- else if (SYMBOL_VALUE_ADDRESS (mfunsym) == SYMBOL_VALUE_ADDRESS (msymbol))
+ else if (SYMBOL_VALUE_ADDRESS (mfunsym)
+ == SYMBOL_VALUE_ADDRESS (msymbol))
/* Avoid infinite recursion */
/* See above comment about why warning is commented out */
- /* warning ("In stub for %s; unable to find real function/line info", SYMBOL_LINKAGE_NAME (msymbol)) */ ;
+ /* warning ("In stub for %s; unable to find real function/line info",
+ SYMBOL_LINKAGE_NAME (msymbol)) */ ;
/* fall through */
else
return find_pc_line (SYMBOL_VALUE_ADDRESS (mfunsym), 0);
case '\\': /* regexp quoting */
if (p[1] == '*')
{
- if (p[2] == '=') /* 'operator\*=' */
+ if (p[2] == '=') /* 'operator\*=' */
*end = p + 3;
else /* 'operator\*' */
*end = p + 2;
else if (p[1] == '[')
{
if (p[2] == ']')
- error (_("mismatched quoting on brackets, try 'operator\\[\\]'"));
+ error (_("mismatched quoting on brackets, "
+ "try 'operator\\[\\]'"));
else if (p[2] == '\\' && p[3] == ']')
{
*end = p + 4; /* 'operator\[\]' */
return p;
case '(':
if (p[1] != ')')
- error (_("`operator ()' must be specified without whitespace in `()'"));
+ error (_("`operator ()' must be specified "
+ "without whitespace in `()'"));
*end = p + 2;
return p;
case '?':
if (p[1] != ':')
- error (_("`operator ?:' must be specified without whitespace in `?:'"));
+ error (_("`operator ?:' must be specified "
+ "without whitespace in `?:'"));
*end = p + 2;
return p;
case '[':
if (p[1] != ']')
- error (_("`operator []' must be specified without whitespace in `[]'"));
+ error (_("`operator []' must be specified "
+ "without whitespace in `[]'"));
*end = p + 2;
return p;
default:
}
printf_filtered ("\n\n");
- printf_filtered ("Source files for which symbols will be read in on demand:\n\n");
+ printf_filtered ("Source files for which symbols "
+ "will be read in on demand:\n\n");
first = 1;
map_partial_symbol_filenames (output_partial_symbol_filename, &first);
struct minimal_symbol *msymbol;
char *val;
int found_misc = 0;
- static enum minimal_symbol_type types[]
+ static const enum minimal_symbol_type types[]
= {mst_data, mst_text, mst_abs, mst_unknown};
- static enum minimal_symbol_type types2[]
+ static const enum minimal_symbol_type types2[]
= {mst_bss, mst_file_text, mst_abs, mst_unknown};
- static enum minimal_symbol_type types3[]
+ static const enum minimal_symbol_type types3[]
= {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown};
- static enum minimal_symbol_type types4[]
+ static const enum minimal_symbol_type types4[]
= {mst_file_bss, mst_text, mst_abs, mst_unknown};
enum minimal_symbol_type ourtype;
enum minimal_symbol_type ourtype2;
if (*opname)
{
- int fix = -1; /* -1 means ok; otherwise number of spaces needed. */
+ int fix = -1; /* -1 means ok; otherwise number of
+ spaces needed. */
if (isalpha (*opname) || *opname == '_' || *opname == '$')
{
e.g., c++ static const members.
We only want to skip enums here. */
&& !(SYMBOL_CLASS (sym) == LOC_CONST
- && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM))
- || (kind == FUNCTIONS_DOMAIN && SYMBOL_CLASS (sym) == LOC_BLOCK)
- || (kind == TYPES_DOMAIN && SYMBOL_CLASS (sym) == LOC_TYPEDEF))))
+ && TYPE_CODE (SYMBOL_TYPE (sym))
+ == TYPE_CODE_ENUM))
+ || (kind == FUNCTIONS_DOMAIN
+ && SYMBOL_CLASS (sym) == LOC_BLOCK)
+ || (kind == TYPES_DOMAIN
+ && SYMBOL_CLASS (sym) == LOC_TYPEDEF))))
{
/* match */
- psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search));
+ psr = (struct symbol_search *)
+ xmalloc (sizeof (struct symbol_search));
psr->block = i;
psr->symtab = real_symtab;
psr->symbol = sym;
== NULL)
{
/* match */
- psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search));
+ psr = (struct symbol_search *)
+ xmalloc (sizeof (struct symbol_search));
psr->block = i;
psr->msymbol = msymbol;
psr->symtab = NULL;
static void
symtab_symbol_info (char *regexp, domain_enum kind, int from_tty)
{
- static char *classnames[] = {"variable", "function", "type", "method"};
+ static const char * const classnames[] =
+ {"variable", "function", "type", "method"};
struct symbol_search *symbols;
struct symbol_search *p;
struct cleanup *old_chain;
/* A callback for map_partial_symbol_filenames. */
static void
-maybe_add_partial_symtab_filename (const char *fullname, const char *filename,
+maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
void *user_data)
{
struct add_partial_filename_data *data = user_data;
/* Track MAIN */
static char *name_of_main;
+enum language language_of_main = language_unknown;
void
set_main_name (const char *name)
{
xfree (name_of_main);
name_of_main = NULL;
+ language_of_main = language_unknown;
}
if (name != NULL)
{
name_of_main = xstrdup (name);
+ language_of_main = language_unknown;
}
}