scott.smith created this revision.
Loading a shared library can require a large amount of work; rather than do
that serially for each library, provide a mechanism to do some amount of
priming before hand.
Repository:
rL LLVM
https://reviews.llvm.org/D32598
Files:
include/lldb/Core/Module.h
include/lldb/Symbol/SymbolFile.h
include/lldb/Symbol/Symtab.h
source/Core/Module.cpp
source/Core/ModuleList.cpp
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
source/Symbol/SymbolFile.cpp
source/Symbol/Symtab.cpp
Index: source/Symbol/Symtab.cpp
===================================================================
--- source/Symbol/Symtab.cpp
+++ source/Symbol/Symtab.cpp
@@ -425,6 +425,12 @@
}
}
+void Symtab::PrimeCaches()
+{
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ InitNameIndexes();
+}
+
void Symtab::AppendSymbolNamesToMap(const IndexCollection &indexes,
bool add_demangled, bool add_mangled,
NameToIndexMap &name_to_index_map) const {
Index: source/Symbol/SymbolFile.cpp
===================================================================
--- source/Symbol/SymbolFile.cpp
+++ source/Symbol/SymbolFile.cpp
@@ -21,6 +21,10 @@
using namespace lldb_private;
+void SymbolFile::PrimeCaches() {
+ // No-op for most implementations.
+}
+
SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
std::unique_ptr<SymbolFile> best_symfile_ap;
if (obj_file != nullptr) {
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -226,6 +226,8 @@
const lldb_private::ConstString &name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
+ void PrimeCaches() override;
+
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1917,6 +1917,12 @@
return sc_list.GetSize() - prev_size;
}
+void SymbolFileDWARF::PrimeCaches() {
+ std::lock_guard<std::recursive_mutex> guard(
+ GetObjectFile()->GetModule()->GetMutex());
+ Index();
+}
+
void SymbolFileDWARF::Index() {
if (m_indexed)
return;
Index: source/Core/ModuleList.cpp
===================================================================
--- source/Core/ModuleList.cpp
+++ source/Core/ModuleList.cpp
@@ -103,6 +103,11 @@
void ModuleList::AppendImpl(const ModuleSP &module_sp, bool use_notifier) {
if (module_sp) {
+ // Do this outside of the lock for parallelism, in case we're called from a
+ // separate thread.
+ if (use_notifier && m_notifier)
+ module_sp->PrimeCaches();
+
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
m_modules.push_back(module_sp);
if (use_notifier && m_notifier)
Index: source/Core/Module.cpp
===================================================================
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -140,7 +140,7 @@
const bool mandatory = true;
ModuleList::RemoveOrphanSharedModules(mandatory);
}
-
+
void
DumpModuleInfo (void)
{
@@ -150,15 +150,15 @@
printf ("%s: %" PRIu64 " modules:\n", LLVM_PRETTY_FUNCTION, (uint64_t)count);
for (size_t i = 0; i < count; ++i)
{
-
+
StreamString strm;
Module *module = modules[i];
const bool in_shared_module_list = ModuleList::ModuleIsInCache (module);
module->GetDescription(&strm, eDescriptionLevelFull);
- printf ("%p: shared = %i, ref_count = %3u, module = %s\n",
- module,
+ printf ("%p: shared = %i, ref_count = %3u, module = %s\n",
+ module,
in_shared_module_list,
- (uint32_t)module->use_count(),
+ (uint32_t)module->use_count(),
strm.GetString().c_str());
}
}
@@ -1432,6 +1432,22 @@
return sc_list.GetSize() - initial_size;
}
+void Module::PrimeCaches() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ SymbolVendor * sym_vendor = GetSymbolVendor();
+ if (!sym_vendor) {
+ return;
+ }
+ // Prime the symbol file first, since it adds symbols to the symbol table.
+ if (SymbolFile *symbol_file = sym_vendor->GetSymbolFile()) {
+ symbol_file->PrimeCaches();
+ }
+ // Now we can prime the symbol table.
+ if (Symtab * symtab = sym_vendor->GetSymtab()) {
+ symtab->PrimeCaches();
+ }
+}
+
void Module::SetSymbolFileFileSpec(const FileSpec &file) {
if (!file.Exists())
return;
Index: include/lldb/Symbol/Symtab.h
===================================================================
--- include/lldb/Symbol/Symtab.h
+++ include/lldb/Symbol/Symtab.h
@@ -40,6 +40,7 @@
Symtab(ObjectFile *objfile);
~Symtab();
+ void PrimeCaches();
void Reserve(size_t count);
Symbol *Resize(size_t count);
uint32_t AddSymbol(const Symbol &symbol);
Index: include/lldb/Symbol/SymbolFile.h
===================================================================
--- include/lldb/Symbol/SymbolFile.h
+++ include/lldb/Symbol/SymbolFile.h
@@ -180,6 +180,8 @@
uint32_t type_mask,
lldb_private::TypeList &type_list) = 0;
+ virtual void PrimeCaches();
+
virtual lldb_private::TypeSystem *
GetTypeSystemForLanguage(lldb::LanguageType language);
Index: include/lldb/Core/Module.h
===================================================================
--- include/lldb/Core/Module.h
+++ include/lldb/Core/Module.h
@@ -614,6 +614,8 @@
const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; }
+ void PrimeCaches();
+
void SetSymbolFileFileSpec(const FileSpec &file);
const llvm::sys::TimePoint<> &GetModificationTime() const {
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits