From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 818C23858002; Tue, 12 Apr 2022 15:41:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 818C23858002 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Delete DWARF psymtab code X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 3d20b8d99a54382e6e1a6c433e71e0775c6856c6 X-Git-Newrev: 6209cde4ddb85a991ed1dda6f143ef08b75558df Message-Id: <20220412154152.818C23858002@sourceware.org> Date: Tue, 12 Apr 2022 15:41:52 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 15:41:52 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6209cde4ddb8= 5a991ed1dda6f143ef08b75558df commit 6209cde4ddb85a991ed1dda6f143ef08b75558df Author: Tom Tromey Date: Sun May 30 08:00:19 2021 -0600 Delete DWARF psymtab code =20 This removes the DWARF psymtab reader. Diff: --- gdb/dwarf2/cu.c | 1 + gdb/dwarf2/index-write.c | 338 +-- gdb/dwarf2/line-header.h | 3 - gdb/dwarf2/public.h | 2 +- gdb/dwarf2/read.c | 3262 +++-----------------= ---- gdb/dwarf2/read.h | 54 +- gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp | 8 + 7 files changed, 455 insertions(+), 3213 deletions(-) diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index d70eb0e25f9..fcb0d77623b 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -20,6 +20,7 @@ #include "defs.h" #include "dwarf2/cu.h" #include "dwarf2/read.h" +#include "objfiles.h" =20 /* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE. */ =20 diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 8efe370acaf..58b0f0b98e3 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -36,7 +36,6 @@ #include "gdb/gdb-index.h" #include "gdbcmd.h" #include "objfiles.h" -#include "psympriv.h" #include "ada-lang.h" =20 #include @@ -412,11 +411,9 @@ typedef std::unordered_map cu_index_map; /* Helper struct for building the address table. */ struct addrmap_index_data { - addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_, - bool using_index_) + addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_) : addr_vec (addr_vec_), - cu_index_htab (cu_index_htab_), - using_index (using_index_) + cu_index_htab (cu_index_htab_) {} =20 data_buf &addr_vec; @@ -424,8 +421,6 @@ struct addrmap_index_data =20 int operator() (CORE_ADDR start_addr, void *obj); =20 - /* True if the DWARF reader uses the new DWARF indexer. */ - bool using_index; /* True if the previous_* fields are valid. We can't write an entry until we see the next entry (since it is only= then that we know the end of the entry). */ @@ -452,11 +447,7 @@ add_address_entry (data_buf &addr_vec, int addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj) { - dwarf2_per_cu_data *per_cu; - if (using_index) - per_cu =3D (dwarf2_per_cu_data *) obj; - else - per_cu =3D obj =3D=3D nullptr ? nullptr : ((dwarf2_psymtab *) obj)->pe= r_cu_data; + dwarf2_per_cu_data *per_cu =3D (dwarf2_per_cu_data *) obj; =20 if (previous_valid) add_address_entry (addr_vec, @@ -483,10 +474,9 @@ addrmap_index_data::operator() (CORE_ADDR start_addr, = void *obj) =20 static void write_address_map (struct addrmap *addrmap, data_buf &addr_vec, - cu_index_map &cu_index_htab, bool using_index) + cu_index_map &cu_index_htab) { - struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab, - using_index); + struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab); =20 addrmap_foreach (addrmap, addrmap_index_data); =20 @@ -501,142 +491,6 @@ write_address_map (struct addrmap *addrmap, data_buf = &addr_vec, addrmap_index_data.previous_cu_index); } =20 -/* Return the symbol kind of PSYM. */ - -static gdb_index_symbol_kind -symbol_kind (struct partial_symbol *psym) -{ - domain_enum domain =3D psym->domain; - enum address_class aclass =3D psym->aclass; - - switch (domain) - { - case VAR_DOMAIN: - switch (aclass) - { - case LOC_BLOCK: - return GDB_INDEX_SYMBOL_KIND_FUNCTION; - case LOC_TYPEDEF: - return GDB_INDEX_SYMBOL_KIND_TYPE; - case LOC_COMPUTED: - case LOC_CONST_BYTES: - case LOC_OPTIMIZED_OUT: - case LOC_STATIC: - return GDB_INDEX_SYMBOL_KIND_VARIABLE; - case LOC_CONST: - /* Note: It's currently impossible to recognize psyms as enum values - short of reading the type info. For now punt. */ - return GDB_INDEX_SYMBOL_KIND_VARIABLE; - default: - /* There are other LOC_FOO values that one might want to classify - as variables, but dwarf2read.c doesn't currently use them. */ - return GDB_INDEX_SYMBOL_KIND_OTHER; - } - case STRUCT_DOMAIN: - return GDB_INDEX_SYMBOL_KIND_TYPE; - default: - return GDB_INDEX_SYMBOL_KIND_OTHER; - } -} - -/* Add a list of partial symbols to SYMTAB. */ - -static void -write_psymbols (struct mapped_symtab *symtab, - std::unordered_set &psyms_seen, - const std::vector &symbols, - offset_type cu_index, - int is_static) -{ - for (partial_symbol *psym : symbols) - { - const char *name =3D psym->ginfo.search_name (); - - if (psym->ginfo.language () =3D=3D language_ada) - { - /* We want to ensure that the Ada main function's name appears - verbatim in the index. However, this name will be of the - form "_ada_mumble", and will be rewritten by ada_decode. - So, recognize it specially here and add it to the index by - hand. */ - if (strcmp (main_name (), name) =3D=3D 0) - { - gdb_index_symbol_kind kind =3D symbol_kind (psym); - - add_index_entry (symtab, name, is_static, kind, cu_index); - } - - /* In order for the index to work when read back into gdb, it - has to supply a funny form of the name: it should be the - encoded name, with any suffixes stripped. Using the - ordinary encoded name will not work properly with the - searching logic in find_name_components_bounds; nor will - using the decoded name. Furthermore, an Ada "verbatim" - name (of the form "") must be entered without the - angle brackets. Note that the current index is unusual, - see PR symtab/24820 for details. */ - std::string decoded =3D ada_decode (name); - if (decoded[0] =3D=3D '<') - name =3D (char *) obstack_copy0 (&symtab->m_string_obstack, - decoded.c_str () + 1, - decoded.length () - 2); - else - name =3D obstack_strdup (&symtab->m_string_obstack, - ada_encode (decoded.c_str ())); - } - - /* Only add a given psymbol once. */ - if (psyms_seen.insert (psym).second) - { - gdb_index_symbol_kind kind =3D symbol_kind (psym); - - add_index_entry (symtab, name, is_static, kind, cu_index); - } - } -} - -/* Recurse into all "included" dependencies and count their symbols as - if they appeared in this psymtab. */ - -static void -recursively_count_psymbols (partial_symtab *psymtab, - size_t &psyms_seen) -{ - for (int i =3D 0; i < psymtab->number_of_dependencies; ++i) - if (psymtab->dependencies[i]->user !=3D NULL) - recursively_count_psymbols (psymtab->dependencies[i], - psyms_seen); - - psyms_seen +=3D psymtab->global_psymbols.size (); - psyms_seen +=3D psymtab->static_psymbols.size (); -} - -/* Recurse into all "included" dependencies and write their symbols as - if they appeared in this psymtab. */ - -static void -recursively_write_psymbols (struct objfile *objfile, - partial_symtab *psymtab, - struct mapped_symtab *symtab, - std::unordered_set &psyms_seen, - offset_type cu_index) -{ - int i; - - for (i =3D 0; i < psymtab->number_of_dependencies; ++i) - if (psymtab->dependencies[i]->user !=3D NULL) - recursively_write_psymbols (objfile, - psymtab->dependencies[i], - symtab, psyms_seen, cu_index); - - write_psymbols (symtab, psyms_seen, - psymtab->global_psymbols, cu_index, - 0); - write_psymbols (symtab, psyms_seen, - psymtab->static_psymbols, cu_index, - 1); -} - /* DWARF-5 .debug_names builder. */ class debug_names { @@ -710,18 +564,6 @@ public: value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static, kind)= ); } =20 - void insert (const partial_symbol *psym, int cu_index, bool is_static, - unit_kind kind) - { - const int dwarf_tag =3D psymbol_tag (psym); - if (dwarf_tag =3D=3D 0) - return; - const char *name =3D psym->ginfo.search_name (); - - insert (dwarf_tag, name, cu_index, is_static, kind, - psym->ginfo.language ()); - } - void insert (const cooked_index_entry *entry) { const auto it =3D m_cu_index_htab.find (entry->per_cu); @@ -863,25 +705,6 @@ public: return m_abbrev_table.size (); } =20 - /* Recurse into all "included" dependencies and store their symbols - as if they appeared in this psymtab. */ - void recursively_write_psymbols - (struct objfile *objfile, - partial_symtab *psymtab, - std::unordered_set &psyms_seen, - int cu_index) - { - for (int i =3D 0; i < psymtab->number_of_dependencies; ++i) - if (psymtab->dependencies[i]->user !=3D NULL) - recursively_write_psymbols - (objfile, psymtab->dependencies[i], psyms_seen, cu_index); - - write_psymbols (psyms_seen, psymtab->global_psymbols, - cu_index, false, unit_kind::cu); - write_psymbols (psyms_seen, psymtab->static_psymbols, - cu_index, true, unit_kind::cu); - } - /* Return number of bytes the .debug_names section will have. This must be called only after calling the build method. */ size_t bytes () const @@ -1148,59 +971,6 @@ private: offset_vec_tmpl m_name_table_entry_offs; }; =20 - /* Try to reconstruct original DWARF tag for given partial_symbol. - This function is not DWARF-5 compliant but it is sufficient for - GDB as a DWARF-5 index consumer. */ - static int psymbol_tag (const struct partial_symbol *psym) - { - domain_enum domain =3D psym->domain; - enum address_class aclass =3D psym->aclass; - - switch (domain) - { - case VAR_DOMAIN: - switch (aclass) - { - case LOC_BLOCK: - return DW_TAG_subprogram; - case LOC_TYPEDEF: - return DW_TAG_typedef; - case LOC_COMPUTED: - case LOC_CONST_BYTES: - case LOC_OPTIMIZED_OUT: - case LOC_STATIC: - return DW_TAG_variable; - case LOC_CONST: - /* Note: It's currently impossible to recognize psyms as enum values - short of reading the type info. For now punt. */ - return DW_TAG_variable; - default: - /* There are other LOC_FOO values that one might want to classify - as variables, but dwarf2read.c doesn't currently use them. */ - return DW_TAG_variable; - } - case STRUCT_DOMAIN: - return DW_TAG_structure_type; - case MODULE_DOMAIN: - return DW_TAG_module; - default: - return 0; - } - } - - /* Call insert for all partial symbols and mark them in PSYMS_SEEN. */ - void write_psymbols (std::unordered_set &psyms_seen, - const std::vector &symbols, - int cu_index, bool is_static, unit_kind kind) - { - for (partial_symbol *psym : symbols) - { - /* Only add a given psymbol once. */ - if (psyms_seen.insert (psym).second) - insert (psym, cu_index, is_static, kind); - } - } - /* Store value of each symbol. */ std::unordered_map, c_str_view_hasher> m_name_to_value_set; @@ -1252,31 +1022,6 @@ check_dwarf64_offsets (dwarf2_per_objfile *per_objfi= le) return false; } =20 -/* The psyms_seen set is potentially going to be largish (~40k - elements when indexing a -g3 build of GDB itself). Estimate the - number of elements in order to avoid too many rehashes, which - require rebuilding buckets and thus many trips to - malloc/free. */ - -static size_t -psyms_seen_size (dwarf2_per_objfile *per_objfile) -{ - if (per_objfile->per_bfd->using_index) - return 0; - - size_t psyms_count =3D 0; - for (const auto &per_cu : per_objfile->per_bfd->all_comp_units) - { - partial_symtab *psymtab =3D per_cu->v.psymtab; - - if (psymtab !=3D NULL && psymtab->user =3D=3D NULL) - recursively_count_psymbols (psymtab, psyms_count); - } - /* Generating an index for gdb itself shows a ratio of - TOTAL_SEEN_SYMS/UNIQUE_SYMS or ~5. 4 seems like a good bet. */ - return psyms_count / 4; -} - /* Assert that FILE's size is EXPECTED_SIZE. Assumes file's seek position is at the end of the file. */ =20 @@ -1346,8 +1091,6 @@ write_cooked_index (dwarf2_per_objfile *per_objfile, const cu_index_map &cu_index_htab, struct mapped_symtab *symtab) { - gdb_assert (per_objfile->per_bfd->using_index); - for (const cooked_index_entry *entry : per_objfile->per_bfd->cooked_index_table->all_entries ()) { @@ -1383,7 +1126,6 @@ static void write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file, FILE *dwz_out_file) { - struct objfile *objfile =3D per_objfile->objfile; mapped_symtab symtab; data_buf objfile_cu_list; data_buf dwz_cu_list; @@ -1402,33 +1144,17 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FI= LE *out_file, work here. Also, the debug_types entries do not appear in all_comp_units, but only in their own hash table. */ =20 - std::unordered_set psyms_seen - (psyms_seen_size (per_objfile)); int counter =3D 0; int types_counter =3D 0; for (int i =3D 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i) { dwarf2_per_cu_data *per_cu =3D per_objfile->per_bfd->all_comp_units[i].get (); - partial_symtab *psymtab =3D (per_objfile->per_bfd->using_index - ? nullptr - : per_cu->v.psymtab); =20 int &this_counter =3D per_cu->is_debug_types ? types_counter : count= er; =20 - if (psymtab !=3D NULL) - { - if (psymtab->user =3D=3D NULL) - recursively_write_psymbols (objfile, psymtab, &symtab, - psyms_seen, this_counter); - } - - if (psymtab !=3D NULL || per_objfile->per_bfd->using_index) - { - const auto insertpair =3D cu_index_htab.emplace (per_cu, - this_counter); - gdb_assert (insertpair.second); - } + const auto insertpair =3D cu_index_htab.emplace (per_cu, this_counte= r); + gdb_assert (insertpair.second); =20 /* The all_comp_units list contains CUs read from the objfile as wel= l as from the eventual dwz file. We need to place the entry in the @@ -1452,21 +1178,14 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FI= LE *out_file, ++this_counter; } =20 - if (per_objfile->per_bfd->using_index) - write_cooked_index (per_objfile, cu_index_htab, &symtab); + write_cooked_index (per_objfile, cu_index_htab, &symtab); =20 /* Dump the address map. */ data_buf addr_vec; - if (per_objfile->per_bfd->using_index) - { - std::vector addrmaps - =3D per_objfile->per_bfd->cooked_index_table->get_addrmaps (); - for (auto map : addrmaps) - write_address_map (map, addr_vec, cu_index_htab, true); - } - else - write_address_map (per_objfile->per_bfd->partial_symtabs->psymtabs_add= rmap, - addr_vec, cu_index_htab, false); + std::vector addrmaps + =3D per_objfile->per_bfd->cooked_index_table->get_addrmaps (); + for (auto map : addrmaps) + write_address_map (map, addr_vec, cu_index_htab); =20 /* Now that we've processed all symbols we can shrink their cu_indices lists. */ @@ -1509,8 +1228,6 @@ write_debug_names (dwarf2_per_objfile *per_objfile, data_buf cu_list; data_buf types_cu_list; debug_names nametable (per_objfile, dwarf5_is_dwarf64, dwarf5_byte_order= ); - std::unordered_set - psyms_seen (psyms_seen_size (per_objfile)); int counter =3D 0; int types_counter =3D 0; for (int i =3D 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i) @@ -1520,13 +1237,6 @@ write_debug_names (dwarf2_per_objfile *per_objfile, =20 int &this_counter =3D per_cu->is_debug_types ? types_counter : count= er; data_buf &this_list =3D per_cu->is_debug_types ? types_cu_list : cu_= list; - partial_symtab *psymtab =3D (per_objfile->per_bfd->using_index - ? nullptr - : per_cu->v.psymtab); - - if (psymtab !=3D nullptr && psymtab->user =3D=3D nullptr) - nametable.recursively_write_psymbols (objfile, psymtab, psyms_seen, - this_counter); =20 nametable.add_cu (per_cu, this_counter); this_list.append_uint (nametable.dwarf5_offset_size (), @@ -1540,10 +1250,9 @@ write_debug_names (dwarf2_per_objfile *per_objfile, - per_objfile->per_bfd->tu_stats.nr_tus)); gdb_assert (types_counter =3D=3D per_objfile->per_bfd->tu_stats.nr_tus); =20 - if (per_objfile->per_bfd->using_index) - for (const cooked_index_entry *entry - : per_objfile->per_bfd->cooked_index_table->all_entries ()) - nametable.insert (entry); + for (const cooked_index_entry *entry + : per_objfile->per_bfd->cooked_index_table->all_entries ()) + nametable.insert (entry); =20 nametable.build (); =20 @@ -1677,22 +1386,19 @@ write_dwarf_index (dwarf2_per_objfile *per_objfile,= const char *dir, const char *basename, const char *dwz_basename, dw_index_kind index_kind) { - dwarf2_per_bfd *per_bfd =3D per_objfile->per_bfd; struct objfile *objfile =3D per_objfile->objfile; =20 - if (per_objfile->per_bfd->using_index - && per_objfile->per_bfd->cooked_index_table =3D=3D nullptr) - error (_("Cannot use an index to create the index")); + if (per_objfile->per_bfd->cooked_index_table =3D=3D nullptr) + { + if (per_objfile->per_bfd->index_table !=3D nullptr + || per_objfile->per_bfd->debug_names_table !=3D nullptr) + error (_("Cannot use an index to create the index")); + error (_("No debugging symbols")); + } =20 if (per_objfile->per_bfd->types.size () > 1) error (_("Cannot make an index when the file has multiple .debug_types= sections")); =20 - if ((per_bfd->partial_symtabs =3D=3D nullptr - || !per_bfd->partial_symtabs->psymtabs - || !per_bfd->partial_symtabs->psymtabs_addrmap) - && per_bfd->cooked_index_table =3D=3D nullptr) - return; - struct stat st; if (stat (objfile_name (objfile), &st) < 0) perror_with_name (objfile_name (objfile)); diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h index 252dddd846b..4adfe91b8ac 100644 --- a/gdb/dwarf2/line-header.h +++ b/gdb/dwarf2/line-header.h @@ -59,9 +59,6 @@ struct file_entry =20 unsigned int length {}; =20 - /* True if referenced by the Line Number Program. */ - bool included_p {}; - /* The associated symbol table, if any. */ struct symtab *symtab {}; }; diff --git a/gdb/dwarf2/public.h b/gdb/dwarf2/public.h index 1723060a2e8..f002ab2f9b1 100644 --- a/gdb/dwarf2/public.h +++ b/gdb/dwarf2/public.h @@ -40,7 +40,7 @@ extern void dwarf2_initialize_objfile (struct objfile *ob= jfile); =20 struct psymbol_functions; extern void dwarf2_build_psymtabs (struct objfile *, - psymbol_functions *psf =3D nullptr); + bool already_attached =3D false); extern void dwarf2_build_frame_info (struct objfile *); =20 #endif /* DWARF2_PUBLIC_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 1f72c1bf723..9e3611700a2 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -64,7 +64,6 @@ #include "block.h" #include "addrmap.h" #include "typeprint.h" -#include "psympriv.h" #include "c-lang.h" #include "go-lang.h" #include "valprint.h" @@ -482,13 +481,8 @@ struct stmt_list_hash that can be shared across objfiles. The non-shareable parts are in type_unit_group_unshareable. */ =20 -struct type_unit_group : public dwarf2_per_cu_data +struct type_unit_group { - /* The TUs that share this DW_AT_stmt_list entry. - This is added to while parsing type units to build partial symtabs, - and is deleted afterwards and not used again. */ - std::vector *tus =3D nullptr; - /* The data used to construct the hash key. */ struct stmt_list_hash hash {}; }; @@ -838,164 +832,6 @@ private: abbrev_table_up m_dwo_abbrev_table; }; =20 -/* When we construct a partial symbol table entry we only - need this much information. */ -struct partial_die_info : public allocate_on_obstack - { - partial_die_info (sect_offset sect_off, const struct abbrev_info *abbr= ev); - - /* Disable assign but still keep copy ctor, which is needed - load_partial_dies. */ - partial_die_info& operator=3D(const partial_die_info& rhs) =3D delete; - partial_die_info (const partial_die_info &) =3D default; - - /* Adjust the partial die before generating a symbol for it. This - function may set the is_external flag or change the DIE's - name. */ - void fixup (struct dwarf2_cu *cu); - - /* Read a minimal amount of information into the minimal die - structure. */ - const gdb_byte *read (const struct die_reader_specs *reader, - const struct abbrev_info &abbrev, - const gdb_byte *info_ptr); - - /* Compute the name of this partial DIE. This memoizes the - result, so it is safe to call multiple times. */ - const char *name (dwarf2_cu *cu); - - /* Offset of this DIE. */ - const sect_offset sect_off; - - /* DWARF-2 tag for this DIE. */ - const ENUM_BITFIELD(dwarf_tag) tag : 16; - - /* Assorted flags describing the data found in this DIE. */ - const unsigned int has_children : 1; - - unsigned int is_external : 1; - unsigned int is_declaration : 1; - unsigned int has_type : 1; - unsigned int has_specification : 1; - unsigned int has_pc_info : 1; - unsigned int has_range_info : 1; - unsigned int may_be_inlined : 1; - - /* This DIE has been marked DW_AT_main_subprogram. */ - unsigned int main_subprogram : 1; - - /* Flag set if the SCOPE field of this structure has been - computed. */ - unsigned int scope_set : 1; - - /* Flag set if the DIE has a byte_size attribute. */ - unsigned int has_byte_size : 1; - - /* Flag set if the DIE has a DW_AT_const_value attribute. */ - unsigned int has_const_value : 1; - - /* Flag set if any of the DIE's children are template arguments. */ - unsigned int has_template_arguments : 1; - - /* Flag set if fixup has been called on this die. */ - unsigned int fixup_called : 1; - - /* Flag set if DW_TAG_imported_unit uses DW_FORM_GNU_ref_alt. */ - unsigned int is_dwz : 1; - - /* Flag set if spec_offset uses DW_FORM_GNU_ref_alt. */ - unsigned int spec_is_dwz : 1; - - unsigned int canonical_name : 1; - - /* The name of this DIE. Normally the value of DW_AT_name, but - sometimes a default name for unnamed DIEs. */ - const char *raw_name =3D nullptr; - - /* The linkage name, if present. */ - const char *linkage_name =3D nullptr; - - /* The scope to prepend to our children. This is generally - allocated on the comp_unit_obstack, so will disappear - when this compilation unit leaves the cache. */ - const char *scope =3D nullptr; - - /* Some data associated with the partial DIE. The tag determines - which field is live. */ - union - { - /* The location description associated with this DIE, if any. */ - struct dwarf_block *locdesc; - /* The offset of an import, for DW_TAG_imported_unit. */ - sect_offset sect_off; - } d {}; - - union - { - /* If HAS_PC_INFO, the PC range associated with this DIE. */ - struct - { - CORE_ADDR lowpc; - CORE_ADDR highpc; - }; - /* If HAS_RANGE_INFO, the ranges offset associated with this DIE. */ - ULONGEST ranges_offset; - }; - - /* Pointer into the info_buffer (or types_buffer) pointing at the targ= et of - DW_AT_sibling, if any. */ - /* NOTE: This member isn't strictly necessary, partial_die_info::read - could return DW_AT_sibling values to its caller load_partial_dies. = */ - const gdb_byte *sibling =3D nullptr; - - /* If HAS_SPECIFICATION, the offset of the DIE referred to by - DW_AT_specification (or DW_AT_abstract_origin or - DW_AT_extension). */ - sect_offset spec_offset {}; - - /* Pointers to this DIE's parent, first child, and next sibling, - if any. */ - struct partial_die_info *die_parent =3D nullptr; - struct partial_die_info *die_child =3D nullptr; - struct partial_die_info *die_sibling =3D nullptr; - - friend struct partial_die_info * - dwarf2_cu::find_partial_die (sect_offset sect_off); - - private: - /* Only need to do look up in dwarf2_cu::find_partial_die. */ - partial_die_info (sect_offset sect_off) - : partial_die_info (sect_off, DW_TAG_padding, 0) - { - } - - partial_die_info (sect_offset sect_off_, enum dwarf_tag tag_, - int has_children_) - : sect_off (sect_off_), tag (tag_), has_children (has_children_) - { - is_external =3D 0; - is_declaration =3D 0; - has_type =3D 0; - has_specification =3D 0; - has_pc_info =3D 0; - has_range_info =3D 0; - may_be_inlined =3D 0; - main_subprogram =3D 0; - scope_set =3D 0; - has_byte_size =3D 0; - has_const_value =3D 0; - has_template_arguments =3D 0; - fixup_called =3D 0; - is_dwz =3D 0; - spec_is_dwz =3D 0; - canonical_name =3D 0; - /* Don't set these using NSDMI (Non-static data member initialisatio= n), - because g++-4.8 will error out. */ - lowpc =3D 0; - highpc =3D 0; - } - }; - /* FIXME: We might want to set this from BFD via bfd_arch_bits_per_byte, but this would require a corresponding change in unpack_field_as_long and friends. */ @@ -1115,63 +951,14 @@ show_dwarf_max_cache_age (struct ui_file *file, int = from_tty, static void dwarf2_find_base_address (struct die_info *die, struct dwarf2_cu *cu); =20 -static dwarf2_psymtab *create_partial_symtab - (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, - const char *name); - class cooked_index_storage; static void build_type_psymtabs_reader (cutu_reader *reader, cooked_index_storage *storage); =20 static void dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile); =20 -static void scan_partial_symbols (struct partial_die_info *, - CORE_ADDR *, CORE_ADDR *, - int, struct dwarf2_cu *); - -static void add_partial_symbol (struct partial_die_info *, - struct dwarf2_cu *); - -static void add_partial_namespace (struct partial_die_info *pdi, - CORE_ADDR *lowpc, CORE_ADDR *highpc, - int set_addrmap, struct dwarf2_cu *cu); - -static void add_partial_module (struct partial_die_info *pdi, CORE_ADDR *l= owpc, - CORE_ADDR *highpc, int set_addrmap, - struct dwarf2_cu *cu); - -static void add_partial_enumeration (struct partial_die_info *enum_pdi, - struct dwarf2_cu *cu); - -static void add_partial_subprogram (struct partial_die_info *pdi, - CORE_ADDR *lowpc, CORE_ADDR *highpc, - int need_pc, struct dwarf2_cu *cu); - static unsigned int peek_abbrev_code (bfd *, const gdb_byte *); =20 -static struct partial_die_info *load_partial_dies - (const struct die_reader_specs *, const gdb_byte *, int); - -/* A pair of partial_die_info and compilation unit. */ -struct cu_partial_die_info -{ - /* The compilation unit of the partial_die_info. */ - struct dwarf2_cu *cu; - /* A partial_die_info. */ - struct partial_die_info *pdi; - - cu_partial_die_info (struct dwarf2_cu *cu, struct partial_die_info *pdi) - : cu (cu), - pdi (pdi) - { /* Nothing. */ } - -private: - cu_partial_die_info () =3D delete; -}; - -static const struct cu_partial_die_info find_partial_die (sect_offset, int, - struct dwarf2_cu *); - static const gdb_byte *read_attribute (const struct die_reader_specs *, struct attribute *, const struct attr_abbrev *, @@ -1222,8 +1009,7 @@ static line_header_up dwarf_decode_line_header (sect_= offset sect_off, struct dwarf2_cu *cu); =20 static void dwarf_decode_lines (struct line_header *, - const file_and_directory &, - struct dwarf2_cu *, dwarf2_psymtab *, + struct dwarf2_cu *, CORE_ADDR, int decode_mapping); =20 static void dwarf2_start_subfile (struct dwarf2_cu *, const char *, @@ -1460,10 +1246,6 @@ static const gdb_byte *skip_one_die (const struct di= e_reader_specs *reader, const struct abbrev_info *abbrev, bool do_skip_children =3D true); =20 -static hashval_t partial_die_hash (const void *item); - -static int partial_die_eq (const void *item_lhs, const void *item_rhs); - static struct dwarf2_per_cu_data *dwarf2_find_containing_comp_unit (sect_offset sect_off, unsigned int offset_in_dwz, dwarf2_per_bfd *per_bfd); @@ -2108,30 +1890,6 @@ struct dwarf2_per_cu_quick_data bool files_read : 1; }; =20 -/* A subclass of psymbol_functions that arranges to read the DWARF - partial symbols when needed. */ -struct lazy_dwarf_reader : public psymbol_functions -{ - using psymbol_functions::psymbol_functions; - - bool can_lazily_read_symbols () override - { - return true; - } - - void read_partial_symbols (struct objfile *objfile) override - { - if (dwarf2_has_info (objfile, nullptr)) - dwarf2_build_psymtabs (objfile, this); - } -}; - -static quick_symbol_functions_up -make_lazy_dwarf_reader () -{ - return quick_symbol_functions_up (new lazy_dwarf_reader); -} - struct dwarf2_base_index_functions : public quick_symbol_functions { bool has_symbols (struct objfile *objfile) override; @@ -2315,11 +2073,6 @@ static void dw2_do_instantiate_symtab (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, bool skip_partial) { - /* Skip type_unit_groups, reading the type units they contain - is handled elsewhere. */ - if (per_cu->type_unit_group_p ()) - return; - { /* The destructor of dwarf2_queue_guard frees any entries left on the queue. After this point we're guaranteed to leave this function @@ -2362,8 +2115,6 @@ dw2_instantiate_symtab (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, bool skip_partial) { - gdb_assert (per_objfile->per_bfd->using_index); - if (!per_objfile->symtab_set_p (per_cu)) { free_cached_comp_units freer (per_objfile); @@ -3002,7 +2753,6 @@ dwarf2_read_gdb_index create_addrmap_from_index (per_objfile, map.get ()); =20 per_bfd->index_table =3D std::move (map); - per_bfd->using_index =3D 1; per_bfd->quick_file_names_table =3D create_quick_file_names_table (per_bfd->all_comp_units.size ()); =20 @@ -3116,8 +2866,6 @@ dw2_get_file_names (dwarf2_per_cu_data *this_cu, { /* This should never be called for TUs. */ gdb_assert (! this_cu->is_debug_types); - /* Nor type unit groups. */ - gdb_assert (! this_cu->type_unit_group_p ()); =20 if (this_cu->v.quick->files_read) return this_cu->v.quick->file_names; @@ -3178,7 +2926,7 @@ dwarf2_per_cu_data::free_cached_file_names () if (fnd !=3D nullptr) fnd->forget_fullname (); =20 - if (per_bfd =3D=3D nullptr || !per_bfd->using_index || v.quick =3D=3D nu= llptr) + if (per_bfd =3D=3D nullptr || v.quick =3D=3D nullptr) return; =20 struct quick_file_names *file_data =3D v.quick->file_names; @@ -3382,7 +3130,6 @@ dwarf2_gdb_index::dump (struct objfile *objfile) { dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); =20 - gdb_assert (per_objfile->per_bfd->using_index); gdb_printf (".gdb_index:"); if (per_objfile->per_bfd->index_table !=3D NULL) { @@ -5003,7 +4750,6 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objf= ile) create_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges); =20 per_bfd->debug_names_table =3D std::move (map); - per_bfd->using_index =3D 1; per_bfd->quick_file_names_table =3D create_quick_file_names_table (per_bfd->all_comp_units.size ()); =20 @@ -5429,7 +5175,6 @@ dwarf2_debug_names_index::dump (struct objfile *objfi= le) { dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); =20 - gdb_assert (per_objfile->per_bfd->using_index); gdb_printf (".debug_names:"); if (per_objfile->per_bfd->debug_names_table) gdb_printf (" exists\n"); @@ -5612,16 +5357,6 @@ dwarf2_initialize_objfile (struct objfile *objfile) { dwarf_read_debug_printf ("readnow requested"); =20 - /* When using READNOW, the using_index flag (set below) indicates th= at - PER_BFD was already initialized, when we loaded some other objfile. */ - if (per_bfd->using_index) - { - dwarf_read_debug_printf ("using_index already set"); - objfile->qf.push_front (make_dwarf_gdb_index ()); - return; - } - - per_bfd->using_index =3D 1; create_all_comp_units (per_objfile); per_bfd->quick_file_names_table =3D create_quick_file_names_table (per_bfd->all_comp_units.size ()); @@ -5666,18 +5401,6 @@ dwarf2_initialize_objfile (struct objfile *objfile) return; } =20 - /* There might already be partial symtabs built for this BFD. This happ= ens - when loading the same binary twice with the index-cache enabled. If = so, - don't try to read an index. The objfile / per_objfile initialization= will - be completed in dwarf2_build_psymtabs, in the standard partial symtabs - code path. */ - if (per_bfd->partial_symtabs !=3D nullptr) - { - dwarf_read_debug_printf ("re-using shared partial symtabs"); - objfile->qf.push_front (make_lazy_dwarf_reader ()); - return; - } - if (dwarf2_read_debug_names (per_objfile)) { dwarf_read_debug_printf ("found debug names"); @@ -5706,7 +5429,6 @@ dwarf2_initialize_objfile (struct objfile *objfile) } =20 global_index_cache.miss (); - per_bfd->using_index =3D true; objfile->qf.push_front (make_cooked_index_funcs ()); } =20 @@ -5715,47 +5437,21 @@ dwarf2_initialize_objfile (struct objfile *objfile) /* Build a partial symbol table. */ =20 void -dwarf2_build_psymtabs (struct objfile *objfile, psymbol_functions *psf) +dwarf2_build_psymtabs (struct objfile *objfile, bool already_attached) { dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - dwarf2_per_bfd *per_bfd =3D per_objfile->per_bfd; - - if (per_bfd->partial_symtabs !=3D nullptr) - { - /* Partial symbols were already read, so now we can simply - attach them. */ - if (psf =3D=3D nullptr) - { - psf =3D new psymbol_functions (per_bfd->partial_symtabs); - objfile->qf.emplace_front (psf); - } - else - psf->set_partial_symtabs (per_bfd->partial_symtabs); - return; - } =20 - if (psf =3D=3D nullptr) + if (already_attached) { - psf =3D new psymbol_functions; - objfile->qf.emplace_front (psf); + if (per_objfile->per_bfd->cooked_index_table !=3D nullptr) + return; } - const std::shared_ptr &partial_symtabs - =3D psf->get_partial_symtabs (); - - /* Set the local reference to partial symtabs, so that we don't try - to read them again if reading another objfile with the same BFD. - If we can't in fact share, this won't make a difference anyway as - the dwarf2_per_bfd object won't be shared. */ - per_bfd->partial_symtabs =3D partial_symtabs; + else + objfile->qf.push_front (make_cooked_index_funcs ()); =20 try { - /* This isn't really ideal: all the data we allocate on the - objfile's obstack is still uselessly kept around. However, - freeing it seems unsafe. */ - psymtab_discarder psymtabs (partial_symtabs.get ()); dwarf2_build_psymtabs_hard (per_objfile); - psymtabs.keep (); =20 /* (maybe) store an index in the cache. */ global_index_cache.store (per_objfile); @@ -5836,111 +5532,6 @@ read_abbrev_offset (dwarf2_per_objfile *per_objfile, return (sect_offset) read_offset (abfd, info_ptr, offset_size); } =20 -/* A partial symtab that is used only for include files. */ -struct dwarf2_include_psymtab : public partial_symtab -{ - dwarf2_include_psymtab (const char *filename, - psymtab_storage *partial_symtabs, - objfile_per_bfd_storage *objfile_per_bfd) - : partial_symtab (filename, partial_symtabs, objfile_per_bfd) - { - } - - void read_symtab (struct objfile *objfile) override - { - /* It's an include file, no symbols to read for it. - Everything is in the includer symtab. */ - - /* The expansion of a dwarf2_include_psymtab is just a trigger for - expansion of the includer psymtab. We use the dependencies[0] fiel= d to - model the includer. But if we go the regular route of calling - expand_psymtab here, and having expand_psymtab call expand_dependen= cies - to expand the includer, we'll only use expand_psymtab on the includ= er - (making it a non-toplevel psymtab), while if we expand the includer= via - another path, we'll use read_symtab (making it a toplevel psymtab). - So, don't pretend a dwarf2_include_psymtab is an actual toplevel - psymtab, and trigger read_symtab on the includer here directly. */ - includer ()->read_symtab (objfile); - } - - void expand_psymtab (struct objfile *objfile) override - { - /* This is not called by read_symtab, and should not be called by any - expand_dependencies. */ - gdb_assert (false); - } - - bool readin_p (struct objfile *objfile) const override - { - return includer ()->readin_p (objfile); - } - - compunit_symtab *get_compunit_symtab (struct objfile *objfile) const ove= rride - { - compunit_symtab *cust =3D includer ()->get_compunit_symtab (objfile); - while (cust !=3D nullptr && cust->user !=3D nullptr) - cust =3D cust->user; - return cust; - } - -private: - partial_symtab *includer () const - { - /* An include psymtab has exactly one dependency: the psymtab that - includes it. */ - gdb_assert (this->number_of_dependencies =3D=3D 1); - return this->dependencies[0]; - } -}; - -/* Allocate a new partial symtab for file named NAME and mark this new - partial symtab as being an include of PST. */ - -static void -dwarf2_create_include_psymtab (dwarf2_per_bfd *per_bfd, - const char *name, - dwarf2_psymtab *pst, - psymtab_storage *partial_symtabs, - objfile_per_bfd_storage *objfile_per_bfd) -{ - dwarf2_include_psymtab *subpst - =3D new dwarf2_include_psymtab (name, partial_symtabs, objfile_per_bfd= ); - - if (!IS_ABSOLUTE_PATH (subpst->filename)) - subpst->dirname =3D pst->dirname; - - subpst->dependencies =3D per_bfd->partial_symtabs->allocate_dependencies= (1); - subpst->dependencies[0] =3D pst; - subpst->number_of_dependencies =3D 1; -} - -/* Read the Line Number Program data and extract the list of files - included by the source file represented by PST. Build an include - partial symtab for each of these included files. */ - -static void -dwarf2_build_include_psymtabs (struct dwarf2_cu *cu, - struct die_info *die, - const file_and_directory &fnd, - dwarf2_psymtab *pst) -{ - line_header_up lh; - struct attribute *attr; - - attr =3D dwarf2_attr (die, DW_AT_stmt_list, cu); - if (attr !=3D nullptr && attr->form_is_unsigned ()) - lh =3D dwarf_decode_line_header ((sect_offset) attr->as_unsigned (), c= u); - if (lh =3D=3D NULL) - return; /* No linetable, so no includes. */ - - /* NOTE: pst->dirname is DW_AT_comp_dir (if present). Also note - that we pass in the raw text_low here; that is ok because we're - only decoding the line table to make include partial symtabs, and - so the addresses aren't really used. */ - dwarf_decode_lines (lh.get (), fnd, cu, pst, - pst->raw_text_low (), 1); -} - static hashval_t hash_signatured_type (const void *item) { @@ -6104,12 +5695,8 @@ add_type_unit (dwarf2_per_objfile *per_objfile, ULON= GEST sig, void **slot) =20 per_objfile->per_bfd->all_comp_units.emplace_back (sig_type_holder.release ()); - if (per_objfile->per_bfd->using_index) - { - sig_type->v.quick =3D - OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, - struct dwarf2_per_cu_quick_data); - } + sig_type->v.quick =3D OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, + struct dwarf2_per_cu_quick_data); =20 if (slot =3D=3D NULL) { @@ -6135,13 +5722,8 @@ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile= *per_objfile, /* Make sure we're not clobbering something we don't expect to. */ gdb_assert (! sig_entry->queued); gdb_assert (per_objfile->get_cu (sig_entry) =3D=3D NULL); - if (per_bfd->using_index) - { - gdb_assert (sig_entry->v.quick !=3D NULL); - gdb_assert (!per_objfile->symtab_set_p (sig_entry)); - } - else - gdb_assert (sig_entry->v.psymtab =3D=3D NULL); + gdb_assert (sig_entry->v.quick !=3D NULL); + gdb_assert (!per_objfile->symtab_set_p (sig_entry)); gdb_assert (sig_entry->signature =3D=3D dwo_entry->signature); gdb_assert (to_underlying (sig_entry->type_offset_in_section) =3D=3D 0 || (to_underlying (sig_entry->type_offset_in_section) @@ -6179,7 +5761,7 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULO= NGEST sig) struct dwo_unit find_dwo_entry, *dwo_entry; void **slot; =20 - gdb_assert (cu->dwo_unit && per_objfile->per_bfd->using_index); + gdb_assert (cu->dwo_unit); =20 /* If TU skeletons have been removed then we may not have read in any TUs yet. */ @@ -6245,7 +5827,7 @@ lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULO= NGEST sig) struct dwo_unit *dwo_entry; void **slot; =20 - gdb_assert (cu->dwo_unit && per_objfile->per_bfd->using_index); + gdb_assert (cu->dwo_unit); gdb_assert (dwp_file !=3D NULL); =20 /* If TU skeletons have been removed then we may not have read in any @@ -6286,7 +5868,7 @@ lookup_signatured_type (struct dwarf2_cu *cu, ULONGES= T sig) { dwarf2_per_objfile *per_objfile =3D cu->per_objfile; =20 - if (cu->dwo_unit && per_objfile->per_bfd->using_index) + if (cu->dwo_unit) { /* We're in a DWO/DWP file, and we're using .gdb_index. These cases require special processing. */ @@ -6979,34 +6561,7 @@ allocate_type_unit_groups_table () static std::unique_ptr create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_stru= ct) { - dwarf2_per_objfile *per_objfile =3D cu->per_objfile; - dwarf2_per_bfd *per_bfd =3D per_objfile->per_bfd; - std::unique_ptr tu_group (new type_unit_group); - tu_group->per_bfd =3D per_bfd; - - if (per_bfd->using_index) - { - tu_group->v.quick =3D OBSTACK_ZALLOC (&per_bfd->obstack, - struct dwarf2_per_cu_quick_data); - } - else - { - unsigned int line_offset =3D to_underlying (line_offset_struct); - dwarf2_psymtab *pst; - std::string name; - - /* Give the symtab a useful name for debug purposes. */ - if ((line_offset & NO_STMT_LIST_TYPE_UNIT_PSYMTAB) !=3D 0) - name =3D string_printf ("", - (line_offset & ~NO_STMT_LIST_TYPE_UNIT_PSYMTAB)); - else - name =3D string_printf ("", line_offset); - - pst =3D create_partial_symtab (tu_group.get (), per_objfile, - name.c_str ()); - pst->anonymous =3D true; - } =20 tu_group->hash.dwo_unit =3D cu->dwo_unit; tu_group->hash.line_sect_off =3D line_offset_struct; @@ -7068,30 +6623,6 @@ get_type_unit_group (struct dwarf2_cu *cu, const str= uct attribute *stmt_list) return tu_group; } =0C -/* Partial symbol tables. */ - -/* Create a psymtab named NAME and assign it to PER_CU. - - The caller must fill in the following details: - dirname, textlow, texthigh. */ - -static dwarf2_psymtab * -create_partial_symtab (dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, - const char *name) -{ - dwarf2_psymtab *pst - =3D new dwarf2_psymtab (name, per_objfile->per_bfd->partial_symtabs.ge= t (), - per_objfile->objfile->per_bfd, per_cu); - - pst->psymtabs_addrmap_supported =3D true; - - /* This is the glue that links PST into GDB's symbol API. */ - per_cu->v.psymtab =3D pst; - - return pst; -} -=0C =20 /* An instance of this is created when scanning DWARF to create a cooked index. */ @@ -7322,166 +6853,16 @@ private: std::vector m_deferred_entries; }; =20 - - -/* DIE reader function for process_psymtab_comp_unit. */ - -static void -process_psymtab_comp_unit_reader (const struct die_reader_specs *reader, - const gdb_byte *info_ptr, - struct die_info *comp_unit_die, - enum language pretend_language) -{ - struct dwarf2_cu *cu =3D reader->cu; - dwarf2_per_objfile *per_objfile =3D cu->per_objfile; - dwarf2_per_bfd *per_bfd =3D per_objfile->per_bfd; - struct objfile *objfile =3D per_objfile->objfile; - struct gdbarch *gdbarch =3D objfile->arch (); - struct dwarf2_per_cu_data *per_cu =3D cu->per_cu; - CORE_ADDR baseaddr; - CORE_ADDR best_lowpc =3D 0, best_highpc =3D 0; - dwarf2_psymtab *pst; - enum pc_bounds_kind cu_bounds_kind; - - gdb_assert (! per_cu->is_debug_types); - - prepare_one_comp_unit (cu, comp_unit_die, pretend_language); - - /* Allocate a new partial symbol table structure. */ - static const char artificial[] =3D ""; - file_and_directory &fnd =3D find_file_and_directory (comp_unit_die, cu); - if (strcmp (fnd.get_name (), artificial) =3D=3D 0) - { - gdb::unique_xmalloc_ptr debug_filename - (concat (artificial, "@", - sect_offset_str (per_cu->sect_off), - (char *) NULL)); - fnd.set_name (std::move (debug_filename)); - } - - pst =3D create_partial_symtab (per_cu, per_objfile, fnd.get_name ()); - - /* This must be done before calling dwarf2_build_include_psymtabs. */ - pst->dirname =3D dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu); - - baseaddr =3D objfile->text_section_offset (); - - dwarf2_find_base_address (comp_unit_die, cu); - - /* Possibly set the default values of LOWPC and HIGHPC from - `DW_AT_ranges'. */ - cu_bounds_kind - =3D dwarf2_get_pc_bounds (comp_unit_die, &best_lowpc, - &best_highpc, cu, - per_bfd->partial_symtabs->psymtabs_addrmap, - pst); - if (cu_bounds_kind =3D=3D PC_BOUNDS_HIGH_LOW && best_lowpc < best_highpc) - { - CORE_ADDR low - =3D (gdbarch_adjust_dwarf2_addr (gdbarch, best_lowpc + baseaddr) - - baseaddr); - CORE_ADDR high - =3D (gdbarch_adjust_dwarf2_addr (gdbarch, best_highpc + baseaddr) - - baseaddr - 1); - /* Store the contiguous range if it is not empty; it can be - empty for CUs with no code. */ - addrmap_set_empty (per_bfd->partial_symtabs->psymtabs_addrmap, - low, high, pst); - } - - /* Check if comp unit has_children. - If so, read the rest of the partial symbols from this comp unit. - If not, there's no more debug_info for this comp unit. */ - if (comp_unit_die->has_children) - { - struct partial_die_info *first_die; - CORE_ADDR lowpc, highpc; - - lowpc =3D ((CORE_ADDR) -1); - highpc =3D ((CORE_ADDR) 0); - - first_die =3D load_partial_dies (reader, info_ptr, 1); - - scan_partial_symbols (first_die, &lowpc, &highpc, - cu_bounds_kind <=3D PC_BOUNDS_INVALID, cu); - - /* If we didn't find a lowpc, set it to highpc to avoid - complaints from `maint check'. */ - if (lowpc =3D=3D ((CORE_ADDR) -1)) - lowpc =3D highpc; - - /* If the compilation unit didn't have an explicit address range, - then use the information extracted from its child dies. */ - if (cu_bounds_kind <=3D PC_BOUNDS_INVALID) - { - best_lowpc =3D lowpc; - best_highpc =3D highpc; - } - } - pst->set_text_low (gdbarch_adjust_dwarf2_addr (gdbarch, - best_lowpc + baseaddr) - - baseaddr); - pst->set_text_high (gdbarch_adjust_dwarf2_addr (gdbarch, - best_highpc + baseaddr) - - baseaddr); - - pst->end (); - - if (!cu->per_cu->imported_symtabs_empty ()) - { - int i; - int len =3D cu->per_cu->imported_symtabs_size (); - - /* Fill in 'dependencies' here; we fill in 'users' in a - post-pass. */ - pst->number_of_dependencies =3D len; - pst->dependencies - =3D per_bfd->partial_symtabs->allocate_dependencies (len); - for (i =3D 0; i < len; ++i) - { - pst->dependencies[i] - =3D cu->per_cu->imported_symtabs->at (i)->v.psymtab; - } - - cu->per_cu->imported_symtabs_free (); - } - - /* Get the list of files included in the current compilation unit, - and build a psymtab for each of them. */ - dwarf2_build_include_psymtabs (cu, comp_unit_die, fnd, pst); - - dwarf_read_debug_printf ("Psymtab for %s unit @%s: %s - %s" - ", %d global, %d static syms", - per_cu->is_debug_types ? "type" : "comp", - sect_offset_str (per_cu->sect_off), - paddress (gdbarch, pst->text_low (objfile)), - paddress (gdbarch, pst->text_high (objfile)), - (int) pst->global_psymbols.size (), - (int) pst->static_psymbols.size ()); -} - /* Subroutine of dwarf2_build_psymtabs_hard to simplify it. Process compilation unit THIS_CU for a psymtab. */ =20 static void process_psymtab_comp_unit (dwarf2_per_cu_data *this_cu, dwarf2_per_objfile *per_objfile, - bool want_partial_unit, - enum language pretend_language, cooked_index_storage *storage) { - /* If this compilation unit was already read in, free the - cached copy in order to read it in again. This is - necessary because we skipped some symbols when we first - read in the compilation unit (see load_partial_dies). - This problem could be avoided, but the benefit is unclear. */ - if (!per_objfile->per_bfd->using_index) - per_objfile->remove_cu (this_cu); - cutu_reader reader (this_cu, per_objfile, nullptr, nullptr, false, - (storage =3D=3D nullptr - ? nullptr - : storage->get_abbrev_cache ())); + storage->get_abbrev_cache ()); =20 if (reader.comp_unit_die =3D=3D nullptr) return; @@ -7510,30 +6891,18 @@ process_psymtab_comp_unit (dwarf2_per_cu_data *this= _cu, } else if (this_cu->is_debug_types) build_type_psymtabs_reader (&reader, storage); - else if (want_partial_unit - || reader.comp_unit_die->tag !=3D DW_TAG_partial_unit) + else if (reader.comp_unit_die->tag !=3D DW_TAG_partial_unit) { - if (per_objfile->per_bfd->using_index) + bool nope =3D false; + if (this_cu->scanned.compare_exchange_strong (nope, true)) { - bool nope =3D false; - if (this_cu->scanned.compare_exchange_strong (nope, true)) - { - prepare_one_comp_unit (reader.cu, reader.comp_unit_die, - pretend_language); - gdb_assert (storage !=3D nullptr); - cooked_indexer indexer (storage, this_cu, - reader.cu->per_cu->lang); - indexer.make_index (&reader); - } + prepare_one_comp_unit (reader.cu, reader.comp_unit_die, + language_minimal); + gdb_assert (storage !=3D nullptr); + cooked_indexer indexer (storage, this_cu, reader.cu->per_cu->lang); + indexer.make_index (&reader); } - else - process_psymtab_comp_unit_reader (&reader, reader.info_ptr, - reader.comp_unit_die, - pretend_language); } - - /* Age out any secondary CUs. */ - per_objfile->age_comp_units (); } =20 /* Reader function for build_type_psymtabs. */ @@ -7542,52 +6911,20 @@ static void build_type_psymtabs_reader (cutu_reader *reader, cooked_index_storage *storage) { - dwarf2_per_objfile *per_objfile =3D reader->cu->per_objfile; struct dwarf2_cu *cu =3D reader->cu; struct dwarf2_per_cu_data *per_cu =3D cu->per_cu; - struct signatured_type *sig_type; - struct type_unit_group *tu_group; - struct attribute *attr; - struct partial_die_info *first_die; - CORE_ADDR lowpc, highpc; - dwarf2_psymtab *pst; - const gdb_byte *info_ptr =3D reader->info_ptr; struct die_info *type_unit_die =3D reader->comp_unit_die; =20 gdb_assert (per_cu->is_debug_types); - sig_type =3D (struct signatured_type *) per_cu; =20 if (! type_unit_die->has_children) return; =20 - attr =3D type_unit_die->attr (DW_AT_stmt_list); - tu_group =3D get_type_unit_group (cu, attr); - - if (tu_group->tus =3D=3D nullptr) - tu_group->tus =3D new std::vector; - tu_group->tus->push_back (sig_type); - prepare_one_comp_unit (cu, type_unit_die, language_minimal); =20 - if (per_objfile->per_bfd->using_index) - { - gdb_assert (storage !=3D nullptr); - cooked_indexer indexer (storage, per_cu, cu->per_cu->lang); - indexer.make_index (reader); - } - else - { - pst =3D create_partial_symtab (per_cu, per_objfile, ""); - pst->anonymous =3D true; - - first_die =3D load_partial_dies (reader, info_ptr, 1); - - lowpc =3D (CORE_ADDR) -1; - highpc =3D (CORE_ADDR) 0; - scan_partial_symbols (first_die, &lowpc, &highpc, 0, cu); - - pst->end (); - } + gdb_assert (storage !=3D nullptr); + cooked_indexer indexer (storage, per_cu, cu->per_cu->lang); + indexer.make_index (reader); } =20 /* Struct used to sort TUs by their abbreviation table offset. */ @@ -7721,45 +7058,14 @@ print_tu_stats (dwarf2_per_objfile *per_objfile) tu_stats->nr_all_type_units_reallocs); } =20 -/* Traversal function for build_type_psymtabs. */ - -static int -build_type_psymtab_dependencies (void **slot, void *info) +struct skeleton_data { - dwarf2_per_objfile *per_objfile =3D (dwarf2_per_objfile *) info; - dwarf2_per_bfd *per_bfd =3D per_objfile->per_bfd; - struct type_unit_group *tu_group =3D (struct type_unit_group *) *slot; - dwarf2_psymtab *pst =3D tu_group->v.psymtab; - int len =3D (tu_group->tus =3D=3D nullptr) ? 0 : tu_group->tus->size (); - int i; + dwarf2_per_objfile *per_objfile; + cooked_index_storage *storage; +}; =20 - gdb_assert (len > 0); - gdb_assert (tu_group->type_unit_group_p ()); - - pst->number_of_dependencies =3D len; - pst->dependencies =3D per_bfd->partial_symtabs->allocate_dependencies (l= en); - for (i =3D 0; i < len; ++i) - { - struct signatured_type *iter =3D tu_group->tus->at (i); - gdb_assert (iter->is_debug_types); - pst->dependencies[i] =3D iter->v.psymtab; - iter->type_unit_group =3D tu_group; - } - - delete tu_group->tus; - tu_group->tus =3D nullptr; - - return 1; -} - -struct skeleton_data -{ - dwarf2_per_objfile *per_objfile; - cooked_index_storage *storage; -}; - -/* Traversal function for process_skeletonless_type_unit. - Read a TU in a DWO file and build partial symbols for it. */ +/* Traversal function for process_skeletonless_type_unit. + Read a TU in a DWO file and build partial symbols for it. */ =20 static int process_skeletonless_type_unit (void **slot, void *info) @@ -7830,27 +7136,6 @@ process_skeletonless_type_units (dwarf2_per_objfile = *per_objfile, } } =20 -/* Compute the 'user' field for each psymtab in DWARF2_PER_OBJFILE. */ - -static void -set_partial_user (dwarf2_per_objfile *per_objfile) -{ - for (const auto &per_cu : per_objfile->per_bfd->all_comp_units) - { - dwarf2_psymtab *pst =3D per_cu->v.psymtab; - - if (pst =3D=3D NULL) - continue; - - for (int j =3D 0; j < pst->number_of_dependencies; ++j) - { - /* Set the 'user' field only if it is not already set. */ - if (pst->dependencies[j]->user =3D=3D NULL) - pst->dependencies[j]->user =3D pst; - } - } -} - /* Build the partial symbol table by doing a quick pass through the .debug_info and .debug_abbrev sections. */ =20 @@ -7863,178 +7148,97 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *pe= r_objfile) dwarf_read_debug_printf ("Building psymtabs of objfile %s ...", objfile_name (objfile)); =20 - scoped_restore restore_reading_psyms - =3D make_scoped_restore (&per_bfd->reading_partial_symbols, true); - per_bfd->map_info_sections (objfile); =20 - /* Any cached compilation units will be linked by the per-objfile - read_in_chain. Make sure to free them when we're done. */ - free_cached_comp_units freer (per_objfile); - - /* Create a temporary address map on a temporary obstack. We later - copy this to the final obstack. */ - auto_obstack temp_obstack; - - scoped_restore save_psymtabs_addrmap - =3D make_scoped_restore (&per_bfd->partial_symtabs->psymtabs_addrmap, - addrmap_create_mutable (&temp_obstack)); - cooked_index_storage index_storage; - cooked_index_storage *index_storage_ptr - =3D per_bfd->using_index ? &index_storage : nullptr; create_all_comp_units (per_objfile); - build_type_psymtabs (per_objfile, index_storage_ptr); + build_type_psymtabs (per_objfile, &index_storage); std::vector> indexes; - if (per_bfd->using_index) - { - per_bfd->quick_file_names_table - =3D create_quick_file_names_table (per_bfd->all_comp_units.size ()); =20 - if (!per_bfd->debug_aranges.empty ()) - read_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges, - index_storage.get_addrmap ()); + per_bfd->quick_file_names_table + =3D create_quick_file_names_table (per_bfd->all_comp_units.size ()); + if (!per_bfd->debug_aranges.empty ()) + read_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges, + index_storage.get_addrmap ()); =20 + { + /* Ensure that complaints are handled correctly. */ + complaint_interceptor complaint_handler; + + using iter_type =3D typeof (per_bfd->all_comp_units.begin ()); + + /* Each thread returns a pair holding a cooked index, and a vector + of errors that should be printed. The latter is done because + GDB's I/O system is not thread-safe. run_on_main_thread could be + used, but that would mean the messages are printed after the + prompt, which looks weird. */ + using result_type =3D std::pair, + std::vector>; + std::vector results + =3D gdb::parallel_for_each (1, per_bfd->all_comp_units.begin (), + per_bfd->all_comp_units.end (), + [=3D] (iter_type iter, iter_type end) { - /* Ensure that complaints are handled correctly. */ - complaint_interceptor complaint_handler; - - using iter_type =3D typeof (per_bfd->all_comp_units.begin ()); - - /* Each thread returns a pair holding a cooked index, and a vector - of errors that should be printed. The latter is done because - GDB's I/O system is not thread-safe. run_on_main_thread could be - used, but that would mean the messages are printed after the - prompt, which looks weird. */ - using result_type =3D std::pair, - std::vector>; - std::vector results - =3D gdb::parallel_for_each (1, per_bfd->all_comp_units.begin (), - per_bfd->all_comp_units.end (), - [=3D] (iter_type iter, iter_type end) - { - std::vector errors; - cooked_index_storage thread_storage; - for (; iter !=3D end; ++iter) - { - dwarf2_per_cu_data *per_cu =3D iter->get (); - try - { - process_psymtab_comp_unit (per_cu, per_objfile, - false, - language_minimal, - &thread_storage); - } - catch (gdb_exception &except) - { - errors.push_back (std::move (except)); - } - } - return result_type (thread_storage.release (), - std::move (errors)); - }); - - /* Only show a given exception a single time. */ - std::unordered_set seen_exceptions; - for (auto &one_result : results) + std::vector errors; + cooked_index_storage thread_storage; + for (; iter !=3D end; ++iter) { - indexes.push_back (std::move (one_result.first)); - for (auto &one_exc : one_result.second) + dwarf2_per_cu_data *per_cu =3D iter->get (); + try + { + process_psymtab_comp_unit (per_cu, per_objfile, + &thread_storage); + } + catch (gdb_exception &except) { - if (seen_exceptions.insert (one_exc).second) - exception_print (gdb_stderr, one_exc); + errors.push_back (std::move (except)); } } + return result_type (thread_storage.release (), std::move (errors)); + }); + + /* Only show a given exception a single time. */ + std::unordered_set seen_exceptions; + for (auto &one_result : results) + { + indexes.push_back (std::move (one_result.first)); + for (auto &one_exc : one_result.second) + if (seen_exceptions.insert (one_exc).second) + exception_print (gdb_stderr, one_exc); } - } - else - { - for (const auto &per_cu : per_bfd->all_comp_units) - { - if (!per_bfd->using_index && per_cu->v.psymtab !=3D NULL) - /* In case a forward DW_TAG_imported_unit has read the CU - already. */ - continue; - process_psymtab_comp_unit (per_cu.get (), per_objfile, false, - language_minimal, nullptr); - } - } + } =20 /* This has to wait until we read the CUs, we need the list of DWOs. */ process_skeletonless_type_units (per_objfile, &index_storage); =20 - /* Now that all TUs have been processed we can fill in the dependencies.= */ - if (!per_bfd->using_index && per_bfd->type_unit_groups !=3D NULL) - { - htab_traverse_noresize (per_bfd->type_unit_groups.get (), - build_type_psymtab_dependencies, per_objfile); - } - if (dwarf_read_debug > 0) print_tu_stats (per_objfile); =20 - if (per_bfd->using_index) - { - indexes.push_back (index_storage.release ()); - /* Remove any NULL entries. This might happen if parallel-for - decides to throttle the number of threads that were used. */ - indexes.erase - (std::remove_if (indexes.begin (), - indexes.end (), - [] (const std::unique_ptr &entry) - { - return entry =3D=3D nullptr; - }), - indexes.end ()); - indexes.shrink_to_fit (); - per_bfd->cooked_index_table.reset - (new cooked_index_vector (std::move (indexes))); - - const cooked_index_entry *main_entry - =3D per_bfd->cooked_index_table->get_main (); - if (main_entry !=3D nullptr) - set_objfile_main_name (objfile, main_entry->name, - main_entry->per_cu->lang); - } - else - { - set_partial_user (per_objfile); + indexes.push_back (index_storage.release ()); + /* Remove any NULL entries. This might happen if parallel-for + decides to throttle the number of threads that were used. */ + indexes.erase + (std::remove_if (indexes.begin (), + indexes.end (), + [] (const std::unique_ptr &entry) + { + return entry =3D=3D nullptr; + }), + indexes.end ()); + indexes.shrink_to_fit (); + per_bfd->cooked_index_table.reset + (new cooked_index_vector (std::move (indexes))); + + const cooked_index_entry *main_entry + =3D per_bfd->cooked_index_table->get_main (); + if (main_entry !=3D nullptr) + set_objfile_main_name (objfile, main_entry->name, + main_entry->per_cu->lang); =20 - per_bfd->partial_symtabs->psymtabs_addrmap - =3D addrmap_create_fixed (per_bfd->partial_symtabs->psymtabs_addrmap, - per_bfd->partial_symtabs->obstack ()); - /* At this point we want to keep the address map. */ - save_psymtabs_addrmap.release (); - } dwarf_read_debug_printf ("Done building psymtabs of %s", objfile_name (objfile)); } =20 -/* Load the partial DIEs for a secondary CU into memory. - This is also used when rereading a primary CU with load_all_dies. */ - -static void -load_partial_comp_unit (dwarf2_per_cu_data *this_cu, - dwarf2_per_objfile *per_objfile, - dwarf2_cu *existing_cu) -{ - cutu_reader reader (this_cu, per_objfile, nullptr, existing_cu, false); - - if (!reader.dummy_p) - { - prepare_one_comp_unit (reader.cu, reader.comp_unit_die, - language_minimal); - - /* Check if comp unit has_children. - If so, read the rest of the partial symbols from this comp unit. - If not, there's no more debug_info for this comp unit. */ - if (reader.comp_unit_die->has_children) - load_partial_dies (&reader, reader.info_ptr, 0); - - reader.keep (); - } -} - static void read_comp_units_from_section (dwarf2_per_objfile *per_objfile, struct dwarf2_section_info *section, @@ -8094,9 +7298,8 @@ read_comp_units_from_section (dwarf2_per_objfile *per= _objfile, this_cu->is_dwz =3D is_dwz; this_cu->section =3D section; =20 - if (per_objfile->per_bfd->using_index) - this_cu->v.quick =3D OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, - struct dwarf2_per_cu_quick_data); + this_cu->v.quick =3D OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, + struct dwarf2_per_cu_quick_data); =20 info_ptr =3D info_ptr + this_cu->length; per_objfile->per_bfd->all_comp_units.push_back (std::move (this_cu)); @@ -8135,745 +7338,120 @@ create_all_comp_units (dwarf2_per_objfile *per_ob= jfile) per_objfile->per_bfd->signatured_types =3D std::move (types_htab); } =20 -/* Process all loaded DIEs for compilation unit CU, starting at - FIRST_DIE. The caller should pass SET_ADDRMAP =3D=3D 1 if the compilat= ion - unit DIE did not have PC info (DW_AT_low_pc and DW_AT_high_pc, or - DW_AT_ranges). See the comments of add_partial_subprogram on how - SET_ADDRMAP is used and how *LOWPC and *HIGHPC are updated. */ +/* Return the initial uleb128 in the die at INFO_PTR. */ =20 -static void -scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc, - CORE_ADDR *highpc, int set_addrmap, - struct dwarf2_cu *cu) +static unsigned int +peek_abbrev_code (bfd *abfd, const gdb_byte *info_ptr) { - struct partial_die_info *pdi; - - /* Now, march along the PDI's, descending into ones which have - interesting children but skipping the children of the other ones, - until we reach the end of the compilation unit. */ - - pdi =3D first_die; - - while (pdi !=3D NULL) - { - pdi->fixup (cu); - - /* Anonymous namespaces or modules have no name but have interesting - children, so we need to look at them. Ditto for anonymous - enums. */ - - if (pdi->raw_name !=3D NULL || pdi->tag =3D=3D DW_TAG_namespace - || pdi->tag =3D=3D DW_TAG_module || pdi->tag =3D=3D DW_TAG_enumeration_= type - || pdi->tag =3D=3D DW_TAG_imported_unit - || pdi->tag =3D=3D DW_TAG_inlined_subroutine) - { - switch (pdi->tag) - { - case DW_TAG_subprogram: - case DW_TAG_inlined_subroutine: - add_partial_subprogram (pdi, lowpc, highpc, set_addrmap, cu); - if (cu->per_cu->lang =3D=3D language_cplus) - scan_partial_symbols (pdi->die_child, lowpc, highpc, - set_addrmap, cu); - break; - case DW_TAG_constant: - case DW_TAG_variable: - case DW_TAG_typedef: - case DW_TAG_union_type: - if (!pdi->is_declaration - || (pdi->tag =3D=3D DW_TAG_variable && pdi->is_external)) - { - add_partial_symbol (pdi, cu); - } - break; - case DW_TAG_class_type: - case DW_TAG_interface_type: - case DW_TAG_structure_type: - if (!pdi->is_declaration) - { - add_partial_symbol (pdi, cu); - } - if ((cu->per_cu->lang =3D=3D language_rust - || cu->per_cu->lang =3D=3D language_cplus) - && pdi->has_children) - scan_partial_symbols (pdi->die_child, lowpc, highpc, - set_addrmap, cu); - break; - case DW_TAG_enumeration_type: - if (!pdi->is_declaration) - add_partial_enumeration (pdi, cu); - break; - case DW_TAG_base_type: - case DW_TAG_generic_subrange: - case DW_TAG_subrange_type: - /* File scope base type definitions are added to the partial - symbol table. */ - add_partial_symbol (pdi, cu); - break; - case DW_TAG_namespace: - add_partial_namespace (pdi, lowpc, highpc, set_addrmap, cu); - break; - case DW_TAG_module: - if (!pdi->is_declaration) - add_partial_module (pdi, lowpc, highpc, set_addrmap, cu); - break; - case DW_TAG_imported_unit: - { - struct dwarf2_per_cu_data *per_cu; - - /* For now we don't handle imported units in type units. */ - if (cu->per_cu->is_debug_types) - { - error (_("Dwarf Error: DW_TAG_imported_unit is not" - " supported in type units [in module %s]"), - objfile_name (cu->per_objfile->objfile)); - } - - per_cu =3D dwarf2_find_containing_comp_unit - (pdi->d.sect_off, pdi->is_dwz, - cu->per_objfile->per_bfd); - - /* Go read the partial unit, if needed. */ - if (per_cu->v.psymtab =3D=3D NULL) - process_psymtab_comp_unit (per_cu, cu->per_objfile, true, - cu->per_cu->lang, nullptr); - - if (pdi->die_parent =3D=3D nullptr - && per_cu->unit_type =3D=3D DW_UT_compile - && per_cu->lang =3D=3D language_cplus) - /* Regard import as hint. See corresponding code in - process_imported_unit_die. */ - break; - - cu->per_cu->imported_symtabs_push (per_cu); - } - break; - case DW_TAG_imported_declaration: - add_partial_symbol (pdi, cu); - break; - default: - break; - } - } - - /* If the die has a sibling, skip to the sibling. */ + unsigned int bytes_read; =20 - pdi =3D pdi->die_sibling; - } + return read_unsigned_leb128 (abfd, info_ptr, &bytes_read); } =20 -/* Functions used to compute the fully scoped name of a partial DIE. - - Normally, this is simple. For C++, the parent DIE's fully scoped - name is concatenated with "::" and the partial DIE's name. - Enumerators are an exception; they use the scope of their parent - enumeration type, i.e. the name of the enumeration type is not - prepended to the enumerator. +/* Read the initial uleb128 in the die at INFO_PTR in compilation unit + READER::CU. Use READER::ABBREV_TABLE to lookup any abbreviation. =20 - There are two complexities. One is DW_AT_specification; in this - case "parent" means the parent of the target of the specification, - instead of the direct parent of the DIE. The other is compilers - which do not emit DW_TAG_namespace; in this case we try to guess - the fully qualified name of structure types from their members' - linkage names. This must be done using the DIE's children rather - than the children of any DW_AT_specification target. We only need - to do this for structures at the top level, i.e. if the target of - any DW_AT_specification (if any; otherwise the DIE itself) does not - have a parent. */ + Return the corresponding abbrev, or NULL if the number is zero (indicat= ing + an empty DIE). In either case *BYTES_READ will be set to the length of + the initial number. */ =20 -/* Compute the scope prefix associated with PDI's parent, in - compilation unit CU. The result will be allocated on CU's - comp_unit_obstack, or a copy of the already allocated PDI->NAME - field. NULL is returned if no prefix is necessary. */ -static const char * -partial_die_parent_scope (struct partial_die_info *pdi, - struct dwarf2_cu *cu) +static const struct abbrev_info * +peek_die_abbrev (const die_reader_specs &reader, + const gdb_byte *info_ptr, unsigned int *bytes_read) { - const char *grandparent_scope; - struct partial_die_info *parent, *real_pdi; + dwarf2_cu *cu =3D reader.cu; + bfd *abfd =3D reader.abfd; + unsigned int abbrev_number + =3D read_unsigned_leb128 (abfd, info_ptr, bytes_read); =20 - /* We need to look at our parent DIE; if we have a DW_AT_specification, - then this means the parent of the specification DIE. */ + if (abbrev_number =3D=3D 0) + return NULL; =20 - real_pdi =3D pdi; - while (real_pdi->has_specification) + const abbrev_info *abbrev + =3D reader.abbrev_table->lookup_abbrev (abbrev_number); + if (!abbrev) { - auto res =3D find_partial_die (real_pdi->spec_offset, - real_pdi->spec_is_dwz, cu); - real_pdi =3D res.pdi; - cu =3D res.cu; + error (_("Dwarf Error: Could not find abbrev number %d in %s" + " at offset %s [in module %s]"), + abbrev_number, cu->per_cu->is_debug_types ? "TU" : "CU", + sect_offset_str (cu->header.sect_off), bfd_get_filename (abfd)); } =20 - parent =3D real_pdi->die_parent; - if (parent =3D=3D NULL) - return NULL; - - if (parent->scope_set) - return parent->scope; - - parent->fixup (cu); + return abbrev; +} =20 - grandparent_scope =3D partial_die_parent_scope (parent, cu); +/* Scan the debug information for CU starting at INFO_PTR in buffer BUFFER. + Returns a pointer to the end of a series of DIEs, terminated by an empty + DIE. Any children of the skipped DIEs will also be skipped. */ =20 - /* GCC 4.0 and 4.1 had a bug (PR c++/28460) where they generated bogus - DW_TAG_namespace DIEs with a name of "::" for the global namespace. - Work around this problem here. */ - if (cu->per_cu->lang =3D=3D language_cplus - && parent->tag =3D=3D DW_TAG_namespace - && strcmp (parent->name (cu), "::") =3D=3D 0 - && grandparent_scope =3D=3D NULL) +static const gdb_byte * +skip_children (const struct die_reader_specs *reader, const gdb_byte *info= _ptr) +{ + while (1) { - parent->scope =3D NULL; - parent->scope_set =3D 1; - return NULL; - } + unsigned int bytes_read; + const abbrev_info *abbrev =3D peek_die_abbrev (*reader, info_ptr, + &bytes_read); =20 - /* Nested subroutines in Fortran get a prefix. */ - if (pdi->tag =3D=3D DW_TAG_enumerator) - /* Enumerators should not get the name of the enumeration as a prefix.= */ - parent->scope =3D grandparent_scope; - else if (parent->tag =3D=3D DW_TAG_namespace - || parent->tag =3D=3D DW_TAG_module - || parent->tag =3D=3D DW_TAG_structure_type - || parent->tag =3D=3D DW_TAG_class_type - || parent->tag =3D=3D DW_TAG_interface_type - || parent->tag =3D=3D DW_TAG_union_type - || parent->tag =3D=3D DW_TAG_enumeration_type - || (cu->per_cu->lang =3D=3D language_fortran - && parent->tag =3D=3D DW_TAG_subprogram - && pdi->tag =3D=3D DW_TAG_subprogram)) - { - if (grandparent_scope =3D=3D NULL) - parent->scope =3D parent->name (cu); + if (abbrev =3D=3D NULL) + return info_ptr + bytes_read; else - parent->scope =3D typename_concat (&cu->comp_unit_obstack, - grandparent_scope, - parent->name (cu), 0, cu); - } - else - { - /* FIXME drow/2004-04-01: What should we be doing with - function-local names? For partial symbols, we should probably be - ignoring them. */ - complaint (_("unhandled containing DIE tag %s for DIE at %s"), - dwarf_tag_name (parent->tag), - sect_offset_str (pdi->sect_off)); - parent->scope =3D grandparent_scope; + info_ptr =3D skip_one_die (reader, info_ptr + bytes_read, abbrev); } - - parent->scope_set =3D 1; - return parent->scope; } =20 -/* Return the fully scoped name associated with PDI, from compilation unit - CU. The result will be allocated with malloc. */ +/* Scan the debug information for CU starting at INFO_PTR in buffer BUFFER. + INFO_PTR should point just after the initial uleb128 of a DIE, and the + abbrev corresponding to that skipped uleb128 should be passed in + ABBREV. + =20 + If DO_SKIP_CHILDREN is true, or if the DIE has no children, this + returns a pointer to this DIE's sibling, skipping any children. + Otherwise, returns a pointer to the DIE's first child. */ =20 -static gdb::unique_xmalloc_ptr -partial_die_full_name (struct partial_die_info *pdi, - struct dwarf2_cu *cu) +static const gdb_byte * +skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_= ptr, + const struct abbrev_info *abbrev, bool do_skip_children) { - const char *parent_scope; + unsigned int bytes_read; + struct attribute attr; + bfd *abfd =3D reader->abfd; + struct dwarf2_cu *cu =3D reader->cu; + const gdb_byte *buffer =3D reader->buffer; + const gdb_byte *buffer_end =3D reader->buffer_end; + unsigned int form, i; =20 - /* If this is a template instantiation, we can not work out the - template arguments from partial DIEs. So, unfortunately, we have - to go through the full DIEs. At least any work we do building - types here will be reused if full symbols are loaded later. */ - if (pdi->has_template_arguments) + if (do_skip_children && abbrev->sibling_offset !=3D (unsigned short) -1) { - pdi->fixup (cu); - - if (pdi->name (cu) !=3D NULL && strchr (pdi->name (cu), '<') =3D=3D = NULL) - { - struct die_info *die; - struct attribute attr; - struct dwarf2_cu *ref_cu =3D cu; - - /* DW_FORM_ref_addr is using section offset. */ - attr.name =3D (enum dwarf_attribute) 0; - attr.form =3D DW_FORM_ref_addr; - attr.u.unsnd =3D to_underlying (pdi->sect_off); - die =3D follow_die_ref (NULL, &attr, &ref_cu); - - return make_unique_xstrdup (dwarf2_full_name (NULL, die, ref_cu)); - } + /* We only handle DW_FORM_ref4 here. */ + const gdb_byte *sibling_data =3D info_ptr + abbrev->sibling_offset; + unsigned int offset =3D read_4_bytes (abfd, sibling_data); + const gdb_byte *sibling_ptr + =3D buffer + to_underlying (cu->header.sect_off) + offset; + if (sibling_ptr >=3D info_ptr && sibling_ptr < reader->buffer_end) + return sibling_ptr; + /* Fall through to the slow way. */ } - - parent_scope =3D partial_die_parent_scope (pdi, cu); - if (parent_scope =3D=3D NULL) - return NULL; - else - return gdb::unique_xmalloc_ptr (typename_concat (NULL, parent_sc= ope, - pdi->name (cu), - 0, cu)); -} - -static void -add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) -{ - dwarf2_per_objfile *per_objfile =3D cu->per_objfile; - struct objfile *objfile =3D per_objfile->objfile; - struct gdbarch *gdbarch =3D objfile->arch (); - CORE_ADDR addr =3D 0; - const char *actual_name =3D NULL; - CORE_ADDR baseaddr; - - baseaddr =3D objfile->text_section_offset (); - - gdb::unique_xmalloc_ptr built_actual_name - =3D partial_die_full_name (pdi, cu); - if (built_actual_name !=3D NULL) - actual_name =3D built_actual_name.get (); - - if (actual_name =3D=3D NULL) - actual_name =3D pdi->name (cu); - - partial_symbol psymbol; - memset (&psymbol, 0, sizeof (psymbol)); - psymbol.ginfo.set_language (cu->per_cu->lang, - &objfile->objfile_obstack); - psymbol.ginfo.set_section_index (-1); - - /* The code below indicates that the psymbol should be installed by - setting this. */ - gdb::optional where; - - switch (pdi->tag) + else if (abbrev->size_if_constant !=3D 0) { - case DW_TAG_inlined_subroutine: - case DW_TAG_subprogram: - addr =3D (gdbarch_adjust_dwarf2_addr (gdbarch, pdi->lowpc + baseaddr) - - baseaddr); - if (pdi->is_external - || cu->per_cu->lang =3D=3D language_ada - || (cu->per_cu->lang =3D=3D language_fortran - && pdi->die_parent !=3D NULL - && pdi->die_parent->tag =3D=3D DW_TAG_subprogram)) - { - /* Normally, only "external" DIEs are part of the global scope. - But in Ada and Fortran, we want to be able to access nested - procedures globally. So all Ada and Fortran subprograms are - stored in the global scope. */ - where =3D psymbol_placement::GLOBAL; - } - else - where =3D psymbol_placement::STATIC; - - psymbol.domain =3D VAR_DOMAIN; - psymbol.aclass =3D LOC_BLOCK; - psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile)); - psymbol.ginfo.set_value_address (addr); - - if (pdi->main_subprogram && actual_name !=3D NULL) - set_objfile_main_name (objfile, actual_name, cu->per_cu->lang); - break; - case DW_TAG_constant: - psymbol.domain =3D VAR_DOMAIN; - psymbol.aclass =3D LOC_STATIC; - where =3D (pdi->is_external - ? psymbol_placement::GLOBAL - : psymbol_placement::STATIC); - break; - case DW_TAG_variable: - if (pdi->d.locdesc) - addr =3D decode_locdesc (pdi->d.locdesc, cu); + info_ptr +=3D abbrev->size_if_constant; + if (do_skip_children && abbrev->has_children) + return skip_children (reader, info_ptr); + return info_ptr; + } =20 - if (pdi->d.locdesc - && addr =3D=3D 0 - && !per_objfile->per_bfd->has_section_at_zero) + for (i =3D 0; i < abbrev->num_attrs; i++) + { + /* The only abbrev we care about is DW_AT_sibling. */ + if (do_skip_children && abbrev->attrs[i].name =3D=3D DW_AT_sibling) { - /* A global or static variable may also have been stripped - out by the linker if unused, in which case its address - will be nullified; do not add such variables into partial - symbol table then. */ - } - else if (pdi->is_external) - { - /* Global Variable. - Don't enter into the minimal symbol tables as there is - a minimal symbol table entry from the ELF symbols already. - Enter into partial symbol table if it has a location - descriptor or a type. - If the location descriptor is missing, new_symbol will create - a LOC_UNRESOLVED symbol, the address of the variable will then - be determined from the minimal symbol table whenever the variable - is referenced. - The address for the partial symbol table entry is not - used by GDB, but it comes in handy for debugging partial symbol - table building. */ - - if (pdi->d.locdesc || pdi->has_type) + read_attribute (reader, &attr, &abbrev->attrs[i], info_ptr); + if (attr.form =3D=3D DW_FORM_ref_addr) + complaint (_("ignoring absolute DW_AT_sibling")); + else { - psymbol.domain =3D VAR_DOMAIN; - psymbol.aclass =3D LOC_STATIC; - psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile)); - psymbol.ginfo.set_value_address (addr); - where =3D psymbol_placement::GLOBAL; - } - } - else - { - int has_loc =3D pdi->d.locdesc !=3D NULL; - - /* Static Variable. Skip symbols whose value we cannot know (those - without location descriptors or constant values). */ - if (!has_loc && !pdi->has_const_value) - return; - - psymbol.domain =3D VAR_DOMAIN; - psymbol.aclass =3D LOC_STATIC; - psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile)); - if (has_loc) - psymbol.ginfo.set_value_address (addr); - where =3D psymbol_placement::STATIC; - } - break; - case DW_TAG_array_type: - case DW_TAG_typedef: - case DW_TAG_base_type: - case DW_TAG_subrange_type: - case DW_TAG_generic_subrange: - psymbol.domain =3D VAR_DOMAIN; - psymbol.aclass =3D LOC_TYPEDEF; - where =3D psymbol_placement::STATIC; - break; - case DW_TAG_imported_declaration: - case DW_TAG_namespace: - psymbol.domain =3D VAR_DOMAIN; - psymbol.aclass =3D LOC_TYPEDEF; - where =3D psymbol_placement::GLOBAL; - break; - case DW_TAG_module: - /* With Fortran 77 there might be a "BLOCK DATA" module - available without any name. If so, we skip the module as it - doesn't bring any value. */ - if (actual_name !=3D nullptr) - { - psymbol.domain =3D MODULE_DOMAIN; - psymbol.aclass =3D LOC_TYPEDEF; - where =3D psymbol_placement::GLOBAL; - } - break; - case DW_TAG_class_type: - case DW_TAG_interface_type: - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_enumeration_type: - /* Skip external references. The DWARF standard says in the section - about "Structure, Union, and Class Type Entries": "An incomplete - structure, union or class type is represented by a structure, - union or class entry that does not have a byte size attribute - and that has a DW_AT_declaration attribute." */ - if (!pdi->has_byte_size && pdi->is_declaration) - return; - - /* NOTE: carlton/2003-10-07: See comment in new_symbol about - static vs. global. */ - psymbol.domain =3D STRUCT_DOMAIN; - psymbol.aclass =3D LOC_TYPEDEF; - where =3D (cu->per_cu->lang =3D=3D language_cplus - ? psymbol_placement::GLOBAL - : psymbol_placement::STATIC); - break; - case DW_TAG_enumerator: - psymbol.domain =3D VAR_DOMAIN; - psymbol.aclass =3D LOC_CONST; - where =3D (cu->per_cu->lang =3D=3D language_cplus - ? psymbol_placement::GLOBAL - : psymbol_placement::STATIC); - break; - default: - break; - } - - if (where.has_value ()) - { - if (built_actual_name !=3D nullptr) - actual_name =3D objfile->intern (actual_name); - if (pdi->linkage_name =3D=3D nullptr - || cu->per_cu->lang =3D=3D language_ada) - psymbol.ginfo.set_linkage_name (actual_name); - else - { - psymbol.ginfo.set_demangled_name (actual_name, - &objfile->objfile_obstack); - psymbol.ginfo.set_linkage_name (pdi->linkage_name); - } - cu->per_cu->v.psymtab->add_psymbol - (psymbol, *where, per_objfile->per_bfd->partial_symtabs.get (), - objfile); - } -} - -/* Read a partial die corresponding to a namespace; also, add a symbol - corresponding to that namespace to the symbol table. NAMESPACE is - the name of the enclosing namespace. */ - -static void -add_partial_namespace (struct partial_die_info *pdi, - CORE_ADDR *lowpc, CORE_ADDR *highpc, - int set_addrmap, struct dwarf2_cu *cu) -{ - /* Add a symbol for the namespace. */ - - add_partial_symbol (pdi, cu); - - /* Now scan partial symbols in that namespace. */ - - if (pdi->has_children) - scan_partial_symbols (pdi->die_child, lowpc, highpc, set_addrmap, cu); -} - -/* Read a partial die corresponding to a Fortran module. */ - -static void -add_partial_module (struct partial_die_info *pdi, CORE_ADDR *lowpc, - CORE_ADDR *highpc, int set_addrmap, struct dwarf2_cu *cu) -{ - /* Add a symbol for the namespace. */ - - add_partial_symbol (pdi, cu); - - /* Now scan partial symbols in that module. */ - - if (pdi->has_children) - scan_partial_symbols (pdi->die_child, lowpc, highpc, set_addrmap, cu); -} - -static int dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, - CORE_ADDR *high_return, struct dwarf2_cu *cu, - addrmap *map, void *datum, dwarf_tag tag); - -/* Read a partial die corresponding to a subprogram or an inlined - subprogram and create a partial symbol for that subprogram. - When the CU language allows it, this routine also defines a partial - symbol for each nested subprogram that this subprogram contains. - If SET_ADDRMAP is true, record the covered ranges in the addrmap. - Set *LOWPC and *HIGHPC to the lowest and highest PC values found in PDI. - - PDI may also be a lexical block, in which case we simply search - recursively for subprograms defined inside that lexical block. - Again, this is only performed when the CU language allows this - type of definitions. */ - -static void -add_partial_subprogram (struct partial_die_info *pdi, - CORE_ADDR *lowpc, CORE_ADDR *highpc, - int set_addrmap, struct dwarf2_cu *cu) -{ - if (pdi->tag =3D=3D DW_TAG_subprogram || pdi->tag =3D=3D DW_TAG_inlined_= subroutine) - { - if (pdi->has_pc_info) - { - if (pdi->lowpc < *lowpc) - *lowpc =3D pdi->lowpc; - if (pdi->highpc > *highpc) - *highpc =3D pdi->highpc; - if (set_addrmap) - { - struct objfile *objfile =3D cu->per_objfile->objfile; - dwarf2_per_bfd *per_bfd =3D cu->per_objfile->per_bfd; - struct gdbarch *gdbarch =3D objfile->arch (); - CORE_ADDR baseaddr; - CORE_ADDR this_highpc; - CORE_ADDR this_lowpc; - - baseaddr =3D objfile->text_section_offset (); - this_lowpc - =3D (gdbarch_adjust_dwarf2_addr (gdbarch, - pdi->lowpc + baseaddr) - - baseaddr); - this_highpc - =3D (gdbarch_adjust_dwarf2_addr (gdbarch, - pdi->highpc + baseaddr) - - baseaddr); - addrmap_set_empty (per_bfd->partial_symtabs->psymtabs_addrmap, - this_lowpc, this_highpc - 1, - cu->per_cu->v.psymtab); - } - } - - if (pdi->has_range_info - && dwarf2_ranges_read (pdi->ranges_offset, &pdi->lowpc, &pdi->highpc, - cu, - (set_addrmap - ? cu->per_objfile->per_bfd->partial_symtabs->psymtabs_addrmap - : nullptr), - set_addrmap ? cu->per_cu->v.psymtab : nullptr, - pdi->tag)) - { - if (pdi->lowpc < *lowpc) - *lowpc =3D pdi->lowpc; - if (pdi->highpc > *highpc) - *highpc =3D pdi->highpc; - } - - if (pdi->has_pc_info || pdi->has_range_info - || (!pdi->is_external && pdi->may_be_inlined)) - { - if (!pdi->is_declaration) - /* Ignore subprogram DIEs that do not have a name, they are - illegal. Do not emit a complaint at this point, we will - do so when we convert this psymtab into a symtab. */ - if (pdi->name (cu)) - add_partial_symbol (pdi, cu); - } - } - - if (! pdi->has_children) - return; - - if (cu->per_cu->lang =3D=3D language_ada - || cu->per_cu->lang =3D=3D language_fortran) - { - pdi =3D pdi->die_child; - while (pdi !=3D NULL) - { - pdi->fixup (cu); - if (pdi->tag =3D=3D DW_TAG_subprogram - || pdi->tag =3D=3D DW_TAG_inlined_subroutine - || pdi->tag =3D=3D DW_TAG_lexical_block) - add_partial_subprogram (pdi, lowpc, highpc, set_addrmap, cu); - pdi =3D pdi->die_sibling; - } - } -} - -/* Read a partial die corresponding to an enumeration type. */ - -static void -add_partial_enumeration (struct partial_die_info *enum_pdi, - struct dwarf2_cu *cu) -{ - struct partial_die_info *pdi; - - if (enum_pdi->name (cu) !=3D NULL) - add_partial_symbol (enum_pdi, cu); - - pdi =3D enum_pdi->die_child; - while (pdi) - { - if (pdi->tag !=3D DW_TAG_enumerator || pdi->raw_name =3D=3D NULL) - complaint (_("malformed enumerator DIE ignored")); - else - add_partial_symbol (pdi, cu); - pdi =3D pdi->die_sibling; - } -} - -/* Return the initial uleb128 in the die at INFO_PTR. */ - -static unsigned int -peek_abbrev_code (bfd *abfd, const gdb_byte *info_ptr) -{ - unsigned int bytes_read; - - return read_unsigned_leb128 (abfd, info_ptr, &bytes_read); -} - -/* Read the initial uleb128 in the die at INFO_PTR in compilation unit - READER::CU. Use READER::ABBREV_TABLE to lookup any abbreviation. - - Return the corresponding abbrev, or NULL if the number is zero (indicat= ing - an empty DIE). In either case *BYTES_READ will be set to the length of - the initial number. */ - -static const struct abbrev_info * -peek_die_abbrev (const die_reader_specs &reader, - const gdb_byte *info_ptr, unsigned int *bytes_read) -{ - dwarf2_cu *cu =3D reader.cu; - bfd *abfd =3D reader.abfd; - unsigned int abbrev_number - =3D read_unsigned_leb128 (abfd, info_ptr, bytes_read); - - if (abbrev_number =3D=3D 0) - return NULL; - - const abbrev_info *abbrev - =3D reader.abbrev_table->lookup_abbrev (abbrev_number); - if (!abbrev) - { - error (_("Dwarf Error: Could not find abbrev number %d in %s" - " at offset %s [in module %s]"), - abbrev_number, cu->per_cu->is_debug_types ? "TU" : "CU", - sect_offset_str (cu->header.sect_off), bfd_get_filename (abfd)); - } - - return abbrev; -} - -/* Scan the debug information for CU starting at INFO_PTR in buffer BUFFER. - Returns a pointer to the end of a series of DIEs, terminated by an empty - DIE. Any children of the skipped DIEs will also be skipped. */ - -static const gdb_byte * -skip_children (const struct die_reader_specs *reader, const gdb_byte *info= _ptr) -{ - while (1) - { - unsigned int bytes_read; - const abbrev_info *abbrev =3D peek_die_abbrev (*reader, info_ptr, - &bytes_read); - - if (abbrev =3D=3D NULL) - return info_ptr + bytes_read; - else - info_ptr =3D skip_one_die (reader, info_ptr + bytes_read, abbrev); - } -} - -/* Scan the debug information for CU starting at INFO_PTR in buffer BUFFER. - INFO_PTR should point just after the initial uleb128 of a DIE, and the - abbrev corresponding to that skipped uleb128 should be passed in - ABBREV. - =20 - If DO_SKIP_CHILDREN is true, or if the DIE has no children, this - returns a pointer to this DIE's sibling, skipping any children. - Otherwise, returns a pointer to the DIE's first child. */ - -static const gdb_byte * -skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_= ptr, - const struct abbrev_info *abbrev, bool do_skip_children) -{ - unsigned int bytes_read; - struct attribute attr; - bfd *abfd =3D reader->abfd; - struct dwarf2_cu *cu =3D reader->cu; - const gdb_byte *buffer =3D reader->buffer; - const gdb_byte *buffer_end =3D reader->buffer_end; - unsigned int form, i; - - if (do_skip_children && abbrev->sibling_offset !=3D (unsigned short) -1) - { - /* We only handle DW_FORM_ref4 here. */ - const gdb_byte *sibling_data =3D info_ptr + abbrev->sibling_offset; - unsigned int offset =3D read_4_bytes (abfd, sibling_data); - const gdb_byte *sibling_ptr - =3D buffer + to_underlying (cu->header.sect_off) + offset; - if (sibling_ptr >=3D info_ptr && sibling_ptr < reader->buffer_end) - return sibling_ptr; - /* Fall through to the slow way. */ - } - else if (abbrev->size_if_constant !=3D 0) - { - info_ptr +=3D abbrev->size_if_constant; - if (do_skip_children && abbrev->has_children) - return skip_children (reader, info_ptr); - return info_ptr; - } - - for (i =3D 0; i < abbrev->num_attrs; i++) - { - /* The only abbrev we care about is DW_AT_sibling. */ - if (do_skip_children && abbrev->attrs[i].name =3D=3D DW_AT_sibling) - { - read_attribute (reader, &attr, &abbrev->attrs[i], info_ptr); - if (attr.form =3D=3D DW_FORM_ref_addr) - complaint (_("ignoring absolute DW_AT_sibling")); - else - { - sect_offset off =3D attr.get_ref_die_offset (); - const gdb_byte *sibling_ptr =3D buffer + to_underlying (off); + sect_offset off =3D attr.get_ref_die_offset (); + const gdb_byte *sibling_ptr =3D buffer + to_underlying (off); =20 if (sibling_ptr < info_ptr) complaint (_("DW_AT_sibling points backwards")); @@ -8987,57 +7565,6 @@ skip_one_die (const struct die_reader_specs *reader,= const gdb_byte *info_ptr, else return info_ptr; } - -/* Locate ORIG_PDI's sibling. - INFO_PTR should point to the start of the next DIE after ORIG_PDI. */ - -static const gdb_byte * -locate_pdi_sibling (const struct die_reader_specs *reader, - struct partial_die_info *orig_pdi, - const gdb_byte *info_ptr) -{ - /* Do we know the sibling already? */ - - if (orig_pdi->sibling) - return orig_pdi->sibling; - - /* Are there any children to deal with? */ - - if (!orig_pdi->has_children) - return info_ptr; - - /* Skip the children the long way. */ - - return skip_children (reader, info_ptr); -} - -/* Expand this partial symbol table into a full symbol table. SELF is - not NULL. */ - -void -dwarf2_psymtab::read_symtab (struct objfile *objfile) -{ - dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - - gdb_assert (!per_objfile->symtab_set_p (per_cu_data)); - - /* If this psymtab is constructed from a debug-only objfile, the - has_section_at_zero flag will not necessarily be correct. We - can get the correct value for this flag by looking at the data - associated with the (presumably stripped) associated objfile. */ - if (objfile->separate_debug_objfile_backlink) - { - dwarf2_per_objfile *per_objfile_backlink - =3D get_dwarf2_per_objfile (objfile->separate_debug_objfile_backlink); - - per_objfile->per_bfd->has_section_at_zero - =3D per_objfile_backlink->per_bfd->has_section_at_zero; - } - - expand_psymtab (objfile); - - process_cu_includes (per_objfile); -} =0C /* Reading in full CUs. */ =20 @@ -9085,18 +7612,6 @@ maybe_queue_comp_unit (struct dwarf2_cu *dependent_c= u, dwarf2_per_objfile *per_objfile, enum language pretend_language) { - /* We may arrive here during partial symbol reading, if we need full - DIEs to process an unusual case (e.g. template arguments). Do - not queue PER_CU, just tell our caller to load its DIEs. */ - if (per_cu->per_bfd->reading_partial_symbols) - { - dwarf2_cu *cu =3D per_objfile->get_cu (per_cu); - - if (cu =3D=3D NULL || cu->dies =3D=3D NULL) - return 1; - return 0; - } - /* Mark the dependence relation so that we don't flush PER_CU too early. */ if (dependent_cu !=3D NULL) @@ -9201,39 +7716,6 @@ process_queue (dwarf2_per_objfile *per_objfile) objfile_name (per_objfile->objfile)); } =20 -/* Read in full symbols for PST, and anything it depends on. */ - -void -dwarf2_psymtab::expand_psymtab (struct objfile *objfile) -{ - gdb_assert (!readin_p (objfile)); - - dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - free_cached_comp_units freer (per_objfile); - expand_dependencies (objfile); - - dw2_do_instantiate_symtab (per_cu_data, per_objfile, false); - gdb_assert (get_compunit_symtab (objfile) !=3D nullptr); -} - -/* See psympriv.h. */ - -bool -dwarf2_psymtab::readin_p (struct objfile *objfile) const -{ - dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - return per_objfile->symtab_set_p (per_cu_data); -} - -/* See psympriv.h. */ - -compunit_symtab * -dwarf2_psymtab::get_compunit_symtab (struct objfile *objfile) const -{ - dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - return per_objfile->get_symtab (per_cu_data); -} - /* Trivial hash function for die_info: the hash value of a DIE is its offset in .debug_info for this objfile. */ =20 @@ -11041,7 +9523,7 @@ find_file_and_directory (struct die_info *die, struc= t dwarf2_cu *cu) =20 static void handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, - const file_and_directory &fnd, CORE_ADDR lowpc) /* ARI: editCase functi= on */ + CORE_ADDR lowpc) /* ARI: editCase function */ { dwarf2_per_objfile *per_objfile =3D cu->per_objfile; struct attribute *attr; @@ -11129,9 +9611,7 @@ handle_DW_AT_stmt_list (struct die_info *die, struct= dwarf2_cu *cu, gdb_assert (die->tag !=3D DW_TAG_partial_unit); } decode_mapping =3D (die->tag !=3D DW_TAG_partial_unit); - dwarf_decode_lines (cu->line_header, fnd, cu, nullptr, lowpc, - decode_mapping); - + dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping); } =20 /* Process DW_TAG_compile_unit or DW_TAG_partial_unit. */ @@ -11176,7 +9656,7 @@ read_file_scope (struct die_info *die, struct dwarf2= _cu *cu) lnp_state_machine::check_line_address) will fail to properly exclude an entry that was removed via --gc-sections. */ if (lowpc !=3D highpc) - handle_DW_AT_stmt_list (die, cu, fnd, lowpc); + handle_DW_AT_stmt_list (die, cu, lowpc); =20 /* Process all dies in compilation unit. */ if (die->child !=3D NULL) @@ -20080,7 +18560,7 @@ struct cooked_index_functions : public dwarf2_base_= index_functions void read_partial_symbols (struct objfile *objfile) override { if (dwarf2_has_info (objfile, nullptr)) - dwarf2_build_psymtabs (objfile); + dwarf2_build_psymtabs (objfile, true); } }; =20 @@ -20103,1029 +18583,208 @@ cooked_index_functions::find_pc_sect_compunit_= symtab return nullptr; =20 if (warn_if_readin && per_objfile->symtab_set_p (per_cu)) - warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"= ), - paddress (objfile->arch (), pc)); - - compunit_symtab *result =3D (recursively_find_pc_sect_compunit_symtab - (dw2_instantiate_symtab (per_cu, per_objfile, - false), - pc)); - gdb_assert (result !=3D nullptr); - return result; -} - -struct compunit_symtab * -cooked_index_functions::find_compunit_symtab_by_address - (struct objfile *objfile, CORE_ADDR address) -{ - if (objfile->sect_index_data =3D=3D -1) - return nullptr; - - dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - if (per_objfile->per_bfd->cooked_index_table =3D=3D nullptr) - return nullptr; - - CORE_ADDR baseaddr =3D objfile->data_section_offset (); - dwarf2_per_cu_data *per_cu - =3D per_objfile->per_bfd->cooked_index_table->lookup (address - basead= dr); - if (per_cu =3D=3D nullptr) - return nullptr; - - return dw2_instantiate_symtab (per_cu, per_objfile, false); -} - -void -cooked_index_functions::expand_matching_symbols - (struct objfile *objfile, - const lookup_name_info &lookup_name, - domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) -{ - dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - if (per_objfile->per_bfd->cooked_index_table =3D=3D nullptr) - return; - const block_search_flags search_flags =3D (global - ? SEARCH_GLOBAL_BLOCK - : SEARCH_STATIC_BLOCK); - const language_defn *lang =3D language_def (language_ada); - symbol_name_matcher_ftype *name_match - =3D lang->get_symbol_name_matcher (lookup_name); - - for (const cooked_index_entry *entry - : per_objfile->per_bfd->cooked_index_table->all_entries ()) - { - if (entry->parent_entry !=3D nullptr) - continue; - - if (!entry->matches (search_flags) - || !entry->matches (domain)) - continue; - - if (name_match (entry->canonical, lookup_name, nullptr)) - dw2_instantiate_symtab (entry->per_cu, per_objfile, false); - } -} - -bool -cooked_index_functions::expand_symtabs_matching - (struct objfile *objfile, - gdb::function_view file_matcher, - const lookup_name_info *lookup_name, - gdb::function_view symbol_match= er, - gdb::function_view expansion_notify, - block_search_flags search_flags, - domain_enum domain, - enum search_dom[...] [diff truncated at 100000 bytes]