diff options
Diffstat (limited to 'gdb/dwarf2/read.c')
-rw-r--r-- | gdb/dwarf2/read.c | 101 |
1 files changed, 45 insertions, 56 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 3d7b6dd..794c397 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1,6 +1,6 @@ /* DWARF 2 debugging format support for GDB. - Copyright (C) 1994-2024 Free Software Foundation, Inc. + Copyright (C) 1994-2025 Free Software Foundation, Inc. Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology, Inc. with support from Florida State University (under contract @@ -32,7 +32,7 @@ #include "dwarf2/aranges.h" #include "dwarf2/attribute.h" #include "dwarf2/comp-unit-head.h" -#include "dwarf2/cooked-index-storage.h" +#include "dwarf2/cooked-index-worker.h" #include "dwarf2/cooked-indexer.h" #include "dwarf2/cu.h" #include "dwarf2/index-cache.h" @@ -728,7 +728,7 @@ show_dwarf_synchronous (struct ui_file *file, int from_tty, /* local function prototypes */ static void build_type_psymtabs_reader (cutu_reader *reader, - cooked_index_storage *storage); + cooked_index_worker_result *storage); static void var_decode_location (struct attribute *attr, struct symbol *sym, @@ -2383,14 +2383,14 @@ read_abbrev_offset (dwarf2_per_objfile *per_objfile, return (sect_offset) read_offset (abfd, info_ptr, offset_size); } -/* A helper for create_debug_types_hash_table. Read types from SECTION +/* A helper for create_dwo_debug_types_hash_table. Read types from SECTION and fill them into DWO_FILE's type unit hash table. It will process only type units, therefore DW_UT_type. */ static void -create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, - dwo_file *dwo_file, dwarf2_section_info *section, - rcuh_kind section_kind) +create_dwo_debug_type_hash_table (dwarf2_per_objfile *per_objfile, + dwo_file *dwo_file, dwarf2_section_info *section, + rcuh_kind section_kind) { struct objfile *objfile = per_objfile->objfile; struct dwarf2_section_info *abbrev_section; @@ -2479,12 +2479,12 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, Note: This function processes DWO files only, not DWP files. */ static void -create_debug_types_hash_table +create_dwo_debug_types_hash_table (dwarf2_per_objfile *per_objfile, dwo_file *dwo_file, gdb::array_view<dwarf2_section_info> type_sections) { for (dwarf2_section_info §ion : type_sections) - create_debug_type_hash_table (per_objfile, dwo_file, §ion, + create_dwo_debug_type_hash_table (per_objfile, dwo_file, §ion, rcuh_kind::TYPE); } @@ -2970,7 +2970,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu &this_cu, dwarf2_cu *existing_cu, bool skip_partial, enum language pretend_language, - const abbrev_table_cache *cache) + const abbrev_table_cache *abbrev_cache) { struct objfile *objfile = per_objfile.objfile; struct dwarf2_section_info *section = this_cu.section; @@ -3030,7 +3030,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu &this_cu, indexer. This assert is avoided in this case because (1) it is irrelevant, and (2) the get_cu method is not thread-safe. */ - gdb_assert (cache != nullptr + gdb_assert (abbrev_cache != nullptr || per_objfile.get_cu (&this_cu) == nullptr); m_new_cu = std::make_unique<dwarf2_cu> (&this_cu, &per_objfile); cu = m_new_cu.get (); @@ -3092,9 +3092,9 @@ cutu_reader::cutu_reader (dwarf2_per_cu &this_cu, gdb_assert (cu->header.abbrev_sect_off == abbrev_table->sect_off); else { - if (cache != nullptr) - abbrev_table = cache->find (abbrev_section, - cu->header.abbrev_sect_off); + if (abbrev_cache != nullptr) + abbrev_table = abbrev_cache->find (abbrev_section, + cu->header.abbrev_sect_off); if (abbrev_table == nullptr) { abbrev_section->read (objfile); @@ -3289,7 +3289,7 @@ get_type_unit_group_key (struct dwarf2_cu *cu, const struct attribute *stmt_list static void process_psymtab_comp_unit (dwarf2_per_cu *this_cu, dwarf2_per_objfile *per_objfile, - cooked_index_storage *storage) + cooked_index_worker_result *storage) { cutu_reader *reader = storage->get_reader (this_cu); if (reader == nullptr) @@ -3326,7 +3326,7 @@ process_psymtab_comp_unit (dwarf2_per_cu *this_cu, static void build_type_psymtabs_reader (cutu_reader *reader, - cooked_index_storage *storage) + cooked_index_worker_result *storage) { struct dwarf2_cu *cu = reader->cu (); dwarf2_per_cu *per_cu = cu->per_cu; @@ -3379,7 +3379,7 @@ struct tu_abbrev_offset static void build_type_psymtabs (dwarf2_per_objfile *per_objfile, - cooked_index_storage *storage) + cooked_index_worker_result *storage) { struct tu_stats *tu_stats = &per_objfile->per_bfd->tu_stats; abbrev_table_up abbrev_table; @@ -3476,7 +3476,7 @@ print_tu_stats (dwarf2_per_objfile *per_objfile) static void process_skeletonless_type_unit (dwo_unit *dwo_unit, dwarf2_per_objfile *per_objfile, - cooked_index_storage *storage) + cooked_index_worker_result *storage) { dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; @@ -3507,7 +3507,7 @@ process_skeletonless_type_unit (dwo_unit *dwo_unit, static void process_skeletonless_type_units (dwarf2_per_objfile *per_objfile, - cooked_index_storage *storage) + cooked_index_worker_result *storage) { /* Skeletonless TUs in DWP files without .gdb_index is not supported yet. */ if (get_dwp_file (per_objfile) == nullptr) @@ -3553,7 +3553,7 @@ private: /* After the last DWARF-reading task has finished, this function does the remaining work to finish the scan. */ - void done_reading (); + void done_reading () override; /* An iterator for the comp units. */ using unit_iterator = std::vector<dwarf2_per_cu_up>::iterator; @@ -3567,12 +3567,13 @@ private: /* A storage object for "leftovers" -- see the 'start' method, but essentially things not parsed during the normal CU parsing passes. */ - cooked_index_storage m_index_storage; + cooked_index_worker_result m_index_storage; }; void -cooked_index_worker_debug_info::process_cus (size_t task_number, unit_iterator first, - unit_iterator end) +cooked_index_worker_debug_info::process_cus (size_t task_number, + unit_iterator first, + unit_iterator end) { SCOPE_EXIT { bfd_thread_cleanup (); }; @@ -3580,7 +3581,7 @@ cooked_index_worker_debug_info::process_cus (size_t task_number, unit_iterator f complaint_interceptor complaint_handler; std::vector<gdb_exception> errors; - cooked_index_storage thread_storage; + cooked_index_worker_result thread_storage; for (auto inner = first; inner != end; ++inner) { dwarf2_per_cu *per_cu = inner->get (); @@ -3591,43 +3592,24 @@ cooked_index_worker_debug_info::process_cus (size_t task_number, unit_iterator f } catch (gdb_exception &except) { - errors.push_back (std::move (except)); + thread_storage.note_error (std::move (except)); } } - m_results[task_number] = result_type (thread_storage.release (), - complaint_handler.release (), - std::move (errors), - thread_storage.release_parent_map ()); + thread_storage.done_reading (complaint_handler.release ()); + m_results[task_number] = std::move (thread_storage); } void cooked_index_worker_debug_info::done_reading () { - /* Only handle the scanning results here. Complaints and exceptions - can only be dealt with on the main thread. */ - std::vector<cooked_index_shard_up> shards; - - for (auto &one_result : m_results) - { - shards.push_back (std::move (std::get<0> (one_result))); - m_all_parents_map.add_map (std::get<3> (one_result)); - } - /* This has to wait until we read the CUs, we need the list of DWOs. */ process_skeletonless_type_units (m_per_objfile, &m_index_storage); - shards.push_back (m_index_storage.release ()); - shards.shrink_to_fit (); + m_results.push_back (std::move (m_index_storage)); - m_all_parents_map.add_map (m_index_storage.release_parent_map ()); - - dwarf2_per_bfd *per_bfd = m_per_objfile->per_bfd; - cooked_index *table - = (gdb::checked_static_cast<cooked_index *> - (per_bfd->index_table.get ())); - table->set_contents (std::move (shards), &m_warnings, - &m_all_parents_map); + /* Call into the base class. */ + cooked_index_worker::done_reading (); } void @@ -6326,7 +6308,7 @@ lookup_dwo_file (dwarf2_per_bfd *per_bfd, const char *dwo_name, Note: This function processes DWO files only, not DWP files. */ static void -create_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file) +create_dwo_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file) { dwarf2_per_objfile *per_objfile = cu->per_objfile; struct objfile *objfile = per_objfile->objfile; @@ -6360,8 +6342,14 @@ create_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file) if (reader.is_dummy()) continue; + /* DWARF 5 .debug_info.dwo sections may contain some type units. Skip + everything that is not a compile unit. */ + if (const auto ut = reader.cu ()->header.unit_type; + ut != DW_UT_compile && ut != DW_UT_split_compile) + continue; + std::optional<ULONGEST> signature - = lookup_dwo_id (cu, reader.top_level_die ()); + = lookup_dwo_id (reader.cu (), reader.top_level_die ()); if (!signature.has_value ()) { complaint (_(DWARF_ERROR_PREFIX @@ -7648,14 +7636,15 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name, dwarf2_locate_dwo_sections (per_objfile->objfile, dwo_file->dbfd.get (), sec, &dwo_file->sections); - create_cus_hash_table (cu, *dwo_file); + create_dwo_cus_hash_table (cu, *dwo_file); if (cu->header.version < 5) - create_debug_types_hash_table (per_objfile, dwo_file.get (), - dwo_file->sections.types); + create_dwo_debug_types_hash_table (per_objfile, dwo_file.get (), + dwo_file->sections.types); else - create_debug_type_hash_table (per_objfile, dwo_file.get (), - &dwo_file->sections.info, rcuh_kind::COMPILE); + create_dwo_debug_type_hash_table (per_objfile, dwo_file.get (), + &dwo_file->sections.info, + rcuh_kind::COMPILE); dwarf_read_debug_printf ("DWO file found: %s", dwo_name); |