diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-24 17:56:10 +0000 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-24 17:56:10 +0000 |
| commit | 63e5fb76ecfed3434252868d8cf07d676f979f2f (patch) | |
| tree | 349d6bd303f53aa57b988dee284c7f264404a8fc /lldb/source/DataFormatters | |
| parent | 2bf871be4c35d70db080dde789cf9bb334c04057 (diff) | |
| download | bcm5719-llvm-63e5fb76ecfed3434252868d8cf07d676f979f2f.tar.gz bcm5719-llvm-63e5fb76ecfed3434252868d8cf07d676f979f2f.zip | |
[Logging] Replace Log::Printf with LLDB_LOG macro (NFC)
This patch replaces explicit calls to log::Printf with the new LLDB_LOGF
macro. The macro is similar to LLDB_LOG but supports printf-style format
strings, instead of formatv-style format strings.
So instead of writing:
if (log)
log->Printf("%s\n", str);
You'd write:
LLDB_LOG(log, "%s\n", str);
This change was done mechanically with the command below. I replaced the
spurious if-checks with vim, since I know how to do multi-line
replacements with it.
find . -type f -name '*.cpp' -exec \
sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" +
Differential revision: https://reviews.llvm.org/D65128
llvm-svn: 366936
Diffstat (limited to 'lldb/source/DataFormatters')
| -rw-r--r-- | lldb/source/DataFormatters/FormatManager.cpp | 161 | ||||
| -rw-r--r-- | lldb/source/DataFormatters/TypeCategoryMap.cpp | 56 |
2 files changed, 100 insertions, 117 deletions
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index dd2808a7cf7..e218687c3e4 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -630,30 +630,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 +660,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 +705,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 +735,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 +779,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 +809,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 +841,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 +855,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 +870,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}", diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp index 69757c9844e..b1075e9878d 100644 --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -180,7 +180,8 @@ TypeCategoryMap::GetFormat(FormattersMatchData &match_data) { if (log) { for (auto match : match_data.GetMatchesVector()) { - log->Printf( + LLDB_LOGF( + log, "[CategoryMap::GetFormat] candidate match = %s %s %s %s reason = " "%" PRIu32, match.GetTypeName().GetCString(), @@ -194,18 +195,16 @@ TypeCategoryMap::GetFormat(FormattersMatchData &match_data) { for (begin = m_active_categories.begin(); begin != end; begin++) { lldb::TypeCategoryImplSP category_sp = *begin; lldb::TypeFormatImplSP current_format; - if (log) - log->Printf("[TypeCategoryMap::GetFormat] Trying to use category %s", - category_sp->GetName()); + LLDB_LOGF(log, "[TypeCategoryMap::GetFormat] 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; } - if (log) - log->Printf( - "[TypeCategoryMap::GetFormat] nothing found - returning empty SP"); + LLDB_LOGF(log, + "[TypeCategoryMap::GetFormat] nothing found - returning empty SP"); return lldb::TypeFormatImplSP(); } @@ -220,7 +219,8 @@ TypeCategoryMap::GetSummaryFormat(FormattersMatchData &match_data) { if (log) { for (auto match : match_data.GetMatchesVector()) { - log->Printf( + LLDB_LOGF( + log, "[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s " "reason = %" PRIu32, match.GetTypeName().GetCString(), @@ -234,18 +234,17 @@ TypeCategoryMap::GetSummaryFormat(FormattersMatchData &match_data) { for (begin = m_active_categories.begin(); begin != end; begin++) { lldb::TypeCategoryImplSP category_sp = *begin; lldb::TypeSummaryImplSP current_format; - if (log) - log->Printf("[CategoryMap::GetSummaryFormat] Trying to use category %s", - category_sp->GetName()); + 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; } - if (log) - log->Printf( - "[CategoryMap::GetSummaryFormat] nothing found - returning empty SP"); + LLDB_LOGF( + log, + "[CategoryMap::GetSummaryFormat] nothing found - returning empty SP"); return lldb::TypeSummaryImplSP(); } @@ -261,7 +260,8 @@ TypeCategoryMap::GetSyntheticChildren(FormattersMatchData &match_data) { if (log) { for (auto match : match_data.GetMatchesVector()) { - log->Printf( + LLDB_LOGF( + log, "[CategoryMap::GetSyntheticChildren] candidate match = %s %s %s %s " "reason = %" PRIu32, match.GetTypeName().GetCString(), @@ -275,19 +275,18 @@ TypeCategoryMap::GetSyntheticChildren(FormattersMatchData &match_data) { for (begin = m_active_categories.begin(); begin != end; begin++) { lldb::TypeCategoryImplSP category_sp = *begin; lldb::SyntheticChildrenSP current_format; - if (log) - log->Printf( - "[CategoryMap::GetSyntheticChildren] Trying to use category %s", - category_sp->GetName()); + 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; } - if (log) - log->Printf("[CategoryMap::GetSyntheticChildren] nothing found - returning " - "empty SP"); + LLDB_LOGF(log, + "[CategoryMap::GetSyntheticChildren] nothing found - returning " + "empty SP"); return lldb::SyntheticChildrenSP(); } @@ -302,7 +301,8 @@ TypeCategoryMap::GetValidator(FormattersMatchData &match_data) { if (log) { for (auto match : match_data.GetMatchesVector()) { - log->Printf( + LLDB_LOGF( + log, "[CategoryMap::GetValidator] candidate match = %s %s %s %s reason = " "%" PRIu32, match.GetTypeName().GetCString(), @@ -316,18 +316,16 @@ TypeCategoryMap::GetValidator(FormattersMatchData &match_data) { for (begin = m_active_categories.begin(); begin != end; begin++) { lldb::TypeCategoryImplSP category_sp = *begin; lldb::TypeValidatorImplSP current_format; - if (log) - log->Printf("[CategoryMap::GetValidator] Trying to use category %s", - category_sp->GetName()); + 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; } - if (log) - log->Printf( - "[CategoryMap::GetValidator] nothing found - returning empty SP"); + LLDB_LOGF(log, + "[CategoryMap::GetValidator] nothing found - returning empty SP"); return lldb::TypeValidatorImplSP(); } |

