diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:53:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-10-23 17:53:01 +0000 |
commit | ead246455adf1a215ec2715dad6533073a6beb4e (patch) | |
tree | f3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/DataFormatters/FormatManager.cpp | |
parent | fdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff) | |
download | src-ead246455adf1a215ec2715dad6533073a6beb4e.tar.gz src-ead246455adf1a215ec2715dad6533073a6beb4e.zip |
Vendor import of stripped lldb trunk r375505, the last commit before thevendor/lldb/lldb-trunk-r375505vendor/lldb
upstream Subversion repository was made read-only, and the LLVM project
migrated to GitHub:
https://llvm.org/svn/llvm-project/lldb/trunk@375505
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=353952
svn path=/vendor/lldb/lldb-r375505/; revision=353953; tag=vendor/lldb/lldb-trunk-r375505
Diffstat (limited to 'source/DataFormatters/FormatManager.cpp')
-rw-r--r-- | source/DataFormatters/FormatManager.cpp | 180 |
1 files changed, 84 insertions, 96 deletions
diff --git a/source/DataFormatters/FormatManager.cpp b/source/DataFormatters/FormatManager.cpp index dd2808a7cf7c..1eac372d79ec 100644 --- a/source/DataFormatters/FormatManager.cpp +++ b/source/DataFormatters/FormatManager.cpp @@ -30,7 +30,7 @@ struct FormatInfo { // current format }; -static FormatInfo g_format_infos[] = { +static constexpr FormatInfo g_format_infos[] = { {eFormatDefault, '\0', "default"}, {eFormatBoolean, 'B', "boolean"}, {eFormatBinary, 'b', "binary"}, @@ -69,7 +69,13 @@ static FormatInfo g_format_infos[] = { {eFormatAddressInfo, 'A', "address"}, {eFormatHexFloat, '\0', "hex float"}, {eFormatInstruction, 'i', "instruction"}, - {eFormatVoid, 'v', "void"}}; + {eFormatVoid, 'v', "void"}, + {eFormatUnicode8, 'u', "unicode8"}, +}; + +static_assert((sizeof(g_format_infos) / sizeof(g_format_infos[0])) == + kNumFormats, + "All formats must have a corresponding info entry."); static uint32_t g_num_format_infos = llvm::array_lengthof(g_format_infos); @@ -630,30 +636,29 @@ FormatManager::GetFormat(ValueObject &valobj, TypeFormatImplSP retval; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS)); if (match_data.GetTypeForCache()) { - if (log) - log->Printf( - "\n\n[FormatManager::GetFormat] Looking into cache for type %s", - match_data.GetTypeForCache().AsCString("<invalid>")); + 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) { - log->Printf( - "[FormatManager::GetFormat] Cache search success. Returning."); + 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; } - if (log) - log->Printf( - "[FormatManager::GetFormat] Cache search failed. Going normal route"); + LLDB_LOGF( + log, + "[FormatManager::GetFormat] Cache search failed. Going normal route"); } retval = m_categories_map.GetFormat(match_data); if (!retval) { - if (log) - log->Printf("[FormatManager::GetFormat] Search failed. Giving language a " - "chance."); + 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)) @@ -661,24 +666,22 @@ FormatManager::GetFormat(ValueObject &valobj, } } if (retval) { - if (log) - log->Printf( - "[FormatManager::GetFormat] Language search success. Returning."); + LLDB_LOGF( + log, + "[FormatManager::GetFormat] Language search success. Returning."); return retval; } } if (!retval) { - if (log) - log->Printf("[FormatManager::GetFormat] Search failed. Giving hardcoded " - "a chance."); + LLDB_LOGF(log, "[FormatManager::GetFormat] Search failed. Giving hardcoded " + "a chance."); retval = GetHardcodedFormat(match_data); } if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) { - if (log) - log->Printf("[FormatManager::GetFormat] Caching %p for type %s", - static_cast<void *>(retval.get()), - match_data.GetTypeForCache().AsCString("<invalid>")); + 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}", @@ -708,30 +711,29 @@ FormatManager::GetSummaryFormat(ValueObject &valobj, TypeSummaryImplSP retval; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS)); if (match_data.GetTypeForCache()) { - if (log) - log->Printf("\n\n[FormatManager::GetSummaryFormat] Looking into cache " - "for type %s", - match_data.GetTypeForCache().AsCString("<invalid>")); + 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) { - log->Printf("[FormatManager::GetSummaryFormat] Cache search success. " - "Returning."); + 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; } - if (log) - log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. " - "Going normal route"); + LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Cache search failed. " + "Going normal route"); } retval = m_categories_map.GetSummaryFormat(match_data); if (!retval) { - if (log) - log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving " - "language a chance."); + 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)) @@ -739,24 +741,21 @@ FormatManager::GetSummaryFormat(ValueObject &valobj, } } if (retval) { - if (log) - log->Printf("[FormatManager::GetSummaryFormat] Language search " - "success. Returning."); + LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Language search " + "success. Returning."); return retval; } } if (!retval) { - if (log) - log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving " - "hardcoded a chance."); + LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Search failed. Giving " + "hardcoded a chance."); retval = GetHardcodedSummaryFormat(match_data); } if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) { - if (log) - log->Printf("[FormatManager::GetSummaryFormat] Caching %p for type %s", - static_cast<void *>(retval.get()), - match_data.GetTypeForCache().AsCString("<invalid>")); + 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}", @@ -786,30 +785,29 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj, SyntheticChildrenSP retval; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS)); if (match_data.GetTypeForCache()) { - if (log) - log->Printf("\n\n[FormatManager::GetSyntheticChildren] Looking into " - "cache for type %s", - match_data.GetTypeForCache().AsCString("<invalid>")); + 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) { - log->Printf("[FormatManager::GetSyntheticChildren] Cache search " - "success. Returning."); + 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; } - if (log) - log->Printf("[FormatManager::GetSyntheticChildren] Cache search failed. " - "Going normal route"); + LLDB_LOGF(log, "[FormatManager::GetSyntheticChildren] Cache search failed. " + "Going normal route"); } retval = m_categories_map.GetSyntheticChildren(match_data); if (!retval) { - if (log) - log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving " - "language a chance."); + 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)) @@ -817,25 +815,23 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj, } } if (retval) { - if (log) - log->Printf("[FormatManager::GetSyntheticChildren] Language search " - "success. Returning."); + LLDB_LOGF(log, "[FormatManager::GetSyntheticChildren] Language search " + "success. Returning."); return retval; } } if (!retval) { - if (log) - log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving " - "hardcoded a chance."); + LLDB_LOGF(log, + "[FormatManager::GetSyntheticChildren] Search failed. Giving " + "hardcoded a chance."); retval = GetHardcodedSyntheticChildren(match_data); } if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) { - if (log) - log->Printf( - "[FormatManager::GetSyntheticChildren] Caching %p for type %s", - static_cast<void *>(retval.get()), - match_data.GetTypeForCache().AsCString("<invalid>")); + 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}", @@ -851,13 +847,13 @@ FormatManager::GetValidator(ValueObject &valobj, TypeValidatorImplSP retval; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS)); if (match_data.GetTypeForCache()) { - if (log) - log->Printf( - "\n\n[FormatManager::GetValidator] Looking into cache for type %s", - match_data.GetTypeForCache().AsCString("<invalid>")); + 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) { - log->Printf( + LLDB_LOGF( + log, "[FormatManager::GetValidator] Cache search success. Returning."); LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}", m_format_cache.GetCacheHits(), @@ -865,16 +861,14 @@ FormatManager::GetValidator(ValueObject &valobj, } return retval; } - if (log) - log->Printf("[FormatManager::GetValidator] Cache search failed. Going " - "normal route"); + LLDB_LOGF(log, "[FormatManager::GetValidator] Cache search failed. Going " + "normal route"); } retval = m_categories_map.GetValidator(match_data); if (!retval) { - if (log) - log->Printf("[FormatManager::GetValidator] Search failed. Giving " - "language a chance."); + 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)) @@ -882,24 +876,21 @@ FormatManager::GetValidator(ValueObject &valobj, } } if (retval) { - if (log) - log->Printf("[FormatManager::GetValidator] Language search success. " - "Returning."); + LLDB_LOGF(log, "[FormatManager::GetValidator] Language search success. " + "Returning."); return retval; } } if (!retval) { - if (log) - log->Printf("[FormatManager::GetValidator] Search failed. Giving " - "hardcoded a chance."); + LLDB_LOGF(log, "[FormatManager::GetValidator] Search failed. Giving " + "hardcoded a chance."); retval = GetHardcodedValidator(match_data); } if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) { - if (log) - log->Printf("[FormatManager::GetValidator] Caching %p for type %s", - static_cast<void *>(retval.get()), - match_data.GetTypeForCache().AsCString("<invalid>")); + 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}", @@ -961,10 +952,7 @@ void FormatManager::LoadSystemFormatters() { lldb::TypeSummaryImplSP string_array_format( new StringSummaryFormat(string_array_flags, "${var%s}")); - lldb::RegularExpressionSP any_size_char_arr( - new RegularExpression(llvm::StringRef("char \\[[0-9]+\\]"))); - lldb::RegularExpressionSP any_size_wchar_arr( - new RegularExpression(llvm::StringRef("wchar_t \\[[0-9]+\\]"))); + RegularExpression any_size_char_arr(llvm::StringRef("char \\[[0-9]+\\]")); TypeCategoryImpl::SharedPointer sys_category_sp = GetCategory(m_system_category_name); @@ -973,8 +961,8 @@ void FormatManager::LoadSystemFormatters() { string_format); sys_category_sp->GetTypeSummariesContainer()->Add( ConstString("unsigned char *"), string_format); - sys_category_sp->GetRegexTypeSummariesContainer()->Add(any_size_char_arr, - string_array_format); + sys_category_sp->GetRegexTypeSummariesContainer()->Add( + std::move(any_size_char_arr), string_array_format); lldb::TypeSummaryImplSP ostype_summary( new StringSummaryFormat(TypeSummaryImpl::Flags() |