Index: lldb/include/lldb/Core/ModuleList.h =================================================================== --- lldb/include/lldb/Core/ModuleList.h +++ lldb/include/lldb/Core/ModuleList.h @@ -58,6 +58,7 @@ FileSpec GetClangModulesCachePath() const; bool SetClangModulesCachePath(const FileSpec &path); + uint64_t GetDemanglingLimit() const; bool GetEnableExternalLookup() const; bool SetEnableExternalLookup(bool new_value); bool GetEnableLLDBIndexCache() const; Index: lldb/source/Core/CoreProperties.td =================================================================== --- lldb/source/Core/CoreProperties.td +++ lldb/source/Core/CoreProperties.td @@ -9,6 +9,10 @@ Global, DefaultStringValue<"">, Desc<"The path to the clang modules cache directory (-fmodules-cache-path).">; + def DemanglingLimit: Property<"demangling-max-length", "UInt64">, + Global, + DefaultUnsignedValue<1000>, + Desc<"The maximum length of the mangled symbol name. Mangled symbols that exceed this threshold will not be demangled when indexing the symbol table. A value of 0 means no limit.">; def SymLinkPaths: Property<"debug-info-symlink-paths", "FileSpecList">, Global, DefaultStringValue<"">, Index: lldb/source/Core/ModuleList.cpp =================================================================== --- lldb/source/Core/ModuleList.cpp +++ lldb/source/Core/ModuleList.cpp @@ -125,6 +125,12 @@ ->GetCurrentValue(); } +uint64_t ModuleListProperties::GetDemanglingLimit() const { + const uint32_t idx = ePropertyDemanglingLimit; + return m_collection_sp->GetPropertyAtIndexAsUInt64( + nullptr, idx, g_modulelist_properties[idx].default_uint_value); +} + bool ModuleListProperties::SetLLDBIndexCachePath(const FileSpec &path) { return m_collection_sp->SetPropertyAtIndexAsFileSpec( nullptr, ePropertyLLDBIndexCachePath, path); Index: lldb/source/Symbol/Symtab.cpp =================================================================== --- lldb/source/Symbol/Symtab.cpp +++ lldb/source/Symbol/Symtab.cpp @@ -297,11 +297,19 @@ std::vector> backlog; backlog.reserve(num_symbols / 2); + const uint64_t mangling_limit = + ModuleList::GetGlobalModuleListProperties().GetDemanglingLimit(); + // Instantiation of the demangler is expensive, so better use a single one // for all entries during batch processing. RichManglingContext rmc; for (uint32_t value = 0; value < num_symbols; ++value) { Symbol *symbol = &m_symbols[value]; + Mangled &mangled = symbol->GetMangled(); + + if (mangling_limit) + if (mangled.GetMangledName().GetLength() > mangling_limit) + continue; // Don't let trampolines get into the lookup by name map If we ever need // the trampoline symbols to be searchable by name we can remove this and @@ -314,7 +322,6 @@ // If the symbol's name string matched a Mangled::ManglingScheme, it is // stored in the mangled field. - Mangled &mangled = symbol->GetMangled(); if (ConstString name = mangled.GetMangledName()) { name_to_index.Append(name, value);