Bug 29385 - [gdb, debug-types, debug-names, dwarf-5] Support .debug_names section with TUs in .debug_info
Summary: [gdb, debug-types, debug-names, dwarf-5] Support .debug_names section with TU...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 enhancement
Target Milestone: 13.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-19 11:32 UTC by Tom de Vries
Modified: 2022-09-06 08:23 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2022-07-19 11:32:23 UTC
[ 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.
Comment 1 Tom de Vries 2022-07-19 11:34:27 UTC
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.
Comment 2 Tom de Vries 2022-08-12 14:22:05 UTC
(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 .
Comment 3 Tom de Vries 2022-08-12 14:24:32 UTC
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.