[binutils-gdb] gdb/dwarf: remove just_read_cus from dwarf2_per_bfd
Simon Marchi via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0f5881b9c2243e45d80455adee898325a434c068 commit 0f5881b9c2243e45d80455adee898325a434c068 Author: Simon Marchi <[email protected]> Date: Sat Feb 21 15:07:25 2026 -0500 gdb/dwarf: remove just_read_cus from dwarf2_per_bfd It is not necessary to keep the just_read_cus vector inside dwarf2_per_bfd. This vector is only needed shortly, while we process the CU expansion queue. Instead of appending expanded comp units in process_full_comp_unit, instantiate a local vector in process_queue, populate it with the expanded comp units, and call process_cu_includes from there. Remove the `if (!iter->is_debug_types ())` check in process_cu_includes: we know that we only append comp units to this vector, no type units. In compute_compunit_symtab_includes, remove the `if (cust == NULL)` check: in process_queue, we only append the per_cus for which a compunit_symtab was indeed created, no need to check it again here. Change-Id: Ia50b703f379ae9dc90c9abc1d5269d4932f16e2d Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/dwarf2/read.c | 36 ++++++++++++++++++------------------ gdb/dwarf2/read.h | 3 --- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 8aa44c9b51b..79464269c1b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -999,7 +999,9 @@ static void open_and_init_dwp_file (dwarf2_per_objfile *per_objfile); static void queue_and_load_all_dwo_tus (dwarf2_cu *cu); -static void process_cu_includes (dwarf2_per_objfile *per_objfile); +static void process_cu_includes + (dwarf2_per_objfile *per_objfile, + const std::vector<dwarf2_per_cu *> &just_read_cus); /* Various complaints about symbol reading that don't abort the process. */ @@ -1640,7 +1642,6 @@ dw2_instantiate_symtab (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, free_cached_comp_units freer (per_objfile); scoped_restore decrementer = increment_reading_symtab (); dw2_do_instantiate_symtab (per_cu, per_objfile, skip_partial); - process_cu_includes (per_objfile); } return per_objfile->get_compunit_symtab (per_cu); @@ -3979,6 +3980,7 @@ process_queue (dwarf2_per_objfile *per_objfile) objfile_name (per_objfile->objfile)); unsigned int expanded_count = 0; + std::vector<dwarf2_per_cu *> just_read_cus; /* The queue starts out with one item, but following a DIE reference may load a new CU, adding it to the end of the queue. */ @@ -4030,7 +4032,14 @@ process_queue (dwarf2_per_objfile *per_objfile) if (per_cu->is_debug_types ()) cust = process_full_type_unit (cu); else - cust = process_full_comp_unit (cu); + { + cust = process_full_comp_unit (cu); + + /* If a compunit_symtab was created, note the per_cu for + inclusion processing later. */ + if (cust != nullptr) + just_read_cus.emplace_back (cu->per_cu); + } per_objfile->set_compunit_symtab (cu->per_cu, cust); @@ -4051,6 +4060,7 @@ process_queue (dwarf2_per_objfile *per_objfile) per_objfile->queue->pop (); } + process_cu_includes (per_objfile, just_read_cus); dwarf_read_debug_printf ("Done expanding %u symtabs.", expanded_count); } @@ -4639,10 +4649,7 @@ compute_compunit_symtab_includes (dwarf2_per_cu *per_cu, if (!per_cu->imported_symtabs.empty ()) { compunit_symtab *cust = per_objfile->get_compunit_symtab (per_cu); - - /* If we don't have a symtab, we can just skip this case. */ - if (cust == NULL) - return; + gdb_assert (cust != nullptr); gdb::unordered_set<dwarf2_per_cu *> all_children; gdb::unordered_set<compunit_symtab *> all_type_symtabs; @@ -4658,15 +4665,11 @@ compute_compunit_symtab_includes (dwarf2_per_cu *per_cu, read. */ static void -process_cu_includes (dwarf2_per_objfile *per_objfile) +process_cu_includes (dwarf2_per_objfile *per_objfile, + const std::vector<dwarf2_per_cu *> &just_read_cus) { - for (dwarf2_per_cu *iter : per_objfile->per_bfd->just_read_cus) - { - if (!iter->is_debug_types ()) - compute_compunit_symtab_includes (iter, per_objfile); - } - - per_objfile->per_bfd->just_read_cus.clear (); + for (dwarf2_per_cu *iter : just_read_cus) + compute_compunit_symtab_includes (iter, per_objfile); } /* Generate full symbol information for CU, whose DIEs have @@ -4773,9 +4776,6 @@ process_full_comp_unit (dwarf2_cu *cu) cust->set_call_site_htab (std::move (cu->call_site_htab)); } - /* Push it for inclusion processing later. */ - per_objfile->per_bfd->just_read_cus.push_back (cu->per_cu); - /* Not needed any more. */ cu->reset_builder (); diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 1883f7b30d8..e9874ce1fab 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -724,9 +724,6 @@ public: gdb::unordered_map<stmt_list_hash, quick_file_names *, stmt_list_hash_hash> quick_file_names_table; - /* The CUs we recently read. */ - std::vector<dwarf2_per_cu *> just_read_cus; - /* If we loaded the index from an external file, this contains the resources associated to the open file, memory mapping, etc. */ index_cache_resource_up index_cache_res;