Index: lldb/include/lldb/Core/Mangled.h =================================================================== --- lldb/include/lldb/Core/Mangled.h +++ lldb/include/lldb/Core/Mangled.h @@ -249,7 +249,8 @@ /// \return /// True on success, false otherwise. bool DemangleWithRichManglingInfo(RichManglingContext &context, - SkipMangledNameFn *skip_mangled_name); + SkipMangledNameFn *skip_mangled_name, + bool store_demangled_name = true); /// Try to identify the mangling scheme used. /// \param[in] name Index: lldb/include/lldb/Core/ModuleList.h =================================================================== --- lldb/include/lldb/Core/ModuleList.h +++ lldb/include/lldb/Core/ModuleList.h @@ -59,6 +59,7 @@ FileSpec GetClangModulesCachePath() const; bool SetClangModulesCachePath(const FileSpec &path); uint64_t GetDemanglingLimit() const; + bool GetCacheDemangledNames() 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 @@ -13,6 +13,10 @@ 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 CacheDemangledNames: Property<"cache-demangled-names", "Boolean">, + Global, + DefaultFalse, + Desc<"Keep the demangled names in memory after indexing the symbol table.">; def SymLinkPaths: Property<"debug-info-symlink-paths", "FileSpecList">, Global, DefaultStringValue<"">, Index: lldb/source/Core/Mangled.cpp =================================================================== --- lldb/source/Core/Mangled.cpp +++ lldb/source/Core/Mangled.cpp @@ -195,8 +195,9 @@ // Explicit demangling for scheduled requests during batch processing. This // makes use of ItaniumPartialDemangler's rich demangle info -bool Mangled::DemangleWithRichManglingInfo( - RichManglingContext &context, SkipMangledNameFn *skip_mangled_name) { +bool Mangled::DemangleWithRichManglingInfo(RichManglingContext &context, + SkipMangledNameFn *skip_mangled_name, + bool store_demangled_name) { // Others are not meant to arrive here. ObjC names or C's main() for example // have their names stored in m_demangled, while m_mangled is empty. assert(m_mangled); @@ -218,8 +219,9 @@ // If we got an info, we have a name. Copy to string pool and connect the // counterparts to accelerate later access in GetDemangledName(). context.ParseFullName(); - m_demangled.SetStringWithMangledCounterpart(context.GetBufferRef(), - m_mangled); + if (store_demangled_name) + m_demangled.SetStringWithMangledCounterpart(context.GetBufferRef(), + m_mangled); return true; } else { m_demangled.SetCString(""); @@ -233,8 +235,9 @@ if (char *d = GetMSVCDemangledStr(m_mangled.GetCString())) { // If we got an info, we have a name. Copy to string pool and connect // the counterparts to accelerate later access in GetDemangledName(). - m_demangled.SetStringWithMangledCounterpart(llvm::StringRef(d), - m_mangled); + if (store_demangled_name) + m_demangled.SetStringWithMangledCounterpart(llvm::StringRef(d), + m_mangled); ::free(d); } else { m_demangled.SetCString(""); Index: lldb/source/Core/ModuleList.cpp =================================================================== --- lldb/source/Core/ModuleList.cpp +++ lldb/source/Core/ModuleList.cpp @@ -131,6 +131,12 @@ nullptr, idx, g_modulelist_properties[idx].default_uint_value); } +bool ModuleListProperties::GetCacheDemangledNames() const { + const uint32_t idx = ePropertyCacheDemangledNames; + return m_collection_sp->GetPropertyAtIndexAsBoolean( + nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0); +} + 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 @@ -299,6 +299,8 @@ const uint64_t mangling_limit = ModuleList::GetGlobalModuleListProperties().GetDemanglingLimit(); + const bool store_mangled_name = + ModuleList::GetGlobalModuleListProperties().GetCacheDemangledNames(); // Instantiation of the demangler is expensive, so better use a single one // for all entries during batch processing. @@ -335,7 +337,8 @@ const SymbolType type = symbol->GetType(); if (type == eSymbolTypeCode || type == eSymbolTypeResolver) { - if (mangled.DemangleWithRichManglingInfo(rmc, lldb_skip_name)) + if (mangled.DemangleWithRichManglingInfo(rmc, lldb_skip_name, + store_mangled_name)) RegisterMangledNameEntry(value, class_contexts, backlog, rmc); } }