]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/dwarf: merge one CU/TU code path
authorSimon Marchi <simon.marchi@polymtl.ca>
Sat, 17 Jan 2026 06:02:31 +0000 (01:02 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 20 Jan 2026 20:57:53 +0000 (15:57 -0500)
Simplify the code by merging the paths for CUs and TUs.  It is also not
necessary to check if the maps are empty.

Change-Id: I43e2cf4bb1217a72dda8a03957ed733f87bf57b2
Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/read.c

index 65e30891f65ba186eff0b0269fdf84fded7bcdfa..67f1ee1d34c3c26ccf7a6901e0266e1792b02cf1 100644 (file)
@@ -7562,30 +7562,19 @@ cutu_reader::lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name,
            dwo_file = add_dwo_file (per_bfd, std::move (new_dwo_file));
        }
 
-      if (dwo_file != NULL)
+      if (dwo_file != nullptr)
        {
-         struct dwo_unit *dwo_cutu = NULL;
+         dwo_unit_set &dwo_units
+           = is_debug_types ? dwo_file->tus : dwo_file->cus;
 
-         if (is_debug_types && !dwo_file->tus.empty ())
+         if (auto dwo_unit_it = dwo_units.find (signature);
+             dwo_unit_it != dwo_units.end ())
            {
-             if (auto it = dwo_file->tus.find (signature);
-                 it != dwo_file->tus.end ())
-               dwo_cutu = it->get ();
-           }
-         else if (!is_debug_types && !dwo_file->cus.empty ())
-           {
-             if (auto it = dwo_file->cus.find (signature);
-                 it != dwo_file->cus.end ())
-               dwo_cutu = it->get ();
-           }
-
-         if (dwo_cutu != NULL)
-           {
-             dwarf_read_debug_printf ("DWO %s %s(%s) found: @%s",
-                                      kind, dwo_name, hex_string (signature),
-                                      host_address_to_string (dwo_cutu));
-
-             return dwo_cutu;
+             dwarf_read_debug_printf
+               ("DWO %s %s(%s) found: @%s", kind, dwo_name,
+                hex_string (signature),
+                host_address_to_string (dwo_unit_it->get ()));
+             return dwo_unit_it->get ();
            }
        }
     }