[Lldb-commits] [lldb] r241184 - When I introduced hard-coded formatters, I made them non-cacheable
Enrico Granata
egranata at apple.com
Wed Jul 1 13:06:40 PDT 2015
Author: enrico
Date: Wed Jul 1 15:06:40 2015
New Revision: 241184
URL: http://llvm.org/viewvc/llvm-project?rev=241184&view=rev
Log:
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
Modified:
lldb/trunk/include/lldb/DataFormatters/TypeFormat.h
lldb/trunk/include/lldb/DataFormatters/TypeSummary.h
lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h
lldb/trunk/include/lldb/DataFormatters/TypeValidator.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/DataFormatters/FormatManager.cpp
Modified: lldb/trunk/include/lldb/DataFormatters/TypeFormat.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeFormat.h?rev=241184&r1=241183&r2=241184&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeFormat.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeFormat.h Wed Jul 1 15:06:40 2015
@@ -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 ()
Modified: lldb/trunk/include/lldb/DataFormatters/TypeSummary.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSummary.h?rev=241184&r1=241183&r2=241184&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeSummary.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeSummary.h Wed Jul 1 15:06:40 2015
@@ -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 ()
{
Modified: lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h?rev=241184&r1=241183&r2=241184&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h Wed Jul 1 15:06:40 2015
@@ -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 ()
{
Modified: lldb/trunk/include/lldb/DataFormatters/TypeValidator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeValidator.h?rev=241184&r1=241183&r2=241184&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeValidator.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeValidator.h Wed Jul 1 15:06:40 2015
@@ -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 ()
{
Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=241184&r1=241183&r2=241184&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Jul 1 15:06:40 2015
@@ -736,7 +736,8 @@ namespace lldb {
eTypeOptionHideChildren = (1u << 3),
eTypeOptionHideValue = (1u << 4),
eTypeOptionShowOneLiner = (1u << 5),
- eTypeOptionHideNames = (1u << 6)
+ eTypeOptionHideNames = (1u << 6),
+ eTypeOptionNonCacheable = (1u << 7)
};
//----------------------------------------------------------------------
Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=241184&r1=241183&r2=241184&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Wed Jul 1 15:06:40 2015
@@ -662,7 +662,8 @@ FormatManager::GetFormat (ValueObject& v
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 (ValueOb
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 (Val
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
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))
More information about the lldb-commits
mailing list