aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/dwarf-index-write.c16
-rw-r--r--gdb/psympriv.h16
-rw-r--r--gdb/psymtab.c168
4 files changed, 115 insertions, 101 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4c2058d..c6df5eb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,19 @@
+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.
+
2018-07-26 Tom Tromey <tromey@redhat.com>
* dbxread.c (end_psymtab): Remove dead code.
diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c
index d283146..0210d2e 100644
--- a/gdb/dwarf-index-write.c
+++ b/gdb/dwarf-index-write.c
@@ -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. */
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 45746a2..f3cb0a6 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -33,11 +33,16 @@
/* This structure is space critical. See space comments at the top of
symtab.h. */
-struct partial_symbol
+struct partial_symbol : public general_symbol_info
{
- /* The general symbol info required for all types of symbols. */
-
- struct general_symbol_info ginfo;
+ /* Return the section for this partial symbol, or nullptr if no
+ section has been set. */
+ struct obj_section *obj_section (struct objfile *objfile) const
+ {
+ if (section >= 0)
+ return &objfile->sections[section];
+ return nullptr;
+ }
/* Name space code. */
@@ -50,9 +55,6 @@ struct partial_symbol
ENUM_BITFIELD(address_class) aclass : SYMBOL_ACLASS_BITS;
};
-#define PSYMBOL_DOMAIN(psymbol) (psymbol)->domain
-#define PSYMBOL_CLASS(psymbol) (psymbol)->aclass
-
/* A convenience enum to give names to some constants used when
searching psymtabs. This is internal to psymtab and should not be
used elsewhere. */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index fa59ee2..9a06d68 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -267,8 +267,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
object's symbol table. */
p = find_pc_sect_psymbol (objfile, tpst, pc, section);
if (p != NULL
- && (SYMBOL_VALUE_ADDRESS (p)
- == BMSYMBOL_VALUE_ADDRESS (msymbol)))
+ && (p->value.address == BMSYMBOL_VALUE_ADDRESS (msymbol)))
return tpst;
/* Also accept the textlow value of a psymtab as a
@@ -276,7 +275,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
symbol tables with line information but no debug
symbols (e.g. those produced by an assembler). */
if (p != NULL)
- this_addr = SYMBOL_VALUE_ADDRESS (p);
+ this_addr = p->value.address;
else
this_addr = tpst->textlow;
@@ -334,8 +333,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
object's symbol table. */
p = find_pc_sect_psymbol (objfile, pst, pc, section);
if (p == NULL
- || (SYMBOL_VALUE_ADDRESS (p)
- != BMSYMBOL_VALUE_ADDRESS (msymbol)))
+ || (p->value.address != BMSYMBOL_VALUE_ADDRESS (msymbol)))
goto next;
}
@@ -425,21 +423,21 @@ find_pc_sect_psymbol (struct objfile *objfile,
{
partial_symbol *p = objfile->global_psymbols[psymtab->globals_offset + i];
- if (SYMBOL_DOMAIN (p) == VAR_DOMAIN
- && PSYMBOL_CLASS (p) == LOC_BLOCK
- && pc >= SYMBOL_VALUE_ADDRESS (p)
- && (SYMBOL_VALUE_ADDRESS (p) > best_pc
+ if (p->domain == VAR_DOMAIN
+ && p->aclass == LOC_BLOCK
+ && pc >= p->value.address
+ && (p->value.address > best_pc
|| (psymtab->textlow == 0
- && best_pc == 0 && SYMBOL_VALUE_ADDRESS (p) == 0)))
+ && best_pc == 0 && p->value.address == 0)))
{
if (section != NULL) /* Match on a specific section. */
{
fixup_psymbol_section (p, objfile);
- if (!matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, p),
+ if (!matching_obj_sections (p->obj_section (objfile),
section))
continue;
}
- best_pc = SYMBOL_VALUE_ADDRESS (p);
+ best_pc = p->value.address;
best = p;
}
}
@@ -448,21 +446,21 @@ find_pc_sect_psymbol (struct objfile *objfile,
{
partial_symbol *p = objfile->static_psymbols[psymtab->statics_offset + i];
- if (SYMBOL_DOMAIN (p) == VAR_DOMAIN
- && PSYMBOL_CLASS (p) == LOC_BLOCK
- && pc >= SYMBOL_VALUE_ADDRESS (p)
- && (SYMBOL_VALUE_ADDRESS (p) > best_pc
+ if (p->domain == VAR_DOMAIN
+ && p->aclass == LOC_BLOCK
+ && pc >= p->value.address
+ && (p->value.address > best_pc
|| (psymtab->textlow == 0
- && best_pc == 0 && SYMBOL_VALUE_ADDRESS (p) == 0)))
+ && best_pc == 0 && p->value.address == 0)))
{
if (section != NULL) /* Match on a specific section. */
{
fixup_psymbol_section (p, objfile);
- if (!matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, p),
+ if (!matching_obj_sections (p->obj_section (objfile),
section))
continue;
}
- best_pc = SYMBOL_VALUE_ADDRESS (p);
+ best_pc = p->value.address;
best = p;
}
}
@@ -478,17 +476,17 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
if (psym == NULL)
return;
- if (SYMBOL_SECTION (psym) >= 0)
+ if (psym->section >= 0)
return;
gdb_assert (objfile);
- switch (PSYMBOL_CLASS (psym))
+ switch (psym->aclass)
{
case LOC_STATIC:
case LOC_LABEL:
case LOC_BLOCK:
- addr = SYMBOL_VALUE_ADDRESS (psym);
+ addr = psym->value.address;
break;
default:
/* Nothing else will be listed in the minsyms -- no use looking
@@ -496,7 +494,7 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
return;
}
- fixup_section (&psym->ginfo, addr, objfile);
+ fixup_section (psym, addr, objfile);
}
/* Psymtab version of lookup_symbol. See its definition in
@@ -554,10 +552,10 @@ static bool
psymbol_name_matches (partial_symbol *psym,
const lookup_name_info &lookup_name)
{
- const language_defn *lang = language_def (SYMBOL_LANGUAGE (psym));
+ const language_defn *lang = language_def (psym->language);
symbol_name_matcher_ftype *name_match
= get_symbol_name_matcher (lang, lookup_name);
- return name_match (SYMBOL_SEARCH_NAME (psym), lookup_name, NULL);
+ return name_match (symbol_search_name (psym), lookup_name, NULL);
}
/* Look in PST for a symbol in DOMAIN whose name matches NAME. Search
@@ -607,11 +605,11 @@ match_partial_symbol (struct objfile *objfile,
center = bottom + (top - bottom) / 2;
gdb_assert (center < top);
- enum language lang = SYMBOL_LANGUAGE (*center);
+ enum language lang = (*center)->language;
const char *lang_ln
= lookup_name.language_lookup_name (lang).c_str ();
- if (ordered_compare (SYMBOL_SEARCH_NAME (*center), lang_ln) >= 0)
+ if (ordered_compare (symbol_search_name (*center), lang_ln) >= 0)
top = center;
else
bottom = center + 1;
@@ -621,8 +619,8 @@ match_partial_symbol (struct objfile *objfile,
while (top <= real_top
&& psymbol_name_matches (*top, lookup_name))
{
- if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
- SYMBOL_DOMAIN (*top), domain))
+ if (symbol_matches_domain ((*top)->language,
+ (*top)->domain, domain))
return *top;
top++;
}
@@ -635,8 +633,8 @@ match_partial_symbol (struct objfile *objfile,
{
for (psym = start; psym < start + length; psym++)
{
- if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
- SYMBOL_DOMAIN (*psym), domain)
+ if (symbol_matches_domain ((*psym)->language,
+ (*psym)->domain, domain)
&& psymbol_name_matches (*psym, lookup_name))
return *psym;
}
@@ -718,7 +716,7 @@ lookup_partial_symbol (struct objfile *objfile,
if (!(center < top))
internal_error (__FILE__, __LINE__,
_("failed internal consistency check"));
- if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center),
+ if (strcmp_iw_ordered (symbol_search_name (*center),
search_name.get ()) >= 0)
{
top = center;
@@ -734,16 +732,16 @@ lookup_partial_symbol (struct objfile *objfile,
/* For `case_sensitivity == case_sensitive_off' strcmp_iw_ordered will
search more exactly than what matches SYMBOL_MATCHES_SEARCH_NAME. */
- while (top >= start && SYMBOL_MATCHES_SEARCH_NAME (*top, lookup_name))
+ while (top >= start && symbol_matches_search_name (*top, lookup_name))
top--;
/* Fixup to have a symbol which matches SYMBOL_MATCHES_SEARCH_NAME. */
top++;
- while (top <= real_top && SYMBOL_MATCHES_SEARCH_NAME (*top, lookup_name))
+ while (top <= real_top && symbol_matches_search_name (*top, lookup_name))
{
- if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
- SYMBOL_DOMAIN (*top), domain))
+ if (symbol_matches_domain ((*top)->language,
+ (*top)->domain, domain))
return *top;
top++;
}
@@ -756,9 +754,9 @@ lookup_partial_symbol (struct objfile *objfile,
{
for (psym = start; psym < start + length; psym++)
{
- if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
- SYMBOL_DOMAIN (*psym), domain)
- && SYMBOL_MATCHES_SEARCH_NAME (*psym, lookup_name))
+ if (symbol_matches_domain ((*psym)->language,
+ (*psym)->domain, domain)
+ && symbol_matches_search_name (*psym, lookup_name))
return *psym;
}
}
@@ -814,14 +812,14 @@ psym_relocate (struct objfile *objfile,
for (partial_symbol *psym : objfile->global_psymbols)
{
fixup_psymbol_section (psym, objfile);
- if (SYMBOL_SECTION (psym) >= 0)
- SYMBOL_VALUE_ADDRESS (psym) += ANOFFSET (delta, SYMBOL_SECTION (psym));
+ if (psym->section >= 0)
+ psym->value.address += ANOFFSET (delta, psym->section);
}
for (partial_symbol *psym : objfile->static_psymbols)
{
fixup_psymbol_section (psym, objfile);
- if (SYMBOL_SECTION (psym) >= 0)
- SYMBOL_VALUE_ADDRESS (psym) += ANOFFSET (delta, SYMBOL_SECTION (psym));
+ if (psym->section >= 0)
+ psym->value.address += ANOFFSET (delta, psym->section);
}
objfile->psymbol_map.clear ();
@@ -893,13 +891,13 @@ print_partial_symbols (struct gdbarch *gdbarch,
while (count-- > 0)
{
QUIT;
- fprintf_filtered (outfile, " `%s'", SYMBOL_LINKAGE_NAME (*p));
- if (SYMBOL_DEMANGLED_NAME (*p) != NULL)
+ fprintf_filtered (outfile, " `%s'", (*p)->name);
+ if (symbol_demangled_name (*p) != NULL)
{
- fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (*p));
+ fprintf_filtered (outfile, " `%s'", symbol_demangled_name (*p));
}
fputs_filtered (", ", outfile);
- switch (SYMBOL_DOMAIN (*p))
+ switch ((*p)->domain)
{
case UNDEF_DOMAIN:
fputs_filtered ("undefined domain, ", outfile);
@@ -917,7 +915,7 @@ print_partial_symbols (struct gdbarch *gdbarch,
fputs_filtered ("<invalid domain>, ", outfile);
break;
}
- switch (PSYMBOL_CLASS (*p))
+ switch ((*p)->aclass)
{
case LOC_UNDEF:
fputs_filtered ("undefined", outfile);
@@ -969,7 +967,7 @@ print_partial_symbols (struct gdbarch *gdbarch,
break;
}
fputs_filtered (", ", outfile);
- fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (*p)), outfile);
+ fputs_filtered (paddress (gdbarch, (*p)->value.address), outfile);
fprintf_filtered (outfile, "\n");
p++;
}
@@ -1364,14 +1362,14 @@ recursively_search_psymtabs
if ((domain == ALL_DOMAIN
|| (domain == VARIABLES_DOMAIN
- && PSYMBOL_CLASS (*psym) != LOC_TYPEDEF
- && PSYMBOL_CLASS (*psym) != LOC_BLOCK)
+ && (*psym)->aclass != LOC_TYPEDEF
+ && (*psym)->aclass != LOC_BLOCK)
|| (domain == FUNCTIONS_DOMAIN
- && PSYMBOL_CLASS (*psym) == LOC_BLOCK)
+ && (*psym)->aclass == LOC_BLOCK)
|| (domain == TYPES_DOMAIN
- && PSYMBOL_CLASS (*psym) == LOC_TYPEDEF))
+ && (*psym)->aclass == LOC_TYPEDEF))
&& psymbol_name_matches (*psym, lookup_name)
- && (sym_matcher == NULL || sym_matcher (SYMBOL_SEARCH_NAME (*psym))))
+ && (sym_matcher == NULL || sym_matcher (symbol_search_name (*psym))))
{
/* Found a match, so notify our caller. */
result = PST_SEARCHED_AND_FOUND;
@@ -1475,9 +1473,9 @@ psym_fill_psymbol_map (struct objfile *objfile,
{
struct partial_symbol *psym = symbols[start + i];
- if (PSYMBOL_CLASS (psym) == LOC_STATIC)
+ if (psym->aclass == LOC_STATIC)
{
- CORE_ADDR addr = SYMBOL_VALUE_ADDRESS (psym);
+ CORE_ADDR addr = psym->value.address;
if (seen_addrs->find (addr) == seen_addrs->end ())
{
seen_addrs->insert (addr);
@@ -1573,8 +1571,8 @@ sort_pst_symbols (struct objfile *objfile, struct partial_symtab *pst)
std::sort (begin, end, [] (partial_symbol *s1, partial_symbol *s2)
{
- return strcmp_iw_ordered (SYMBOL_SEARCH_NAME (s1),
- SYMBOL_SEARCH_NAME (s2)) < 0;
+ return strcmp_iw_ordered (symbol_search_name (s1),
+ symbol_search_name (s2)) < 0;
});
}
@@ -1621,17 +1619,18 @@ psymbol_hash (const void *addr, int length)
{
unsigned long h = 0;
struct partial_symbol *psymbol = (struct partial_symbol *) addr;
- unsigned int lang = psymbol->ginfo.language;
- unsigned int domain = PSYMBOL_DOMAIN (psymbol);
- unsigned int theclass = PSYMBOL_CLASS (psymbol);
+ unsigned int lang = psymbol->language;
+ unsigned int domain = psymbol->domain;
+ unsigned int theclass = psymbol->aclass;
- h = hash_continue (&psymbol->ginfo.value, sizeof (psymbol->ginfo.value), h);
+ h = hash_continue (&psymbol->value, sizeof (psymbol->value), h);
h = hash_continue (&lang, sizeof (unsigned int), h);
h = hash_continue (&domain, sizeof (unsigned int), h);
h = hash_continue (&theclass, sizeof (unsigned int), h);
/* Note that psymbol names are interned via symbol_set_names, so
there's no need to hash the contents of the name here. */
- h = hash_continue (&psymbol->ginfo.name, sizeof (psymbol->ginfo.name), h);
+ h = hash_continue (&psymbol->name,
+ sizeof (psymbol->name), h);
return h;
}
@@ -1646,15 +1645,15 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
struct partial_symbol *sym1 = (struct partial_symbol *) addr1;
struct partial_symbol *sym2 = (struct partial_symbol *) addr2;
- return (memcmp (&sym1->ginfo.value, &sym2->ginfo.value,
- sizeof (sym1->ginfo.value)) == 0
- && sym1->ginfo.language == sym2->ginfo.language
- && PSYMBOL_DOMAIN (sym1) == PSYMBOL_DOMAIN (sym2)
- && PSYMBOL_CLASS (sym1) == PSYMBOL_CLASS (sym2)
+ return (memcmp (&sym1->value, &sym2->value,
+ sizeof (sym1->value)) == 0
+ && sym1->language == sym2->language
+ && 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
contents of the name here. */
- && sym1->ginfo.name == sym2->ginfo.name);
+ && sym1->name == sym2->name);
}
/* Initialize a partial symbol bcache. */
@@ -1719,18 +1718,15 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
{
struct partial_symbol psymbol;
- /* We must ensure that the entire struct has been zeroed before
- assigning to it, because an assignment may not touch some of the
- holes. */
- memset (&psymbol, 0, sizeof (psymbol));
+ psymbol.value.address = coreaddr;
+ psymbol.section = -1;
+ psymbol.domain = domain;
+ psymbol.aclass = theclass;
- SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
- SYMBOL_SECTION (&psymbol) = -1;
- SYMBOL_SET_LANGUAGE (&psymbol, language, &objfile->objfile_obstack);
- PSYMBOL_DOMAIN (&psymbol) = domain;
- PSYMBOL_CLASS (&psymbol) = theclass;
-
- SYMBOL_SET_NAMES (&psymbol, name, namelength, copy_name, objfile);
+ memset (&psymbol.language_specific, 0, sizeof (psymbol.language_specific));
+ psymbol.ada_mangled = 0;
+ symbol_set_language (&psymbol, language, &objfile->objfile_obstack);
+ symbol_set_names (&psymbol, name, namelength, copy_name, objfile);
/* Stash the partial symbol away in the cache. */
return psymbol_bcache_full (&psymbol, objfile->psymbol_cache, added);
@@ -2252,13 +2248,13 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
length = ps->n_static_syms;
while (length--)
{
- sym = block_lookup_symbol (b, SYMBOL_SEARCH_NAME (*psym),
+ sym = block_lookup_symbol (b, symbol_search_name (*psym),
symbol_name_match_type::SEARCH_NAME,
- SYMBOL_DOMAIN (*psym));
+ (*psym)->domain);
if (!sym)
{
printf_filtered ("Static symbol `");
- puts_filtered (SYMBOL_LINKAGE_NAME (*psym));
+ puts_filtered ((*psym)->name);
printf_filtered ("' only found in ");
puts_filtered (ps->filename);
printf_filtered (" psymtab\n");
@@ -2270,13 +2266,13 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
length = ps->n_global_syms;
while (length--)
{
- sym = block_lookup_symbol (b, SYMBOL_SEARCH_NAME (*psym),
+ sym = block_lookup_symbol (b, symbol_search_name (*psym),
symbol_name_match_type::SEARCH_NAME,
- SYMBOL_DOMAIN (*psym));
+ (*psym)->domain);
if (!sym)
{
printf_filtered ("Global symbol `");
- puts_filtered (SYMBOL_LINKAGE_NAME (*psym));
+ puts_filtered ((*psym)->name);
printf_filtered ("' only found in ");
puts_filtered (ps->filename);
printf_filtered (" psymtab\n");