public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Always use dwarf2_initialize_objfile
Date: Thu, 21 Apr 2022 18:20:39 +0000 (GMT)	[thread overview]
Message-ID: <20220421182039.4306038346B4@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=31de881f8f9a03499002d28ff42286b79c24a97d

commit 31de881f8f9a03499002d28ff42286b79c24a97d
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Apr 19 11:32:04 2022 -0600

    Always use dwarf2_initialize_objfile
    
    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.

Diff:
---
 gdb/coffread.c      |  4 +---
 gdb/dwarf2/public.h |  3 ---
 gdb/dwarf2/read.c   | 15 +++++----------
 gdb/machoread.c     |  2 +-
 gdb/xcoffread.c     |  4 +---
 5 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index f5ef1285440..da871d5af11 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -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 ())
     {
diff --git a/gdb/dwarf2/public.h b/gdb/dwarf2/public.h
index f002ab2f9b1..a9d4682c856 100644
--- a/gdb/dwarf2/public.h
+++ b/gdb/dwarf2/public.h
@@ -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 */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 8586463f550..d6fccf83dd2 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -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);
   }
 };
 
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 90f25b3c191..8c4b08f8cea 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -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.  */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 566c0824cd5..d8735d29ede 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -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


                 reply	other threads:[~2022-04-21 18:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220421182039.4306038346B4@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).