]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/dwarf: remove unnecessary compunit_symtab_set_p check in process_queue
authorSimon Marchi <simon.marchi@polymtl.ca>
Sat, 21 Feb 2026 20:07:27 +0000 (15:07 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 10 Mar 2026 17:35:22 +0000 (13:35 -0400)
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 <tom@tromey.com>
gdb/dwarf2/read.c

index f478f0d2cce663417de1a29fc65b00b3c9b845da..d553a2e1134d3519aa168222687e76cc72be1482 100644 (file)
@@ -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);
            }
        }