Use symbol's obstack, not an objfile.
* coffread.c (process_coff_symbol): Update.
* dwarf2read.c (fixup_go_packaging, new_symbol_full): Update.
* jv-lang.c (add_class_symbol): Update.
* mdebugread.c (new_symbol): Update.
* minsyms.c (prim_record_minimal_symbol_full)
(terminate_minimal_symbol_table): Update.
* psymtab.c (add_psymbol_to_bcache): Clear entire symbol. Update.
* stabsread.c (define_symbol, read_enum_type): Update.
* symtab.c (symbol_set_demangled_name, symbol_get_demangled_name):
Handle Ada specially.
(symbol_set_language): Add 'obstack' argument.
(symbol_set_names): Update.
(symbol_natural_name, symbol_demangled_name): Always use
ada_decode_symbol.
* symtab.h (struct general_symbol_info)
<language_specific::obstack>: New field.
<ada_mangled>: New field.
(SYMBOL_SET_LANGUAGE): Add 'obstack' argument.
(symbol_set_language): Update.
+2013-04-08 Tom Tromey <tromey@redhat.com>
+
+ * ada-lang.c (ada_decode_symbol): Check and set 'ada_mangled'.
+ Use symbol's obstack, not an objfile.
+ * coffread.c (process_coff_symbol): Update.
+ * dwarf2read.c (fixup_go_packaging, new_symbol_full): Update.
+ * jv-lang.c (add_class_symbol): Update.
+ * mdebugread.c (new_symbol): Update.
+ * minsyms.c (prim_record_minimal_symbol_full)
+ (terminate_minimal_symbol_table): Update.
+ * psymtab.c (add_psymbol_to_bcache): Clear entire symbol. Update.
+ * stabsread.c (define_symbol, read_enum_type): Update.
+ * symtab.c (symbol_set_demangled_name, symbol_get_demangled_name):
+ Handle Ada specially.
+ (symbol_set_language): Add 'obstack' argument.
+ (symbol_set_names): Update.
+ (symbol_natural_name, symbol_demangled_name): Always use
+ ada_decode_symbol.
+ * symtab.h (struct general_symbol_info)
+ <language_specific::obstack>: New field.
+ <ada_mangled>: New field.
+ (SYMBOL_SET_LANGUAGE): Add 'obstack' argument.
+ (symbol_set_language): Update.
+
2013-04-08 Tom Tromey <tromey@redhat.com>
* symtab.c (symbol_init_cplus_specific, symbol_set_demangled_name):
when a decoded name is cached in it. */
const char *
-ada_decode_symbol (const struct general_symbol_info *gsymbol)
+ada_decode_symbol (const struct general_symbol_info *arg)
{
- struct general_symbol_info *gsymbol_rw
- = (struct general_symbol_info *) gsymbol;
- const char **resultp
- = &gsymbol_rw->language_specific.mangled_lang.demangled_name;
+ struct general_symbol_info *gsymbol = (struct general_symbol_info *) arg;
+ const char **resultp =
+ &gsymbol->language_specific.mangled_lang.demangled_name;
- if (*resultp == NULL)
+ if (!gsymbol->ada_mangled)
{
const char *decoded = ada_decode (gsymbol->name);
+ struct obstack *obstack = gsymbol->language_specific.obstack;
- if (gsymbol->obj_section != NULL)
- {
- struct objfile *objf = gsymbol->obj_section->objfile;
+ gsymbol->ada_mangled = 1;
- *resultp = obstack_copy0 (&objf->objfile_obstack,
- decoded, strlen (decoded));
- }
- /* Sometimes, we can't find a corresponding objfile, in which
- case, we put the result on the heap. Since we only decode
- when needed, we hope this usually does not cause a
- significant memory leak (FIXME). */
- if (*resultp == NULL)
+ if (obstack != NULL)
+ *resultp = obstack_copy0 (obstack, decoded, strlen (decoded));
+ else
{
+ /* Sometimes, we can't find a corresponding objfile, in
+ which case, we put the result on the heap. Since we only
+ decode when needed, we hope this usually does not cause a
+ significant memory leak (FIXME). */
+
char **slot = (char **) htab_find_slot (decoded_names_store,
decoded, INSERT);
name = cs->c_name;
name = EXTERNAL_NAME (name, objfile->obfd);
- SYMBOL_SET_LANGUAGE (sym, current_subfile->language);
+ SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+ &objfile->objfile_obstack);
SYMBOL_SET_NAMES (sym, name, strlen (name), 1, objfile);
/* default assumptions */
TYPE_TAG_NAME (type) = TYPE_NAME (type);
sym = allocate_symbol (objfile);
- SYMBOL_SET_LANGUAGE (sym, language_go);
+ SYMBOL_SET_LANGUAGE (sym, language_go, &objfile->objfile_obstack);
SYMBOL_SET_NAMES (sym, saved_package_name,
strlen (saved_package_name), 0, objfile);
/* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
OBJSTAT (objfile, n_syms++);
/* Cache this symbol's name and the name's demangled form (if any). */
- SYMBOL_SET_LANGUAGE (sym, cu->language);
+ SYMBOL_SET_LANGUAGE (sym, cu->language, &objfile->objfile_obstack);
linkagename = dwarf2_physname (name, die, cu);
SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile);
struct objfile *objfile = get_dynamics_objfile (get_type_arch (type));
sym = allocate_symbol (objfile);
- SYMBOL_SET_LANGUAGE (sym, language_java);
+ SYMBOL_SET_LANGUAGE (sym, language_java, &objfile->objfile_obstack);
SYMBOL_SET_LINKAGE_NAME (sym, TYPE_TAG_NAME (type));
SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
/* SYMBOL_VALUE (sym) = valu; */
{
struct symbol *s = allocate_symbol (mdebugread_objfile);
- SYMBOL_SET_LANGUAGE (s, psymtab_language);
+ SYMBOL_SET_LANGUAGE (s, psymtab_language,
+ &mdebugread_objfile->objfile_obstack);
SYMBOL_SET_NAMES (s, name, strlen (name), 1, mdebugread_objfile);
return s;
}
msym_bunch = new;
}
msymbol = &msym_bunch->contents[msym_bunch_index];
- SYMBOL_SET_LANGUAGE (msymbol, language_auto);
+ SYMBOL_SET_LANGUAGE (msymbol, language_auto, &objfile->objfile_obstack);
SYMBOL_SET_NAMES (msymbol, name, name_len, copy_name, objfile);
SYMBOL_VALUE_ADDRESS (msymbol) = address;
memset (m, 0, sizeof (*m));
/* Don't rely on these enumeration values being 0's. */
MSYMBOL_TYPE (m) = mst_unknown;
- SYMBOL_SET_LANGUAGE (m, language_unknown);
+ SYMBOL_SET_LANGUAGE (m, language_unknown, &objfile->objfile_obstack);
}
}
{
struct partial_symbol psymbol;
- /* We must ensure that the entire 'value' field has been zeroed
- before assigning to it, because an assignment may not write the
- entire field. */
- memset (&psymbol.ginfo.value, 0, sizeof (psymbol.ginfo.value));
+ /* We must ensure that the entire struct has been zeroed before
+ assigning to it, because an assignment may not touch some of the
+ holes. */
+ memset (&psymbol, 0, sizeof (psymbol));
/* val and coreaddr are mutually exclusive, one of them *will* be zero. */
if (val != 0)
}
SYMBOL_SECTION (&psymbol) = 0;
SYMBOL_OBJ_SECTION (&psymbol) = NULL;
- SYMBOL_SET_LANGUAGE (&psymbol, language);
+ SYMBOL_SET_LANGUAGE (&psymbol, language, &objfile->objfile_obstack);
PSYMBOL_DOMAIN (&psymbol) = domain;
PSYMBOL_CLASS (&psymbol) = class;
else
{
normal:
- SYMBOL_SET_LANGUAGE (sym, current_subfile->language);
+ SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+ &objfile->objfile_obstack);
if (SYMBOL_LANGUAGE (sym) == language_cplus)
{
char *name = alloca (p - string + 1);
sym = allocate_symbol (objfile);
SYMBOL_SET_LINKAGE_NAME (sym, name);
- SYMBOL_SET_LANGUAGE (sym, current_subfile->language);
+ SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+ &objfile->objfile_obstack);
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_VALUE (sym) = n;
gsymbol->language_specific.cplus_specific->demangled_name = name;
}
+ else if (gsymbol->language == language_ada)
+ {
+ if (name == NULL)
+ {
+ gsymbol->ada_mangled = 0;
+ gsymbol->language_specific.obstack = obstack;
+ }
+ else
+ {
+ gsymbol->ada_mangled = 1;
+ gsymbol->language_specific.mangled_lang.demangled_name = name;
+ }
+ }
else
gsymbol->language_specific.mangled_lang.demangled_name = name;
}
else
return NULL;
}
- else
- return gsymbol->language_specific.mangled_lang.demangled_name;
+ else if (gsymbol->language == language_ada)
+ {
+ if (!gsymbol->ada_mangled)
+ return NULL;
+ /* Fall through. */
+ }
+
+ return gsymbol->language_specific.mangled_lang.demangled_name;
}
\f
void
symbol_set_language (struct general_symbol_info *gsymbol,
- enum language language)
+ enum language language,
+ struct obstack *obstack)
{
gsymbol->language = language;
if (gsymbol->language == language_d
|| gsymbol->language == language_objc
|| gsymbol->language == language_fortran)
{
- symbol_set_demangled_name (gsymbol, NULL, NULL);
+ symbol_set_demangled_name (gsymbol, NULL, obstack);
+ }
+ else if (gsymbol->language == language_ada)
+ {
+ gdb_assert (gsymbol->ada_mangled == 0);
+ gsymbol->language_specific.obstack = obstack;
}
else if (gsymbol->language == language_cplus)
gsymbol->language_specific.cplus_specific = NULL;
name[len] = '\0';
gsymbol->name = name;
}
- symbol_set_demangled_name (gsymbol, NULL, NULL);
+ symbol_set_demangled_name (gsymbol, NULL, &objfile->objfile_obstack);
return;
}
return symbol_get_demangled_name (gsymbol);
break;
case language_ada:
- if (symbol_get_demangled_name (gsymbol) != NULL)
- return symbol_get_demangled_name (gsymbol);
- else
- return ada_decode_symbol (gsymbol);
- break;
+ return ada_decode_symbol (gsymbol);
default:
break;
}
dem_name = symbol_get_demangled_name (gsymbol);
break;
case language_ada:
- dem_name = symbol_get_demangled_name (gsymbol);
- if (dem_name == NULL)
- dem_name = ada_decode_symbol (gsymbol);
+ dem_name = ada_decode_symbol (gsymbol);
break;
default:
break;
union
{
+ /* A pointer to an obstack that can be used for storage associated
+ with this symbol. This is only used by Ada, and only when the
+ 'ada_mangled' field is zero. */
+ struct obstack *obstack;
+
/* This is used by languages which wish to store a demangled name.
currently used by Ada, Java, and Objective C. */
struct mangled_lang
ENUM_BITFIELD(language) language : 8;
+ /* This is only used by Ada. If set, then the 'mangled_lang' field
+ of language_specific is valid. Otherwise, the 'obstack' field is
+ valid. */
+ unsigned int ada_mangled : 1;
+
/* Which section is this symbol in? This is an index into
section_offsets for this objfile. Negative means that the symbol
does not get relocated relative to a section.
/* Initializes the language dependent portion of a symbol
depending upon the language for the symbol. */
-#define SYMBOL_SET_LANGUAGE(symbol,language) \
- (symbol_set_language (&(symbol)->ginfo, (language)))
+#define SYMBOL_SET_LANGUAGE(symbol,language,obstack) \
+ (symbol_set_language (&(symbol)->ginfo, (language), (obstack)))
extern void symbol_set_language (struct general_symbol_info *symbol,
- enum language language);
+ enum language language,
+ struct obstack *obstack);
/* Set just the linkage name of a symbol; do not try to demangle
it. Used for constructs which do not have a mangled name,