mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-25 02:28:18 +00:00
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
This commit is contained in:
parent
ae94f11d55
commit
d4cb1dddeb
@ -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 ()
|
||||
|
@ -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 ()
|
||||
{
|
||||
|
@ -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 ()
|
||||
{
|
||||
|
@ -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 ()
|
||||
{
|
||||
|
@ -736,7 +736,8 @@ namespace lldb {
|
||||
eTypeOptionHideChildren = (1u << 3),
|
||||
eTypeOptionHideValue = (1u << 4),
|
||||
eTypeOptionShowOneLiner = (1u << 5),
|
||||
eTypeOptionHideNames = (1u << 6)
|
||||
eTypeOptionHideNames = (1u << 6),
|
||||
eTypeOptionNonCacheable = (1u << 7)
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user