Skip to content

Commit 57eea4c

Browse files
committed
gdb/dwarf: skip broken .debug_macro.dwo
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 28f1578 ("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 Approved-By: Tom Tromey <[email protected]>
1 parent 8422833 commit 57eea4c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

gdb/dwarf2/read.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7516,6 +7516,7 @@ cutu_reader::locate_dwo_sections (objfile *objfile, dwo_file &dwo_file)
75167516
{
75177517
const struct dwop_section_names *names = &dwop_section_names;
75187518
dwo_sections &dwo_sections = dwo_file.sections;
7519+
bool complained_about_macro_already = false;
75197520

75207521
for (asection *sec : gdb_bfd_sections (dwo_file.dbfd))
75217522
{
@@ -7534,7 +7535,24 @@ cutu_reader::locate_dwo_sections (objfile *objfile, dwo_file &dwo_file)
75347535
else if (names->macinfo_dwo.matches (sec->name))
75357536
dw_sect = &dwo_sections.macinfo;
75367537
else if (names->macro_dwo.matches (sec->name))
7537-
dw_sect = &dwo_sections.macro;
7538+
{
7539+
/* gcc versions <= 13 generate multiple .debug_macro.dwo sections with
7540+
some unresolved links between them. It's not usable, so do as if
7541+
there were not there. */
7542+
if (!complained_about_macro_already)
7543+
{
7544+
if (dwo_sections.macro.s.section == nullptr)
7545+
dw_sect = &dwo_sections.macro;
7546+
else
7547+
{
7548+
warning (_("Multiple .debug_macro.dwo sections found in "
7549+
"%s, ignoring them."), dwo_file.dbfd->filename);
7550+
7551+
dwo_sections.macro = dwarf2_section_info {};
7552+
complained_about_macro_already = true;
7553+
}
7554+
}
7555+
}
75387556
else if (names->rnglists_dwo.matches (sec->name))
75397557
dw_sect = &dwo_sections.rnglists;
75407558
else if (names->str_dwo.matches (sec->name))

0 commit comments

Comments
 (0)