]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Handle DW_FORM_data4 in read-debug-names.c
authorTom Tromey <tom@tromey.com>
Fri, 14 Feb 2025 00:45:23 +0000 (17:45 -0700)
committerTom Tromey <tom@tromey.com>
Fri, 14 Feb 2025 20:13:47 +0000 (13:13 -0700)
The recent .debug_names patches caused the writer to emit
DW_FORM_data4.  Unfortunately the reader did not handle this form.

This patch updates the reader to handle a few DW_FORM_data* forms.

The complaint that is there went unnoticed -- I only found this when
debugging a failure in another series.  More evidence, IMO, that
complaints should be removed.

I think the reason the failure itself went unnoticed is that the
symbol table code in gdb often works by accident, and in particular in
small programs like the ones in the test suite, it's often the case
that a CU will be expanded for some other reason, causing the test to
pass without really touching the index code.  The aforementioned
series is aimed at fixing this.

It would probably be good to unify the abbrev/form code to some
degree, but it's mildly a pain as some forms don't make sense here and
because we recently discovered other issues with gdb's DW_FORM_data*
handling.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/dwarf2/read-debug-names.c

index 4447c5c240a9a4e90ab29d3d57175899b4220ab7..5383cf2feeed5a08a25ea4aac2c8939424db0637 100644 (file)
@@ -194,6 +194,17 @@ mapped_debug_names_reader::scan_one_entry (const char *name,
          ull = read_offset (abfd, entry, offset_size);
          entry += offset_size;
          break;
+       case DW_FORM_data1:
+         ull = *entry++;
+         break;
+       case DW_FORM_data2:
+         ull = read_2_bytes (abfd, entry);
+         entry += 2;
+         break;
+       case DW_FORM_data4:
+         ull = read_4_bytes (abfd, entry);
+         entry += 4;
+         break;
        case DW_FORM_ref4:
          ull = read_4_bytes (abfd, entry);
          entry += 4;
@@ -207,9 +218,12 @@ mapped_debug_names_reader::scan_one_entry (const char *name,
          entry += 8;
          break;
        default:
-         complaint (_("Unsupported .debug_names form %s [in module %s]"),
-                    dwarf_form_name (attr.form),
-                    bfd_get_filename (abfd));
+         /* A warning instead of a complaint, because this one is
+            more like a bug in gdb.  */
+         warning (_("Unsupported .debug_names form %s [in module %s].\n"
+                    "This normally should not happen, please file a bug report."),
+                  dwarf_form_name (attr.form),
+                  bfd_get_filename (abfd));
          return nullptr;
        }
       switch (attr.dw_idx)