[PATCH] D75119: [DWARF] Use DWARFDataExtractor::getInitialLength to parse debug_names

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 12:40:38 PST 2020


probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

I love it.



================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp:382
     return createStringError(errc::illegal_byte_sequence,
-                             "Section too small: cannot read header.");
-  UnitLength = AS.getU32(Offset);
-  if (UnitLength >= dwarf::DW_LENGTH_lo_reserved &&
-      UnitLength != dwarf::DW_LENGTH_DWARF64)
-    return createStringError(errc::illegal_byte_sequence,
-                             "Unsupported reserved unit length value");
-  Format = (UnitLength == dwarf::DW_LENGTH_DWARF64) ? dwarf::DWARF64
-                                                    : dwarf::DWARF32;
-
-  // These fields are the same for 32-bit and 64-bit DWARF formats.
-  constexpr unsigned CommonHeaderSize = 2 + // Version
-                                        2 + // Padding
-                                        4 + // CU count
-                                        4 + // Local TU count
-                                        4 + // Foreign TU count
-                                        4 + // Bucket count
-                                        4 + // Name count
-                                        4 + // Abbreviations table size
-                                        4;  // Augmentation string size
-  // Check that we can read the fixed-size part.
-  if (!AS.isValidOffsetForDataOfSize(
-          StartingOffset,
-          CommonHeaderSize + dwarf::getUnitLengthFieldByteSize(Format)))
-    return createStringError(errc::illegal_byte_sequence,
-                             "Section too small: cannot read header.");
-  if (Format == dwarf::DWARF64)
-    UnitLength = AS.getU64(Offset);
-  Version = AS.getU16(Offset);
-  // Skip padding
-  *Offset += 2;
-  CompUnitCount = AS.getU32(Offset);
-  LocalTypeUnitCount = AS.getU32(Offset);
-  ForeignTypeUnitCount = AS.getU32(Offset);
-  BucketCount = AS.getU32(Offset);
-  NameCount = AS.getU32(Offset);
-  AbbrevTableSize = AS.getU32(Offset);
-  AugmentationStringSize = alignTo(AS.getU32(Offset), 4);
-
-  if (!AS.isValidOffsetForDataOfSize(*Offset, AugmentationStringSize))
-    return createStringError(
-        errc::illegal_byte_sequence,
-        "Section too small: cannot read header augmentation.");
+                             "parsing debug_names header at 0x%" PRIx64 ": %s",
+                             Offset, toString(std::move(E)).c_str());
----------------
maybe `.debug_names` (with leading dot) (although I admit the names in MachO are different)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75119/new/

https://reviews.llvm.org/D75119





More information about the llvm-commits mailing list