Author: enrico Date: Mon Oct 5 20:02:47 2015 New Revision: 249366 URL: http://llvm.org/viewvc/llvm-project?rev=249366&view=rev Log: Introduce a FormattersMatchData class which contains all the information that data formatters need in one place, and also allows for lazy computation of expensive chunks of information if need be
This is a NFC commit that is essentially plumbing the new currency through the system Modified: lldb/trunk/include/lldb/DataFormatters/FormatClasses.h lldb/trunk/include/lldb/DataFormatters/FormatManager.h lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme lldb/trunk/source/DataFormatters/FormatClasses.cpp lldb/trunk/source/DataFormatters/FormatManager.cpp lldb/trunk/source/DataFormatters/LanguageCategory.cpp lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp Modified: lldb/trunk/include/lldb/DataFormatters/FormatClasses.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatClasses.h?rev=249366&r1=249365&r2=249366&view=diff ============================================================================== --- lldb/trunk/include/lldb/DataFormatters/FormatClasses.h (original) +++ lldb/trunk/include/lldb/DataFormatters/FormatClasses.h Mon Oct 5 20:02:47 2015 @@ -118,6 +118,36 @@ private: }; typedef std::vector<FormattersMatchCandidate> FormattersMatchVector; +typedef std::vector<lldb::LanguageType> CandidateLanguagesVector; + +class FormattersMatchData +{ +public: + FormattersMatchData (ValueObject&, + lldb::DynamicValueType); + + FormattersMatchVector + GetMatchesVector (); + + ConstString + GetTypeForCache (); + + CandidateLanguagesVector + GetCandidateLanguages (); + + ValueObject& + GetValueObject (); + + lldb::DynamicValueType + GetDynamicValueType (); + +private: + ValueObject& m_valobj; + lldb::DynamicValueType m_dynamic_value_type; + std::pair<FormattersMatchVector,bool> m_formatters_match_vector; + ConstString m_type_for_cache; + CandidateLanguagesVector m_candidate_languages; +}; class TypeNameSpecifierImpl { Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=249366&r1=249365&r2=249366&view=diff ============================================================================== --- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original) +++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Mon Oct 5 20:02:47 2015 @@ -311,16 +311,16 @@ private: ConstString m_vectortypes_category_name; lldb::TypeFormatImplSP - GetHardcodedFormat (ValueObject&,lldb::DynamicValueType); + GetHardcodedFormat (FormattersMatchData&); lldb::TypeSummaryImplSP - GetHardcodedSummaryFormat (ValueObject&,lldb::DynamicValueType); + GetHardcodedSummaryFormat (FormattersMatchData&); lldb::SyntheticChildrenSP - GetHardcodedSyntheticChildren (ValueObject&,lldb::DynamicValueType); + GetHardcodedSyntheticChildren (FormattersMatchData&); lldb::TypeValidatorImplSP - GetHardcodedValidator (ValueObject&,lldb::DynamicValueType); + GetHardcodedValidator (FormattersMatchData&); TypeCategoryMap& GetCategories () @@ -338,6 +338,8 @@ private: void LoadVectorFormatters (); + + friend class FormattersMatchData; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h?rev=249366&r1=249365&r2=249366&view=diff ============================================================================== --- lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h (original) +++ lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h Mon Oct 5 20:02:47 2015 @@ -31,51 +31,39 @@ public: LanguageCategory (lldb::LanguageType lang_type); bool - Get (ValueObject& valobj, - lldb::DynamicValueType dynamic, - FormattersMatchVector matches, + Get (FormattersMatchData& match_data, lldb::TypeFormatImplSP& format_sp); bool - Get (ValueObject& valobj, - lldb::DynamicValueType dynamic, - FormattersMatchVector matches, + Get (FormattersMatchData& match_data, lldb::TypeSummaryImplSP& format_sp); bool - Get (ValueObject& valobj, - lldb::DynamicValueType dynamic, - FormattersMatchVector matches, + Get (FormattersMatchData& match_data, lldb::SyntheticChildrenSP& format_sp); bool - Get (ValueObject& valobj, - lldb::DynamicValueType dynamic, - FormattersMatchVector matches, + Get (FormattersMatchData& match_data, lldb::TypeValidatorImplSP& format_sp); bool - GetHardcoded (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormatManager& fmt_mgr, + GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, lldb::TypeFormatImplSP& format_sp); bool - GetHardcoded (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormatManager& fmt_mgr, + GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, lldb::TypeSummaryImplSP& format_sp); bool - GetHardcoded (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormatManager& fmt_mgr, + GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, lldb::SyntheticChildrenSP& format_sp); bool - GetHardcoded (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormatManager& fmt_mgr, + GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, lldb::TypeValidatorImplSP& format_sp); lldb::TypeCategoryImplSP Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h?rev=249366&r1=249365&r2=249366&view=diff ============================================================================== --- lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h (original) +++ lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h Mon Oct 5 20:02:47 2015 @@ -101,26 +101,18 @@ namespace lldb_private { } lldb::TypeFormatImplSP - GetFormat (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormattersMatchVector matches); + GetFormat (FormattersMatchData& match_data); lldb::TypeSummaryImplSP - GetSummaryFormat (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormattersMatchVector matches); + GetSummaryFormat (FormattersMatchData& match_data); #ifndef LLDB_DISABLE_PYTHON lldb::SyntheticChildrenSP - GetSyntheticChildren (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormattersMatchVector matches); + GetSyntheticChildren (FormattersMatchData& match_data); #endif lldb::TypeValidatorImplSP - GetValidator (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormattersMatchVector matches); + GetValidator (FormattersMatchData& match_data); private: Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=249366&r1=249365&r2=249366&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Mon Oct 5 20:02:47 2015 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme LastUpgradeVersion = "0610" - version = "1.8"> + version = "1.3"> <BuildAction parallelizeBuildables = "NO" buildImplicitDependencies = "YES"> @@ -23,10 +23,10 @@ </BuildActionEntries> </BuildAction> <TestAction + buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES" - buildConfiguration = "Debug"> + shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> </Testables> <MacroExpansion> @@ -80,14 +80,16 @@ isEnabled = "YES"> </EnvironmentVariable> </EnvironmentVariables> + <AdditionalOptions> + </AdditionalOptions> </TestAction> <LaunchAction + buildConfiguration = "DebugClang" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" customWorkingDirectory = "/Volumes/work/gclayton/Documents/devb/attach" - buildConfiguration = "DebugClang" ignoresPersistentStateOnLaunch = "YES" debugDocumentVersioning = "YES" debugServiceExtension = "internal" @@ -143,10 +145,10 @@ </AdditionalOptions> </LaunchAction> <ProfileAction + buildConfiguration = "Release" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" - buildConfiguration = "Release" ignoresPersistentStateOnLaunch = "YES" debugDocumentVersioning = "YES"> <BuildableProductRunnable Modified: lldb/trunk/source/DataFormatters/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatClasses.cpp?rev=249366&r1=249365&r2=249366&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/FormatClasses.cpp (original) +++ lldb/trunk/source/DataFormatters/FormatClasses.cpp Mon Oct 5 20:02:47 2015 @@ -9,6 +9,8 @@ #include "lldb/DataFormatters/FormatClasses.h" +#include "lldb/DataFormatters/FormatManager.h" + // C Includes // C++ Includes @@ -20,3 +22,48 @@ using namespace lldb; using namespace lldb_private; +FormattersMatchData::FormattersMatchData (ValueObject& valobj, lldb::DynamicValueType use_dynamic) : + m_valobj(valobj), + m_dynamic_value_type(use_dynamic), + m_formatters_match_vector({},false), + m_type_for_cache(), + m_candidate_languages() +{ + m_type_for_cache = FormatManager::GetTypeForCache(valobj, use_dynamic); + m_candidate_languages = FormatManager::GetCandidateLanguages(valobj); +} + +FormattersMatchVector +FormattersMatchData::GetMatchesVector () +{ + if (!m_formatters_match_vector.second) + { + m_formatters_match_vector.second = true; + m_formatters_match_vector.first = FormatManager::GetPossibleMatches(m_valobj, m_dynamic_value_type); + } + return m_formatters_match_vector.first; +} + +ConstString +FormattersMatchData::GetTypeForCache () +{ + return m_type_for_cache; +} + +CandidateLanguagesVector +FormattersMatchData::GetCandidateLanguages () +{ + return m_candidate_languages; +} + +ValueObject& +FormattersMatchData::GetValueObject () +{ + return m_valobj; +} + +lldb::DynamicValueType +FormattersMatchData::GetDynamicValueType () +{ + return m_dynamic_value_type; +} Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=249366&r1=249365&r2=249366&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/FormatManager.cpp (original) +++ lldb/trunk/source/DataFormatters/FormatManager.cpp Mon Oct 5 20:02:47 2015 @@ -697,16 +697,15 @@ FormatManager::GetCategoryForLanguage (l } lldb::TypeFormatImplSP -FormatManager::GetHardcodedFormat (ValueObject& valobj, - lldb::DynamicValueType use_dynamic) +FormatManager::GetHardcodedFormat (FormattersMatchData& match_data) { TypeFormatImplSP retval_sp; - for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj)) + for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type)) { - if (lang_category->GetHardcoded(valobj, use_dynamic, *this, retval_sp)) + if (lang_category->GetHardcoded(*this, match_data, retval_sp)) break; } } @@ -718,14 +717,15 @@ lldb::TypeFormatImplSP FormatManager::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { + FormattersMatchData match_data(valobj, use_dynamic); + TypeFormatImplSP retval; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); - ConstString valobj_type(GetTypeForCache(valobj, use_dynamic)); - if (valobj_type) + if (match_data.GetTypeForCache()) { if (log) - log->Printf("\n\n[FormatManager::GetFormat] Looking into cache for type %s", valobj_type.AsCString("<invalid>")); - if (m_format_cache.GetFormat(valobj_type,retval)) + log->Printf("\n\n[FormatManager::GetFormat] Looking into cache for type %s", match_data.GetTypeForCache().AsCString("<invalid>")); + if (m_format_cache.GetFormat(match_data.GetTypeForCache(),retval)) { if (log) { @@ -739,18 +739,16 @@ FormatManager::GetFormat (ValueObject& v log->Printf("[FormatManager::GetFormat] Cache search failed. Going normal route"); } - FormattersMatchVector matches = GetPossibleMatches(valobj, use_dynamic); - - retval = m_categories_map.GetFormat(valobj, use_dynamic, matches); + retval = m_categories_map.GetFormat(match_data); if (!retval) { if (log) log->Printf("[FormatManager::GetFormat] Search failed. Giving language a chance."); - for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj)) + for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type)) { - if (lang_category->Get(valobj, use_dynamic, matches, retval)) + if (lang_category->Get(match_data, retval)) break; } } @@ -765,16 +763,16 @@ FormatManager::GetFormat (ValueObject& v { if (log) log->Printf("[FormatManager::GetFormat] Search failed. Giving hardcoded a chance."); - retval = GetHardcodedFormat(valobj, use_dynamic); + retval = GetHardcodedFormat(match_data); } - if (valobj_type && (!retval || !retval->NonCacheable())) + if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) { if (log) log->Printf("[FormatManager::GetFormat] Caching %p for type %s", static_cast<void*>(retval.get()), - valobj_type.AsCString("<invalid>")); - m_format_cache.SetFormat(valobj_type,retval); + match_data.GetTypeForCache().AsCString("<invalid>")); + m_format_cache.SetFormat(match_data.GetTypeForCache(),retval); } if (log && log->GetDebug()) log->Printf("[FormatManager::GetFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses()); @@ -782,16 +780,15 @@ FormatManager::GetFormat (ValueObject& v } lldb::TypeSummaryImplSP -FormatManager::GetHardcodedSummaryFormat (ValueObject& valobj, - lldb::DynamicValueType use_dynamic) +FormatManager::GetHardcodedSummaryFormat (FormattersMatchData& match_data) { TypeSummaryImplSP retval_sp; - for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj)) + for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type)) { - if (lang_category->GetHardcoded(valobj, use_dynamic, *this, retval_sp)) + if (lang_category->GetHardcoded(*this, match_data, retval_sp)) break; } } @@ -803,14 +800,15 @@ lldb::TypeSummaryImplSP FormatManager::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { + FormattersMatchData match_data(valobj, use_dynamic); + TypeSummaryImplSP retval; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); - ConstString valobj_type(GetTypeForCache(valobj, use_dynamic)); - if (valobj_type) + if (match_data.GetTypeForCache()) { if (log) - log->Printf("\n\n[FormatManager::GetSummaryFormat] Looking into cache for type %s", valobj_type.AsCString("<invalid>")); - if (m_format_cache.GetSummary(valobj_type,retval)) + log->Printf("\n\n[FormatManager::GetSummaryFormat] Looking into cache for type %s", match_data.GetTypeForCache().AsCString("<invalid>")); + if (m_format_cache.GetSummary(match_data.GetTypeForCache(),retval)) { if (log) { @@ -824,18 +822,16 @@ FormatManager::GetSummaryFormat (ValueOb log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. Going normal route"); } - FormattersMatchVector matches = GetPossibleMatches(valobj, use_dynamic); - - retval = m_categories_map.GetSummaryFormat(valobj, use_dynamic, matches); + retval = m_categories_map.GetSummaryFormat(match_data); if (!retval) { if (log) log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving language a chance."); - for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj)) + for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type)) { - if (lang_category->Get(valobj, use_dynamic, matches, retval)) + if (lang_category->Get(match_data, retval)) break; } } @@ -850,16 +846,16 @@ FormatManager::GetSummaryFormat (ValueOb { if (log) log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving hardcoded a chance."); - retval = GetHardcodedSummaryFormat(valobj, use_dynamic); + retval = GetHardcodedSummaryFormat(match_data); } - if (valobj_type && (!retval || !retval->NonCacheable())) + if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) { if (log) log->Printf("[FormatManager::GetSummaryFormat] Caching %p for type %s", static_cast<void*>(retval.get()), - valobj_type.AsCString("<invalid>")); - m_format_cache.SetSummary(valobj_type,retval); + match_data.GetTypeForCache().AsCString("<invalid>")); + m_format_cache.SetSummary(match_data.GetTypeForCache(),retval); } if (log && log->GetDebug()) log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses()); @@ -868,16 +864,15 @@ FormatManager::GetSummaryFormat (ValueOb #ifndef LLDB_DISABLE_PYTHON lldb::SyntheticChildrenSP -FormatManager::GetHardcodedSyntheticChildren (ValueObject& valobj, - lldb::DynamicValueType use_dynamic) +FormatManager::GetHardcodedSyntheticChildren (FormattersMatchData& match_data) { SyntheticChildrenSP retval_sp; - for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj)) + for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type)) { - if (lang_category->GetHardcoded(valobj, use_dynamic, *this, retval_sp)) + if (lang_category->GetHardcoded(*this, match_data, retval_sp)) break; } } @@ -889,14 +884,15 @@ lldb::SyntheticChildrenSP FormatManager::GetSyntheticChildren (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { + FormattersMatchData match_data(valobj, use_dynamic); + SyntheticChildrenSP retval; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); - ConstString valobj_type(GetTypeForCache(valobj, use_dynamic)); - if (valobj_type) + if (match_data.GetTypeForCache()) { if (log) - log->Printf("\n\n[FormatManager::GetSyntheticChildren] Looking into cache for type %s", valobj_type.AsCString("<invalid>")); - if (m_format_cache.GetSynthetic(valobj_type,retval)) + log->Printf("\n\n[FormatManager::GetSyntheticChildren] Looking into cache for type %s", match_data.GetTypeForCache().AsCString("<invalid>")); + if (m_format_cache.GetSynthetic(match_data.GetTypeForCache(),retval)) { if (log) { @@ -910,18 +906,16 @@ FormatManager::GetSyntheticChildren (Val log->Printf("[FormatManager::GetSyntheticChildren] Cache search failed. Going normal route"); } - FormattersMatchVector matches = GetPossibleMatches(valobj, use_dynamic); - - retval = m_categories_map.GetSyntheticChildren(valobj, use_dynamic, matches); + retval = m_categories_map.GetSyntheticChildren(match_data); if (!retval) { if (log) log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving language a chance."); - for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj)) + for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type)) { - if (lang_category->Get(valobj, use_dynamic, matches, retval)) + if (lang_category->Get(match_data, retval)) break; } } @@ -936,16 +930,16 @@ FormatManager::GetSyntheticChildren (Val { if (log) log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving hardcoded a chance."); - retval = GetHardcodedSyntheticChildren(valobj, use_dynamic); + retval = GetHardcodedSyntheticChildren(match_data); } - if (valobj_type && (!retval || !retval->NonCacheable())) + if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) { if (log) log->Printf("[FormatManager::GetSyntheticChildren] Caching %p for type %s", static_cast<void*>(retval.get()), - valobj_type.AsCString("<invalid>")); - m_format_cache.SetSynthetic(valobj_type,retval); + match_data.GetTypeForCache().AsCString("<invalid>")); + m_format_cache.SetSynthetic(match_data.GetTypeForCache(),retval); } if (log && log->GetDebug()) log->Printf("[FormatManager::GetSyntheticChildren] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses()); @@ -957,14 +951,15 @@ lldb::TypeValidatorImplSP FormatManager::GetValidator (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { + FormattersMatchData match_data(valobj, use_dynamic); + TypeValidatorImplSP retval; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); - ConstString valobj_type(GetTypeForCache(valobj, use_dynamic)); - if (valobj_type) + if (match_data.GetTypeForCache()) { if (log) - log->Printf("\n\n[FormatManager::GetValidator] Looking into cache for type %s", valobj_type.AsCString("<invalid>")); - if (m_format_cache.GetValidator(valobj_type,retval)) + log->Printf("\n\n[FormatManager::GetValidator] Looking into cache for type %s", match_data.GetTypeForCache().AsCString("<invalid>")); + if (m_format_cache.GetValidator(match_data.GetTypeForCache(),retval)) { if (log) { @@ -978,18 +973,16 @@ FormatManager::GetValidator (ValueObject log->Printf("[FormatManager::GetValidator] Cache search failed. Going normal route"); } - FormattersMatchVector matches = GetPossibleMatches(valobj, use_dynamic); - - retval = m_categories_map.GetValidator(valobj, use_dynamic, matches); + retval = m_categories_map.GetValidator(match_data); if (!retval) { if (log) log->Printf("[FormatManager::GetValidator] Search failed. Giving language a chance."); - for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj)) + for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type)) { - if (lang_category->Get(valobj, use_dynamic, matches, retval)) + if (lang_category->Get(match_data, retval)) break; } } @@ -1004,16 +997,16 @@ FormatManager::GetValidator (ValueObject { if (log) log->Printf("[FormatManager::GetValidator] Search failed. Giving hardcoded a chance."); - retval = GetHardcodedValidator(valobj, use_dynamic); + retval = GetHardcodedValidator(match_data); } - if (valobj_type && (!retval || !retval->NonCacheable())) + if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) { if (log) log->Printf("[FormatManager::GetValidator] Caching %p for type %s", static_cast<void*>(retval.get()), - valobj_type.AsCString("<invalid>")); - m_format_cache.SetValidator(valobj_type,retval); + match_data.GetTypeForCache().AsCString("<invalid>")); + m_format_cache.SetValidator(match_data.GetTypeForCache(),retval); } if (log && log->GetDebug()) log->Printf("[FormatManager::GetValidator] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses()); @@ -1021,16 +1014,15 @@ FormatManager::GetValidator (ValueObject } lldb::TypeValidatorImplSP -FormatManager::GetHardcodedValidator (ValueObject& valobj, - lldb::DynamicValueType use_dynamic) +FormatManager::GetHardcodedValidator (FormattersMatchData& match_data) { TypeValidatorImplSP retval_sp; - for (lldb::LanguageType lang_type : GetCandidateLanguages(valobj)) + for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) { if (LanguageCategory* lang_category = GetCategoryForLanguage(lang_type)) { - if (lang_category->GetHardcoded(valobj, use_dynamic, *this, retval_sp)) + if (lang_category->GetHardcoded(*this, match_data, retval_sp)) break; } } Modified: lldb/trunk/source/DataFormatters/LanguageCategory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LanguageCategory.cpp?rev=249366&r1=249365&r2=249366&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/LanguageCategory.cpp (original) +++ lldb/trunk/source/DataFormatters/LanguageCategory.cpp Mon Oct 5 20:02:47 2015 @@ -45,9 +45,7 @@ LanguageCategory::LanguageCategory (lldb } bool -LanguageCategory::Get (ValueObject& valobj, - lldb::DynamicValueType dynamic, - FormattersMatchVector matches, +LanguageCategory::Get (FormattersMatchData& match_data, lldb::TypeFormatImplSP& format_sp) { if (!m_category_sp) @@ -56,24 +54,23 @@ LanguageCategory::Get (ValueObject& valo if (!IsEnabled()) return false; - ConstString type_name = FormatManager::GetTypeForCache(valobj, dynamic); - if (type_name) + if (match_data.GetTypeForCache()) { - if (m_format_cache.GetFormat(type_name, format_sp)) + if (m_format_cache.GetFormat(match_data.GetTypeForCache(), format_sp)) return format_sp.get() != nullptr; } - bool result = m_category_sp->Get(valobj, matches, format_sp); - if (type_name && (!format_sp || !format_sp->NonCacheable())) + + ValueObject& valobj(match_data.GetValueObject()); + bool result = m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp); + if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable())) { - m_format_cache.SetFormat(type_name, format_sp); + m_format_cache.SetFormat(match_data.GetTypeForCache(), format_sp); } return result; } bool -LanguageCategory::Get (ValueObject& valobj, - lldb::DynamicValueType dynamic, - FormattersMatchVector matches, +LanguageCategory::Get (FormattersMatchData& match_data, lldb::TypeSummaryImplSP& format_sp) { if (!m_category_sp) @@ -82,24 +79,23 @@ LanguageCategory::Get (ValueObject& valo if (!IsEnabled()) return false; - ConstString type_name = FormatManager::GetTypeForCache(valobj, dynamic); - if (type_name) + if (match_data.GetTypeForCache()) { - if (m_format_cache.GetSummary(type_name, format_sp)) + if (m_format_cache.GetSummary(match_data.GetTypeForCache(), format_sp)) return format_sp.get() != nullptr; } - bool result = m_category_sp->Get(valobj, matches, format_sp); - if (type_name && (!format_sp || !format_sp->NonCacheable())) + + ValueObject& valobj(match_data.GetValueObject()); + bool result = m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp); + if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable())) { - m_format_cache.SetSummary(type_name, format_sp); + m_format_cache.SetSummary(match_data.GetTypeForCache(), format_sp); } return result; } bool -LanguageCategory::Get (ValueObject& valobj, - lldb::DynamicValueType dynamic, - FormattersMatchVector matches, +LanguageCategory::Get (FormattersMatchData& match_data, lldb::SyntheticChildrenSP& format_sp) { if (!m_category_sp) @@ -108,24 +104,23 @@ LanguageCategory::Get (ValueObject& valo if (!IsEnabled()) return false; - ConstString type_name = FormatManager::GetTypeForCache(valobj, dynamic); - if (type_name) + if (match_data.GetTypeForCache()) { - if (m_format_cache.GetSynthetic(type_name, format_sp)) + if (m_format_cache.GetSynthetic(match_data.GetTypeForCache(), format_sp)) return format_sp.get() != nullptr; } - bool result = m_category_sp->Get(valobj, matches, format_sp); - if (type_name && (!format_sp || !format_sp->NonCacheable())) + + ValueObject& valobj(match_data.GetValueObject()); + bool result = m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp); + if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable())) { - m_format_cache.SetSynthetic(type_name, format_sp); + m_format_cache.SetSynthetic(match_data.GetTypeForCache(), format_sp); } return result; } bool -LanguageCategory::Get (ValueObject& valobj, - lldb::DynamicValueType dynamic, - FormattersMatchVector matches, +LanguageCategory::Get (FormattersMatchData& match_data, lldb::TypeValidatorImplSP& format_sp) { if (!m_category_sp) @@ -134,108 +129,109 @@ LanguageCategory::Get (ValueObject& valo if (!IsEnabled()) return false; - ConstString type_name = FormatManager::GetTypeForCache(valobj, dynamic); - if (type_name) + if (match_data.GetTypeForCache()) { - if (m_format_cache.GetValidator(type_name, format_sp)) + if (m_format_cache.GetValidator(match_data.GetTypeForCache(), format_sp)) return format_sp.get() != nullptr; } - bool result = m_category_sp->Get(valobj, matches, format_sp); - if (type_name && (!format_sp || !format_sp->NonCacheable())) + + ValueObject& valobj(match_data.GetValueObject()); + bool result = m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp); + if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable())) { - m_format_cache.SetValidator(type_name, format_sp); + m_format_cache.SetValidator(match_data.GetTypeForCache(), format_sp); } return result; } bool -LanguageCategory::GetHardcoded (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormatManager& fmt_mgr, +LanguageCategory::GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, lldb::TypeFormatImplSP& format_sp) { if (!IsEnabled()) return false; - ConstString type_name = FormatManager::GetTypeForCache(valobj, use_dynamic); - + ValueObject& valobj(match_data.GetValueObject()); + lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType()); + for (auto& candidate : m_hardcoded_formats) { if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr))) break; } - if (type_name && (!format_sp || !format_sp->NonCacheable())) + if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable())) { - m_format_cache.SetFormat(type_name, format_sp); + m_format_cache.SetFormat(match_data.GetTypeForCache(), format_sp); } return format_sp.get() != nullptr; } bool -LanguageCategory::GetHardcoded (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormatManager& fmt_mgr, +LanguageCategory::GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, lldb::TypeSummaryImplSP& format_sp) { if (!IsEnabled()) return false; - - ConstString type_name = FormatManager::GetTypeForCache(valobj, use_dynamic); + ValueObject& valobj(match_data.GetValueObject()); + lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType()); + for (auto& candidate : m_hardcoded_summaries) { if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr))) break; } - if (type_name && (!format_sp || !format_sp->NonCacheable())) + if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable())) { - m_format_cache.SetSummary(type_name, format_sp); + m_format_cache.SetSummary(match_data.GetTypeForCache(), format_sp); } return format_sp.get() != nullptr; } bool -LanguageCategory::GetHardcoded (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormatManager& fmt_mgr, +LanguageCategory::GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, lldb::SyntheticChildrenSP& format_sp) { if (!IsEnabled()) return false; - ConstString type_name = FormatManager::GetTypeForCache(valobj, use_dynamic); + ValueObject& valobj(match_data.GetValueObject()); + lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType()); for (auto& candidate : m_hardcoded_synthetics) { if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr))) break; } - if (type_name && (!format_sp || !format_sp->NonCacheable())) + if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable())) { - m_format_cache.SetSynthetic(type_name, format_sp); + m_format_cache.SetSynthetic(match_data.GetTypeForCache(), format_sp); } return format_sp.get() != nullptr; } bool -LanguageCategory::GetHardcoded (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormatManager& fmt_mgr, +LanguageCategory::GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, lldb::TypeValidatorImplSP& format_sp) { if (!IsEnabled()) return false; - ConstString type_name = FormatManager::GetTypeForCache(valobj, use_dynamic); + ValueObject& valobj(match_data.GetValueObject()); + lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType()); for (auto& candidate : m_hardcoded_validators) { if ((format_sp = candidate(valobj, use_dynamic, fmt_mgr))) break; } - if (type_name && (!format_sp || !format_sp->NonCacheable())) + if (match_data.GetTypeForCache() && (!format_sp || !format_sp->NonCacheable())) { - m_format_cache.SetValidator(type_name, format_sp); + m_format_cache.SetValidator(match_data.GetTypeForCache(), format_sp); } return format_sp.get() != nullptr; } Modified: lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp?rev=249366&r1=249365&r2=249366&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp (original) +++ lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp Mon Oct 5 20:02:47 2015 @@ -218,9 +218,7 @@ TypeCategoryMap::AnyMatches (ConstString } lldb::TypeFormatImplSP -TypeCategoryMap::GetFormat (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormattersMatchVector matches) +TypeCategoryMap::GetFormat (FormattersMatchData& match_data) { Mutex::Locker locker(m_map_mutex); @@ -231,7 +229,7 @@ TypeCategoryMap::GetFormat (ValueObject& if (log) { - for (auto match : matches) + for (auto match : match_data.GetMatchesVector()) { log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32, match.GetTypeName().GetCString(), @@ -248,7 +246,7 @@ TypeCategoryMap::GetFormat (ValueObject& lldb::TypeFormatImplSP current_format; if (log) log->Printf("[TypeCategoryMap::GetFormat] Trying to use category %s", category_sp->GetName()); - if (!category_sp->Get(valobj, matches, current_format, &reason_why)) + if (!category_sp->Get(match_data.GetValueObject(), match_data.GetMatchesVector(), current_format, &reason_why)) continue; return current_format; } @@ -258,9 +256,7 @@ TypeCategoryMap::GetFormat (ValueObject& } lldb::TypeSummaryImplSP -TypeCategoryMap::GetSummaryFormat (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormattersMatchVector matches) +TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data) { Mutex::Locker locker(m_map_mutex); @@ -271,7 +267,7 @@ TypeCategoryMap::GetSummaryFormat (Value if (log) { - for (auto match : matches) + for (auto match : match_data.GetMatchesVector()) { log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32, match.GetTypeName().GetCString(), @@ -288,7 +284,7 @@ TypeCategoryMap::GetSummaryFormat (Value lldb::TypeSummaryImplSP current_format; if (log) log->Printf("[CategoryMap::GetSummaryFormat] Trying to use category %s", category_sp->GetName()); - if (!category_sp->Get(valobj, matches, current_format, &reason_why)) + if (!category_sp->Get(match_data.GetValueObject(), match_data.GetMatchesVector(), current_format, &reason_why)) continue; return current_format; } @@ -299,9 +295,7 @@ TypeCategoryMap::GetSummaryFormat (Value #ifndef LLDB_DISABLE_PYTHON lldb::SyntheticChildrenSP -TypeCategoryMap::GetSyntheticChildren (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormattersMatchVector matches) +TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data) { Mutex::Locker locker(m_map_mutex); @@ -313,7 +307,7 @@ TypeCategoryMap::GetSyntheticChildren (V if (log) { - for (auto match : matches) + for (auto match : match_data.GetMatchesVector()) { log->Printf("[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s reason = %" PRIu32, match.GetTypeName().GetCString(), @@ -330,7 +324,7 @@ TypeCategoryMap::GetSyntheticChildren (V lldb::SyntheticChildrenSP current_format; if (log) log->Printf("[CategoryMap::GetSyntheticChildren] Trying to use category %s", category_sp->GetName()); - if (!category_sp->Get(valobj, matches, current_format, &reason_why)) + if (!category_sp->Get(match_data.GetValueObject(), match_data.GetMatchesVector(), current_format, &reason_why)) continue; return current_format; } @@ -341,9 +335,7 @@ TypeCategoryMap::GetSyntheticChildren (V #endif lldb::TypeValidatorImplSP -TypeCategoryMap::GetValidator (ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - FormattersMatchVector matches) +TypeCategoryMap::GetValidator (FormattersMatchData& match_data) { Mutex::Locker locker(m_map_mutex); @@ -354,7 +346,7 @@ TypeCategoryMap::GetValidator (ValueObje if (log) { - for (auto match : matches) + for (auto match : match_data.GetMatchesVector()) { log->Printf("[CategoryMap::GetValidator] candidate match = %s %s %s %s reason = %" PRIu32, match.GetTypeName().GetCString(), @@ -371,7 +363,7 @@ TypeCategoryMap::GetValidator (ValueObje lldb::TypeValidatorImplSP current_format; if (log) log->Printf("[CategoryMap::GetValidator] Trying to use category %s", category_sp->GetName()); - if (!category_sp->Get(valobj, matches, current_format, &reason_why)) + if (!category_sp->Get(match_data.GetValueObject(), match_data.GetMatchesVector(), current_format, &reason_why)) continue; return current_format; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits