[Lldb-commits] [lldb] r364009 - DWARF: Add "dwo_num" field to the DIERef class

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 21 00:56:51 PDT 2019


Author: labath
Date: Fri Jun 21 00:56:50 2019
New Revision: 364009

URL: http://llvm.org/viewvc/llvm-project?rev=364009&view=rev
Log:
DWARF: Add "dwo_num" field to the DIERef class

Summary:
When dwo support was introduced, it used a trick where debug info
entries were referenced by the offset of the compile unit in the main
file, but the die offset was relative to the dwo file. Although there
was some elegance to it, this representation was starting to reach its
breaking point:
- the fact that the skeleton compile unit owned the DWO file meant that
  it was impossible (or at least hard and unintuitive) to support DWO
  files containing more than one compile unit. These kinds of files are
  produced by LTO for example.
- it made it impossible to reference any DIEs in the skeleton compile
  unit (although the skeleton units are generally empty, clang still
  puts some info into them with -fsplit-dwarf-inlining).
- (current motivation) it made it very hard to support type units placed
  in DWO files, as type units don't have any skeleton units which could
  be referenced in the main file

This patch addresses this problem by introducing an new
"dwo_num" field to the DIERef class, whose purpose is to identify the
dwo file. It's kind of similar to the dwo_id field in DWARF5 unit
headers, but while this is a 64bit hash whose main purpose is to catch
file mismatches, this is just a smaller integer used to indentify a
loaded dwo file. Currently, this is based on the index of the skeleton
compile unit which owns the dwo file, but it is intended to be
eventually independent of that (to support the LTO use case).

Simultaneously the cu_offset is dropped to conserve space, as it is no
longer necessary.  This means we can remove the "BaseObjectOffset" field
from the DWARFUnit class. It also means we can remove some of the
workarounds put in place to support the skeleton-unit+dwo-die combo.
More work is needed to remove all of them, which is out of scope of this
patch.

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: mehdi_amini, dexonsmith, arphaman, lldb-commits

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

Modified:
    lldb/trunk/lit/SymbolFile/DWARF/find-variable-file.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Modified: lldb/trunk/lit/SymbolFile/DWARF/find-variable-file.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/find-variable-file.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/lit/SymbolFile/DWARF/find-variable-file.cpp (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/find-variable-file.cpp Fri Jun 21 00:56:50 2019
@@ -8,6 +8,16 @@
 // RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
 // RUN:   FileCheck --check-prefix=TWO %s
 
+// Run the same test with split-dwarf. This is interesting because the two
+// split compile units will have the same offset (0).
+// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -gsplit-dwarf %s
+// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -gsplit-dwarf %S/Inputs/find-variable-file-2.cpp
+// RUN: ld.lld %t-1.o %t-2.o -o %t
+// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \
+// RUN:   FileCheck --check-prefix=ONE %s
+// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
+// RUN:   FileCheck --check-prefix=TWO %s
+
 // RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s
 // RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %S/Inputs/find-variable-file-2.cpp
 // RUN: ld.lld %t-1.o %t-2.o -o %t

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp Fri Jun 21 00:56:50 2019
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "Plugins/SymbolFile/DWARF/AppleDWARFIndex.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h"
 #include "Plugins/SymbolFile/DWARF/DWARFUnit.h"
 #include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h"
@@ -133,14 +132,14 @@ void AppleDWARFIndex::GetNamespaces(Cons
     m_apple_namespaces_up->FindByName(name.GetStringRef(), offsets);
 }
 
-void AppleDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info,
+void AppleDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
                                    const CompilerDeclContext &parent_decl_ctx,
                                    uint32_t name_type_mask,
                                    std::vector<DWARFDIE> &dies) {
   DIEArray offsets;
   m_apple_names_up->FindByName(name.GetStringRef(), offsets);
   for (const DIERef &die_ref : offsets) {
-    ProcessFunctionDIE(name.GetStringRef(), die_ref, info, parent_decl_ctx,
+    ProcessFunctionDIE(name.GetStringRef(), die_ref, dwarf, parent_decl_ctx,
                        name_type_mask, dies);
   }
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h Fri Jun 21 00:56:50 2019
@@ -42,7 +42,7 @@ public:
   void GetTypes(ConstString name, DIEArray &offsets) override;
   void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
   void GetNamespaces(ConstString name, DIEArray &offsets) override;
-  void GetFunctions(ConstString name, DWARFDebugInfo &info,
+  void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
                     const CompilerDeclContext &parent_decl_ctx,
                     uint32_t name_type_mask,
                     std::vector<DWARFDIE> &dies) override;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp Fri Jun 21 00:56:50 2019
@@ -11,8 +11,8 @@
 
 void llvm::format_provider<DIERef>::format(const DIERef &ref, raw_ostream &OS,
                                            StringRef Style) {
+  if (ref.dwo_num())
+    OS << format_hex_no_prefix(*ref.dwo_num(), 8) << "/";
   OS << (ref.section() == DIERef::DebugInfo ? "INFO" : "TYPE");
-  if (ref.unit_offset())
-    OS << "/" << format_hex_no_prefix(*ref.unit_offset(), 8);
   OS << "/" << format_hex_no_prefix(ref.die_offset(), 8);
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h Fri Jun 21 00:56:50 2019
@@ -12,42 +12,45 @@
 #include "lldb/Core/dwarf.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FormatProviders.h"
+#include <cassert>
 #include <vector>
 
 /// Identifies a DWARF debug info entry within a given Module. It contains three
 /// "coordinates":
-/// - section: identifies the section of the debug info entry: debug_info or
-///   debug_types
-/// - unit_offset: the offset of the unit containing the debug info entry. For
-///   regular (unsplit) units, this field is optional, as the die_offset is
-///   enough to uniquely identify the containing unit. For split units, this
-///   field must contain the offset of the skeleton unit in the main object
-///   file.
-/// - die_offset: The offset of te debug info entry as an absolute offset from
+/// - dwo_num: identifies the dwo file in the Module. If this field is not set,
+///   the DIERef references the main file.
+/// - section: identifies the section of the debug info entry in the given file:
+///   debug_info or debug_types.
+/// - die_offset: The offset of the debug info entry as an absolute offset from
 ///   the beginning of the section specified in the section field.
 class DIERef {
 public:
   enum Section : uint8_t { DebugInfo, DebugTypes };
 
-  DIERef(Section s, llvm::Optional<dw_offset_t> u, dw_offset_t d)
-      : m_section(s), m_unit_offset(u.getValueOr(DW_INVALID_OFFSET)),
-        m_die_offset(d) {}
-
-  Section section() const { return static_cast<Section>(m_section); }
+  DIERef(llvm::Optional<uint32_t> dwo_num, Section section,
+         dw_offset_t die_offset)
+      : m_dwo_num(dwo_num.getValueOr(0)), m_dwo_num_valid(bool(dwo_num)),
+        m_section(section), m_die_offset(die_offset) {
+    assert(this->dwo_num() == dwo_num && "Dwo number out of range?");
+  }
 
-  llvm::Optional<dw_offset_t> unit_offset() const {
-    if (m_unit_offset != DW_INVALID_OFFSET)
-      return m_unit_offset;
+  llvm::Optional<uint32_t> dwo_num() const {
+    if (m_dwo_num_valid)
+      return m_dwo_num;
     return llvm::None;
   }
 
+  Section section() const { return static_cast<Section>(m_section); }
+
   dw_offset_t die_offset() const { return m_die_offset; }
 
 private:
-  unsigned m_section : 1;
-  dw_offset_t m_unit_offset;
+  uint32_t m_dwo_num : 30;
+  uint32_t m_dwo_num_valid : 1;
+  uint32_t m_section : 1;
   dw_offset_t m_die_offset;
 };
+static_assert(sizeof(DIERef) == 8, "");
 
 typedef std::vector<DIERef> DIEArray;
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp Fri Jun 21 00:56:50 2019
@@ -21,10 +21,8 @@ llvm::Optional<DIERef> DWARFBaseDIE::Get
   if (!IsValid())
     return llvm::None;
 
-  dw_offset_t cu_offset = m_cu->GetOffset();
-  if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
-    cu_offset = m_cu->GetBaseObjOffset();
-  return DIERef(m_cu->GetDebugSection(), cu_offset, m_die->GetOffset());
+  return DIERef(m_cu->GetSymbolFileDWARF().GetDwoNum(), m_cu->GetDebugSection(),
+                m_die->GetOffset());
 }
 
 dw_tag_t DWARFBaseDIE::Tag() const {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp Fri Jun 21 00:56:50 2019
@@ -151,9 +151,9 @@ DWARFDIE::LookupDeepestBlock(lldb::addr_
         if (cu->ContainsDIEOffset(block_die->GetOffset()))
           return DWARFDIE(cu, block_die);
         else
-          return DWARFDIE(dwarf->DebugInfo()->GetUnit(
-                              DIERef(cu->GetDebugSection(), cu->GetOffset(),
-                                     block_die->GetOffset())),
+          return DWARFDIE(dwarf->DebugInfo()->GetUnit(DIERef(
+                              cu->GetSymbolFileDWARF().GetDwoNum(),
+                              cu->GetDebugSection(), block_die->GetOffset())),
                           block_die);
       }
     }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Fri Jun 21 00:56:50 2019
@@ -149,8 +149,6 @@ DWARFUnit *DWARFDebugInfo::GetUnitAtOffs
 }
 
 DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef &die_ref) {
-  if (die_ref.unit_offset())
-    return GetUnitAtOffset(die_ref.section(), *die_ref.unit_offset());
   return GetUnitContainingDIEOffset(die_ref.section(), die_ref.die_offset());
 }
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Fri Jun 21 00:56:50 2019
@@ -226,12 +226,6 @@ bool DWARFDebugInfoEntry::GetDIENamesAnd
     DWARFRangeList &ranges, int &decl_file, int &decl_line, int &decl_column,
     int &call_file, int &call_line, int &call_column,
     DWARFExpression *frame_base) const {
-  SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile();
-  if (dwo_symbol_file)
-    return GetDIENamesAndRanges(
-        dwo_symbol_file->GetCompileUnit(), name, mangled, ranges, decl_file,
-        decl_line, decl_column, call_file, call_line, call_column, frame_base);
-
   dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
   dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
   std::vector<DWARFDIE> dies;
@@ -611,16 +605,7 @@ dw_offset_t DWARFDebugInfoEntry::GetAttr
     const DWARFUnit *cu, const dw_attr_t attr, DWARFFormValue &form_value,
     dw_offset_t *end_attr_offset_ptr,
     bool check_specification_or_abstract_origin) const {
-  SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile();
-  if (dwo_symbol_file && m_tag != DW_TAG_compile_unit &&
-                         m_tag != DW_TAG_partial_unit)
-    return GetAttributeValue(dwo_symbol_file->GetCompileUnit(), attr,
-                             form_value, end_attr_offset_ptr,
-                             check_specification_or_abstract_origin);
-
-  auto abbrevDecl = GetAbbreviationDeclarationPtr(cu);
-
-  if (abbrevDecl) {
+  if (auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu)) {
     uint32_t attr_idx = abbrevDecl->FindAttributeIndex(attr);
 
     if (attr_idx != DW_INVALID_INDEX) {
@@ -665,6 +650,10 @@ dw_offset_t DWARFDebugInfoEntry::GetAttr
     }
   }
 
+  // If we're a unit DIE, also check the attributes of the dwo unit (if any).
+  if (GetParent())
+    return 0;
+  SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile();
   if (!dwo_symbol_file)
     return 0;
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp Fri Jun 21 00:56:50 2019
@@ -7,10 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
-
 #include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
 
 using namespace lldb_private;
 using namespace lldb;
@@ -18,11 +17,11 @@ using namespace lldb;
 DWARFIndex::~DWARFIndex() = default;
 
 void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
-                                    DWARFDebugInfo &info,
+                                    SymbolFileDWARF &dwarf,
                                     const CompilerDeclContext &parent_decl_ctx,
                                     uint32_t name_type_mask,
                                     std::vector<DWARFDIE> &dies) {
-  DWARFDIE die = info.GetDIE(ref);
+  DWARFDIE die = dwarf.GetDIE(ref);
   if (!die) {
     ReportInvalidDIERef(ref, name);
     return;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h Fri Jun 21 00:56:50 2019
@@ -13,7 +13,6 @@
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
 #include "Plugins/SymbolFile/DWARF/DWARFFormValue.h"
 
-class DWARFDebugInfo;
 class DWARFDeclContext;
 class DWARFDIE;
 
@@ -40,7 +39,7 @@ public:
   virtual void GetTypes(ConstString name, DIEArray &offsets) = 0;
   virtual void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) = 0;
   virtual void GetNamespaces(ConstString name, DIEArray &offsets) = 0;
-  virtual void GetFunctions(ConstString name, DWARFDebugInfo &info,
+  virtual void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
                             const CompilerDeclContext &parent_decl_ctx,
                             uint32_t name_type_mask,
                             std::vector<DWARFDIE> &dies) = 0;
@@ -58,7 +57,7 @@ protected:
   /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
   /// vector.
   void ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
-                          DWARFDebugInfo &info,
+                          SymbolFileDWARF &dwarf,
                           const CompilerDeclContext &parent_decl_ctx,
                           uint32_t name_type_mask, std::vector<DWARFDIE> &dies);
 };

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp Fri Jun 21 00:56:50 2019
@@ -363,7 +363,6 @@ void DWARFUnit::AddUnitDIE(const DWARFDe
   else if (gnu_ranges_base)
     dwo_cu->SetRangesBase(*gnu_ranges_base);
 
-  dwo_cu->SetBaseObjOffset(GetOffset());
   SetDwoStrOffsetsBase(dwo_cu);
 }
 
@@ -419,10 +418,6 @@ void DWARFUnit::SetRangesBase(dw_addr_t
   m_ranges_base = ranges_base;
 }
 
-void DWARFUnit::SetBaseObjOffset(dw_offset_t base_obj_offset) {
-  m_base_obj_offset = base_obj_offset;
-}
-
 void DWARFUnit::SetStrOffsetsBase(dw_offset_t str_offsets_base) {
   m_str_offsets_base = str_offsets_base;
 }
@@ -480,6 +475,12 @@ DWARFUnit::GetDIE(dw_offset_t die_offset
   return DWARFDIE(); // Not found
 }
 
+DWARFUnit &DWARFUnit::GetNonSkeletonUnit() {
+  if (SymbolFileDWARFDwo *dwo = GetDwoSymbolFile())
+    return *dwo->GetCompileUnit();
+  return *this;
+}
+
 uint8_t DWARFUnit::GetAddressByteSize(const DWARFUnit *cu) {
   if (cu)
     return cu->GetAddressByteSize();
@@ -719,8 +720,6 @@ SymbolFileDWARFDwo *DWARFUnit::GetDwoSym
   return m_dwo_symbol_file.get();
 }
 
-dw_offset_t DWARFUnit::GetBaseObjOffset() const { return m_base_obj_offset; }
-
 const DWARFDebugAranges &DWARFUnit::GetFunctionAranges() {
   if (m_func_aranges_up == nullptr) {
     m_func_aranges_up.reset(new DWARFDebugAranges());

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h Fri Jun 21 00:56:50 2019
@@ -148,7 +148,6 @@ public:
   dw_addr_t GetStrOffsetsBase() const { return m_str_offsets_base; }
   void SetAddrBase(dw_addr_t addr_base);
   void SetRangesBase(dw_addr_t ranges_base);
-  void SetBaseObjOffset(dw_offset_t base_obj_offset);
   void SetStrOffsetsBase(dw_offset_t str_offsets_base);
   virtual void BuildAddressRangeTable(DWARFDebugAranges *debug_aranges) = 0;
 
@@ -166,6 +165,8 @@ public:
 
   DWARFDIE GetDIE(dw_offset_t die_offset);
 
+  DWARFUnit &GetNonSkeletonUnit();
+
   static uint8_t GetAddressByteSize(const DWARFUnit *cu);
 
   static uint8_t GetDefaultAddressSize();
@@ -203,8 +204,6 @@ public:
 
   SymbolFileDWARFDwo *GetDwoSymbolFile() const;
 
-  dw_offset_t GetBaseObjOffset() const;
-
   die_iterator_range dies() {
     ExtractDIEsIfNeeded();
     return die_iterator_range(m_die_array.begin(), m_die_array.end());
@@ -284,9 +283,6 @@ protected:
   llvm::Optional<lldb_private::FileSpec> m_file_spec;
   dw_addr_t m_addr_base = 0;   // Value of DW_AT_addr_base
   dw_addr_t m_ranges_base = 0; // Value of DW_AT_ranges_base
-  // If this is a dwo compile unit this is the offset of the base compile unit
-  // in the main object file
-  dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET;
 
   /// Value of DW_AT_stmt_list.
   dw_offset_t m_line_table_offset = DW_INVALID_OFFSET;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp Fri Jun 21 00:56:50 2019
@@ -64,10 +64,11 @@ DebugNamesDWARFIndex::ToDIERef(const Deb
   // GetDwoSymbolFile to call this automatically because of mutual recursion
   // between this and DWARFDebugInfoEntry::GetAttributeValue.
   cu->ExtractUnitDIEIfNeeded();
-  uint64_t die_bias = cu->GetDwoSymbolFile() ? 0 : *cu_offset;
+  cu = &cu->GetNonSkeletonUnit();
 
   if (llvm::Optional<uint64_t> die_offset = entry.getDIEUnitOffset())
-    return DIERef(DIERef::Section::DebugInfo, *cu_offset, die_bias + *die_offset);
+    return DIERef(cu->GetSymbolFileDWARF().GetDwoNum(),
+                  DIERef::Section::DebugInfo, cu->GetOffset() + *die_offset);
 
   return llvm::None;
 }
@@ -165,8 +166,7 @@ void DebugNamesDWARFIndex::GetCompleteOb
     if (!ref)
       continue;
 
-    DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo,
-                                                 *ref->unit_offset());
+    DWARFUnit *cu = m_debug_info.GetUnit(*ref);
     if (!cu || !cu->Supports_DW_AT_APPLE_objc_complete_type()) {
       incomplete_types.push_back(*ref);
       continue;
@@ -222,12 +222,12 @@ void DebugNamesDWARFIndex::GetNamespaces
 }
 
 void DebugNamesDWARFIndex::GetFunctions(
-    ConstString name, DWARFDebugInfo &info,
+    ConstString name, SymbolFileDWARF &dwarf,
     const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
     std::vector<DWARFDIE> &dies) {
 
   std::vector<DWARFDIE> v;
-  m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, v);
+  m_fallback.GetFunctions(name, dwarf, parent_decl_ctx, name_type_mask, v);
 
   for (const DebugNames::Entry &entry :
        m_debug_names_up->equal_range(name.GetStringRef())) {
@@ -236,7 +236,7 @@ void DebugNamesDWARFIndex::GetFunctions(
       continue;
 
     if (llvm::Optional<DIERef> ref = ToDIERef(entry))
-      ProcessFunctionDIE(name.GetStringRef(), *ref, info, parent_decl_ctx,
+      ProcessFunctionDIE(name.GetStringRef(), *ref, dwarf, parent_decl_ctx,
                          name_type_mask, v);
   }
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h Fri Jun 21 00:56:50 2019
@@ -34,7 +34,7 @@ public:
   void GetTypes(ConstString name, DIEArray &offsets) override;
   void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
   void GetNamespaces(ConstString name, DIEArray &offsets) override;
-  void GetFunctions(ConstString name, DWARFDebugInfo &info,
+  void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
                     const CompilerDeclContext &parent_decl_ctx,
                     uint32_t name_type_mask,
                     std::vector<DWARFDIE> &dies) override;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Fri Jun 21 00:56:50 2019
@@ -61,7 +61,7 @@ public:
     DIEInfo(dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h);
 
     explicit operator DIERef() const {
-      return DIERef(DIERef::Section::DebugInfo, llvm::None, die_offset);
+      return DIERef(llvm::None, DIERef::Section::DebugInfo, die_offset);
     }
   };
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp Fri Jun 21 00:56:50 2019
@@ -102,18 +102,17 @@ void ManualDWARFIndex::IndexUnit(DWARFUn
 
   const LanguageType cu_language = unit.GetLanguageType();
 
-  IndexUnitImpl(unit, cu_language, unit.GetOffset(), set);
+  IndexUnitImpl(unit, cu_language, set);
 
   SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile();
   if (dwo_symbol_file && dwo_symbol_file->GetCompileUnit()) {
-    IndexUnitImpl(*dwo_symbol_file->GetCompileUnit(), cu_language,
-                  unit.GetOffset(), set);
+    IndexUnitImpl(*dwo_symbol_file->GetCompileUnit(), cu_language, set);
   }
 }
 
-void ManualDWARFIndex::IndexUnitImpl(
-    DWARFUnit &unit, const LanguageType cu_language,
-    const dw_offset_t cu_offset, IndexSet &set) {
+void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
+                                     const LanguageType cu_language,
+                                     IndexSet &set) {
   for (const DWARFDebugInfoEntry &die : unit.dies()) {
     const dw_tag_t tag = die.Tag();
 
@@ -243,7 +242,7 @@ void ManualDWARFIndex::IndexUnitImpl(
       }
     }
 
-    DIERef ref(unit.GetDebugSection(), cu_offset, die.GetOffset());
+    DIERef ref = *DWARFDIE(&unit, &die).GetDIERef();
     switch (tag) {
     case DW_TAG_inlined_subroutine:
     case DW_TAG_subprogram:
@@ -358,10 +357,10 @@ void ManualDWARFIndex::GetGlobalVariable
   m_set.globals.Find(regex, offsets);
 }
 
-void ManualDWARFIndex::GetGlobalVariables(const DWARFUnit &cu,
+void ManualDWARFIndex::GetGlobalVariables(const DWARFUnit &unit,
                                           DIEArray &offsets) {
   Index();
-  m_set.globals.FindAllEntriesForCompileUnit(cu.GetOffset(), offsets);
+  m_set.globals.FindAllEntriesForUnit(unit, offsets);
 }
 
 void ManualDWARFIndex::GetObjCMethods(ConstString class_name,
@@ -393,7 +392,7 @@ void ManualDWARFIndex::GetNamespaces(Con
   m_set.namespaces.Find(name, offsets);
 }
 
-void ManualDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info,
+void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
                                     const CompilerDeclContext &parent_decl_ctx,
                                     uint32_t name_type_mask,
                                     std::vector<DWARFDIE> &dies) {
@@ -405,7 +404,7 @@ void ManualDWARFIndex::GetFunctions(Cons
     m_set.function_methods.Find(name, offsets);
     m_set.function_fullnames.Find(name, offsets);
     for (const DIERef &die_ref: offsets) {
-      DWARFDIE die = info.GetDIE(die_ref);
+      DWARFDIE die = dwarf.GetDIE(die_ref);
       if (!die)
         continue;
       if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
@@ -416,7 +415,7 @@ void ManualDWARFIndex::GetFunctions(Cons
     DIEArray offsets;
     m_set.function_basenames.Find(name, offsets);
     for (const DIERef &die_ref: offsets) {
-      DWARFDIE die = info.GetDIE(die_ref);
+      DWARFDIE die = dwarf.GetDIE(die_ref);
       if (!die)
         continue;
       if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
@@ -429,7 +428,7 @@ void ManualDWARFIndex::GetFunctions(Cons
     DIEArray offsets;
     m_set.function_methods.Find(name, offsets);
     for (const DIERef &die_ref: offsets) {
-      if (DWARFDIE die = info.GetDIE(die_ref))
+      if (DWARFDIE die = dwarf.GetDIE(die_ref))
         dies.push_back(die);
     }
   }
@@ -439,7 +438,7 @@ void ManualDWARFIndex::GetFunctions(Cons
     DIEArray offsets;
     m_set.function_selectors.Find(name, offsets);
     for (const DIERef &die_ref: offsets) {
-      if (DWARFDIE die = info.GetDIE(die_ref))
+      if (DWARFDIE die = dwarf.GetDIE(die_ref))
         dies.push_back(die);
     }
   }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h Fri Jun 21 00:56:50 2019
@@ -13,6 +13,8 @@
 #include "Plugins/SymbolFile/DWARF/NameToDIE.h"
 #include "llvm/ADT/DenseSet.h"
 
+class DWARFDebugInfo;
+
 namespace lldb_private {
 class ManualDWARFIndex : public DWARFIndex {
 public:
@@ -26,14 +28,14 @@ public:
   void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
   void GetGlobalVariables(const RegularExpression &regex,
                           DIEArray &offsets) override;
-  void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override;
+  void GetGlobalVariables(const DWARFUnit &unit, DIEArray &offsets) override;
   void GetObjCMethods(ConstString class_name, DIEArray &offsets) override;
   void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
                             DIEArray &offsets) override;
   void GetTypes(ConstString name, DIEArray &offsets) override;
   void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
   void GetNamespaces(ConstString name, DIEArray &offsets) override;
-  void GetFunctions(ConstString name, DWARFDebugInfo &info,
+  void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
                     const CompilerDeclContext &parent_decl_ctx,
                     uint32_t name_type_mask,
                     std::vector<DWARFDIE> &dies) override;
@@ -56,9 +58,9 @@ private:
   void Index();
   void IndexUnit(DWARFUnit &unit, IndexSet &set);
 
-  static void
-  IndexUnitImpl(DWARFUnit &unit, const lldb::LanguageType cu_language,
-                const dw_offset_t cu_offset, IndexSet &set);
+  static void IndexUnitImpl(DWARFUnit &unit,
+                            const lldb::LanguageType cu_language,
+                            IndexSet &set);
 
   /// Non-null value means we haven't built the index yet.
   DWARFDebugInfo *m_debug_info;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp Fri Jun 21 00:56:50 2019
@@ -7,16 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "NameToDIE.h"
+#include "DWARFUnit.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StreamString.h"
 
-#include "DWARFDebugInfo.h"
-#include "DWARFDebugInfoEntry.h"
-#include "SymbolFileDWARF.h"
-
 using namespace lldb;
 using namespace lldb_private;
 
@@ -26,7 +23,6 @@ void NameToDIE::Finalize() {
 }
 
 void NameToDIE::Insert(ConstString name, const DIERef &die_ref) {
-  assert(die_ref.unit_offset().hasValue());
   m_map.Append(name, die_ref);
 }
 
@@ -39,13 +35,16 @@ size_t NameToDIE::Find(const RegularExpr
   return m_map.GetValues(regex, info_array);
 }
 
-size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
-                                               DIEArray &info_array) const {
+size_t NameToDIE::FindAllEntriesForUnit(const DWARFUnit &unit,
+                                        DIEArray &info_array) const {
   const size_t initial_size = info_array.size();
   const uint32_t size = m_map.GetSize();
   for (uint32_t i = 0; i < size; ++i) {
     const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
-    if (cu_offset == *die_ref.unit_offset())
+    if (unit.GetSymbolFileDWARF().GetDwoNum() == die_ref.dwo_num() &&
+        unit.GetDebugSection() == die_ref.section() &&
+        unit.GetOffset() <= die_ref.die_offset() &&
+        die_ref.die_offset() < unit.GetNextUnitOffset())
       info_array.push_back(die_ref);
   }
   return info_array.size() - initial_size;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h Fri Jun 21 00:56:50 2019
@@ -16,7 +16,7 @@
 #include "lldb/Core/dwarf.h"
 #include "lldb/lldb-defines.h"
 
-class SymbolFileDWARF;
+class DWARFUnit;
 
 class NameToDIE {
 public:
@@ -38,8 +38,8 @@ public:
   size_t Find(const lldb_private::RegularExpression &regex,
               DIEArray &info_array) const;
 
-  size_t FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
-                                      DIEArray &info_array) const;
+  size_t FindAllEntriesForUnit(const DWARFUnit &unit,
+                               DIEArray &info_array) const;
 
   void
   ForEach(std::function<bool(lldb_private::ConstString name,

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Jun 21 00:56:50 2019
@@ -1199,6 +1199,15 @@ void SymbolFileDWARF::ParseDeclsForConte
       ast_parser->GetDeclForUIDFromDWARF(decl);
 }
 
+user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
+  if (GetDebugMapSymfile())
+    return GetID() | ref.die_offset();
+
+  return user_id_t(GetDwoNum().getValueOr(0x7fffffff)) << 32 |
+         ref.die_offset() |
+         (lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63);
+}
+
 llvm::Optional<SymbolFileDWARF::DecodedUID>
 SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) {
   // This method can be called without going through the symbol vendor so we
@@ -1215,25 +1224,20 @@ SymbolFileDWARF::DecodeUID(lldb::user_id
     SymbolFileDWARF *dwarf = debug_map->GetSymbolFileByOSOIndex(
         debug_map->GetOSOIndexFromUserID(uid));
     return DecodedUID{
-        *dwarf,
-        {DIERef::Section::DebugInfo, DW_INVALID_OFFSET, dw_offset_t(uid)}};
+        *dwarf, {llvm::None, DIERef::Section::DebugInfo, dw_offset_t(uid)}};
   }
-  DIERef::Section section =
-      uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo;
-  uint32_t dwarf_id = uid >> 32 & 0x7fffffff;
   dw_offset_t die_offset = uid;
-
   if (die_offset == DW_INVALID_OFFSET)
     return llvm::None;
 
-  SymbolFileDWARF *dwarf = this;
-  if (DebugInfo()) {
-    if (DWARFUnit *unit = DebugInfo()->GetUnitAtIndex(dwarf_id)) {
-      if (unit->GetDwoSymbolFile())
-        dwarf = unit->GetDwoSymbolFile();
-    }
-  }
-  return DecodedUID{*dwarf, {section, DW_INVALID_OFFSET, die_offset}};
+  DIERef::Section section =
+      uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo;
+
+  llvm::Optional<uint32_t> dwo_num = uid >> 32 & 0x7fffffff;
+  if (*dwo_num == 0x7fffffff)
+    dwo_num = llvm::None;
+
+  return DecodedUID{*this, {dwo_num, section, die_offset}};
 }
 
 DWARFDIE
@@ -1493,6 +1497,14 @@ lldb::ModuleSP SymbolFileDWARF::GetDWOMo
 
 DWARFDIE
 SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
+  if (die_ref.dwo_num()) {
+    return DebugInfo()
+        ->GetUnitAtIndex(*die_ref.dwo_num())
+        ->GetDwoSymbolFile()
+        ->GetDIE(die_ref);
+  }
+
+
   DWARFDebugInfo *debug_info = DebugInfo();
   if (debug_info)
     return debug_info->GetDIE(die_ref);
@@ -2235,10 +2247,6 @@ uint32_t SymbolFileDWARF::FindFunctions(
 
   const uint32_t original_size = sc_list.GetSize();
 
-  DWARFDebugInfo *info = DebugInfo();
-  if (info == nullptr)
-    return 0;
-
   llvm::DenseSet<const DWARFDebugInfoEntry *> resolved_dies;
   DIEArray offsets;
   CompilerDeclContext empty_decl_ctx;
@@ -2246,7 +2254,7 @@ uint32_t SymbolFileDWARF::FindFunctions(
     parent_decl_ctx = &empty_decl_ctx;
 
   std::vector<DWARFDIE> dies;
-  m_index->GetFunctions(name, *info, *parent_decl_ctx, name_type_mask, dies);
+  m_index->GetFunctions(name, *this, *parent_decl_ctx, name_type_mask, dies);
   for (const DWARFDIE &die: dies) {
     if (resolved_dies.insert(die.GetDIE()).second)
       ResolveFunction(die, include_inlines, sc_list);
@@ -3081,7 +3089,8 @@ size_t SymbolFileDWARF::ParseVariablesFo
         sc.comp_unit->SetVariableList(variables);
 
         DIEArray die_offsets;
-        m_index->GetGlobalVariables(*dwarf_cu, die_offsets);
+        m_index->GetGlobalVariables(dwarf_cu->GetNonSkeletonUnit(),
+                                    die_offsets);
         const size_t num_matches = die_offsets.size();
         if (num_matches) {
           for (size_t i = 0; i < num_matches; ++i) {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Jun 21 00:56:50 2019
@@ -275,11 +275,7 @@ public:
     return ref ? GetUID(*ref) : LLDB_INVALID_UID;
   }
 
-  lldb::user_id_t GetUID(const DIERef &ref) {
-    return GetID() | ref.die_offset() |
-           (lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes)
-            << 63);
-  }
+  lldb::user_id_t GetUID(DIERef ref);
 
   virtual std::unique_ptr<SymbolFileDWARFDwo>
   GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
@@ -290,6 +286,8 @@ public:
   // the method returns a pointer to the base compile unit.
   virtual DWARFCompileUnit *GetBaseCompileUnit() { return nullptr; }
 
+  virtual llvm::Optional<uint32_t> GetDwoNum() { return llvm::None; }
+
   static bool
   DIEInDeclContext(const lldb_private::CompilerDeclContext *parent_decl_ctx,
                    const DWARFDIE &die);

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp Fri Jun 21 00:56:50 2019
@@ -124,8 +124,7 @@ SymbolFileDWARFDwo::GetTypeSystemForLang
 
 DWARFDIE
 SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) {
-  lldbassert(!die_ref.unit_offset() ||
-             *die_ref.unit_offset() == m_base_dwarf_cu.GetOffset());
-  return DebugInfo()->GetDIEForDIEOffset(die_ref.section(),
-                                         die_ref.die_offset());
+  if (*die_ref.dwo_num() == GetDwoNum())
+    return DebugInfo()->GetDIE(die_ref);
+  return GetBaseSymbolFile().GetDIE(die_ref);
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h?rev=364009&r1=364008&r2=364009&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h Fri Jun 21 00:56:50 2019
@@ -44,6 +44,8 @@ public:
 
   DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; }
 
+  llvm::Optional<uint32_t> GetDwoNum() override { return GetID() >> 32; }
+
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
                        lldb_private::DWARFDataExtractor &data) override;




More information about the lldb-commits mailing list