Skip to content

Commit 5ab819f

Browse files
committed
[lldb] Split up checks and add info to error
1 parent 6291e13 commit 5ab819f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,20 @@ Error DWARFUnitHeader::applyIndexEntry(const DWARFUnitIndex::Entry *Entry) {
349349
Offset);
350350

351351
auto *UnitContrib = IndexEntry->getContribution();
352-
if (!UnitContrib ||
353-
UnitContrib->getLength() != (getLength() + getUnitLengthFieldByteSize()))
352+
if (!UnitContrib)
354353
return createStringError(errc::invalid_argument,
355354
"DWARF package unit at offset 0x%8.8" PRIx64
356-
" has an inconsistent index",
355+
" has no contribution index",
357356
Offset);
358357

358+
uint64_t IndexLength = getLength() + getUnitLengthFieldByteSize();
359+
if (UnitContrib->getLength() != IndexLength)
360+
return createStringError(errc::invalid_argument,
361+
"DWARF package unit at offset 0x%8.8" PRIx64
362+
" has an inconsistent index (expected: %" PRIu64
363+
", actual: %" PRIu64 ")",
364+
Offset, UnitContrib->getLength(), IndexLength);
365+
359366
auto *AbbrEntry = IndexEntry->getContribution(DW_SECT_ABBREV);
360367
if (!AbbrEntry)
361368
return createStringError(errc::invalid_argument,

llvm/test/DebugInfo/X86/invalid-cu-length-dwp.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## llvm-dwarfdump used to crash with this input because of an invalid size
55
## of the compilation unit contribution in the .debug_cu_index section.
66

7-
# CHECK: warning: DWARF package unit at offset 0x00000000 has an inconsistent index
7+
# CHECK: warning: DWARF package unit at offset 0x00000000 has an inconsistent index (expected: 23, actual: 24)
88

99
.section .debug_abbrev.dwo, "e", @progbits
1010
.LAbbrBegin:

0 commit comments

Comments
 (0)