[Lldb-commits] [lldb] r318554 - [lldb] Ensure that dwo/dwp are not double-indexed

Alexander Shaposhnikov via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 17 12:50:54 PST 2017


Author: alexshap
Date: Fri Nov 17 12:50:54 2017
New Revision: 318554

URL: http://llvm.org/viewvc/llvm-project?rev=318554&view=rev
Log:
[lldb] Ensure that dwo/dwp are not double-indexed

DWO/DWP should not be indexed directly.
Instead, the corresponding base file should be used.
This diff adds an assert to DWARFCompileUnit::Index
and adjusts the methods 
SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE,
SymbolFileDWARF::GetObjCMethodDIEOffsets accordingly.

Differential revision: https://reviews.llvm.org/D39825

Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
    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/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=318554&r1=318553&r2=318554&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Fri Nov 17 12:50:54 2017
@@ -620,6 +620,10 @@ void DWARFCompileUnit::Index(NameToDIE &
                              NameToDIE &objc_class_selectors,
                              NameToDIE &globals, NameToDIE &types,
                              NameToDIE &namespaces) {
+  assert(!m_dwarf2Data->GetBaseCompileUnit() &&
+         "DWARFCompileUnit associated with .dwo or .dwp "
+         "should not be indexed directly");
+
   Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
 
   if (log) {

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=318554&r1=318553&r2=318554&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Nov 17 12:50:54 2017
@@ -209,6 +209,10 @@ static const char *resolveCompDir(const
   return nullptr;
 }
 
+DWARFCompileUnit *SymbolFileDWARF::GetBaseCompileUnit() {
+  return nullptr;
+}
+
 void SymbolFileDWARF::Initialize() {
   LogChannelDWARF::Initialize();
   PluginManager::RegisterPlugin(GetPluginNameStatic(),

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=318554&r1=318553&r2=318554&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Nov 17 12:50:54 2017
@@ -276,8 +276,8 @@ public:
   GetCompUnitForDWARFCompUnit(DWARFCompileUnit *dwarf_cu,
                               uint32_t cu_idx = UINT32_MAX);
 
-  size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name,
-                                 DIEArray &method_die_offsets);
+  virtual size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name,
+                                         DIEArray &method_die_offsets);
 
   bool Supports_DW_AT_APPLE_objc_complete_type(DWARFCompileUnit *cu);
 
@@ -299,6 +299,11 @@ public:
   GetDwoSymbolFileForCompileUnit(DWARFCompileUnit &dwarf_cu,
                                  const DWARFDebugInfoEntry &cu_die);
 
+  // For regular SymbolFileDWARF instances the method returns nullptr,
+  // for the instances of the subclass SymbolFileDWARFDwo
+  // the method returns a pointer to the base compile unit.
+  virtual DWARFCompileUnit *GetBaseCompileUnit();
+
 protected:
   typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>
       DIEToTypePtr;
@@ -392,7 +397,7 @@ protected:
   virtual lldb::TypeSP
   FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx);
 
-  lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
+  virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
       const DWARFDIE &die, const lldb_private::ConstString &type_name,
       bool must_be_implementation);
 

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=318554&r1=318553&r2=318554&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp Fri Nov 17 12:50:54 2017
@@ -99,6 +99,12 @@ SymbolFileDWARFDwo::GetForwardDeclClangT
   return GetBaseSymbolFile()->GetForwardDeclClangTypeToDie();
 }
 
+size_t SymbolFileDWARFDwo::GetObjCMethodDIEOffsets(
+    lldb_private::ConstString class_name, DIEArray &method_die_offsets) {
+  return GetBaseSymbolFile()->GetObjCMethodDIEOffsets(
+      class_name, method_die_offsets);
+}
+
 UniqueDWARFASTTypeMap &SymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap() {
   return GetBaseSymbolFile()->GetUniqueDWARFASTTypeMap();
 }
@@ -109,6 +115,17 @@ lldb::TypeSP SymbolFileDWARFDwo::FindDef
       die_decl_ctx);
 }
 
+lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
+    const DWARFDIE &die, const lldb_private::ConstString &type_name,
+    bool must_be_implementation) {
+  return GetBaseSymbolFile()->FindCompleteObjCDefinitionTypeForDIE(
+      die, type_name, must_be_implementation);
+}
+
+DWARFCompileUnit *SymbolFileDWARFDwo::GetBaseCompileUnit() {
+  return m_base_dwarf_cu;
+}
+
 SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
   return m_base_dwarf_cu->GetSymbolFileDWARF();
 }

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=318554&r1=318553&r2=318554&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h Fri Nov 17 12:50:54 2017
@@ -33,6 +33,9 @@ public:
   lldb_private::DWARFExpression::LocationListFormat
   GetLocationListFormat() const override;
 
+  size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name,
+                                 DIEArray &method_die_offsets) override;
+
   lldb_private::TypeSystem *
   GetTypeSystemForLanguage(lldb::LanguageType language) override;
 
@@ -45,6 +48,8 @@ public:
     return nullptr;
   }
 
+  DWARFCompileUnit *GetBaseCompileUnit() override;
+
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
                        lldb_private::DWARFDataExtractor &data) override;
@@ -62,6 +67,10 @@ protected:
   lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
       const DWARFDeclContext &die_decl_ctx) override;
 
+  lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
+      const DWARFDIE &die, const lldb_private::ConstString &type_name,
+      bool must_be_implementation) override;
+
   SymbolFileDWARF *GetBaseSymbolFile();
 
   lldb::ObjectFileSP m_obj_file_sp;




More information about the lldb-commits mailing list