[Lldb-commits] [lldb] 1a2d25f - Revert "[lldb/DWARF] Simplify DIE extraction code slightly"

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 30 01:00:53 PDT 2021


Author: Pavel Labath
Date: 2021-03-30T09:59:34+02:00
New Revision: 1a2d25fcdd732fc3326c1e9a9729b3b2b08b5d17

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

LOG: Revert "[lldb/DWARF] Simplify DIE extraction code slightly"

This reverts commit 1b96e133cf5215cb9ebfe7f14630f479c1611f22 due to
failures on windows.

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index e501bb9af7fb..86b18615da7d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -153,15 +153,17 @@ void DWARFUnit::ExtractDIEsRWLocked() {
 
   DWARFDebugInfoEntry die;
 
+  uint32_t depth = 0;
   // We are in our compile unit, parse starting at the offset we were told to
   // parse
   const DWARFDataExtractor &data = GetData();
   std::vector<uint32_t> die_index_stack;
   die_index_stack.reserve(32);
+  die_index_stack.push_back(0);
   bool prev_die_had_children = false;
   while (offset < next_cu_offset && die.Extract(data, this, &offset)) {
     const bool null_die = die.IsNULL();
-    if (die_index_stack.size() == 0) {
+    if (depth == 0) {
       assert(m_die_array.empty() && "Compile unit DIE already added");
 
       // The average bytes per DIE entry has been seen to be around 14-20 so
@@ -199,12 +201,11 @@ void DWARFUnit::ExtractDIEsRWLocked() {
             m_die_array.back().SetHasChildren(false);
         }
       } else {
-        die.SetParentIndex(m_die_array.size() - die_index_stack.rbegin()[1]);
+        die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
 
         if (die_index_stack.back())
           m_die_array[die_index_stack.back()].SetSiblingIndex(
               m_die_array.size() - die_index_stack.back());
-        die_index_stack.back() = m_die_array.size();
 
         // Only push the DIE if it isn't a NULL DIE
         m_die_array.push_back(die);
@@ -213,19 +214,24 @@ void DWARFUnit::ExtractDIEsRWLocked() {
 
     if (null_die) {
       // NULL DIE.
-      if (!die_index_stack.empty()) {
+      if (!die_index_stack.empty())
         die_index_stack.pop_back();
-        prev_die_had_children = false;
-      }
+
+      if (depth > 0)
+        --depth;
+      prev_die_had_children = false;
     } else {
+      die_index_stack.back() = m_die_array.size() - 1;
       // Normal DIE
       const bool die_has_children = die.HasChildren();
-      if (die_has_children)
+      if (die_has_children) {
         die_index_stack.push_back(0);
+        ++depth;
+      }
       prev_die_had_children = die_has_children;
     }
 
-    if (die_index_stack.size() == 0)
+    if (depth == 0)
       break; // We are done with this compile unit!
   }
 


        


More information about the lldb-commits mailing list