]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Always use dwarf2_initialize_objfile
authorTom Tromey <tromey@adacore.com>
Tue, 19 Apr 2022 17:32:04 +0000 (11:32 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 21 Apr 2022 18:18:25 +0000 (12:18 -0600)
Internally we noticed that some tests would fail like so on Windows:

warning: Section .debug_aranges in [...] has duplicate debug_info_offset 0x0, ignoring .debug_aranges.

Debugging showed that, in fact, a second CU was being created at this
offset.  We tracked this down to the fact that, while the ELF reader
is careful to re-use the per-BFD data, other readers are not, and
could re-read the DWARF data multiple times.

However, since the change to allow an objfile to have multiple "quick
symbol" implementations, there's no reason for this approach -- it's
safe and easy for all symbol readers to reuse the per-BFD data when
reading DWARF.

This patch implements this idea, simplifying dwarf2_build_psymtabs and
making it private, and then switching to dwarf2_initialize_objfile as
the sole way to start the DWARF reader.

Note that, while I think the call to dwarf2_build_frame_info in
machoread.c is also obsolete, I haven't attempted to remove it here.

gdb/coffread.c
gdb/dwarf2/public.h
gdb/dwarf2/read.c
gdb/machoread.c
gdb/xcoffread.c

index f5ef12854405307345830a306474f45f0a976877..da871d5af11b207e8d402ea46491ecf0ee030ca2 100644 (file)
@@ -702,11 +702,9 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   if (dwarf2_has_info (objfile, NULL))
     {
       /* DWARF2 sections.  */
-      dwarf2_build_psymtabs (objfile);
+      dwarf2_initialize_objfile (objfile);
     }
 
-  dwarf2_build_frame_info (objfile);
-
   /* Try to add separate debug file if no symbols table found.   */
   if (!objfile->has_partial_symbols ())
     {
index f002ab2f9b14278c31e7023f322b03685ef786fb..a9d4682c856bcd78088f8e734dab74f5362cdb7f 100644 (file)
@@ -38,9 +38,6 @@ enum class dw_index_kind
    entry on the objfile's "qf" list.  */
 extern void dwarf2_initialize_objfile (struct objfile *objfile);
 
-struct psymbol_functions;
-extern void dwarf2_build_psymtabs (struct objfile *,
-                                  bool already_attached = false);
 extern void dwarf2_build_frame_info (struct objfile *);
 
 #endif /* DWARF2_PUBLIC_H */
index 8586463f5505a563831bca7c251d360f5b9bf1af..d6fccf83dd2a9091811523efbf5118ea72a75b0a 100644 (file)
@@ -5340,18 +5340,13 @@ dwarf2_initialize_objfile (struct objfile *objfile)
 
 /* Build a partial symbol table.  */
 
-void
-dwarf2_build_psymtabs (struct objfile *objfile, bool already_attached)
+static void
+dwarf2_build_psymtabs (struct objfile *objfile)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
-  if (already_attached)
-    {
-      if (per_objfile->per_bfd->index_table != nullptr)
-       return;
-    }
-  else
-    objfile->qf.push_front (make_cooked_index_funcs ());
+  if (per_objfile->per_bfd->index_table != nullptr)
+    return;
 
   try
     {
@@ -18457,7 +18452,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions
   void read_partial_symbols (struct objfile *objfile) override
   {
     if (dwarf2_has_info (objfile, nullptr))
-      dwarf2_build_psymtabs (objfile, true);
+      dwarf2_build_psymtabs (objfile);
   }
 };
 
index 90f25b3c191211c402f2a478bfce9da51e5e9501..8c4b08f8cea41e8da66bc372c0d4911ba1567537 100644 (file)
@@ -860,7 +860,7 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   if (dwarf2_has_info (objfile, NULL))
     {
       /* DWARF 2 sections */
-      dwarf2_build_psymtabs (objfile);
+      dwarf2_initialize_objfile (objfile);
     }
 
   /* Then the oso.  */
index 566c0824cd5a1a521718636557e4026fb42db45f..d8735d29ede1996be5bcb3689c0940064c15a5e6 100644 (file)
@@ -2872,9 +2872,7 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
   /* DWARF2 sections.  */
 
   if (dwarf2_has_info (objfile, &dwarf2_xcoff_names))
-    dwarf2_build_psymtabs (objfile);
-
-  dwarf2_build_frame_info (objfile);
+    dwarf2_initialize_objfile (objfile);
 }
 \f
 static void