From: Tom Tromey Date: Fri, 24 Apr 2020 21:35:01 +0000 (-0600) Subject: Convert symbol_set_demangled_name to a method X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ff985671077a60f82e3cd8bcceda3efa0f3fabe6;p=binutils-gdb.git Convert symbol_set_demangled_name to a method This changes symbol_set_demangled_name to be a method on general_symbol_info, and updates the users. gdb/ChangeLog 2020-04-24 Tom Tromey * symtab.h (struct general_symbol_info) : New method. (symbol_set_demangled_name): Don't declare. * symtab.c (general_symbol_info::set_demangled_name): Rename from symbol_set_demangled_name. (general_symbol_info::set_language) (general_symbol_info::compute_and_set_names): Update. * minsyms.c (minimal_symbol_reader::install): Update. * dwarf2/read.c (new_symbol): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8911ff5dfdb..e2312778821 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2020-04-24 Tom Tromey + + * symtab.h (struct general_symbol_info) : New + method. + (symbol_set_demangled_name): Don't declare. + * symtab.c (general_symbol_info::set_demangled_name): Rename from + symbol_set_demangled_name. + (general_symbol_info::set_language) + (general_symbol_info::compute_and_set_names): Update. + * minsyms.c (minimal_symbol_reader::install): Update. + * dwarf2/read.c (new_symbol): Update. + 2020-04-24 Tom Tromey PR python/23662: diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 14d53a20e8b..86d3a7b7fdb 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -20569,9 +20569,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, between gfortran, iFort etc. */ if (cu->language == language_fortran && symbol_get_demangled_name (sym) == NULL) - symbol_set_demangled_name (sym, - dwarf2_full_name (name, die, cu), - NULL); + sym->set_demangled_name (dwarf2_full_name (name, die, cu), NULL); /* Default assumptions. Use the passed type or decode it from the die. */ diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 2c1262b0dd6..47c6f0bc0cd 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1418,9 +1418,8 @@ minimal_symbol_reader::install () /* This will be freed later, by compute_and_set_names. */ char *demangled_name = symbol_find_demangled_name (msym, msym->linkage_name ()); - symbol_set_demangled_name - (msym, demangled_name, - &m_objfile->per_bfd->storage_obstack); + msym->set_demangled_name + (demangled_name, &m_objfile->per_bfd->storage_obstack); msym->name_set = 1; } /* This mangled_name_hash computation has to be outside of diff --git a/gdb/symtab.c b/gdb/symtab.c index 4e9f91056b8..c9c75e94182 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -667,29 +667,27 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id) return (mangled_name); } -/* Set the demangled name of GSYMBOL to NAME. NAME must be already - correctly allocated. */ +/* See symtab.h. */ void -symbol_set_demangled_name (struct general_symbol_info *gsymbol, - const char *name, - struct obstack *obstack) +general_symbol_info::set_demangled_name (const char *name, + struct obstack *obstack) { - if (gsymbol->language () == language_ada) + if (language () == language_ada) { if (name == NULL) { - gsymbol->ada_mangled = 0; - gsymbol->language_specific.obstack = obstack; + ada_mangled = 0; + language_specific.obstack = obstack; } else { - gsymbol->ada_mangled = 1; - gsymbol->language_specific.demangled_name = name; + ada_mangled = 1; + language_specific.demangled_name = name; } } else - gsymbol->language_specific.demangled_name = name; + language_specific.demangled_name = name; } /* Return the demangled name of GSYMBOL. */ @@ -722,7 +720,7 @@ general_symbol_info::set_language (enum language language, || language == language_objc || language == language_fortran) { - symbol_set_demangled_name (this, NULL, obstack); + set_demangled_name (NULL, obstack); } else if (language == language_ada) { @@ -872,7 +870,7 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name, m_name = obstack_strndup (&per_bfd->storage_obstack, linkage_name.data (), linkage_name.length ()); - symbol_set_demangled_name (this, NULL, &per_bfd->storage_obstack); + set_demangled_name (NULL, &per_bfd->storage_obstack); return; } @@ -962,8 +960,7 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name, m_language = (*slot)->language; m_name = (*slot)->mangled.data (); - symbol_set_demangled_name (this, (*slot)->demangled.get (), - &per_bfd->storage_obstack); + set_demangled_name ((*slot)->demangled.get (), &per_bfd->storage_obstack); } /* See symtab.h. */ diff --git a/gdb/symtab.h b/gdb/symtab.h index 77f60e6c24a..ee570f92285 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -454,6 +454,11 @@ struct general_symbol_info void set_linkage_name (const char *linkage_name) { m_name = linkage_name; } + /* Set the demangled name of this symbol to NAME. NAME must be + already correctly allocated. If the symbol's language is Ada, + then the name is ignored and the obstack is set. */ + void set_demangled_name (const char *name, struct obstack *obstack); + enum language language () const { return m_language; } @@ -537,10 +542,6 @@ struct general_symbol_info short section; }; -extern void symbol_set_demangled_name (struct general_symbol_info *, - const char *, - struct obstack *); - extern const char *symbol_get_demangled_name (const struct general_symbol_info *);