diff options
-rw-r--r-- | lldb/source/Core/ValueObjectSyntheticFilter.cpp | 86 |
1 files changed, 78 insertions, 8 deletions
diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp index cf1e107dd86..888933416d4 100644 --- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp +++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp @@ -12,6 +12,8 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/ValueObjectSyntheticFilter.h" + +#include "lldb/Core/Log.h" #include "lldb/Core/ValueObject.h" #include "lldb/DataFormatters/TypeSynthetic.h" @@ -65,13 +67,7 @@ ValueObjectSynthetic::ValueObjectSynthetic (ValueObject &parent, lldb::Synthetic m_might_have_children(eLazyBoolCalculate), m_provides_value(eLazyBoolCalculate) { -#ifdef FOOBAR - std::string new_name(parent.GetName().AsCString()); - new_name += "$$__synth__"; - SetName (ConstString(new_name.c_str())); -#else SetName(parent.GetName()); -#endif CopyValueData(m_parent); CreateSynthFilter(); } @@ -108,14 +104,32 @@ ValueObjectSynthetic::GetDisplayTypeName() size_t ValueObjectSynthetic::CalculateNumChildren(uint32_t max) { + Log* log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS); + UpdateValueIfNeeded(); if (m_synthetic_children_count < UINT32_MAX) return m_synthetic_children_count <= max ? m_synthetic_children_count : max; if (max < UINT32_MAX) - return m_synth_filter_ap->CalculateNumChildren(max); + { + size_t num_children = m_synth_filter_ap->CalculateNumChildren(max); + if (log) + log->Printf("[ValueObjectSynthetic::CalculateNumChildren] for VO of name %s and type %s, the filter returned %zu child values", + GetName().AsCString(), + GetTypeName().AsCString(), + num_children); + return num_children; + } else - return (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren(max)); + { + size_t num_children = (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren(max)); + if (log) + log->Printf("[ValueObjectSynthetic::CalculateNumChildren] for VO of name %s and type %s, the filter returned %zu child values", + GetName().AsCString(), + GetTypeName().AsCString(), + num_children); + return num_children; + } } lldb::ValueObjectSP @@ -159,6 +173,8 @@ ValueObjectSynthetic::CreateSynthFilter () bool ValueObjectSynthetic::UpdateValue () { + Log* log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS); + SetValueIsValid (false); m_error.Clear(); @@ -175,6 +191,11 @@ ValueObjectSynthetic::UpdateValue () ConstString new_parent_type_name = m_parent->GetTypeName(); if (new_parent_type_name != m_parent_type_name) { + if (log) + log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, type changed from %s to %s, recomputing synthetic filter", + GetName().AsCString(), + m_parent_type_name.AsCString(), + new_parent_type_name.AsCString()); m_parent_type_name = new_parent_type_name; CreateSynthFilter(); } @@ -182,6 +203,8 @@ ValueObjectSynthetic::UpdateValue () // let our backend do its update if (m_synth_filter_ap->Update() == false) { + if (log) + log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said caches are stale - clearing", GetName().AsCString()); // filter said that cached values are stale m_children_byindex.Clear(); m_name_toindex.Clear(); @@ -192,6 +215,11 @@ ValueObjectSynthetic::UpdateValue () m_synthetic_children_count = UINT32_MAX; m_might_have_children = eLazyBoolCalculate; } + else + { + if (log) + log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said caches are still valid", GetName().AsCString()); + } m_provides_value = eLazyBoolCalculate; @@ -199,11 +227,17 @@ ValueObjectSynthetic::UpdateValue () if (synth_val && synth_val->CanProvideValue()) { + if (log) + log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said it can provide a value", GetName().AsCString()); + m_provides_value = eLazyBoolYes; CopyValueData(synth_val.get()); } else { + if (log) + log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said it will not provide a value", GetName().AsCString()); + m_provides_value = eLazyBoolNo; CopyValueData(m_parent); } @@ -215,6 +249,13 @@ ValueObjectSynthetic::UpdateValue () lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create) { + Log* log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS); + + if (log) + log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, retrieving child at index %zu", + GetName().AsCString(), + idx); + UpdateValueIfNeeded(); ValueObject *valobj; @@ -222,7 +263,19 @@ ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create) { if (can_create && m_synth_filter_ap.get() != nullptr) { + if (log) + log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu not cached and will be created", + GetName().AsCString(), + idx); + lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex (idx); + + if (log) + log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu created as %p", + GetName().AsCString(), + idx, + synth_guy.get()); + if (!synth_guy) return synth_guy; m_children_byindex.SetValueForKey(idx, synth_guy.get()); @@ -230,10 +283,27 @@ ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create) return synth_guy; } else + { + if (log) + log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu not cached and cannot be created (can_create = %s, synth_filter = %p)", + GetName().AsCString(), + idx, + can_create ? "yes" : "no", + m_synth_filter_ap.get()); + return lldb::ValueObjectSP(); + } } else + { + if (log) + log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu cached as %p", + GetName().AsCString(), + idx, + valobj); + return valobj->GetSP(); + } } lldb::ValueObjectSP |