diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -181,7 +181,6 @@ virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0; virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0; - /// The characteristics of an array type. struct ArrayInfo { int64_t first_index = 0; @@ -236,6 +235,15 @@ llvm::DenseSet &searched_symbol_files, TypeMap &types); + // Find types in a specific scope. + // \param scope + // Must be either the fully qualified scope (without leading ::) or empty + virtual void + FindTypes(ConstString name, ConstString scope, + const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, + llvm::DenseSet &searched_symbol_files, + TypeMap &types); + /// Find types specified by a CompilerContextPattern. /// \param languages /// Only return results in these languages. @@ -318,19 +326,14 @@ /// /// \returns 0.0 if no information has been parsed or if there is /// no computational cost to parsing the debug information. - virtual StatsDuration GetDebugInfoParseTime() { - return StatsDuration(0.0); - } + virtual StatsDuration GetDebugInfoParseTime() { return StatsDuration(0.0); } /// Return the time it took to index the debug information in the object /// file. /// /// \returns 0.0 if the file doesn't need to be indexed or if it /// hasn't been indexed yet, or a valid duration if it has. - virtual StatsDuration GetDebugInfoIndexTime() { - return StatsDuration(0.0); - } - + virtual StatsDuration GetDebugInfoIndexTime() { return StatsDuration(0.0); } protected: void AssertModuleLock(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -191,6 +191,13 @@ const std::string &scope_qualified_name, std::vector &mangled_names) override; + void + FindTypes(lldb_private::ConstString name, lldb_private::ConstString scope, + const lldb_private::CompilerDeclContext &parent_decl_ctx, + uint32_t max_matches, + llvm::DenseSet &searched_symbol_files, + lldb_private::TypeMap &types) override; + void FindTypes(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -21,6 +21,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" @@ -1115,7 +1116,8 @@ if (const char *include_path = module_die.GetAttributeValueAsString( DW_AT_LLVM_include_path, nullptr)) { FileSpec include_spec(include_path, dwarf_cu->GetPathStyle()); - MakeAbsoluteAndRemap(include_spec, *dwarf_cu, m_objfile_sp->GetModule()); + MakeAbsoluteAndRemap(include_spec, *dwarf_cu, + m_objfile_sp->GetModule()); module.search_path = ConstString(include_spec.GetPath()); } if (const char *sysroot = dwarf_cu->DIE().GetAttributeValueAsString( @@ -1942,7 +1944,7 @@ block_die = function_die.LookupDeepestBlock(file_vm_addr); } - if (!sc.function || ! lookup_block) + if (!sc.function || !lookup_block) return; Block &block = sc.function->GetBlock(true); @@ -2330,7 +2332,8 @@ if (log) { GetObjectFile()->GetModule()->LogMessage( log, - "SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, sc_list)", + "SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, " + "sc_list)", name.GetCString(), name_type_mask); } @@ -2363,8 +2366,7 @@ log, "SymbolFileDWARF::FindFunctions (name=\"%s\", " "name_type_mask=0x%x, include_inlines=%d, sc_list) => %u", - name.GetCString(), name_type_mask, include_inlines, - num_matches); + name.GetCString(), name_type_mask, include_inlines, num_matches); } } @@ -2418,6 +2420,15 @@ uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { + FindTypes(name, ConstString(), parent_decl_ctx, max_matches, + searched_symbol_files, types); +} + +void SymbolFileDWARF::FindTypes( + ConstString name, ConstString scope, + const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, + llvm::DenseSet &searched_symbol_files, + TypeMap &types) { std::lock_guard guard(GetModuleMutex()); // Make sure we haven't already searched this SymbolFile before. if (!searched_symbol_files.insert(this).second) @@ -2444,10 +2455,16 @@ if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) return; + const char *sc = scope.AsCString(""); + std::string s; m_index->GetTypes(name, [&](DWARFDIE die) { if (!DIEInDeclContext(parent_decl_ctx, die)) return true; // The containing decl contexts don't match + const char *qn = die.GetQualifiedName(s); + if (strncmp(sc, qn, strlen(sc))) + return true; + Type *matching_type = ResolveType(die, true, true); if (!matching_type) return true; diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp --- a/lldb/source/Symbol/SymbolFile.cpp +++ b/lldb/source/Symbol/SymbolFile.cpp @@ -135,6 +135,19 @@ llvm::DenseSet &searched_symbol_files, TypeMap &types) {} +void SymbolFile::FindTypes( + ConstString basename, ConstString scope, + const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, + llvm::DenseSet &searched_symbol_files, + TypeMap &types) { + FindTypes(basename, parent_decl_ctx, max_matches, searched_symbol_files, + types); + TypeClass type_class = eTypeClassAny; + types.RemoveMismatchedTypes(std::string(basename.GetCString()), + std::string(scope.GetCString()), type_class, + true); +} + void SymbolFile::FindTypes(llvm::ArrayRef pattern, LanguageSet languages, llvm::DenseSet &searched_symbol_files, @@ -147,9 +160,11 @@ // We assert that we have to module lock by trying to acquire the lock from a // different thread. Note that we must abort if the result is true to // guarantee correctness. - assert(std::async(std::launch::async, - [this] { return this->GetModuleMutex().try_lock(); }) - .get() == false && + assert(std::async( + std::launch::async, + [this] { + return this->GetModuleMutex().try_lock(); + }).get() == false && "Module is not locked"); #endif }