[Lldb-commits] [lldb] 3d7177a - [lldb/DWARF] Remove one more auto-dwo method

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 22 04:06:52 PST 2020


Author: Pavel Labath
Date: 2020-01-22T13:03:57+01:00
New Revision: 3d7177acd751704d42278ea78e5353943187045d

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

LOG: [lldb/DWARF] Remove one more auto-dwo method

Summary:
Our DWARFUnit was automatically forwarding the requests to the split
unit when looking for a DIE by offset. llvm::DWARFUnit does not do that,
and is not likely to start doing it any time soon.

This patch deletes the this logic and updates the callers to request the
correct unit instead. While doing that, I've found a bit of duplicated
code for lookup up a function and block by address, so I've extracted
that into a helper function.

Reviewers: JDevlieghere, aprantl, clayborg, jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73112

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
    lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 1e04baca2c58..c8014c6231cd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -191,7 +191,7 @@ DWARFDIE
 DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
   DWARFUnit *cu = GetUnit(die_ref);
   if (cu)
-    return cu->GetDIE(die_ref.die_offset());
+    return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
   return DWARFDIE(); // Not found
 }
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 4ac07515a21c..ee189f9331e5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -534,9 +534,6 @@ static bool CompareDIEOffset(const DWARFDebugInfoEntry &die,
 DWARFDIE
 DWARFUnit::GetDIE(dw_offset_t die_offset) {
   if (die_offset != DW_INVALID_OFFSET) {
-    if (GetDwoSymbolFile())
-      return GetDwoSymbolFile()->GetCompileUnit()->GetDIE(die_offset);
-
     if (ContainsDIEOffset(die_offset)) {
       ExtractDIEsIfNeeded();
       DWARFDebugInfoEntry::const_iterator end = m_die_array.cend();

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 19e15b527903..f025a5794f0c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1771,6 +1771,32 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
   return *m_global_aranges_up;
 }
 
+void SymbolFileDWARF::ResolveFunctionAndBlock(lldb::addr_t file_vm_addr,
+                                              bool lookup_block,
+                                              SymbolContext &sc) {
+  assert(sc.comp_unit);
+  DWARFUnit &cu = GetDWARFCompileUnit(sc.comp_unit)->GetNonSkeletonUnit();
+  DWARFDIE function_die = cu.LookupAddress(file_vm_addr);
+  DWARFDIE block_die;
+  if (function_die) {
+    sc.function = sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
+    if (sc.function == nullptr)
+      sc.function = ParseFunction(*sc.comp_unit, function_die);
+
+    if (sc.function && lookup_block)
+      block_die = function_die.LookupDeepestBlock(file_vm_addr);
+  }
+
+  if (!sc.function || ! lookup_block)
+    return;
+
+  Block &block = sc.function->GetBlock(true);
+  if (block_die)
+    sc.block = block.FindBlockByID(block_die.GetID());
+  else
+    sc.block = block.FindBlockByID(function_die.GetID());
+}
+
 uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
                                                SymbolContextItem resolve_scope,
                                                SymbolContext &sc) {
@@ -1834,17 +1860,11 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
             bool force_check_line_table = false;
             if (resolve_scope &
                 (eSymbolContextFunction | eSymbolContextBlock)) {
-              DWARFDIE function_die = dwarf_cu->LookupAddress(file_vm_addr);
-              DWARFDIE block_die;
-              if (function_die) {
-                sc.function =
-                    sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
-                if (sc.function == nullptr)
-                  sc.function = ParseFunction(*sc.comp_unit, function_die);
-
-                if (sc.function && (resolve_scope & eSymbolContextBlock))
-                  block_die = function_die.LookupDeepestBlock(file_vm_addr);
-              } else {
+              ResolveFunctionAndBlock(file_vm_addr,
+                                      resolve_scope & eSymbolContextBlock, sc);
+              if (sc.function)
+                resolved |= eSymbolContextFunction;
+              else {
                 // We might have had a compile unit that had discontiguous
                 // address ranges where the gaps are symbols that don't have
                 // any debug info. Discontiguous compile unit address ranges
@@ -1853,21 +1873,8 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
                 // of the aranges down.
                 force_check_line_table = true;
               }
-
-              if (sc.function != nullptr) {
-                resolved |= eSymbolContextFunction;
-
-                if (resolve_scope & eSymbolContextBlock) {
-                  Block &block = sc.function->GetBlock(true);
-
-                  if (block_die)
-                    sc.block = block.FindBlockByID(block_die.GetID());
-                  else
-                    sc.block = block.FindBlockByID(function_die.GetID());
-                  if (sc.block)
-                    resolved |= eSymbolContextBlock;
-                }
-              }
+              if (sc.block)
+                resolved |= eSymbolContextBlock;
             }
 
             if ((resolve_scope & eSymbolContextLineEntry) ||
@@ -1967,30 +1974,8 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec,
                   const lldb::addr_t file_vm_addr =
                       sc.line_entry.range.GetBaseAddress().GetFileAddress();
                   if (file_vm_addr != LLDB_INVALID_ADDRESS) {
-                    DWARFDIE function_die =
-                        GetDWARFCompileUnit(dc_cu)->LookupAddress(file_vm_addr);
-                    DWARFDIE block_die;
-                    if (function_die) {
-                      sc.function =
-                          sc.comp_unit->FindFunctionByUID(function_die.GetID())
-                              .get();
-                      if (sc.function == nullptr)
-                        sc.function =
-                            ParseFunction(*sc.comp_unit, function_die);
-
-                      if (sc.function && (resolve_scope & eSymbolContextBlock))
-                        block_die =
-                            function_die.LookupDeepestBlock(file_vm_addr);
-                    }
-
-                    if (sc.function != nullptr) {
-                      Block &block = sc.function->GetBlock(true);
-
-                      if (block_die)
-                        sc.block = block.FindBlockByID(block_die.GetID());
-                      else if (function_die)
-                        sc.block = block.FindBlockByID(function_die.GetID());
-                    }
+                    ResolveFunctionAndBlock(
+                        file_vm_addr, resolve_scope & eSymbolContextBlock, sc);
                   }
                 }
 
@@ -3122,7 +3107,8 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(Function &func) {
 
   size_t functions_added = 0;
   const dw_offset_t function_die_offset = func.GetID();
-  DWARFDIE function_die = dwarf_cu->GetDIE(function_die_offset);
+  DWARFDIE function_die =
+      dwarf_cu->GetNonSkeletonUnit().GetDIE(function_die_offset);
   if (function_die) {
     ParseBlocksRecursive(*comp_unit, &func.GetBlock(false), function_die,
                          LLDB_INVALID_ADDRESS, 0);

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 5183ad33f3a9..1e6b518c76ad 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -381,6 +381,13 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
   bool ResolveFunction(const DWARFDIE &die, bool include_inlines,
                        lldb_private::SymbolContextList &sc_list);
 
+  /// Resolve functions and (possibly) blocks for the given file address and a
+  /// compile unit. The compile unit comes from the sc argument and it must be
+  /// set. The results of the lookup (if any) are written back to the symbol
+  /// context.
+  void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block,
+                               lldb_private::SymbolContext &sc);
+
   virtual lldb::TypeSP
   FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx);
 


        


More information about the lldb-commits mailing list