kastiglione created this revision. kastiglione added reviewers: jingham, augusto2112. Herald added a project: All. kastiglione requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
The `formatter` logs include a function name, but these functions are mostly templates and the template type parameter is not printed, which is useful context. This change adds a new log which is printed upon entry of `FormatManager::Get`, which shows the formatter context as either `format`, `summary`, or `synthetic`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D154128 Files: lldb/source/DataFormatters/FormatManager.cpp Index: lldb/source/DataFormatters/FormatManager.cpp =================================================================== --- lldb/source/DataFormatters/FormatManager.cpp +++ lldb/source/DataFormatters/FormatManager.cpp @@ -596,15 +596,24 @@ return retval_sp; } +namespace { +template <typename ImplSP> const char *FormatterKind; +template <> const char *FormatterKind<lldb::TypeFormatImplSP> = "format"; +template <> const char *FormatterKind<lldb::TypeSummaryImplSP> = "summary"; +template <> const char *FormatterKind<lldb::SyntheticChildrenSP> = "synthetic"; +} // namespace + template <typename ImplSP> ImplSP FormatManager::Get(ValueObject &valobj, lldb::DynamicValueType use_dynamic) { + Log *log = GetLog(LLDBLog::DataFormatters); + LLDB_LOGF(log, "\n\n[%s] Begin %s lookup.", __FUNCTION__, + FormatterKind<ImplSP>); + FormattersMatchData match_data(valobj, use_dynamic); if (ImplSP retval_sp = GetCached<ImplSP>(match_data)) return retval_sp; - Log *log = GetLog(LLDBLog::DataFormatters); - 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)) { @@ -628,7 +637,7 @@ ImplSP retval_sp; Log *log = GetLog(LLDBLog::DataFormatters); if (match_data.GetTypeForCache()) { - LLDB_LOGF(log, "\n\n[%s] Looking into cache for type %s", __FUNCTION__, + LLDB_LOGF(log, "[%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) {
Index: lldb/source/DataFormatters/FormatManager.cpp =================================================================== --- lldb/source/DataFormatters/FormatManager.cpp +++ lldb/source/DataFormatters/FormatManager.cpp @@ -596,15 +596,24 @@ return retval_sp; } +namespace { +template <typename ImplSP> const char *FormatterKind; +template <> const char *FormatterKind<lldb::TypeFormatImplSP> = "format"; +template <> const char *FormatterKind<lldb::TypeSummaryImplSP> = "summary"; +template <> const char *FormatterKind<lldb::SyntheticChildrenSP> = "synthetic"; +} // namespace + template <typename ImplSP> ImplSP FormatManager::Get(ValueObject &valobj, lldb::DynamicValueType use_dynamic) { + Log *log = GetLog(LLDBLog::DataFormatters); + LLDB_LOGF(log, "\n\n[%s] Begin %s lookup.", __FUNCTION__, + FormatterKind<ImplSP>); + FormattersMatchData match_data(valobj, use_dynamic); if (ImplSP retval_sp = GetCached<ImplSP>(match_data)) return retval_sp; - Log *log = GetLog(LLDBLog::DataFormatters); - 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)) { @@ -628,7 +637,7 @@ ImplSP retval_sp; Log *log = GetLog(LLDBLog::DataFormatters); if (match_data.GetTypeForCache()) { - LLDB_LOGF(log, "\n\n[%s] Looking into cache for type %s", __FUNCTION__, + LLDB_LOGF(log, "[%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-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits