mirror of
https://github.com/intel/llvm.git
synced 2026-01-17 06:40:01 +08:00
Replace redundant code in FormatManager and FormatCache with templates (NFC)
This is a preparatory patch for an upcoming bugfix. FormatManager and friends have four identical implementations of many accessor functions to deal with the four types of shared pointers in the FormatCache. This patch replaces these implementations with templates. While this patch drastically reduces the amount of source code and its maintainablity, it doesn't actually improve code size. I'd argue, this is still an improvement. rdar://problem/57756763 Differential Revision: https://reviews.llvm.org/D71231
This commit is contained in:
@@ -33,36 +33,22 @@ private:
|
||||
|
||||
public:
|
||||
Entry();
|
||||
Entry(lldb::TypeFormatImplSP);
|
||||
Entry(lldb::TypeSummaryImplSP);
|
||||
Entry(lldb::SyntheticChildrenSP);
|
||||
Entry(lldb::TypeValidatorImplSP);
|
||||
Entry(lldb::TypeFormatImplSP, lldb::TypeSummaryImplSP,
|
||||
lldb::SyntheticChildrenSP, lldb::TypeValidatorImplSP);
|
||||
|
||||
template<typename ImplSP> bool IsCached();
|
||||
bool IsFormatCached();
|
||||
|
||||
bool IsSummaryCached();
|
||||
|
||||
bool IsSyntheticCached();
|
||||
|
||||
bool IsValidatorCached();
|
||||
|
||||
lldb::TypeFormatImplSP GetFormat();
|
||||
void Get(lldb::TypeFormatImplSP &);
|
||||
void Get(lldb::TypeSummaryImplSP &);
|
||||
void Get(lldb::SyntheticChildrenSP &);
|
||||
void Get(lldb::TypeValidatorImplSP &);
|
||||
|
||||
lldb::TypeSummaryImplSP GetSummary();
|
||||
|
||||
lldb::SyntheticChildrenSP GetSynthetic();
|
||||
|
||||
lldb::TypeValidatorImplSP GetValidator();
|
||||
|
||||
void SetFormat(lldb::TypeFormatImplSP);
|
||||
|
||||
void SetSummary(lldb::TypeSummaryImplSP);
|
||||
|
||||
void SetSynthetic(lldb::SyntheticChildrenSP);
|
||||
|
||||
void SetValidator(lldb::TypeValidatorImplSP);
|
||||
void Set(lldb::TypeFormatImplSP);
|
||||
void Set(lldb::TypeSummaryImplSP);
|
||||
void Set(lldb::SyntheticChildrenSP);
|
||||
void Set(lldb::TypeValidatorImplSP);
|
||||
};
|
||||
typedef std::map<ConstString, Entry> CacheMap;
|
||||
CacheMap m_map;
|
||||
@@ -76,25 +62,11 @@ private:
|
||||
public:
|
||||
FormatCache();
|
||||
|
||||
bool GetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
|
||||
|
||||
bool GetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
|
||||
|
||||
bool GetSynthetic(ConstString type,
|
||||
lldb::SyntheticChildrenSP &synthetic_sp);
|
||||
|
||||
bool GetValidator(ConstString type,
|
||||
lldb::TypeValidatorImplSP &summary_sp);
|
||||
|
||||
void SetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
|
||||
|
||||
void SetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
|
||||
|
||||
void SetSynthetic(ConstString type,
|
||||
lldb::SyntheticChildrenSP &synthetic_sp);
|
||||
|
||||
void SetValidator(ConstString type,
|
||||
lldb::TypeValidatorImplSP &synthetic_sp);
|
||||
template <typename ImplSP> bool Get(ConstString type, ImplSP &format_impl_sp);
|
||||
void Set(ConstString type, lldb::TypeFormatImplSP &format_sp);
|
||||
void Set(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
|
||||
void Set(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp);
|
||||
void Set(ConstString type, lldb::TypeValidatorImplSP &synthetic_sp);
|
||||
|
||||
void Clear();
|
||||
|
||||
@@ -102,6 +74,7 @@ public:
|
||||
|
||||
uint64_t GetCacheMisses() { return m_cache_misses; }
|
||||
};
|
||||
|
||||
} // namespace lldb_private
|
||||
|
||||
#endif // lldb_FormatCache_h_
|
||||
|
||||
@@ -208,14 +208,9 @@ private:
|
||||
ConstString m_system_category_name;
|
||||
ConstString m_vectortypes_category_name;
|
||||
|
||||
lldb::TypeFormatImplSP GetHardcodedFormat(FormattersMatchData &);
|
||||
|
||||
lldb::TypeSummaryImplSP GetHardcodedSummaryFormat(FormattersMatchData &);
|
||||
|
||||
lldb::SyntheticChildrenSP
|
||||
GetHardcodedSyntheticChildren(FormattersMatchData &);
|
||||
|
||||
lldb::TypeValidatorImplSP GetHardcodedValidator(FormattersMatchData &);
|
||||
template <typename ImplSP>
|
||||
ImplSP GetCached(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
|
||||
template <typename ImplSP> ImplSP GetHardcoded(FormattersMatchData &);
|
||||
|
||||
TypeCategoryMap &GetCategories() { return m_categories_map; }
|
||||
|
||||
|
||||
@@ -77,14 +77,7 @@ public:
|
||||
|
||||
uint32_t GetCount() { return m_map.size(); }
|
||||
|
||||
lldb::TypeFormatImplSP GetFormat(FormattersMatchData &match_data);
|
||||
|
||||
lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data);
|
||||
|
||||
lldb::SyntheticChildrenSP
|
||||
GetSyntheticChildren(FormattersMatchData &match_data);
|
||||
|
||||
lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data);
|
||||
template <typename ImplSP> void Get(FormattersMatchData &, ImplSP &);
|
||||
|
||||
private:
|
||||
class delete_matching_categories {
|
||||
|
||||
@@ -17,46 +17,7 @@ using namespace lldb_private;
|
||||
|
||||
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_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_validator_sp() {
|
||||
SetFormat(format_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_validator_sp() {
|
||||
SetSummary(summary_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_validator_sp() {
|
||||
SetSynthetic(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);
|
||||
}
|
||||
m_synthetic_cached(false), m_validator_cached(false) {}
|
||||
|
||||
bool FormatCache::Entry::IsFormatCached() { return m_format_cached; }
|
||||
|
||||
@@ -66,36 +27,38 @@ bool FormatCache::Entry::IsSyntheticCached() { return m_synthetic_cached; }
|
||||
|
||||
bool FormatCache::Entry::IsValidatorCached() { return m_validator_cached; }
|
||||
|
||||
lldb::TypeFormatImplSP FormatCache::Entry::GetFormat() { return m_format_sp; }
|
||||
|
||||
lldb::TypeSummaryImplSP FormatCache::Entry::GetSummary() {
|
||||
return m_summary_sp;
|
||||
void FormatCache::Entry::Get(lldb::TypeFormatImplSP &retval) {
|
||||
retval = m_format_sp;
|
||||
}
|
||||
|
||||
lldb::SyntheticChildrenSP FormatCache::Entry::GetSynthetic() {
|
||||
return m_synthetic_sp;
|
||||
void FormatCache::Entry::Get(lldb::TypeSummaryImplSP &retval) {
|
||||
retval = m_summary_sp;
|
||||
}
|
||||
|
||||
lldb::TypeValidatorImplSP FormatCache::Entry::GetValidator() {
|
||||
return m_validator_sp;
|
||||
void FormatCache::Entry::Get(lldb::SyntheticChildrenSP &retval) {
|
||||
retval = m_synthetic_sp;
|
||||
}
|
||||
|
||||
void FormatCache::Entry::SetFormat(lldb::TypeFormatImplSP format_sp) {
|
||||
void FormatCache::Entry::Get(lldb::TypeValidatorImplSP &retval) {
|
||||
retval = m_validator_sp;
|
||||
}
|
||||
|
||||
void FormatCache::Entry::Set(lldb::TypeFormatImplSP format_sp) {
|
||||
m_format_cached = true;
|
||||
m_format_sp = format_sp;
|
||||
}
|
||||
|
||||
void FormatCache::Entry::SetSummary(lldb::TypeSummaryImplSP summary_sp) {
|
||||
void FormatCache::Entry::Set(lldb::TypeSummaryImplSP summary_sp) {
|
||||
m_summary_cached = true;
|
||||
m_summary_sp = summary_sp;
|
||||
}
|
||||
|
||||
void FormatCache::Entry::SetSynthetic(lldb::SyntheticChildrenSP synthetic_sp) {
|
||||
void FormatCache::Entry::Set(lldb::SyntheticChildrenSP synthetic_sp) {
|
||||
m_synthetic_cached = true;
|
||||
m_synthetic_sp = synthetic_sp;
|
||||
}
|
||||
|
||||
void FormatCache::Entry::SetValidator(lldb::TypeValidatorImplSP validator_sp) {
|
||||
void FormatCache::Entry::Set(lldb::TypeValidatorImplSP validator_sp) {
|
||||
m_validator_cached = true;
|
||||
m_validator_sp = validator_sp;
|
||||
}
|
||||
@@ -117,100 +80,72 @@ FormatCache::Entry &FormatCache::GetEntry(ConstString type) {
|
||||
return m_map[type];
|
||||
}
|
||||
|
||||
bool FormatCache::GetFormat(ConstString type,
|
||||
lldb::TypeFormatImplSP &format_sp) {
|
||||
template<> bool FormatCache::Entry::IsCached<lldb::TypeFormatImplSP>() {
|
||||
return IsFormatCached();
|
||||
}
|
||||
template<> bool FormatCache::Entry::IsCached<lldb::TypeSummaryImplSP> () {
|
||||
return IsSummaryCached();
|
||||
}
|
||||
template<> bool FormatCache::Entry::IsCached<lldb::SyntheticChildrenSP>() {
|
||||
return IsSyntheticCached();
|
||||
}
|
||||
template<> bool FormatCache::Entry::IsCached<lldb::TypeValidatorImplSP>() {
|
||||
return IsValidatorCached();
|
||||
}
|
||||
|
||||
template <typename ImplSP>
|
||||
bool FormatCache::Get(ConstString type, ImplSP &format_impl_sp) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
auto entry = GetEntry(type);
|
||||
if (entry.IsFormatCached()) {
|
||||
if (entry.IsCached<ImplSP>()) {
|
||||
#ifdef LLDB_CONFIGURATION_DEBUG
|
||||
m_cache_hits++;
|
||||
#endif
|
||||
format_sp = entry.GetFormat();
|
||||
entry.Get(format_impl_sp);
|
||||
return true;
|
||||
}
|
||||
#ifdef LLDB_CONFIGURATION_DEBUG
|
||||
m_cache_misses++;
|
||||
#endif
|
||||
format_sp.reset();
|
||||
format_impl_sp.reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FormatCache::GetSummary(ConstString type,
|
||||
lldb::TypeSummaryImplSP &summary_sp) {
|
||||
/// Explicit instantiations for the four types.
|
||||
/// \{
|
||||
template bool
|
||||
FormatCache::Get<lldb::TypeValidatorImplSP>(ConstString,
|
||||
lldb::TypeValidatorImplSP &);
|
||||
template bool
|
||||
FormatCache::Get<lldb::TypeFormatImplSP>(ConstString, lldb::TypeFormatImplSP &);
|
||||
template bool
|
||||
FormatCache::Get<lldb::TypeSummaryImplSP>(ConstString,
|
||||
lldb::TypeSummaryImplSP &);
|
||||
template bool
|
||||
FormatCache::Get<lldb::SyntheticChildrenSP>(ConstString,
|
||||
lldb::SyntheticChildrenSP &);
|
||||
/// \}
|
||||
|
||||
void FormatCache::Set(ConstString type, lldb::TypeFormatImplSP &format_sp) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
auto entry = GetEntry(type);
|
||||
if (entry.IsSummaryCached()) {
|
||||
#ifdef LLDB_CONFIGURATION_DEBUG
|
||||
m_cache_hits++;
|
||||
#endif
|
||||
summary_sp = entry.GetSummary();
|
||||
return true;
|
||||
}
|
||||
#ifdef LLDB_CONFIGURATION_DEBUG
|
||||
m_cache_misses++;
|
||||
#endif
|
||||
summary_sp.reset();
|
||||
return false;
|
||||
GetEntry(type).Set(format_sp);
|
||||
}
|
||||
|
||||
bool FormatCache::GetSynthetic(ConstString type,
|
||||
lldb::SyntheticChildrenSP &synthetic_sp) {
|
||||
void FormatCache::Set(ConstString type, lldb::TypeSummaryImplSP &summary_sp) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
auto entry = GetEntry(type);
|
||||
if (entry.IsSyntheticCached()) {
|
||||
#ifdef LLDB_CONFIGURATION_DEBUG
|
||||
m_cache_hits++;
|
||||
#endif
|
||||
synthetic_sp = entry.GetSynthetic();
|
||||
return true;
|
||||
}
|
||||
#ifdef LLDB_CONFIGURATION_DEBUG
|
||||
m_cache_misses++;
|
||||
#endif
|
||||
synthetic_sp.reset();
|
||||
return false;
|
||||
GetEntry(type).Set(summary_sp);
|
||||
}
|
||||
|
||||
bool FormatCache::GetValidator(ConstString type,
|
||||
lldb::TypeValidatorImplSP &validator_sp) {
|
||||
void FormatCache::Set(ConstString type,
|
||||
lldb::SyntheticChildrenSP &synthetic_sp) {
|
||||
std::lock_guard<std::recursive_mutex> guard(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;
|
||||
GetEntry(type).Set(synthetic_sp);
|
||||
}
|
||||
|
||||
void FormatCache::SetFormat(ConstString type,
|
||||
lldb::TypeFormatImplSP &format_sp) {
|
||||
void FormatCache::Set(ConstString type,
|
||||
lldb::TypeValidatorImplSP &validator_sp) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
GetEntry(type).SetFormat(format_sp);
|
||||
}
|
||||
|
||||
void FormatCache::SetSummary(ConstString type,
|
||||
lldb::TypeSummaryImplSP &summary_sp) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
GetEntry(type).SetSummary(summary_sp);
|
||||
}
|
||||
|
||||
void FormatCache::SetSynthetic(ConstString type,
|
||||
lldb::SyntheticChildrenSP &synthetic_sp) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
GetEntry(type).SetSynthetic(synthetic_sp);
|
||||
}
|
||||
|
||||
void FormatCache::SetValidator(ConstString type,
|
||||
lldb::TypeValidatorImplSP &validator_sp) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||
GetEntry(type).SetValidator(validator_sp);
|
||||
GetEntry(type).Set(validator_sp);
|
||||
}
|
||||
|
||||
void FormatCache::Clear() {
|
||||
|
||||
@@ -610,302 +610,93 @@ FormatManager::GetCategoryForLanguage(lldb::LanguageType lang_type) {
|
||||
return lang_category;
|
||||
}
|
||||
|
||||
lldb::TypeFormatImplSP
|
||||
FormatManager::GetHardcodedFormat(FormattersMatchData &match_data) {
|
||||
TypeFormatImplSP retval_sp;
|
||||
|
||||
template <typename ImplSP>
|
||||
ImplSP FormatManager::GetHardcoded(FormattersMatchData &match_data) {
|
||||
ImplSP retval_sp;
|
||||
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
|
||||
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
|
||||
if (lang_category->GetHardcoded(*this, match_data, retval_sp))
|
||||
break;
|
||||
return retval_sp;
|
||||
}
|
||||
}
|
||||
return retval_sp;
|
||||
}
|
||||
|
||||
template <typename ImplSP> ImplSP
|
||||
FormatManager::GetCached(ValueObject &valobj,
|
||||
lldb::DynamicValueType use_dynamic) {
|
||||
ImplSP retval_sp;
|
||||
FormattersMatchData match_data(valobj, use_dynamic);
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
|
||||
if (match_data.GetTypeForCache()) {
|
||||
LLDB_LOGF(log, "\n\n[%s] Looking into cache for type %s", __FUNCTION__,
|
||||
match_data.GetTypeForCache().AsCString("<invalid>"));
|
||||
if (m_format_cache.Get(match_data.GetTypeForCache(), retval_sp)) {
|
||||
if (log) {
|
||||
LLDB_LOGF(log, "[%s] Cache search success. Returning.", __FUNCTION__);
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(),
|
||||
m_format_cache.GetCacheMisses());
|
||||
}
|
||||
return retval_sp;
|
||||
}
|
||||
LLDB_LOGF(log, "[%s] Cache search failed. Going normal route",
|
||||
__FUNCTION__);
|
||||
}
|
||||
|
||||
m_categories_map.Get(match_data, retval_sp);
|
||||
if (!retval_sp) {
|
||||
LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.",
|
||||
__FUNCTION__);
|
||||
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
|
||||
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
|
||||
if (lang_category->Get(match_data, retval_sp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (retval_sp) {
|
||||
LLDB_LOGF(log, "[%s] Language search success. Returning.", __FUNCTION__);
|
||||
return retval_sp;
|
||||
}
|
||||
}
|
||||
if (!retval_sp) {
|
||||
LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", __FUNCTION__);
|
||||
retval_sp = GetHardcoded<ImplSP>(match_data);
|
||||
}
|
||||
|
||||
if (match_data.GetTypeForCache() && (!retval_sp || !retval_sp->NonCacheable())) {
|
||||
LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__,
|
||||
static_cast<void *>(retval_sp.get()),
|
||||
match_data.GetTypeForCache().AsCString("<invalid>"));
|
||||
m_format_cache.Set(match_data.GetTypeForCache(), retval_sp);
|
||||
}
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
|
||||
return retval_sp;
|
||||
}
|
||||
|
||||
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_DATAFORMATTERS));
|
||||
if (match_data.GetTypeForCache()) {
|
||||
LLDB_LOGF(log,
|
||||
"\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) {
|
||||
LLDB_LOGF(
|
||||
log, "[FormatManager::GetFormat] Cache search success. Returning.");
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(),
|
||||
m_format_cache.GetCacheMisses());
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
LLDB_LOGF(
|
||||
log,
|
||||
"[FormatManager::GetFormat] Cache search failed. Going normal route");
|
||||
}
|
||||
|
||||
retval = m_categories_map.GetFormat(match_data);
|
||||
if (!retval) {
|
||||
LLDB_LOGF(log,
|
||||
"[FormatManager::GetFormat] Search failed. Giving language a "
|
||||
"chance.");
|
||||
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
|
||||
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
|
||||
if (lang_category->Get(match_data, retval))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (retval) {
|
||||
LLDB_LOGF(
|
||||
log,
|
||||
"[FormatManager::GetFormat] Language search success. Returning.");
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
if (!retval) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetFormat] Search failed. Giving hardcoded "
|
||||
"a chance.");
|
||||
retval = GetHardcodedFormat(match_data);
|
||||
}
|
||||
|
||||
if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetFormat] Caching %p for type %s",
|
||||
static_cast<void *>(retval.get()),
|
||||
match_data.GetTypeForCache().AsCString("<invalid>"));
|
||||
m_format_cache.SetFormat(match_data.GetTypeForCache(), retval);
|
||||
}
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
|
||||
return retval;
|
||||
}
|
||||
|
||||
lldb::TypeSummaryImplSP
|
||||
FormatManager::GetHardcodedSummaryFormat(FormattersMatchData &match_data) {
|
||||
TypeSummaryImplSP retval_sp;
|
||||
|
||||
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
|
||||
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
|
||||
if (lang_category->GetHardcoded(*this, match_data, retval_sp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retval_sp;
|
||||
return GetCached<lldb::TypeFormatImplSP>(valobj, use_dynamic);
|
||||
}
|
||||
|
||||
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_DATAFORMATTERS));
|
||||
if (match_data.GetTypeForCache()) {
|
||||
LLDB_LOGF(log,
|
||||
"\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) {
|
||||
LLDB_LOGF(log,
|
||||
"[FormatManager::GetSummaryFormat] Cache search success. "
|
||||
"Returning.");
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(),
|
||||
m_format_cache.GetCacheMisses());
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Cache search failed. "
|
||||
"Going normal route");
|
||||
}
|
||||
|
||||
retval = m_categories_map.GetSummaryFormat(match_data);
|
||||
if (!retval) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Search failed. Giving "
|
||||
"language a chance.");
|
||||
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
|
||||
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
|
||||
if (lang_category->Get(match_data, retval))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (retval) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Language search "
|
||||
"success. Returning.");
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
if (!retval) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Search failed. Giving "
|
||||
"hardcoded a chance.");
|
||||
retval = GetHardcodedSummaryFormat(match_data);
|
||||
}
|
||||
|
||||
if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Caching %p for type %s",
|
||||
static_cast<void *>(retval.get()),
|
||||
match_data.GetTypeForCache().AsCString("<invalid>"));
|
||||
m_format_cache.SetSummary(match_data.GetTypeForCache(), retval);
|
||||
}
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
|
||||
return retval;
|
||||
}
|
||||
|
||||
lldb::SyntheticChildrenSP
|
||||
FormatManager::GetHardcodedSyntheticChildren(FormattersMatchData &match_data) {
|
||||
SyntheticChildrenSP retval_sp;
|
||||
|
||||
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
|
||||
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
|
||||
if (lang_category->GetHardcoded(*this, match_data, retval_sp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retval_sp;
|
||||
return GetCached<lldb::TypeSummaryImplSP>(valobj, use_dynamic);
|
||||
}
|
||||
|
||||
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_DATAFORMATTERS));
|
||||
if (match_data.GetTypeForCache()) {
|
||||
LLDB_LOGF(log,
|
||||
"\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) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetSyntheticChildren] Cache search "
|
||||
"success. Returning.");
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(),
|
||||
m_format_cache.GetCacheMisses());
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
LLDB_LOGF(log, "[FormatManager::GetSyntheticChildren] Cache search failed. "
|
||||
"Going normal route");
|
||||
}
|
||||
|
||||
retval = m_categories_map.GetSyntheticChildren(match_data);
|
||||
if (!retval) {
|
||||
LLDB_LOGF(log,
|
||||
"[FormatManager::GetSyntheticChildren] Search failed. Giving "
|
||||
"language a chance.");
|
||||
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
|
||||
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
|
||||
if (lang_category->Get(match_data, retval))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (retval) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetSyntheticChildren] Language search "
|
||||
"success. Returning.");
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
if (!retval) {
|
||||
LLDB_LOGF(log,
|
||||
"[FormatManager::GetSyntheticChildren] Search failed. Giving "
|
||||
"hardcoded a chance.");
|
||||
retval = GetHardcodedSyntheticChildren(match_data);
|
||||
}
|
||||
|
||||
if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) {
|
||||
LLDB_LOGF(log,
|
||||
"[FormatManager::GetSyntheticChildren] Caching %p for type %s",
|
||||
static_cast<void *>(retval.get()),
|
||||
match_data.GetTypeForCache().AsCString("<invalid>"));
|
||||
m_format_cache.SetSynthetic(match_data.GetTypeForCache(), retval);
|
||||
}
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
|
||||
return retval;
|
||||
return GetCached<lldb::SyntheticChildrenSP>(valobj, use_dynamic);
|
||||
}
|
||||
|
||||
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_DATAFORMATTERS));
|
||||
if (match_data.GetTypeForCache()) {
|
||||
LLDB_LOGF(
|
||||
log, "\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) {
|
||||
LLDB_LOGF(
|
||||
log,
|
||||
"[FormatManager::GetValidator] Cache search success. Returning.");
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(),
|
||||
m_format_cache.GetCacheMisses());
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
LLDB_LOGF(log, "[FormatManager::GetValidator] Cache search failed. Going "
|
||||
"normal route");
|
||||
}
|
||||
|
||||
retval = m_categories_map.GetValidator(match_data);
|
||||
if (!retval) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetValidator] Search failed. Giving "
|
||||
"language a chance.");
|
||||
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
|
||||
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
|
||||
if (lang_category->Get(match_data, retval))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (retval) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetValidator] Language search success. "
|
||||
"Returning.");
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
if (!retval) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetValidator] Search failed. Giving "
|
||||
"hardcoded a chance.");
|
||||
retval = GetHardcodedValidator(match_data);
|
||||
}
|
||||
|
||||
if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) {
|
||||
LLDB_LOGF(log, "[FormatManager::GetValidator] Caching %p for type %s",
|
||||
static_cast<void *>(retval.get()),
|
||||
match_data.GetTypeForCache().AsCString("<invalid>"));
|
||||
m_format_cache.SetValidator(match_data.GetTypeForCache(), retval);
|
||||
}
|
||||
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
|
||||
m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
|
||||
return retval;
|
||||
}
|
||||
|
||||
lldb::TypeValidatorImplSP
|
||||
FormatManager::GetHardcodedValidator(FormattersMatchData &match_data) {
|
||||
TypeValidatorImplSP retval_sp;
|
||||
|
||||
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
|
||||
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
|
||||
if (lang_category->GetHardcoded(*this, match_data, retval_sp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retval_sp;
|
||||
return GetCached<lldb::TypeValidatorImplSP>(valobj, use_dynamic);
|
||||
}
|
||||
|
||||
FormatManager::FormatManager()
|
||||
|
||||
@@ -43,7 +43,7 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
|
||||
return false;
|
||||
|
||||
if (match_data.GetTypeForCache()) {
|
||||
if (m_format_cache.GetFormat(match_data.GetTypeForCache(), format_sp))
|
||||
if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
|
||||
return format_sp.get() != nullptr;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
|
||||
m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
|
||||
if (match_data.GetTypeForCache() &&
|
||||
(!format_sp || !format_sp->NonCacheable())) {
|
||||
m_format_cache.SetFormat(match_data.GetTypeForCache(), format_sp);
|
||||
m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
|
||||
return false;
|
||||
|
||||
if (match_data.GetTypeForCache()) {
|
||||
if (m_format_cache.GetSummary(match_data.GetTypeForCache(), format_sp))
|
||||
if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
|
||||
return format_sp.get() != nullptr;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
|
||||
m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
|
||||
if (match_data.GetTypeForCache() &&
|
||||
(!format_sp || !format_sp->NonCacheable())) {
|
||||
m_format_cache.SetSummary(match_data.GetTypeForCache(), format_sp);
|
||||
m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
|
||||
return false;
|
||||
|
||||
if (match_data.GetTypeForCache()) {
|
||||
if (m_format_cache.GetSynthetic(match_data.GetTypeForCache(), format_sp))
|
||||
if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
|
||||
return format_sp.get() != nullptr;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
|
||||
m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
|
||||
if (match_data.GetTypeForCache() &&
|
||||
(!format_sp || !format_sp->NonCacheable())) {
|
||||
m_format_cache.SetSynthetic(match_data.GetTypeForCache(), format_sp);
|
||||
m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
|
||||
return false;
|
||||
|
||||
if (match_data.GetTypeForCache()) {
|
||||
if (m_format_cache.GetValidator(match_data.GetTypeForCache(), format_sp))
|
||||
if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
|
||||
return format_sp.get() != nullptr;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
|
||||
m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
|
||||
if (match_data.GetTypeForCache() &&
|
||||
(!format_sp || !format_sp->NonCacheable())) {
|
||||
m_format_cache.SetValidator(match_data.GetTypeForCache(), format_sp);
|
||||
m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
|
||||
}
|
||||
if (match_data.GetTypeForCache() &&
|
||||
(!format_sp || !format_sp->NonCacheable())) {
|
||||
m_format_cache.SetFormat(match_data.GetTypeForCache(), format_sp);
|
||||
m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
|
||||
}
|
||||
return format_sp.get() != nullptr;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
|
||||
}
|
||||
if (match_data.GetTypeForCache() &&
|
||||
(!format_sp || !format_sp->NonCacheable())) {
|
||||
m_format_cache.SetSummary(match_data.GetTypeForCache(), format_sp);
|
||||
m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
|
||||
}
|
||||
return format_sp.get() != nullptr;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
|
||||
}
|
||||
if (match_data.GetTypeForCache() &&
|
||||
(!format_sp || !format_sp->NonCacheable())) {
|
||||
m_format_cache.SetSynthetic(match_data.GetTypeForCache(), format_sp);
|
||||
m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
|
||||
}
|
||||
return format_sp.get() != nullptr;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
|
||||
}
|
||||
if (match_data.GetTypeForCache() &&
|
||||
(!format_sp || !format_sp->NonCacheable())) {
|
||||
m_format_cache.SetValidator(match_data.GetTypeForCache(), format_sp);
|
||||
m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
|
||||
}
|
||||
return format_sp.get() != nullptr;
|
||||
}
|
||||
|
||||
@@ -169,8 +169,8 @@ bool TypeCategoryMap::AnyMatches(
|
||||
return false;
|
||||
}
|
||||
|
||||
lldb::TypeFormatImplSP
|
||||
TypeCategoryMap::GetFormat(FormattersMatchData &match_data) {
|
||||
template <typename ImplSP>
|
||||
void TypeCategoryMap::Get(FormattersMatchData &match_data, ImplSP &retval) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
|
||||
|
||||
uint32_t reason_why;
|
||||
@@ -182,8 +182,8 @@ TypeCategoryMap::GetFormat(FormattersMatchData &match_data) {
|
||||
for (auto match : match_data.GetMatchesVector()) {
|
||||
LLDB_LOGF(
|
||||
log,
|
||||
"[CategoryMap::GetFormat] candidate match = %s %s %s %s reason = "
|
||||
"%" PRIu32,
|
||||
"[%s] candidate match = %s %s %s %s reason = %" PRIu32,
|
||||
__FUNCTION__,
|
||||
match.GetTypeName().GetCString(),
|
||||
match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
|
||||
match.DidStripReference() ? "strip-reference" : "no-strip-reference",
|
||||
@@ -194,140 +194,34 @@ TypeCategoryMap::GetFormat(FormattersMatchData &match_data) {
|
||||
|
||||
for (begin = m_active_categories.begin(); begin != end; begin++) {
|
||||
lldb::TypeCategoryImplSP category_sp = *begin;
|
||||
lldb::TypeFormatImplSP current_format;
|
||||
LLDB_LOGF(log, "[TypeCategoryMap::GetFormat] Trying to use category %s",
|
||||
ImplSP current_format;
|
||||
LLDB_LOGF(log, "[%s] Trying to use category %s", __FUNCTION__,
|
||||
category_sp->GetName());
|
||||
if (!category_sp->Get(match_data.GetValueObject(),
|
||||
match_data.GetMatchesVector(), current_format,
|
||||
&reason_why))
|
||||
continue;
|
||||
return current_format;
|
||||
|
||||
retval = std::move(current_format);
|
||||
return;
|
||||
}
|
||||
LLDB_LOGF(log,
|
||||
"[TypeCategoryMap::GetFormat] nothing found - returning empty SP");
|
||||
return lldb::TypeFormatImplSP();
|
||||
LLDB_LOGF(log, "[%s] nothing found - returning empty SP", __FUNCTION__);
|
||||
}
|
||||
|
||||
lldb::TypeSummaryImplSP
|
||||
TypeCategoryMap::GetSummaryFormat(FormattersMatchData &match_data) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
|
||||
/// Explicit instantiations for the four types.
|
||||
/// \{
|
||||
template void TypeCategoryMap::Get<lldb::TypeValidatorImplSP>(
|
||||
FormattersMatchData &match_data, lldb::TypeValidatorImplSP &retval);
|
||||
|
||||
uint32_t reason_why;
|
||||
ActiveCategoriesIterator begin, end = m_active_categories.end();
|
||||
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
|
||||
|
||||
if (log) {
|
||||
for (auto match : match_data.GetMatchesVector()) {
|
||||
LLDB_LOGF(
|
||||
log,
|
||||
"[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s "
|
||||
"reason = %" PRIu32,
|
||||
match.GetTypeName().GetCString(),
|
||||
match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
|
||||
match.DidStripReference() ? "strip-reference" : "no-strip-reference",
|
||||
match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
|
||||
match.GetReason());
|
||||
}
|
||||
}
|
||||
|
||||
for (begin = m_active_categories.begin(); begin != end; begin++) {
|
||||
lldb::TypeCategoryImplSP category_sp = *begin;
|
||||
lldb::TypeSummaryImplSP current_format;
|
||||
LLDB_LOGF(log, "[CategoryMap::GetSummaryFormat] Trying to use category %s",
|
||||
category_sp->GetName());
|
||||
if (!category_sp->Get(match_data.GetValueObject(),
|
||||
match_data.GetMatchesVector(), current_format,
|
||||
&reason_why))
|
||||
continue;
|
||||
return current_format;
|
||||
}
|
||||
LLDB_LOGF(
|
||||
log,
|
||||
"[CategoryMap::GetSummaryFormat] nothing found - returning empty SP");
|
||||
return lldb::TypeSummaryImplSP();
|
||||
}
|
||||
|
||||
lldb::SyntheticChildrenSP
|
||||
TypeCategoryMap::GetSyntheticChildren(FormattersMatchData &match_data) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
|
||||
|
||||
uint32_t reason_why;
|
||||
|
||||
ActiveCategoriesIterator begin, end = m_active_categories.end();
|
||||
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
|
||||
|
||||
if (log) {
|
||||
for (auto match : match_data.GetMatchesVector()) {
|
||||
LLDB_LOGF(
|
||||
log,
|
||||
"[CategoryMap::GetSyntheticChildren] candidate match = %s %s %s %s "
|
||||
"reason = %" PRIu32,
|
||||
match.GetTypeName().GetCString(),
|
||||
match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
|
||||
match.DidStripReference() ? "strip-reference" : "no-strip-reference",
|
||||
match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
|
||||
match.GetReason());
|
||||
}
|
||||
}
|
||||
|
||||
for (begin = m_active_categories.begin(); begin != end; begin++) {
|
||||
lldb::TypeCategoryImplSP category_sp = *begin;
|
||||
lldb::SyntheticChildrenSP current_format;
|
||||
LLDB_LOGF(log,
|
||||
"[CategoryMap::GetSyntheticChildren] Trying to use category %s",
|
||||
category_sp->GetName());
|
||||
if (!category_sp->Get(match_data.GetValueObject(),
|
||||
match_data.GetMatchesVector(), current_format,
|
||||
&reason_why))
|
||||
continue;
|
||||
return current_format;
|
||||
}
|
||||
LLDB_LOGF(log,
|
||||
"[CategoryMap::GetSyntheticChildren] nothing found - returning "
|
||||
"empty SP");
|
||||
return lldb::SyntheticChildrenSP();
|
||||
}
|
||||
|
||||
lldb::TypeValidatorImplSP
|
||||
TypeCategoryMap::GetValidator(FormattersMatchData &match_data) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
|
||||
|
||||
uint32_t reason_why;
|
||||
ActiveCategoriesIterator begin, end = m_active_categories.end();
|
||||
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
|
||||
|
||||
if (log) {
|
||||
for (auto match : match_data.GetMatchesVector()) {
|
||||
LLDB_LOGF(
|
||||
log,
|
||||
"[CategoryMap::GetValidator] candidate match = %s %s %s %s reason = "
|
||||
"%" PRIu32,
|
||||
match.GetTypeName().GetCString(),
|
||||
match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
|
||||
match.DidStripReference() ? "strip-reference" : "no-strip-reference",
|
||||
match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
|
||||
match.GetReason());
|
||||
}
|
||||
}
|
||||
|
||||
for (begin = m_active_categories.begin(); begin != end; begin++) {
|
||||
lldb::TypeCategoryImplSP category_sp = *begin;
|
||||
lldb::TypeValidatorImplSP current_format;
|
||||
LLDB_LOGF(log, "[CategoryMap::GetValidator] Trying to use category %s",
|
||||
category_sp->GetName());
|
||||
if (!category_sp->Get(match_data.GetValueObject(),
|
||||
match_data.GetMatchesVector(), current_format,
|
||||
&reason_why))
|
||||
continue;
|
||||
return current_format;
|
||||
}
|
||||
LLDB_LOGF(log,
|
||||
"[CategoryMap::GetValidator] nothing found - returning empty SP");
|
||||
return lldb::TypeValidatorImplSP();
|
||||
}
|
||||
template void
|
||||
TypeCategoryMap::Get<lldb::TypeFormatImplSP>(FormattersMatchData &match_data,
|
||||
lldb::TypeFormatImplSP &retval);
|
||||
template void
|
||||
TypeCategoryMap::Get<lldb::TypeSummaryImplSP>(FormattersMatchData &match_data,
|
||||
lldb::TypeSummaryImplSP &retval);
|
||||
template void TypeCategoryMap::Get<lldb::SyntheticChildrenSP>(
|
||||
FormattersMatchData &match_data, lldb::SyntheticChildrenSP &retval);
|
||||
/// \}
|
||||
|
||||
void TypeCategoryMap::ForEach(ForEachCallback callback) {
|
||||
if (callback) {
|
||||
|
||||
Reference in New Issue
Block a user