Use a member function to set a symbol's language
This removes symbol_set_language and SYMBOL_SET_LANGUAGE in favor of a new function general_symbol_info::set_language. symbol and minimal_symbol already inherit from that struct so this works naturally. gdb/ChangeLog: 2019-12-15 Christian Biesinger <cbiesinger@google.com> * ada-exp.y (write_ambiguous_var): Update. * coffread.c (process_coff_symbol): Update. * ctfread.c (ctf_add_enum_member_cb): Update. (new_symbol): Update. * dwarf2read.c (fixup_go_packaging): Update. (new_symbol): Update. * language.c (language_alloc_type_symbol): Update. * mdebugread.c (new_symbol): Update. * minsyms.c (minimal_symbol_reader::record_full): Update. * psymtab.c (add_psymbol_to_bcache): Update. * stabsread.c (define_symbol): Update. (read_enum_type): Update. * symtab.c (symbol_set_language): Make this a member function... (general_symbol_info::set_language): ... here. * symtab.h (struct general_symbol_info) <set_language>: New function. (SYMBOL_SET_LANGUAGE): Remove. (symbol_set_language): Remove. Change-Id: Ideafb6c384004b9adef793a1192735c501da41d5
This commit is contained in:
parent
c1b5c1ebc9
commit
d3ecddab5f
@ -1,3 +1,23 @@
|
||||
2019-12-15 Christian Biesinger <cbiesinger@google.com>
|
||||
|
||||
* ada-exp.y (write_ambiguous_var): Update.
|
||||
* coffread.c (process_coff_symbol): Update.
|
||||
* ctfread.c (ctf_add_enum_member_cb): Update.
|
||||
(new_symbol): Update.
|
||||
* dwarf2read.c (fixup_go_packaging): Update.
|
||||
(new_symbol): Update.
|
||||
* language.c (language_alloc_type_symbol): Update.
|
||||
* mdebugread.c (new_symbol): Update.
|
||||
* minsyms.c (minimal_symbol_reader::record_full): Update.
|
||||
* psymtab.c (add_psymbol_to_bcache): Update.
|
||||
* stabsread.c (define_symbol): Update.
|
||||
(read_enum_type): Update.
|
||||
* symtab.c (symbol_set_language): Make this a member function...
|
||||
(general_symbol_info::set_language): ... here.
|
||||
* symtab.h (struct general_symbol_info) <set_language>: New function.
|
||||
(SYMBOL_SET_LANGUAGE): Remove.
|
||||
(symbol_set_language): Remove.
|
||||
|
||||
2019-12-15 Christian Biesinger <cbiesinger@google.com>
|
||||
|
||||
* ada-lang.c (ada_add_block_symbols): Update.
|
||||
|
@ -1106,7 +1106,7 @@ write_ambiguous_var (struct parser_state *par_state,
|
||||
|
||||
SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN;
|
||||
sym->set_linkage_name (obstack_strndup (&temp_parse_space, name, len));
|
||||
symbol_set_language (sym, language_ada, nullptr);
|
||||
sym->set_language (language_ada, nullptr);
|
||||
|
||||
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
|
||||
write_exp_elt_block (par_state, block);
|
||||
|
@ -1566,8 +1566,8 @@ process_coff_symbol (struct coff_symbol *cs,
|
||||
|
||||
name = cs->c_name;
|
||||
name = EXTERNAL_NAME (name, objfile->obfd);
|
||||
SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
|
||||
&objfile->objfile_obstack);
|
||||
sym->set_language (get_current_subfile ()->language,
|
||||
&objfile->objfile_obstack);
|
||||
SYMBOL_SET_NAMES (sym, name, true, objfile);
|
||||
|
||||
/* default assumptions */
|
||||
|
@ -379,7 +379,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg)
|
||||
struct symbol *sym = allocate_symbol (ccp->of);
|
||||
OBJSTAT (ccp->of, n_syms++);
|
||||
|
||||
SYMBOL_SET_LANGUAGE (sym, language_c, &ccp->of->objfile_obstack);
|
||||
sym->set_language (language_c, &ccp->of->objfile_obstack);
|
||||
SYMBOL_SET_NAMES (sym, name, false, ccp->of);
|
||||
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
|
||||
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
|
||||
@ -408,7 +408,7 @@ new_symbol (ctf_context_t *ccp, struct type *type, ctf_id_t tid)
|
||||
sym = allocate_symbol (objfile);
|
||||
OBJSTAT (objfile, n_syms++);
|
||||
|
||||
SYMBOL_SET_LANGUAGE (sym, language_c, &objfile->objfile_obstack);
|
||||
sym->set_language (language_c, &objfile->objfile_obstack);
|
||||
SYMBOL_SET_NAMES (sym, name.get (), true, objfile);
|
||||
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
|
||||
SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
|
||||
|
@ -9952,7 +9952,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
|
||||
struct symbol *sym;
|
||||
|
||||
sym = allocate_symbol (objfile);
|
||||
SYMBOL_SET_LANGUAGE (sym, language_go, &objfile->objfile_obstack);
|
||||
sym->set_language (language_go, &objfile->objfile_obstack);
|
||||
SYMBOL_SET_NAMES (sym, saved_package_name, false, objfile);
|
||||
/* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
|
||||
e.g., "main" finds the "main" module and not C's main(). */
|
||||
@ -21782,7 +21782,7 @@ new_symbol (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, &objfile->objfile_obstack);
|
||||
sym->set_language (cu->language, &objfile->objfile_obstack);
|
||||
linkagename = dwarf2_physname (name, die, cu);
|
||||
SYMBOL_SET_NAMES (sym, linkagename, false, objfile);
|
||||
|
||||
|
@ -1051,7 +1051,7 @@ language_alloc_type_symbol (enum language lang, struct type *type)
|
||||
symbol = new (gdbarch_obstack (gdbarch)) struct symbol ();
|
||||
|
||||
symbol->name = TYPE_NAME (type);
|
||||
symbol_set_language (symbol, lang, nullptr);
|
||||
symbol->set_language (lang, nullptr);
|
||||
symbol->owner.arch = gdbarch;
|
||||
SYMBOL_OBJFILE_OWNED (symbol) = 0;
|
||||
SYMBOL_TYPE (symbol) = type;
|
||||
|
@ -4761,8 +4761,7 @@ new_symbol (const char *name)
|
||||
{
|
||||
struct symbol *s = allocate_symbol (mdebugread_objfile);
|
||||
|
||||
SYMBOL_SET_LANGUAGE (s, psymtab_language,
|
||||
&mdebugread_objfile->objfile_obstack);
|
||||
s->set_language (psymtab_language, &mdebugread_objfile->objfile_obstack);
|
||||
SYMBOL_SET_NAMES (s, name, true, mdebugread_objfile);
|
||||
return s;
|
||||
}
|
||||
|
@ -1128,8 +1128,8 @@ minimal_symbol_reader::record_full (gdb::string_view name,
|
||||
m_msym_bunch = newobj;
|
||||
}
|
||||
msymbol = &m_msym_bunch->contents[m_msym_bunch_index];
|
||||
symbol_set_language (msymbol, language_auto,
|
||||
&m_objfile->per_bfd->storage_obstack);
|
||||
msymbol->set_language (language_auto,
|
||||
&m_objfile->per_bfd->storage_obstack);
|
||||
|
||||
if (copy_name)
|
||||
msymbol->name = obstack_strndup (&m_objfile->per_bfd->storage_obstack,
|
||||
|
@ -1584,8 +1584,7 @@ add_psymbol_to_bcache (gdb::string_view name, bool copy_name,
|
||||
psymbol.ginfo.section = section;
|
||||
psymbol.domain = domain;
|
||||
psymbol.aclass = theclass;
|
||||
symbol_set_language (&psymbol.ginfo, language,
|
||||
objfile->partial_symtabs->obstack ());
|
||||
psymbol.ginfo.set_language (language, objfile->partial_symtabs->obstack ());
|
||||
symbol_set_names (&psymbol.ginfo, name, copy_name,
|
||||
objfile->per_bfd);
|
||||
|
||||
|
@ -700,8 +700,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
|
||||
SYMBOL_LINE (sym) = 0; /* unknown */
|
||||
}
|
||||
|
||||
SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
|
||||
&objfile->objfile_obstack);
|
||||
sym->set_language (get_current_subfile ()->language,
|
||||
&objfile->objfile_obstack);
|
||||
|
||||
if (is_cplus_marker (string[0]))
|
||||
{
|
||||
@ -3638,8 +3638,8 @@ read_enum_type (const char **pp, struct type *type,
|
||||
|
||||
sym = allocate_symbol (objfile);
|
||||
sym->set_linkage_name (name);
|
||||
SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
|
||||
&objfile->objfile_obstack);
|
||||
sym->set_language (get_current_subfile ()->language,
|
||||
&objfile->objfile_obstack);
|
||||
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
|
||||
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
|
||||
SYMBOL_VALUE (sym) = n;
|
||||
|
16
gdb/symtab.c
16
gdb/symtab.c
@ -712,28 +712,26 @@ symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
|
||||
depending upon the language for the symbol. */
|
||||
|
||||
void
|
||||
symbol_set_language (struct general_symbol_info *gsymbol,
|
||||
enum language language,
|
||||
struct obstack *obstack)
|
||||
general_symbol_info::set_language (enum language language,
|
||||
struct obstack *obstack)
|
||||
{
|
||||
gsymbol->m_language = language;
|
||||
m_language = language;
|
||||
if (language == language_cplus
|
||||
|| language == language_d
|
||||
|| language == language_go
|
||||
|| language == language_objc
|
||||
|| language == language_fortran)
|
||||
{
|
||||
symbol_set_demangled_name (gsymbol, NULL, obstack);
|
||||
symbol_set_demangled_name (this, NULL, obstack);
|
||||
}
|
||||
else if (language == language_ada)
|
||||
{
|
||||
gdb_assert (gsymbol->ada_mangled == 0);
|
||||
gsymbol->language_specific.obstack = obstack;
|
||||
gdb_assert (ada_mangled == 0);
|
||||
language_specific.obstack = obstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset (&gsymbol->language_specific, 0,
|
||||
sizeof (gsymbol->language_specific));
|
||||
memset (&language_specific, 0, sizeof (language_specific));
|
||||
}
|
||||
}
|
||||
|
||||
|
12
gdb/symtab.h
12
gdb/symtab.h
@ -428,6 +428,10 @@ struct general_symbol_info
|
||||
enum language language () const
|
||||
{ return m_language; }
|
||||
|
||||
/* Initializes the language dependent portion of a symbol
|
||||
depending upon the language for the symbol. */
|
||||
void set_language (enum language language, struct obstack *obstack);
|
||||
|
||||
/* Name of the symbol. This is a required field. Storage for the
|
||||
name is allocated on the objfile_obstack for the associated
|
||||
objfile. For languages like C++ that make a distinction between
|
||||
@ -531,14 +535,6 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym);
|
||||
? (&(((objfile)->sections)[(symbol)->section])) \
|
||||
: NULL)
|
||||
|
||||
/* Initializes the language dependent portion of a symbol
|
||||
depending upon the language for the symbol. */
|
||||
#define SYMBOL_SET_LANGUAGE(symbol,language,obstack) \
|
||||
(symbol_set_language ((symbol), (language), (obstack)))
|
||||
extern void symbol_set_language (struct general_symbol_info *symbol,
|
||||
enum language language,
|
||||
struct obstack *obstack);
|
||||
|
||||
/* Try to determine the demangled name for a symbol, based on the
|
||||
language of that symbol. If the language is set to language_auto,
|
||||
it will attempt to find any demangling algorithm that works and
|
||||
|
Loading…
x
Reference in New Issue
Block a user