[llvm] bddab92 - Use new DWARFDataExtractor::getInitialLength in DWARFDebugFrame

Pavel Labath via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 04:12:27 PST 2020


Author: Pavel Labath
Date: 2020-03-04T13:01:35+01:00
New Revision: bddab9285812e060c776233fc779654c1447f9e0

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

LOG: Use new DWARFDataExtractor::getInitialLength in DWARFDebugFrame

Added: 
    

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
index 851646770539..c3057f245d7d 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -364,18 +364,11 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
   while (Data.isValidOffset(Offset)) {
     uint64_t StartOffset = Offset;
 
-    bool IsDWARF64 = false;
-    uint64_t Length = Data.getRelocatedValue(4, &Offset);
+    uint64_t Length;
+    DwarfFormat Format;
+    std::tie(Length, Format) = Data.getInitialLength(&Offset);
     uint64_t Id;
 
-    if (Length == dwarf::DW_LENGTH_DWARF64) {
-      // DWARF-64 is distinguished by the first 32 bits of the initial length
-      // field being 0xffffffff. Then, the next 64 bits are the actual entry
-      // length.
-      IsDWARF64 = true;
-      Length = Data.getRelocatedValue(8, &Offset);
-    }
-
     // At this point, Offset points to the next field after Length.
     // Length is the structure size excluding itself. Compute an offset one
     // past the end of the structure (needed to know how many instructions to
@@ -384,6 +377,7 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
     uint64_t EndStructureOffset = Offset + Length;
 
     // The Id field's size depends on the DWARF format
+    bool IsDWARF64 = Format == DWARF64;
     Id = Data.getRelocatedValue((IsDWARF64 && !IsEH) ? 8 : 4, &Offset);
     bool IsCIE =
         ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID || (IsEH && !Id));


        


More information about the llvm-commits mailing list