diff options
-rw-r--r-- | gdb/ChangeLog | 34 | ||||
-rw-r--r-- | gdb/ada-lang.c | 2 | ||||
-rw-r--r-- | gdb/buildsym.c | 2 | ||||
-rw-r--r-- | gdb/coffread.c | 2 | ||||
-rw-r--r-- | gdb/ctfread.c | 8 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 6 | ||||
-rw-r--r-- | gdb/jit.c | 4 | ||||
-rw-r--r-- | gdb/language.c | 2 | ||||
-rw-r--r-- | gdb/mdebugread.c | 2 | ||||
-rw-r--r-- | gdb/minsyms.c | 24 | ||||
-rw-r--r-- | gdb/psymtab.c | 17 | ||||
-rw-r--r-- | gdb/stabsread.c | 10 | ||||
-rw-r--r-- | gdb/symtab.c | 44 | ||||
-rw-r--r-- | gdb/symtab.h | 30 |
14 files changed, 106 insertions, 81 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 293ec52..8600e2e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,39 @@ 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 default. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 030c4aa..b798889 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1376,7 +1376,7 @@ ada_decode_symbol (const struct general_symbol_info *arg) 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; diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 79f8305..df74508 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -135,7 +135,7 @@ add_symbol_to_list (struct symbol *symbol, struct pending **listhead) 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 diff --git a/gdb/coffread.c b/gdb/coffread.c index e591651..3e5ade8 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1568,7 +1568,7 @@ process_coff_symbol (struct coff_symbol *cs, 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; diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 65e6ebb..001120d 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -399,7 +399,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg) 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; @@ -428,7 +428,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid) 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; @@ -1048,7 +1048,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg) 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: @@ -1064,7 +1064,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg) 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: diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 2520780..819d37c 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -9953,7 +9953,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) 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; @@ -10878,7 +10878,7 @@ dwarf2_compute_name (const char *name, /* 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. */ @@ -21873,7 +21873,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, /* 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. */ @@ -672,8 +672,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) 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; diff --git a/gdb/language.c b/gdb/language.c index ac74c7f..bf990da 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -1052,7 +1052,7 @@ language_alloc_type_symbol (enum language lang, struct type *type) 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; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 8d896d5..314b6bd 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4762,7 +4762,7 @@ new_symbol (const char *name) 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; } diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 8bbffc7..88606ce 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1132,10 +1132,10 @@ minimal_symbol_reader::record_full (gdb::string_view name, &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; @@ -1397,22 +1397,23 @@ minimal_symbol_reader::install () 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 @@ -1431,10 +1432,9 @@ minimal_symbol_reader::install () 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); diff --git a/gdb/psymtab.c b/gdb/psymtab.c index ba403ae..4c53e73 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -835,7 +835,7 @@ print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile, 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'", @@ -1534,9 +1534,9 @@ psymbol_hash (const void *addr, int length) 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; } @@ -1557,9 +1557,9 @@ psymbol_compare (const void *addr1, const void *addr2, int length) && 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 @@ -1585,8 +1585,7 @@ add_psymbol_to_bcache (gdb::string_view name, bool copy_name, 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 *) @@ -2110,7 +2109,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) 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"); @@ -2128,7 +2127,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) 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"); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 5828ddd..0b60402 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -749,14 +749,10 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, 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, diff --git a/gdb/symtab.c b/gdb/symtab.c index 2655137..099e920 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -855,19 +855,19 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol, 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, @@ -875,9 +875,9 @@ symbol_set_names (struct general_symbol_info *gsymbol, 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; } @@ -896,7 +896,7 @@ symbol_set_names (struct general_symbol_info *gsymbol, 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 @@ -920,9 +920,9 @@ symbol_set_names (struct general_symbol_info *gsymbol, 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 @@ -957,18 +957,17 @@ symbol_set_names (struct general_symbol_info *gsymbol, (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. */ @@ -991,7 +990,7 @@ general_symbol_info::natural_name () const default: break; } - return name; + return linkage_name (); } /* See symtab.h. */ @@ -1025,7 +1024,7 @@ const char * general_symbol_info::search_name () const { if (language () == language_ada) - return name; + return linkage_name (); else return natural_name (); } @@ -1670,7 +1669,8 @@ fixup_section (struct general_symbol_info *ginfo, 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 diff --git a/gdb/symtab.h b/gdb/symtab.h index e18cd65..a168296 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -389,7 +389,7 @@ struct general_symbol_info 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 @@ -419,11 +419,11 @@ struct general_symbol_info /* 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; } @@ -432,13 +432,21 @@ struct general_symbol_info 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 @@ -544,18 +552,6 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym); 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) \ @@ -1092,7 +1088,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack { /* 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; |