From 7960c9431a130bbe4202981e45586df68961c2dd Mon Sep 17 00:00:00 2001 From: Tony Tao Date: Thu, 3 Jul 2025 14:01:13 -0400 Subject: [PATCH] make NextCUOffset checks consistent --- llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp | 2 +- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp index 4f0a6d96ace9e..06f0999b6e034 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp @@ -30,7 +30,7 @@ bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, "DWARF unit from offset 0x%8.8" PRIx64 " incl. " "to offset 0x%8.8" PRIx64 " excl. " "tries to read DIEs at offset 0x%8.8" PRIx64, - U.getOffset(), U.getNextUnitOffset(), *OffsetPtr)); + U.getOffset(), UEndOffset, *OffsetPtr)); return false; } assert(DebugInfoData.isValidOffset(UEndOffset - 1)); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index ef59c82fc6a01..f19fa5a1169d5 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -294,9 +294,9 @@ Error DWARFUnitHeader::extract(DWARFContext &Context, // Header fields all parsed, capture the size of this unit header. assert(*offset_ptr - Offset <= 255 && "unexpected header size"); Size = uint8_t(*offset_ptr - Offset); - uint64_t NextCUOffset = Offset + getUnitLengthFieldByteSize() + getLength(); + uint64_t NextCUOffset = getNextUnitOffset(); - if (!debug_info.isValidOffset(getNextUnitOffset() - 1)) + if (!debug_info.isValidOffset(NextCUOffset - 1)) return createStringError(errc::invalid_argument, "DWARF unit from offset 0x%8.8" PRIx64 " incl. " "to offset 0x%8.8" PRIx64 " excl. "