From: Tom Tromey Date: Mon, 8 Apr 2013 19:56:03 +0000 (+0000) Subject: * ada-lang.c (ada_decode_symbol): Check and set 'ada_mangled'. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f85f34ede85d0c306e689736c6694caa2f0a0f78;p=binutils-gdb.git * 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) : New field. : New field. (SYMBOL_SET_LANGUAGE): Add 'obstack' argument. (symbol_set_language): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 17772f96479..3764fc943f2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,27 @@ +2013-04-08 Tom Tromey + + * 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) + : New field. + : New field. + (SYMBOL_SET_LANGUAGE): Add 'obstack' argument. + (symbol_set_language): Update. + 2013-04-08 Tom Tromey * symtab.c (symbol_init_cplus_specific, symbol_set_demangled_name): diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 43d6e3c4fc3..0329dd9eb87 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1297,30 +1297,28 @@ static struct htab *decoded_names_store; 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); diff --git a/gdb/coffread.c b/gdb/coffread.c index b5ad8c22eb0..f4f2afd05f4 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1586,7 +1586,8 @@ process_coff_symbol (struct coff_symbol *cs, 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 */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 76a32b68787..ad7860752fd 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6953,7 +6953,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) 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, @@ -15975,7 +15975,7 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, 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); diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c index 1bd862469d6..00818f62c2a 100644 --- a/gdb/jv-lang.c +++ b/gdb/jv-lang.c @@ -186,7 +186,7 @@ add_class_symbol (struct type *type, CORE_ADDR addr) 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; */ diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index a943cf95b86..d922207e6a1 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4878,7 +4878,8 @@ new_symbol (char *name) { 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; } diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 059b70a6dc7..900364aa524 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -916,7 +916,7 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name, 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; @@ -1265,7 +1265,7 @@ terminate_minimal_symbol_table (struct objfile *objfile) 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); } } diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 1d5f0ee42d9..e36268dbd56 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1589,10 +1589,10 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name, { 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) @@ -1605,7 +1605,7 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name, } 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; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 7939d6fc571..5fa183f678b 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -709,7 +709,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, 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); @@ -3675,7 +3676,8 @@ read_enum_type (char **pp, struct type *type, 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; diff --git a/gdb/symtab.c b/gdb/symtab.c index d56faa6b96a..8ef3966fc16 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -448,6 +448,19 @@ symbol_set_demangled_name (struct general_symbol_info *gsymbol, 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; } @@ -464,8 +477,14 @@ symbol_get_demangled_name (const struct general_symbol_info *gsymbol) 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; } @@ -474,7 +493,8 @@ symbol_get_demangled_name (const struct general_symbol_info *gsymbol) 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 @@ -483,7 +503,12 @@ symbol_set_language (struct general_symbol_info *gsymbol, || 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; @@ -688,7 +713,7 @@ symbol_set_names (struct general_symbol_info *gsymbol, name[len] = '\0'; gsymbol->name = name; } - symbol_set_demangled_name (gsymbol, NULL, NULL); + symbol_set_demangled_name (gsymbol, NULL, &objfile->objfile_obstack); return; } @@ -815,11 +840,7 @@ symbol_natural_name (const struct general_symbol_info *gsymbol) 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; } @@ -845,9 +866,7 @@ symbol_demangled_name (const struct general_symbol_info *gsymbol) 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; diff --git a/gdb/symtab.h b/gdb/symtab.h index 7c27bf927b0..a1da44be9cb 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -135,6 +135,11 @@ struct general_symbol_info 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 @@ -153,6 +158,11 @@ struct general_symbol_info 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. @@ -196,10 +206,11 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_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,