[llvm] bbaa639 - [llvm/DebugInfo] Print DW_AT_ranges offset as part of verifier error.

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 16:45:36 PDT 2020


Author: Jonas Devlieghere
Date: 2020-04-27T16:45:17-07:00
New Revision: bbaa639ba966d2a20c00554701af1168caca6dfb

URL: https://github.com/llvm/llvm-project/commit/bbaa639ba966d2a20c00554701af1168caca6dfb
DIFF: https://github.com/llvm/llvm-project/commit/bbaa639ba966d2a20c00554701af1168caca6dfb.diff

LOG: [llvm/DebugInfo] Print DW_AT_ranges offset as part of verifier error.

Print the DW_AT_ranges offset as part of the verifier error, like we do
for the DW_AT_stmt_list offset.

Added: 
    

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
    llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index beca8cc0bc7d..74584712ad30 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -458,7 +458,8 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
     // Make sure the offset in the DW_AT_ranges attribute is valid.
     if (auto SectionOffset = AttrValue.Value.getAsSectionOffset()) {
       if (*SectionOffset >= DObj.getRangesSection().Data.size())
-        ReportError("DW_AT_ranges offset is beyond .debug_ranges bounds:");
+        ReportError("DW_AT_ranges offset is beyond .debug_ranges bounds: " +
+                    llvm::formatv("{0:x8}", *SectionOffset));
       break;
     }
     ReportError("DIE has invalid DW_AT_ranges encoding:");

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index c9823201f554..2caf6ca71a77 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -2008,8 +2008,9 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRanges) {
   ASSERT_TRUE((bool)ErrOrSections);
   std::unique_ptr<DWARFContext> DwarfContext =
       DWARFContext::create(*ErrOrSections, 8);
-  VerifyError(*DwarfContext,
-              "error: DW_AT_ranges offset is beyond .debug_ranges bounds:");
+  VerifyError(
+      *DwarfContext,
+      "error: DW_AT_ranges offset is beyond .debug_ranges bounds: 0x00001000");
 }
 
 TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStmtList) {


        


More information about the llvm-commits mailing list