From: Tom Tromey Date: Fri, 14 Feb 2025 00:45:23 +0000 (-0700) Subject: Handle DW_FORM_data4 in read-debug-names.c X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9436542558915d5564d05ccb29d1b43a26e37698;p=thirdparty%2Fbinutils-gdb.git Handle DW_FORM_data4 in read-debug-names.c 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 --- diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index 4447c5c240a..5383cf2feee 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -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)