[Lldb-commits] [PATCH] D40474: DWZ 09/11: Main functionality

2018-03-18 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 138860.

https://reviews.llvm.org/D40474

Files:
  include/lldb/Utility/ConstString.h
  include/lldb/Utility/FileSpec.h
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnitDWZ.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFileOffset.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFileOffset.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFPartialUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFPartialUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -18,10 +18,12 @@
 #include 
 #include 
 #include 
+#include 
 
 // Other libraries and framework includes
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/RWMutex.h"
 
 #include "lldb/Utility/Flags.h"
 
@@ -312,6 +314,13 @@
   // the method returns a pointer to the base compile unit.
   virtual DWARFUnit *GetBaseCompileUnit();
 
+  SymbolFileDWARF *GetDWZSymbolFile() const {
+if (!m_dwz_common_file)
+  return nullptr;
+return m_dwz_common_file->SymbolFile();
+  }
+  bool GetIsDWZ() const { return m_is_dwz; }
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
@@ -473,6 +482,44 @@
 
   SymbolFileDWARFDwp *GetDwpSymbolFile();
 
+  void InitializeDWZ();
+
+  class DWZCommonFile {
+  public:
+// C++14: Use heterogenous lookup.
+DWZCommonFile(const lldb_private::FileSpec _ref);
+DWZCommonFile(std::unique_ptr symbol_file,
+lldb::ObjectFileSP obj_file, lldb::ModuleSP module);
+SymbolFileDWARF *SymbolFile() const { return m_symbol_file.get(); }
+
+bool operator==(const DWZCommonFile ) const {
+  return m_filespec_ref == rhs.m_filespec_ref;
+}
+bool operator!=(const DWZCommonFile ) const { return !(*this == rhs); }
+class Hasher {
+public:
+  size_t operator()(const DWZCommonFile ) const {
+return lldb_private::FileSpec::Hasher()(key.m_filespec_ref);
+  }
+};
+
+size_t m_use_count = 0;
+
+  private:
+std::unique_ptr m_symbol_file;
+lldb::ObjectFileSP m_obj_file;
+lldb::ModuleSP m_module;
+const lldb_private::FileSpec _filespec_ref;
+
+DISALLOW_COPY_AND_ASSIGN(DWZCommonFile);
+  };
+  DWZCommonFile *m_dwz_common_file = nullptr;
+  void DWZCommonFileClear();
+  static std::unordered_set
+  m_filespec_to_dwzcommonfile;
+  static llvm::sys::RWMutex m_filespec_to_dwzcommonfile_mutex;
+  bool m_is_dwz = false;
+
   lldb::ModuleWP m_debug_map_module_wp;
   SymbolFileDWARFDebugMap *m_debug_map_symfile;
 
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -410,7 +410,9 @@
   m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(),
   m_unique_ast_type_map() {}
 
-SymbolFileDWARF::~SymbolFileDWARF() {}
+SymbolFileDWARF::~SymbolFileDWARF() {
+  DWZCommonFileClear();
+}
 
 static const ConstString () {
   static ConstString g_dwarf_section_name("__DWARF");
@@ -426,6 +428,7 @@
 }
 
 TypeSystem *SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType language) {
+  lldbassert(!GetIsDWZ());
   SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
   TypeSystem *type_system;
   if (debug_map_symfile) {
@@ -488,6 +491,8 @@
 else
   m_apple_objc_ap.reset();
   }
+
+  InitializeDWZ();
 }
 
 bool SymbolFileDWARF::SupportedVersion(uint16_t version) {
@@ -2056,6 +2061,8 @@
   if (dwarf_cu) {
 // dwarf_cu->ExtractDIEsIfNeeded(false) will return zero if the
 // DIEs for a compile unit have already been parsed.
+// While DW_TAG_partial_unit will not be indexed directly each such
+// unit will be used by some other unit of this SymbolFileDWARF.
 if (dwarf_cu->ExtractDIEsIfNeeded(false) > 1)
   clear_cu_dies[cu_idx] = true;
   }
@@ -4390,3 +4397,134 @@
   });
   return m_dwp_symfile.get();
 }
+
+std::unordered_set
+SymbolFileDWARF::m_filespec_to_dwzcommonfile;
+llvm::sys::RWMutex 

[Lldb-commits] [PATCH] D40474: DWZ 09/11: Main functionality

2018-03-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added a reviewer: davide.
labath added a comment.

I think the most controversial issue here is the testing... davide may have 
some thoughts on that.




Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4529
+SymbolFileDWARF::DWZCommonFile::DWZCommonFile(
+std::unique_ptr &_file,
+lldb::ObjectFileSP &_file, lldb::ModuleSP &)

the references are superfluous here (this just caught my eye because it's at 
the bottom of the patch).


https://reviews.llvm.org/D40474



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D40474: DWZ 09/11: Main functionality

2018-03-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Too many changes to give the whole thing the OK to checkin. I will worry about 
each one as an individual patch. 02/11 next.


https://reviews.llvm.org/D40474



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D40474: DWZ 09/11: Main functionality

2018-03-11 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

ping: Are there more comments how to make this whole patchset accepted 
upstream? Thanks.


https://reviews.llvm.org/D40474



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D40474: DWZ 09/11: Main functionality

2018-02-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 135060.
jankratochvil marked an inline comment as done.
jankratochvil retitled this revision from "DWZ 11/12: Main functionality" to 
"DWZ 09/11: Main functionality".

https://reviews.llvm.org/D40474

Files:
  include/lldb/Utility/ConstString.h
  include/lldb/Utility/FileSpec.h
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnitDWZ.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFileOffset.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFileOffset.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFPartialUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFPartialUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -18,10 +18,12 @@
 #include 
 #include 
 #include 
+#include 
 
 // Other libraries and framework includes
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/RWMutex.h"
 
 #include "lldb/Utility/Flags.h"
 
@@ -312,6 +314,13 @@
   // the method returns a pointer to the base compile unit.
   virtual DWARFUnit *GetBaseCompileUnit();
 
+  SymbolFileDWARF *GetDWZSymbolFile() const {
+if (!m_dwz_common_file)
+  return nullptr;
+return m_dwz_common_file->SymbolFile();
+  }
+  bool GetIsDWZ() const { return m_is_dwz; }
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
@@ -473,6 +482,44 @@
 
   SymbolFileDWARFDwp *GetDwpSymbolFile();
 
+  void InitializeDWZ();
+
+  class DWZCommonFile {
+  public:
+// C++14: Use heterogenous lookup.
+DWZCommonFile(const lldb_private::FileSpec _ref);
+DWZCommonFile(std::unique_ptr &_file,
+lldb::ObjectFileSP &_file, lldb::ModuleSP &);
+SymbolFileDWARF *SymbolFile() const { return m_symbol_file.get(); }
+
+bool operator==(const DWZCommonFile ) const {
+  return m_filespec_ref == rhs.m_filespec_ref;
+}
+bool operator!=(const DWZCommonFile ) const { return !(*this == rhs); }
+class Hasher {
+public:
+  size_t operator()(const DWZCommonFile ) const {
+return lldb_private::FileSpec::Hasher()(key.m_filespec_ref);
+  }
+};
+
+size_t m_use_count = 0;
+
+  private:
+std::unique_ptr m_symbol_file;
+lldb::ObjectFileSP m_obj_file;
+lldb::ModuleSP m_module;
+const lldb_private::FileSpec _filespec_ref;
+
+DISALLOW_COPY_AND_ASSIGN(DWZCommonFile);
+  };
+  DWZCommonFile *m_dwz_common_file = nullptr;
+  void DWZCommonFileClear();
+  static std::unordered_set
+  m_filespec_to_dwzcommonfile;
+  static llvm::sys::RWMutex m_filespec_to_dwzcommonfile_mutex;
+  bool m_is_dwz = false;
+
   lldb::ModuleWP m_debug_map_module_wp;
   SymbolFileDWARFDebugMap *m_debug_map_symfile;
 
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -410,7 +410,9 @@
   m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(),
   m_unique_ast_type_map() {}
 
-SymbolFileDWARF::~SymbolFileDWARF() {}
+SymbolFileDWARF::~SymbolFileDWARF() {
+  DWZCommonFileClear();
+}
 
 static const ConstString () {
   static ConstString g_dwarf_section_name("__DWARF");
@@ -426,6 +428,7 @@
 }
 
 TypeSystem *SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType language) {
+  lldbassert(!GetIsDWZ());
   SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
   TypeSystem *type_system;
   if (debug_map_symfile) {
@@ -488,6 +491,8 @@
 else
   m_apple_objc_ap.reset();
   }
+
+  InitializeDWZ();
 }
 
 bool SymbolFileDWARF::SupportedVersion(uint16_t version) {
@@ -2055,6 +2060,8 @@
   if (dwarf_cu) {
 // dwarf_cu->ExtractDIEsIfNeeded(false) will return zero if the
 // DIEs for a compile unit have already been parsed.
+// While DW_TAG_partial_unit will not be indexed directly each such
+// unit will be used by some other unit of this SymbolFileDWARF.
 if (dwarf_cu->ExtractDIEsIfNeeded(false) > 1)
   clear_cu_dies[cu_idx] = true;
   }
@@ -4392,3 +4399,134 @@
   });
   return m_dwp_symfile.get();
 }
+
+std::unordered_set