[llvm] [DebugInfo] Report errors when DWARFUnitHeader::applyIndexEntry fails (PR #89156)

Alex Langford via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 10:06:41 PDT 2024


================
@@ -334,21 +338,33 @@ Error DWARFUnitHeader::extract(DWARFContext &Context,
   return Error::success();
 }
 
-bool DWARFUnitHeader::applyIndexEntry(const DWARFUnitIndex::Entry *Entry) {
+Error DWARFUnitHeader::applyIndexEntry(const DWARFUnitIndex::Entry *Entry) {
   assert(Entry);
   assert(!IndexEntry);
   IndexEntry = Entry;
   if (AbbrOffset)
-    return false;
+    return createStringError(errc::invalid_argument,
+                             "DWARF package unit at offset 0x%8.8" PRIx64
+                             " has a non-zero abbreviation offset",
+                             Offset);
+
   auto *UnitContrib = IndexEntry->getContribution();
   if (!UnitContrib ||
       UnitContrib->getLength() != (getLength() + getUnitLengthFieldByteSize()))
-    return false;
+    return createStringError(errc::invalid_argument,
+                             "DWARF package unit at offset 0x%8.8" PRIx64
+                             " has an inconsistent index",
+                             Offset);
----------------
bulbazord wrote:

I can split them into separate cases and then test them separately (I think).  I'll also update the error message :)

https://github.com/llvm/llvm-project/pull/89156


More information about the llvm-commits mailing list