[binutils-gdb] gdb/dwarf: remove unnecessary compunit_symtab_set_p check in process_queue
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=83bdee99c4f9b1f014762ee59ad18fd71e355880 commit 83bdee99c4f9b1f014762ee59ad18fd71e355880 Author: Simon Marchi <[email protected]> Date: Sat Feb 21 15:07:27 2026 -0500 gdb/dwarf: remove unnecessary compunit_symtab_set_p check in process_queue We know that enqueued per_cu objects never have a matching compunit_symtab object set. The two places where per_cus are enqueued are: - maybe_queue_comp_unit, which has its own compunit_symtab_set_p check - dw2_do_instantiate_symtab, which is only called if per_cu does not have a compunit_symtab yet process_queue therefore does not need to consider the possibility of the compunit_symtab being set already. Change-Id: Id8565d7f659813047ee15603598f9abd39993adc Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/dwarf2/read.c | 103 ++++++++++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index f478f0d2cce..d553a2e1134 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -3985,71 +3985,68 @@ process_queue (dwarf2_per_objfile *per_objfile) { dwarf2_queue_item &item = per_objfile->queue->front (); dwarf2_per_cu *per_cu = item.per_cu; + dwarf2_cu *cu = per_objfile->get_cu (per_cu); - if (!per_objfile->compunit_symtab_set_p (per_cu)) - { - dwarf2_cu *cu = per_objfile->get_cu (per_cu); + gdb_assert (!per_objfile->compunit_symtab_set_p (per_cu)); - /* Skip dummy CUs. */ - if (cu != nullptr) - { - namespace chr = std::chrono; + /* Skip dummy CUs. */ + if (cu != nullptr) + { + namespace chr = std::chrono; - unsigned int debug_print_threshold; - char buf[100]; - std::optional<chr::time_point<chr::steady_clock>> start_time; + unsigned int debug_print_threshold; + char buf[100]; + std::optional<chr::time_point<chr::steady_clock>> start_time; - if (signatured_type *sig_type = per_cu->as_signatured_type (); - sig_type != nullptr) - { - sprintf (buf, "TU %s at offset %s", - hex_string (sig_type->signature), - sect_offset_str (per_cu->sect_off ())); - /* There can be 100s of TUs. - Only print them in verbose mode. */ - debug_print_threshold = 2; - } - else - { - sprintf (buf, "CU at offset %s", - sect_offset_str (per_cu->sect_off ())); - debug_print_threshold = 1; - } + if (signatured_type *sig_type = per_cu->as_signatured_type (); + sig_type != nullptr) + { + sprintf (buf, "TU %s at offset %s", + hex_string (sig_type->signature), + sect_offset_str (per_cu->sect_off ())); + /* There can be 100s of TUs. Only print them in verbose mode. */ + debug_print_threshold = 2; + } + else + { + sprintf (buf, "CU at offset %s", + sect_offset_str (per_cu->sect_off ())); + debug_print_threshold = 1; + } - if (dwarf_read_debug >= debug_print_threshold) - { - dwarf_read_debug_printf ("Expanding symtab of %s", buf); - start_time = chr::steady_clock::now (); - } + if (dwarf_read_debug >= debug_print_threshold) + { + dwarf_read_debug_printf ("Expanding symtab of %s", buf); + start_time = chr::steady_clock::now (); + } - ++expanded_count; + ++expanded_count; - compunit_symtab *cust; + compunit_symtab *cust; - if (per_cu->is_debug_types ()) - cust = process_full_type_unit (cu); - else - { - cust = process_full_comp_unit (cu); + if (per_cu->is_debug_types ()) + cust = process_full_type_unit (cu); + else + { + 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); - } + /* 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); + per_objfile->set_compunit_symtab (cu->per_cu, cust); - if (dwarf_read_debug >= debug_print_threshold) - { - const auto end_time = chr::steady_clock::now (); - const auto time_spent = end_time - *start_time; - const auto ms - = chr::duration_cast<chr::milliseconds> (time_spent); + if (dwarf_read_debug >= debug_print_threshold) + { + const auto end_time = chr::steady_clock::now (); + const auto time_spent = end_time - *start_time; + const auto ms + = chr::duration_cast<chr::milliseconds> (time_spent); - dwarf_read_debug_printf ("Done expanding %s, took %.3fs", buf, - ms.count () / 1000.0); - } + dwarf_read_debug_printf ("Done expanding %s, took %.3fs", buf, + ms.count () / 1000.0); } }