]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Avoid some pointer chasing in DWARF reader
authorTom Tromey <tom@tromey.com>
Fri, 26 Mar 2021 15:37:22 +0000 (09:37 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 26 Mar 2021 15:37:22 +0000 (09:37 -0600)
I noticed a spot in the DWARF reader using "per_objfile->per_bfd",
where a local per_bfd variable had already been created.  Looking
through the file, I found a number of such spots.  This patch changes
them to use the already-existing local, avoiding a bit of excess
pointer chasing.

gdb/ChangeLog
2021-03-26  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (dwarf2_read_debug_names)
(dwarf2_build_psymtabs_hard, create_addrmap_from_aranges)
(dw2_debug_names_iterator::next, create_type_unit_group):
Simplify.

gdb/ChangeLog
gdb/dwarf2/read.c

index 173b08bf04b50eee5b477c2aaddee3dc55b14bdf..8e7b92087aab59ab05b570253b6904300d1b48a8 100644 (file)
@@ -1,3 +1,10 @@
+2021-03-26  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.c (dwarf2_read_debug_names)
+       (dwarf2_build_psymtabs_hard, create_addrmap_from_aranges)
+       (dw2_debug_names_iterator::next, create_type_unit_group):
+       Simplify.
+
 2021-03-25  Pedro Alves  <pedro@palves.net>
 
        * gdb.server/bkpt-other-inferior.exp: Only enable remote output
index ee6f3f7f7e14f722ec9bb6780563fa0bbbe268cc..2f4b54b1aa3a39f710eb05094de1bfefef3c7f75 100644 (file)
@@ -2774,7 +2774,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile,
                     dwarf2_per_cu_data *,
                     gdb::hash_enum<sect_offset>>
     debug_info_offset_to_per_cu;
-  for (dwarf2_per_cu_data *per_cu : per_objfile->per_bfd->all_comp_units)
+  for (dwarf2_per_cu_data *per_cu : per_bfd->all_comp_units)
     {
       const auto insertpair
        = debug_info_offset_to_per_cu.emplace (per_cu->sect_off, per_cu);
@@ -5299,7 +5299,7 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
   dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
 
   if (!read_debug_names_from_section (objfile, objfile_name (objfile),
-                                     &per_objfile->per_bfd->debug_names, *map))
+                                     &per_bfd->debug_names, *map))
     return false;
 
   /* Don't use the index if it's empty.  */
@@ -5341,7 +5341,7 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
   per_bfd->debug_names_table = std::move (map);
   per_bfd->using_index = 1;
   per_bfd->quick_file_names_table =
-    create_quick_file_names_table (per_objfile->per_bfd->all_comp_units.size ());
+    create_quick_file_names_table (per_bfd->all_comp_units.size ());
 
   return true;
 }
@@ -5596,7 +5596,7 @@ dw2_debug_names_iterator::next ()
        {
        case DW_IDX_compile_unit:
          /* Don't crash on bad data.  */
-         if (ull >= m_per_objfile->per_bfd->all_comp_units.size ())
+         if (ull >= per_bfd->all_comp_units.size ())
            {
              complaint (_(".debug_names entry has bad CU index %s"
                           " [in module %s]"),
@@ -7455,7 +7455,7 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
   struct dwarf2_per_cu_data *per_cu;
   struct type_unit_group *tu_group;
 
-  tu_group = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, type_unit_group);
+  tu_group = OBSTACK_ZALLOC (&per_bfd->obstack, type_unit_group);
   per_cu = &tu_group->per_cu;
   per_cu->per_bfd = per_bfd;
 
@@ -8081,8 +8081,7 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile)
                           objfile_name (objfile));
 
   scoped_restore restore_reading_psyms
-    = make_scoped_restore (&per_objfile->per_bfd->reading_partial_symbols,
-                          true);
+    = make_scoped_restore (&per_bfd->reading_partial_symbols, true);
 
   per_bfd->info.read (objfile);