Change representation of psymbol to flush out accessors

This is the psymbol analog to the patch to change the representation
of minimal symbols:

    https://sourceware.org/ml/gdb-patches/2013-10/msg00524.html

It has the same rationale: namely, that we're going to change the code
to apply psymbol offsets at runtime.  This will be done by adding an
argument to the SYMBOL_VALUE_ADDRESS macro -- but since we can't
convert all the symbol types at once, we need a new approach.

Because gdb now is in C++, this patch changes partial_symbol to
inherit from general_symbol_info, rather than renaming the field.
This simplifies code in some places.

Also, as noted before, these macros implement a kind of "phony
polymorphism" that is not actually useful in practice; so this patch
removes the macros in favor of simply referring directly to members.
In a few cases -- obj_section in this patch and the symbol address in
the future -- methods will be used instead.

Note that this removes the blanket memset from add_psymbol_to_bcache.
This hasn't really been needed since bcache was modified to allow
holes in objects and since psymtab took advantage of that.  This
deletion was required due to changing partial_symbol to derive from
general_symbol_info.

gdb/ChangeLog
2018-07-26  Tom Tromey  <tom@tromey.com>

	* dwarf-index-write.c (write_psymbols, debug_names::insert)
	(debug_names::write_psymbols): Update.
	* psympriv.h (struct partial_symbol): Derive from
	general_symbol_info.
	<obj_section>: New method.
	(PSYMBOL_DOMAIN, PSYMBOL_CLASS): Remove.n
	* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymtab)
	(find_pc_sect_psymbol, fixup_psymbol_section)
	(match_partial_symbol, lookup_partial_symbol, relocate_psymtabs)
	(print_partial_symbols, recursively_search_psymtabs)
	(compare_psymbols, psymbol_hash, psymbol_compare)
	(add_psymbol_to_bcache, maintenance_check_psymtabs)
	(psymbol_name_matches, psym_fill_psymbol_map): Update.
This commit is contained in:
Tom Tromey
2018-05-03 16:36:17 -06:00
parent 08994e1ddc
commit 8a6d423450
4 changed files with 115 additions and 101 deletions

View File

@ -499,8 +499,8 @@ write_address_map (struct objfile *objfile, data_buf &addr_vec,
static gdb_index_symbol_kind
symbol_kind (struct partial_symbol *psym)
{
domain_enum domain = PSYMBOL_DOMAIN (psym);
enum address_class aclass = PSYMBOL_CLASS (psym);
domain_enum domain = psym->domain;
enum address_class aclass = psym->aclass;
switch (domain)
{
@ -546,7 +546,7 @@ write_psymbols (struct mapped_symtab *symtab,
{
struct partial_symbol *psym = *psymp;
if (SYMBOL_LANGUAGE (psym) == language_ada)
if (psym->language == language_ada)
error (_("Ada is not currently supported by the index"));
/* Only add a given psymbol once. */
@ -554,7 +554,7 @@ write_psymbols (struct mapped_symtab *symtab,
{
gdb_index_symbol_kind kind = symbol_kind (psym);
add_index_entry (symtab, SYMBOL_SEARCH_NAME (psym),
add_index_entry (symtab, symbol_search_name (psym),
is_static, kind, cu_index);
}
}
@ -688,7 +688,7 @@ public:
const int dwarf_tag = psymbol_tag (psym);
if (dwarf_tag == 0)
return;
const char *const name = SYMBOL_SEARCH_NAME (psym);
const char *const name = symbol_search_name (psym);
const auto insertpair
= m_name_to_value_set.emplace (c_str_view (name),
std::set<symbol_value> ());
@ -1141,8 +1141,8 @@ private:
GDB as a DWARF-5 index consumer. */
static int psymbol_tag (const struct partial_symbol *psym)
{
domain_enum domain = PSYMBOL_DOMAIN (psym);
enum address_class aclass = PSYMBOL_CLASS (psym);
domain_enum domain = psym->domain;
enum address_class aclass = psym->aclass;
switch (domain)
{
@ -1183,7 +1183,7 @@ private:
{
struct partial_symbol *psym = *psymp;
if (SYMBOL_LANGUAGE (psym) == language_ada)
if (psym->language == language_ada)
error (_("Ada is not currently supported by the index"));
/* Only add a given psymbol once. */