From d4cb1dddebe5a65672d62fe379956f7324749fa4 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 1 Jul 2015 20:06:40 +0000 Subject: [PATCH] When I introduced hard-coded formatters, I made them non-cacheable This is because - in theory - the formatter could match on not just the type, but also other properties of a ValueObject, so a per-type caching would not be a good thing On the other hand, that is not always true - sometimes the matching truly is per-type So, introduce a non-cacheable attribute on formatters that decides whether a formatter should or should not be cached. That way, the few formatters that don't want themselves cached can do so, but most formatters (including most hard-coded ones) can cache themselves just fine llvm-svn: 241184 --- lldb/include/lldb/DataFormatters/TypeFormat.h | 27 +++++++++++++++++++ .../include/lldb/DataFormatters/TypeSummary.h | 27 +++++++++++++++++++ .../lldb/DataFormatters/TypeSynthetic.h | 27 +++++++++++++++++++ .../lldb/DataFormatters/TypeValidator.h | 27 +++++++++++++++++++ lldb/include/lldb/lldb-enumerations.h | 3 ++- lldb/source/DataFormatters/FormatManager.cpp | 14 ++++++---- 6 files changed, 119 insertions(+), 6 deletions(-) diff --git a/lldb/include/lldb/DataFormatters/TypeFormat.h b/lldb/include/lldb/DataFormatters/TypeFormat.h index 1090d7843e53..8aa7c60b4938 100644 --- a/lldb/include/lldb/DataFormatters/TypeFormat.h +++ b/lldb/include/lldb/DataFormatters/TypeFormat.h @@ -115,6 +115,22 @@ namespace lldb_private { return *this; } + bool + GetNonCacheable () const + { + return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable; + } + + Flags& + SetNonCacheable (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionNonCacheable; + else + m_flags &= ~lldb::eTypeOptionNonCacheable; + return *this; + } + uint32_t GetValue () { @@ -153,6 +169,11 @@ namespace lldb_private { { return m_flags.GetSkipReferences(); } + bool + NonCacheable () const + { + return m_flags.GetNonCacheable(); + } void SetCascades (bool value) @@ -171,6 +192,12 @@ namespace lldb_private { { m_flags.SetSkipReferences(value); } + + void + SetNonCacheable (bool value) + { + m_flags.SetNonCacheable(value); + } uint32_t GetOptions () diff --git a/lldb/include/lldb/DataFormatters/TypeSummary.h b/lldb/include/lldb/DataFormatters/TypeSummary.h index fbbeddf4ac59..c2838eac27f1 100644 --- a/lldb/include/lldb/DataFormatters/TypeSummary.h +++ b/lldb/include/lldb/DataFormatters/TypeSummary.h @@ -211,6 +211,22 @@ namespace lldb_private { return *this; } + bool + GetNonCacheable () const + { + return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable; + } + + Flags& + SetNonCacheable (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionNonCacheable; + else + m_flags &= ~lldb::eTypeOptionNonCacheable; + return *this; + } + uint32_t GetValue () { @@ -252,6 +268,11 @@ namespace lldb_private { { return m_flags.GetSkipReferences(); } + bool + NonCacheable () const + { + return m_flags.GetNonCacheable(); + } virtual bool DoesPrintChildren (ValueObject* valobj) const @@ -319,6 +340,12 @@ namespace lldb_private { m_flags.SetHideItemNames(value); } + virtual void + SetNonCacheable (bool value) + { + m_flags.SetNonCacheable(value); + } + uint32_t GetOptions () { diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index c2b1a66cba01..ff6691c9a1b8 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -236,6 +236,22 @@ namespace lldb_private { return *this; } + bool + GetNonCacheable () const + { + return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable; + } + + Flags& + SetNonCacheable (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionNonCacheable; + else + m_flags &= ~lldb::eTypeOptionNonCacheable; + return *this; + } + uint32_t GetValue () { @@ -277,6 +293,11 @@ namespace lldb_private { { return m_flags.GetSkipReferences(); } + bool + NonCacheable () const + { + return m_flags.GetNonCacheable(); + } void SetCascades (bool value) @@ -296,6 +317,12 @@ namespace lldb_private { m_flags.SetSkipReferences(value); } + void + SetNonCacheable (bool value) + { + m_flags.SetNonCacheable(value); + } + uint32_t GetOptions () { diff --git a/lldb/include/lldb/DataFormatters/TypeValidator.h b/lldb/include/lldb/DataFormatters/TypeValidator.h index b501e47943fa..d06fac01f824 100644 --- a/lldb/include/lldb/DataFormatters/TypeValidator.h +++ b/lldb/include/lldb/DataFormatters/TypeValidator.h @@ -115,6 +115,22 @@ public: return *this; } + bool + GetNonCacheable () const + { + return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable; + } + + Flags& + SetNonCacheable (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionNonCacheable; + else + m_flags &= ~lldb::eTypeOptionNonCacheable; + return *this; + } + uint32_t GetValue () { @@ -153,6 +169,11 @@ public: { return m_flags.GetSkipReferences(); } + bool + NonCacheable () const + { + return m_flags.GetNonCacheable(); + } void SetCascades (bool value) @@ -172,6 +193,12 @@ public: m_flags.SetSkipReferences(value); } + void + SetNonCacheable (bool value) + { + m_flags.SetNonCacheable(value); + } + uint32_t GetOptions () { diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index ea8910525866..28614ffb23e1 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -736,7 +736,8 @@ namespace lldb { eTypeOptionHideChildren = (1u << 3), eTypeOptionHideValue = (1u << 4), eTypeOptionShowOneLiner = (1u << 5), - eTypeOptionHideNames = (1u << 6) + eTypeOptionHideNames = (1u << 6), + eTypeOptionNonCacheable = (1u << 7) }; //---------------------------------------------------------------------- diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 5e0adcb28d1b..47456ba5c45b 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -662,7 +662,8 @@ FormatManager::GetFormat (ValueObject& valobj, log->Printf("[FormatManager::GetFormat] Search failed. Giving hardcoded a chance."); retval = GetHardcodedFormat(valobj, use_dynamic); } - else if (valobj_type) + + if (valobj_type && (!retval || !retval->NonCacheable())) { if (log) log->Printf("[FormatManager::GetFormat] Caching %p for type %s", @@ -719,7 +720,8 @@ FormatManager::GetSummaryFormat (ValueObject& valobj, log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving hardcoded a chance."); retval = GetHardcodedSummaryFormat(valobj, use_dynamic); } - else if (valobj_type) + + if (valobj_type && (!retval || !retval->NonCacheable())) { if (log) log->Printf("[FormatManager::GetSummaryFormat] Caching %p for type %s", @@ -777,7 +779,8 @@ FormatManager::GetSyntheticChildren (ValueObject& valobj, log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving hardcoded a chance."); retval = GetHardcodedSyntheticChildren(valobj, use_dynamic); } - else if (valobj_type) + + if (valobj_type && (!retval || !retval->NonCacheable())) { if (log) log->Printf("[FormatManager::GetSyntheticChildren] Caching %p for type %s", @@ -822,7 +825,8 @@ FormatManager::GetValidator (ValueObject& valobj, log->Printf("[FormatManager::GetValidator] Search failed. Giving hardcoded a chance."); retval = GetHardcodedValidator(valobj, use_dynamic); } - else if (valobj_type) + + if (valobj_type && (!retval || !retval->NonCacheable())) { if (log) log->Printf("[FormatManager::GetValidator] Caching %p for type %s", @@ -1611,7 +1615,7 @@ FormatManager::LoadHardcodedFormatters() [](lldb_private::ValueObject& valobj, lldb::DynamicValueType, FormatManager& fmt_mgr) -> SyntheticChildren::SharedPointer { - static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true), + static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true).SetNonCacheable(true), "vector_type synthetic children", lldb_private::formatters::VectorTypeSyntheticFrontEndCreator)); if (valobj.GetClangType().IsVectorType(nullptr, nullptr))