Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 2/2] gdb/dwarf: skip broken .debug_macro.dwo
Date: Tue,  6 May 2025 13:03:47 -0400	[thread overview]
Message-ID: <20250506170406.124741-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20250506170406.124741-1-simon.marchi@efficios.com>

Running gdb.base/errno.exp with gcc <= 13 with split DWARF results in:

    $ make check TESTS="gdb.base/errno.exp" RUNTESTFLAGS="CC_FOR_TARGET=gcc-13 --target_board=fission"
    (gdb) break -qualified main
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:7549: internal-error: locate_dwo_sections: Assertion `!dw_sect->readin' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    ...
    FAIL: gdb.base/errno.exp: macros: gdb_breakpoint: set breakpoint at main (GDB internal error)

The assert being hit has been added in 28f15782adab ("gdb/dwarf: read
multiple .debug_info.dwo sections"), but it merely exposed an existing
problem.

gcc versions <= 13 are affected by this bug:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111409

Basically, it produces .dwo files with multiple .debug_macro.dwo
sections, with some unresolved links between them.  I think that this
macro debug info is unusable, and all we can do is ignore it.

In locate_dwo_sections, if we detect a second .debug_macro.dwo section,
forget about the previous .debug_macro.dwo and any subsequent one.  This
will effectively make it as if the macro debug info wasn't there at all.

The errno test seems happy with it:

    # of expected passes            84
    # of expected failures          8

Change-Id: I6489b4713954669bf69f6e91865063ddcd1ac2c8
---
 gdb/dwarf2/read.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 550968abc95c..63c0c007563e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -7516,6 +7516,7 @@ cutu_reader::locate_dwo_sections (objfile *objfile, dwo_file &dwo_file)
 {
   const struct dwop_section_names *names = &dwop_section_names;
   dwo_sections &dwo_sections = dwo_file.sections;
+  bool complained_about_macro_already = false;
 
   for (asection *sec : gdb_bfd_sections (dwo_file.dbfd))
     {
@@ -7534,7 +7535,24 @@ cutu_reader::locate_dwo_sections (objfile *objfile, dwo_file &dwo_file)
       else if (names->macinfo_dwo.matches (sec->name))
 	dw_sect = &dwo_sections.macinfo;
       else if (names->macro_dwo.matches (sec->name))
-	dw_sect = &dwo_sections.macro;
+	{
+	  /* gcc versions <= 13 generate multiple .debug_macro.dwo sections with
+	     some unresolved links between them.  It's not usable, so do as if
+	     there were not there.  */
+	  if (!complained_about_macro_already)
+	    {
+	      if (dwo_sections.macro.s.section == nullptr)
+		dw_sect = &dwo_sections.macro;
+	      else
+		{
+		  complaint (_("Multiple .debug_macro.dwo sections found in "
+			       "%s, ignoring them."), dwo_file.dbfd->filename);
+
+		  dwo_sections.macro = dwarf2_section_info {};
+		  complained_about_macro_already = true;
+		}
+	    }
+	}
       else if (names->rnglists_dwo.matches (sec->name))
 	dw_sect = &dwo_sections.rnglists;
       else if (names->str_dwo.matches (sec->name))
-- 
2.49.0


  reply	other threads:[~2025-05-06 17:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 17:03 [PATCH 1/2] gdb/dwarf: move loops into locate_dw{o,z}_sections Simon Marchi
2025-05-06 17:03 ` Simon Marchi [this message]
2025-05-12 17:55   ` [PATCH 2/2] gdb/dwarf: skip broken .debug_macro.dwo Tom Tromey
2025-05-12 18:08     ` Simon Marchi
2025-05-12 18:48       ` Tom Tromey
2025-05-12 18:50         ` Simon Marchi
2025-05-12 21:06           ` Tom Tromey
2025-05-12 17:52 ` [PATCH 1/2] gdb/dwarf: move loops into locate_dw{o,z}_sections Tom Tromey

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=20250506170406.124741-2-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@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