From fd1dde1a2f708ff47570454fe350d07bb74bbd3b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 19 Apr 2019 03:34:28 +0000 Subject: [PATCH] [DWARF] Use hasFileAtIndex to properly verify DWARF 5 after rL358732 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358734 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/DebugInfo/DWARF/DWARFVerifier.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/lib/DebugInfo/DWARF/DWARFVerifier.cpp index 5ff25b5209e..8fea97aa3c2 100644 --- a/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -705,7 +705,6 @@ void DWARFVerifier::verifyDebugLineRows() { continue; // Verify prologue. - uint32_t MaxFileIndex = LineTable->Prologue.FileNames.size(); uint32_t MaxDirIndex = LineTable->Prologue.IncludeDirectories.size(); uint32_t FileIndex = 1; StringMap FullPathMap; @@ -763,13 +762,16 @@ void DWARFVerifier::verifyDebugLineRows() { } // Verify file index. - if (Row.File > MaxFileIndex) { + if (!LineTable->hasFileAtIndex(Row.File)) { ++NumDebugLineErrors; + bool isDWARF5 = LineTable->Prologue.getVersion() >= 5; error() << ".debug_line[" << format("0x%08" PRIx64, *toSectionOffset(Die.find(DW_AT_stmt_list))) << "][" << RowIndex << "] has invalid file index " << Row.File - << " (valid values are [1," << MaxFileIndex << "]):\n"; + << " (valid values are [" << (isDWARF5 ? "0," : "1,") + << LineTable->Prologue.FileNames.size() + << (isDWARF5 ? ")" : "]") << "):\n"; DWARFDebugLine::Row::dumpTableHeader(OS); Row.dump(OS); OS << '\n'; -- 2.50.1