[Lldb-commits] [lldb] r166460 - in /lldb/trunk: include/lldb/API/SBValue.h include/lldb/Core/ValueObject.h include/lldb/Core/ValueObjectSyntheticFilter.h scripts/Python/interface/SBValue.i source/API/SBValue.cpp source/Core/ValueObject.cpp source/Core/ValueObjectSyntheticFilter.cpp
Greg Clayton
gclayton at apple.com
Mon Oct 22 18:50:11 PDT 2012
Author: gclayton
Date: Mon Oct 22 20:50:10 2012
New Revision: 166460
URL: http://llvm.org/viewvc/llvm-project?rev=166460&view=rev
Log:
<rdar://problem/12493007>
Added a new API call to help efficiently determine if a SBValue could have children:
bool
SBValue::MightHaveChildren ();
This is inteneded to be used bui GUI programs that need to show if a SBValue needs a disclosure triangle when displaying a hierarchical type in a tree view without having to complete the type (by calling SBValue::GetNumChildren()) as completing the type is expensive.
Modified:
lldb/trunk/include/lldb/API/SBValue.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
lldb/trunk/scripts/Python/interface/SBValue.i
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=166460&r1=166459&r2=166460&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Mon Oct 22 20:50:10 2012
@@ -293,6 +293,25 @@
lldb::SBDeclaration
GetDeclaration ();
+ //------------------------------------------------------------------
+ /// Find out if a SBValue might have children.
+ ///
+ /// This call is much more efficient than GetNumChildren() as it
+ /// doesn't need to complete the underlying type. This is designed
+ /// to be used in a UI environment in order to detect if the
+ /// disclosure triangle should be displayed or not.
+ ///
+ /// This function returns true for class, union, structure,
+ /// pointers, references, arrays and more. Again, it does so without
+ /// doing any expensive type completion.
+ ///
+ /// @return
+ /// Returns \b true if the SBValue might have children, or \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ bool
+ MightHaveChildren ();
+
uint32_t
GetNumChildren ();
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=166460&r1=166459&r2=166460&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Oct 22 20:50:10 2012
@@ -1071,6 +1071,25 @@
m_did_calculate_complete_objc_class_type = true;
}
+ //------------------------------------------------------------------
+ /// Find out if a SBValue might have children.
+ ///
+ /// This call is much more efficient than CalculateNumChildren() as
+ /// it doesn't need to complete the underlying type. This is designed
+ /// to be used in a UI environment in order to detect if the
+ /// disclosure triangle should be displayed or not.
+ ///
+ /// This function returns true for class, union, structure,
+ /// pointers, references, arrays and more. Again, it does so without
+ /// doing any expensive type completion.
+ ///
+ /// @return
+ /// Returns \b true if the SBValue might have children, or \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ virtual bool
+ MightHaveChildren();
+
protected:
typedef ClusterManager<ValueObject> ValueObjectManager;
Modified: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=166460&r1=166459&r2=166460&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Mon Oct 22 20:50:10 2012
@@ -39,6 +39,9 @@
virtual ConstString
GetTypeName();
+ virtual bool
+ MightHaveChildren();
+
virtual uint32_t
CalculateNumChildren();
Modified: lldb/trunk/scripts/Python/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=166460&r1=166459&r2=166460&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValue.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValue.i Mon Oct 22 20:50:10 2012
@@ -302,6 +302,9 @@
lldb::SBDeclaration
GetDeclaration ();
+ bool
+ MightHaveChildren ();
+
uint32_t
GetNumChildren ();
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=166460&r1=166459&r2=166460&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Mon Oct 22 20:50:10 2012
@@ -1354,6 +1354,20 @@
return fail_value;
}
+bool
+SBValue::MightHaveChildren ()
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ bool has_children = false;
+ lldb::ValueObjectSP value_sp(GetSP());
+ if (value_sp)
+ has_children = value_sp->MightHaveChildren();
+
+ if (log)
+ log->Printf ("SBValue(%p)::HasChildren() => %i", value_sp.get(), has_children);
+ return has_children;
+}
+
uint32_t
SBValue::GetNumChildren ()
{
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=166460&r1=166459&r2=166460&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Oct 22 20:50:10 2012
@@ -597,6 +597,30 @@
}
return m_children.GetChildrenCount();
}
+
+bool
+ValueObject::MightHaveChildren()
+{
+ bool has_children;
+ clang_type_t clang_type = GetClangType();
+ if (clang_type)
+ {
+ const uint32_t type_info = ClangASTContext::GetTypeInfo (clang_type,
+ GetClangAST(),
+ NULL);
+ if (type_info & (ClangASTContext::eTypeHasChildren |
+ ClangASTContext::eTypeIsPointer |
+ ClangASTContext::eTypeIsReference))
+ has_children = true;
+ }
+ else
+ {
+ has_children = GetNumChildren () > 0;
+ }
+ return has_children;
+}
+
+// Should only be called by ValueObject::GetNumChildren()
void
ValueObject::SetNumChildren (uint32_t num_children)
{
Modified: lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp?rev=166460&r1=166459&r2=166460&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp Mon Oct 22 20:50:10 2012
@@ -96,6 +96,14 @@
return (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren());
}
+bool
+ValueObjectSynthetic::MightHaveChildren()
+{
+ // TODO: make this more efficient by adding API calls to calculate this efficiently
+ return GetNumChildren () > 0;
+}
+
+
clang::ASTContext *
ValueObjectSynthetic::GetClangASTImpl ()
{
More information about the lldb-commits
mailing list