summaryrefslogtreecommitdiff
path: root/source/DataFormatters/FormatCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/DataFormatters/FormatCache.cpp')
-rw-r--r--source/DataFormatters/FormatCache.cpp76
1 files changed, 71 insertions, 5 deletions
diff --git a/source/DataFormatters/FormatCache.cpp b/source/DataFormatters/FormatCache.cpp
index 3721f182f91e..aaa4bc1f958a 100644
--- a/source/DataFormatters/FormatCache.cpp
+++ b/source/DataFormatters/FormatCache.cpp
@@ -25,16 +25,20 @@ FormatCache::Entry::Entry () :
m_format_cached(false),
m_summary_cached(false),
m_synthetic_cached(false),
+m_validator_cached(false),
m_format_sp(),
m_summary_sp(),
-m_synthetic_sp()
+m_synthetic_sp(),
+m_validator_sp()
{}
FormatCache::Entry::Entry (lldb::TypeFormatImplSP format_sp) :
m_summary_cached(false),
m_synthetic_cached(false),
+m_validator_cached(false),
m_summary_sp(),
-m_synthetic_sp()
+m_synthetic_sp(),
+m_validator_sp()
{
SetFormat (format_sp);
}
@@ -42,8 +46,10 @@ m_synthetic_sp()
FormatCache::Entry::Entry (lldb::TypeSummaryImplSP summary_sp) :
m_format_cached(false),
m_synthetic_cached(false),
+m_validator_cached(false),
m_format_sp(),
-m_synthetic_sp()
+m_synthetic_sp(),
+m_validator_sp()
{
SetSummary (summary_sp);
}
@@ -51,17 +57,31 @@ m_synthetic_sp()
FormatCache::Entry::Entry (lldb::SyntheticChildrenSP synthetic_sp) :
m_format_cached(false),
m_summary_cached(false),
+m_validator_cached(false),
m_format_sp(),
-m_summary_sp()
+m_summary_sp(),
+m_validator_sp()
{
SetSynthetic (synthetic_sp);
}
-FormatCache::Entry::Entry (lldb::TypeFormatImplSP format_sp, lldb::TypeSummaryImplSP summary_sp, lldb::SyntheticChildrenSP synthetic_sp)
+FormatCache::Entry::Entry (lldb::TypeValidatorImplSP validator_sp) :
+m_format_cached(false),
+m_summary_cached(false),
+m_synthetic_cached(false),
+m_format_sp(),
+m_summary_sp(),
+m_synthetic_sp()
+{
+ SetValidator (validator_sp);
+}
+
+FormatCache::Entry::Entry (lldb::TypeFormatImplSP format_sp, lldb::TypeSummaryImplSP summary_sp, lldb::SyntheticChildrenSP synthetic_sp, lldb::TypeValidatorImplSP validator_sp)
{
SetFormat (format_sp);
SetSummary (summary_sp);
SetSynthetic (synthetic_sp);
+ SetValidator (validator_sp);
}
bool
@@ -82,6 +102,12 @@ FormatCache::Entry::IsSyntheticCached ()
return m_synthetic_cached;
}
+bool
+FormatCache::Entry::IsValidatorCached ()
+{
+ return m_validator_cached;
+}
+
lldb::TypeFormatImplSP
FormatCache::Entry::GetFormat ()
{
@@ -100,6 +126,12 @@ FormatCache::Entry::GetSynthetic ()
return m_synthetic_sp;
}
+lldb::TypeValidatorImplSP
+FormatCache::Entry::GetValidator ()
+{
+ return m_validator_sp;
+}
+
void
FormatCache::Entry::SetFormat (lldb::TypeFormatImplSP format_sp)
{
@@ -121,6 +153,13 @@ FormatCache::Entry::SetSynthetic (lldb::SyntheticChildrenSP synthetic_sp)
m_synthetic_sp = synthetic_sp;
}
+void
+FormatCache::Entry::SetValidator (lldb::TypeValidatorImplSP validator_sp)
+{
+ m_validator_cached = true;
+ m_validator_sp = validator_sp;
+}
+
FormatCache::FormatCache () :
m_map(),
m_mutex (Mutex::eMutexTypeRecursive)
@@ -201,6 +240,26 @@ FormatCache::GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& sy
return false;
}
+bool
+FormatCache::GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp)
+{
+ Mutex::Locker lock(m_mutex);
+ auto entry = GetEntry(type);
+ if (entry.IsValidatorCached())
+ {
+#ifdef LLDB_CONFIGURATION_DEBUG
+ m_cache_hits++;
+#endif
+ validator_sp = entry.GetValidator();
+ return true;
+ }
+#ifdef LLDB_CONFIGURATION_DEBUG
+ m_cache_misses++;
+#endif
+ validator_sp.reset();
+ return false;
+}
+
void
FormatCache::SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp)
{
@@ -223,6 +282,13 @@ FormatCache::SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& sy
}
void
+FormatCache::SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp)
+{
+ Mutex::Locker lock(m_mutex);
+ GetEntry(type).SetValidator(validator_sp);
+}
+
+void
FormatCache::Clear ()
{
Mutex::Locker lock(m_mutex);