aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-12-11 19:50:43 -0500
committerChristian Biesinger <cbiesinger@google.com>2019-12-16 00:44:58 -0600
commitd3ecddab5fc036fb57588a9bfff73575dc419052 (patch)
treec8f55940571566a15e9ecec31841d9ee038835b6
parentc1b5c1ebc938b6dc0277363b8c47d75b0b5a621f (diff)
downloadgdb-d3ecddab5fc036fb57588a9bfff73575dc419052.zip
gdb-d3ecddab5fc036fb57588a9bfff73575dc419052.tar.gz
gdb-d3ecddab5fc036fb57588a9bfff73575dc419052.tar.bz2
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
-rw-r--r--gdb/ChangeLog20
-rw-r--r--gdb/ada-exp.y2
-rw-r--r--gdb/coffread.c4
-rw-r--r--gdb/ctfread.c4
-rw-r--r--gdb/dwarf2read.c4
-rw-r--r--gdb/language.c2
-rw-r--r--gdb/mdebugread.c3
-rw-r--r--gdb/minsyms.c4
-rw-r--r--gdb/psymtab.c3
-rw-r--r--gdb/stabsread.c8
-rw-r--r--gdb/symtab.c16
-rw-r--r--gdb/symtab.h12
12 files changed, 47 insertions, 35 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 60cf8c1..f3b27bd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,25 @@
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.
(ada_collect_symbol_completion_matches): Update.
* ax-gdb.c (gen_expr): Update.
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 6b1bdfa..a02e22d 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -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);
diff --git a/gdb/coffread.c b/gdb/coffread.c
index d0a9233..e591651 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -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 */
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index c5f9130..06a4bc2 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -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;
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 6a09d55..ecfae68 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -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);
diff --git a/gdb/language.c b/gdb/language.c
index ed85035..76efc49 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -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;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index ceffc01..8d896d5 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -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;
}
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 6afa393..8bbffc7 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -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,
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 28b452b..ba403ae 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -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);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 1b5426e..5828ddd 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -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;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a082ee2..2655137 100644
--- a/gdb/symtab.c
+++ b/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));
}
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 09e2a20..e18cd65 100644
--- a/gdb/symtab.h
+++ b/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