+2019-12-26 Christian Biesinger <cbiesinger@google.com>
+
+ * ada-lang.c (ada_decode_symbol): Update.
+ * buildsym.c (add_symbol_to_list): Update.
+ * coffread.c (process_coff_symbol): Update.
+ * ctfread.c (ctf_add_enum_member_cb): Update.
+ (new_symbol): Update.
+ (ctf_add_var_cb): Update.
+ * dwarf2read.c (fixup_go_packaging): Update.
+ (dwarf2_compute_name): Update.
+ (new_symbol): Update.
+ * jit.c (finalize_symtab): Update.
+ * language.c (language_alloc_type_symbol): Update.
+ * mdebugread.c (new_symbol): Update.
+ * minsyms.c (minimal_symbol_reader::record_full): Update.
+ (minimal_symbol_reader::install): Update.
+ * psymtab.c (print_partial_symbols): Update.
+ (psymbol_hash): Update.
+ (psymbol_compare): Update.
+ (add_psymbol_to_bcache): Update.
+ (maintenance_check_psymtabs): Update.
+ * stabsread.c (define_symbol): Update.
+ * symtab.c (symbol_set_names): Rename to...
+ (general_symbol_info::compute_and_set_names): ...this.
+ (general_symbol_info::natural_name): Update.
+ (general_symbol_info::search_name): Update.
+ (fixup_section): Update.
+ * symtab.h (struct general_symbol_info) <name>: Rename to...
+ <m_name>: ...this.
+ <compute_and_set_names>: Rename from...
+ (symbol_set_names): ...this.
+ (SYMBOL_SET_NAMES): Remove.
+ (struct symbol) <ctor>: Update.
+
2019-12-26 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention that multithreaded symbol loading is now on by
if (!gsymbol->ada_mangled)
{
- std::string decoded = ada_decode (gsymbol->name);
+ std::string decoded = ada_decode (gsymbol->linkage_name ());
struct obstack *obstack = gsymbol->language_specific.obstack;
gsymbol->ada_mangled = 1;
struct pending *link;
/* If this is an alias for another symbol, don't add it. */
- if (symbol->name && symbol->name[0] == '#')
+ if (symbol->linkage_name () && symbol->linkage_name ()[0] == '#')
return;
/* We keep PENDINGSIZE symbols in each link of the list. If we
name = EXTERNAL_NAME (name, objfile->obfd);
sym->set_language (get_current_subfile ()->language,
&objfile->objfile_obstack);
- SYMBOL_SET_NAMES (sym, name, true, objfile);
+ sym->compute_and_set_names (name, true, objfile->per_bfd);
/* default assumptions */
SYMBOL_VALUE (sym) = cs->c_value;
OBJSTAT (ccp->of, n_syms++);
sym->set_language (language_c, &ccp->of->objfile_obstack);
- SYMBOL_SET_NAMES (sym, name, false, ccp->of);
+ sym->compute_and_set_names (name, false, ccp->of->per_bfd);
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_TYPE (sym) = fip->ptype;
OBJSTAT (objfile, n_syms++);
sym->set_language (language_c, &objfile->objfile_obstack);
- SYMBOL_SET_NAMES (sym, name.get (), true, objfile);
+ sym->compute_and_set_names (name.get (), true, objfile->per_bfd);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
if (type)
{
sym = new_symbol (ccp, type, id);
- SYMBOL_SET_NAMES (sym, name, false, ccp->of);
+ sym->compute_and_set_names (name, false, ccp->of->per_bfd);
}
break;
case CTF_K_STRUCT:
SYMBOL_TYPE (sym) = type;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
- SYMBOL_SET_NAMES (sym, name, false, ccp->of);
+ sym->compute_and_set_names (name, false, ccp->of->per_bfd);
add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
break;
default:
sym = allocate_symbol (objfile);
sym->set_language (language_go, &objfile->objfile_obstack);
- SYMBOL_SET_NAMES (sym, saved_package_name, false, objfile);
+ sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd);
/* 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(). */
SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
/* For Fortran GDB prefers DW_AT_*linkage_name for the physname if present
but otherwise compute it by typename_concat inside GDB.
FIXME: Actually this is not really true, or at least not always true.
- It's all very confusing. SYMBOL_SET_NAMES doesn't try to demangle
+ It's all very confusing. compute_and_set_names doesn't try to demangle
Fortran names because there is no mangling standard. So new_symbol
will set the demangled name to the result of dwarf2_full_name, and it is
the demangled name that GDB uses if it exists. */
/* Cache this symbol's name and the name's demangled form (if any). */
sym->set_language (cu->language, &objfile->objfile_obstack);
linkagename = dwarf2_physname (name, die, cu);
- SYMBOL_SET_NAMES (sym, linkagename, false, objfile);
+ sym->compute_and_set_names (linkagename, false, objfile->per_bfd);
/* Fortran does not have mangling standard and the mangling does differ
between gfortran, iFort etc. */
SYMBOL_TYPE (block_name) = lookup_function_type (block_type);
SYMBOL_BLOCK_VALUE (block_name) = new_block;
- block_name->name = obstack_strdup (&objfile->objfile_obstack,
- gdb_block_iter.name.get ());
+ block_name->m_name = obstack_strdup (&objfile->objfile_obstack,
+ gdb_block_iter.name.get ());
BLOCK_FUNCTION (new_block) = block_name;
gdbarch = TYPE_OWNER (type).gdbarch;
symbol = new (gdbarch_obstack (gdbarch)) struct symbol ();
- symbol->name = TYPE_NAME (type);
+ symbol->m_name = TYPE_NAME (type);
symbol->set_language (lang, nullptr);
symbol->owner.arch = gdbarch;
SYMBOL_OBJFILE_OWNED (symbol) = 0;
struct symbol *s = allocate_symbol (mdebugread_objfile);
s->set_language (psymtab_language, &mdebugread_objfile->objfile_obstack);
- SYMBOL_SET_NAMES (s, name, true, mdebugread_objfile);
+ s->compute_and_set_names (name, true, mdebugread_objfile->per_bfd);
return s;
}
&m_objfile->per_bfd->storage_obstack);
if (copy_name)
- msymbol->name = obstack_strndup (&m_objfile->per_bfd->storage_obstack,
- name.data (), name.size ());
+ msymbol->m_name = obstack_strndup (&m_objfile->per_bfd->storage_obstack,
+ name.data (), name.size ());
else
- msymbol->name = name.data ();
+ msymbol->m_name = name.data ();
SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
MSYMBOL_SECTION (msymbol) = section;
for (minimal_symbol *msym = start; msym < end; ++msym)
{
size_t idx = msym - msymbols;
- hash_values[idx].name_length = strlen (msym->name);
+ hash_values[idx].name_length = strlen (msym->linkage_name ());
if (!msym->name_set)
{
- /* This will be freed later, by symbol_set_names. */
+ /* This will be freed later, by compute_and_set_names. */
char *demangled_name
- = symbol_find_demangled_name (msym, msym->name);
+ = symbol_find_demangled_name (msym, msym->linkage_name ());
symbol_set_demangled_name
(msym, demangled_name,
&m_objfile->per_bfd->storage_obstack);
msym->name_set = 1;
}
/* This mangled_name_hash computation has to be outside of
- the name_set check, or symbol_set_names below will
+ the name_set check, or compute_and_set_names below will
be called with an invalid hash value. */
hash_values[idx].mangled_name_hash
- = fast_hash (msym->name, hash_values[idx].name_length);
+ = fast_hash (msym->linkage_name (),
+ hash_values[idx].name_length);
hash_values[idx].minsym_hash
= msymbol_hash (msym->linkage_name ());
/* We only use this hash code if the search name differs
for (minimal_symbol *msym = start; msym < end; ++msym)
{
size_t idx = msym - msymbols;
- symbol_set_names
- (msym,
- gdb::string_view(msym->name,
- hash_values[idx].name_length),
+ msym->compute_and_set_names
+ (gdb::string_view (msym->linkage_name (),
+ hash_values[idx].name_length),
false,
m_objfile->per_bfd,
hash_values[idx].mangled_name_hash);
while (count-- > 0)
{
QUIT;
- fprintf_filtered (outfile, " `%s'", (*p)->ginfo.name);
+ fprintf_filtered (outfile, " `%s'", (*p)->ginfo.linkage_name ());
if ((*p)->ginfo.demangled_name () != NULL)
{
fprintf_filtered (outfile, " `%s'",
h = fast_hash (&lang, sizeof (unsigned int), h);
h = fast_hash (&domain, sizeof (unsigned int), h);
h = fast_hash (&theclass, sizeof (unsigned int), h);
- /* Note that psymbol names are interned via symbol_set_names, so
+ /* Note that psymbol names are interned via compute_and_set_names, so
there's no need to hash the contents of the name here. */
- h = fast_hash (&psymbol->ginfo.name, sizeof (psymbol->ginfo.name), h);
+ h = fast_hash (&psymbol->ginfo.m_name, sizeof (psymbol->ginfo.m_name), h);
return h;
}
&& sym1->domain == sym2->domain
&& sym1->aclass == sym2->aclass
/* Note that psymbol names are interned via
- symbol_set_names, so there's no need to compare the
+ compute_and_set_names, so there's no need to compare the
contents of the name here. */
- && sym1->ginfo.name == sym2->ginfo.name);
+ && sym1->ginfo.linkage_name () == sym2->ginfo.linkage_name ());
}
/* Helper function, initialises partial symbol structure and stashes
psymbol.domain = domain;
psymbol.aclass = theclass;
psymbol.ginfo.set_language (language, objfile->partial_symtabs->obstack ());
- symbol_set_names (&psymbol.ginfo, name, copy_name,
- objfile->per_bfd);
+ psymbol.ginfo.compute_and_set_names (name, copy_name, objfile->per_bfd);
/* Stash the partial symbol away in the cache. */
return ((struct partial_symbol *)
if (!sym)
{
printf_filtered ("Static symbol `");
- puts_filtered ((*psym)->ginfo.name);
+ puts_filtered ((*psym)->ginfo.linkage_name ());
printf_filtered ("' only found in ");
puts_filtered (ps->filename);
printf_filtered (" psymtab\n");
if (!sym)
{
printf_filtered ("Global symbol `");
- puts_filtered ((*psym)->ginfo.name);
+ puts_filtered ((*psym)->ginfo.linkage_name ());
printf_filtered ("' only found in ");
puts_filtered (ps->filename);
printf_filtered (" psymtab\n");
new_name = cp_canonicalize_string (name);
}
if (!new_name.empty ())
- {
- SYMBOL_SET_NAMES (sym,
- new_name,
- 1, objfile);
- }
+ sym->compute_and_set_names (new_name, true, objfile->per_bfd);
else
- SYMBOL_SET_NAMES (sym, gdb::string_view (string, p - string), true,
- objfile);
+ sym->compute_and_set_names (gdb::string_view (string, p - string), true,
+ objfile->per_bfd);
if (sym->language () == language_cplus)
cp_scan_for_anonymous_namespaces (get_buildsym_compunit (), sym,
so the pointer can be discarded after calling this function. */
void
-symbol_set_names (struct general_symbol_info *gsymbol,
- gdb::string_view linkage_name, bool copy_name,
- struct objfile_per_bfd_storage *per_bfd,
- gdb::optional<hashval_t> hash)
+general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
+ bool copy_name,
+ objfile_per_bfd_storage *per_bfd,
+ gdb::optional<hashval_t> hash)
{
struct demangled_name_entry **slot;
- if (gsymbol->language () == language_ada)
+ if (language () == language_ada)
{
/* In Ada, we do the symbol lookups using the mangled name, so
we can save some space by not storing the demangled name. */
if (!copy_name)
- gsymbol->name = linkage_name.data ();
+ m_name = linkage_name.data ();
else
{
char *name = (char *) obstack_alloc (&per_bfd->storage_obstack,
memcpy (name, linkage_name.data (), linkage_name.length ());
name[linkage_name.length ()] = '\0';
- gsymbol->name = name;
+ m_name = name;
}
- symbol_set_demangled_name (gsymbol, NULL, &per_bfd->storage_obstack);
+ symbol_set_demangled_name (this, NULL, &per_bfd->storage_obstack);
return;
}
if (*slot == NULL
/* A C version of the symbol may have already snuck into the table.
This happens to, e.g., main.init (__go_init_main). Cope. */
- || (gsymbol->language () == language_go && (*slot)->demangled == nullptr))
+ || (language () == language_go && (*slot)->demangled == nullptr))
{
/* A 0-terminated copy of the linkage name. Callers must set COPY_NAME
to true if the string might not be nullterminated. We have to make
allocated from the heap and needs to be freed by us, just
like if we called symbol_find_demangled_name here. */
gdb::unique_xmalloc_ptr<char> demangled_name
- (gsymbol->language_specific.demangled_name
- ? const_cast<char *> (gsymbol->language_specific.demangled_name)
- : symbol_find_demangled_name (gsymbol, linkage_name_copy.data ()));
+ (language_specific.demangled_name
+ ? const_cast<char *> (language_specific.demangled_name)
+ : symbol_find_demangled_name (this, linkage_name_copy.data ()));
/* Suppose we have demangled_name==NULL, copy_name==0, and
linkage_name_copy==linkage_name. In this case, we already have the
(gdb::string_view (mangled_ptr, linkage_name.length ()));
}
(*slot)->demangled = std::move (demangled_name);
- (*slot)->language = gsymbol->language ();
+ (*slot)->language = language ();
}
- else if (gsymbol->language () == language_unknown
- || gsymbol->language () == language_auto)
- gsymbol->m_language = (*slot)->language;
+ else if (language () == language_unknown || language () == language_auto)
+ m_language = (*slot)->language;
- gsymbol->name = (*slot)->mangled.data ();
+ m_name = (*slot)->mangled.data ();
if ((*slot)->demangled != nullptr)
- symbol_set_demangled_name (gsymbol, (*slot)->demangled.get (),
+ symbol_set_demangled_name (this, (*slot)->demangled.get (),
&per_bfd->storage_obstack);
else
- symbol_set_demangled_name (gsymbol, NULL, &per_bfd->storage_obstack);
+ symbol_set_demangled_name (this, NULL, &per_bfd->storage_obstack);
}
/* See symtab.h. */
default:
break;
}
- return name;
+ return linkage_name ();
}
/* See symtab.h. */
general_symbol_info::search_name () const
{
if (language () == language_ada)
- return name;
+ return linkage_name ();
else
return natural_name ();
}
e.g. on PowerPC64, where the minimal symbol for a function will
point to the function descriptor, while the debug symbol will
point to the actual function code. */
- msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->name, objfile);
+ msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->linkage_name (),
+ objfile);
if (msym)
ginfo->section = MSYMBOL_SECTION (msym);
else
and linkage_name () are different. */
const char *linkage_name () const
- { return name; }
+ { return m_name; }
/* Return SYMBOL's "natural" name, i.e. the name that it was called in
the original source code. In languages like C++ where symbols may
/* Set just the linkage name of a symbol; do not try to demangle
it. Used for constructs which do not have a mangled name,
- e.g. struct tags. Unlike SYMBOL_SET_NAMES, linkage_name must
+ e.g. struct tags. Unlike compute_and_set_names, linkage_name must
be terminated and either already on the objfile's obstack or
permanently allocated. */
void set_linkage_name (const char *linkage_name)
- { name = linkage_name; }
+ { m_name = linkage_name; }
enum language language () const
{ return m_language; }
depending upon the language for the symbol. */
void set_language (enum language language, struct obstack *obstack);
+ /* Set the linkage and natural names of a symbol, by demangling
+ the linkage name. If linkage_name may not be nullterminated,
+ copy_name must be set to true. */
+ void compute_and_set_names (gdb::string_view linkage_name, bool copy_name,
+ struct objfile_per_bfd_storage *per_bfd,
+ gdb::optional<hashval_t> hash
+ = gdb::optional<hashval_t> ());
+
/* 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
the mangled name and demangled name, this is the mangled
name. */
- const char *name;
+ const char *m_name;
/* Value of the symbol. Which member of this union to use, and what
it means, depends on what kind of symbol this is and its
extern char *symbol_find_demangled_name (struct general_symbol_info *gsymbol,
const char *mangled);
-/* Set the linkage and natural names of a symbol, by demangling
- the linkage name. If linkage_name may not be nullterminated,
- copy_name must be set to true. */
-#define SYMBOL_SET_NAMES(symbol,linkage_name,copy_name,objfile) \
- symbol_set_names ((symbol), linkage_name, copy_name, \
- (objfile)->per_bfd)
-extern void symbol_set_names (struct general_symbol_info *symbol,
- gdb::string_view linkage_name, bool copy_name,
- struct objfile_per_bfd_storage *per_bfd,
- gdb::optional<hashval_t> hash
- = gdb::optional<hashval_t> ());
-
/* Return true if NAME matches the "search" name of SYMBOL, according
to the symbol's language. */
#define SYMBOL_MATCHES_SEARCH_NAME(symbol, name) \
{
/* We can't use an initializer list for members of a base class, and
general_symbol_info needs to stay a POD type. */
- name = nullptr;
+ m_name = nullptr;
value.ivalue = 0;
language_specific.obstack = nullptr;
m_language = language_unknown;