[ spin-off of PR29381. ] When running the test-case gdb.cp/cpexprs-debug-types.exp with target board cc-with-debug-names on a system which defaults to dwarf5, gdb rejects the .debug_names index because it cannot find a .debug_types section: ... The .debug_names index is rejected in dwarf2_read_debug_names because: ... if (map->tu_count != 0) { /* We can only handle a single .debug_types when we have an index. */ if (per_bfd->types.size () != 1) return false; ... The .debug_types section was eliminated in dwarf 5.
Part of enabling this will be to address the computation of CU size, which is broken for this use case. Tentative patch at PR29381 comment 3.
(In reply to Tom de Vries from comment #1) > Part of enabling this will be to address the computation of CU size, which > is broken for this use case. Tentative patch at PR29381 comment 3. That's already taken care of in https://sourceware.org/pipermail/gdb-patches/2022-August/191313.html .
Tentative patch (in combination with patch mentioned in previous comment): ... diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 6c6ca96f8d9..8e82f464293 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4736,13 +4736,16 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) { /* We can only handle a single .debug_types when we have an index. */ - if (per_bfd->types.size () != 1) + if (per_bfd->types.size () > 1) { per_bfd->all_comp_units.clear (); return false; } - dwarf2_section_info *section = &per_bfd->types[0]; + dwarf2_section_info *section + = (per_bfd->types.size () == 1 + ? &per_bfd->types[0] + : &per_bfd->info); create_signatured_type_table_from_debug_names (per_objfile, *map, section, &per_bfd->abbrev); ... Allows test-case gdb.cp/cpexprs-debug-types.exp to pass on target board cc-with-debug-names/gdb:debug_flags=-gdwarf-5.
https://sourceware.org/pipermail/gdb-patches/2022-August/191365.html
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d878bb39e417fa23b8dc62fed916708e776a9b71