[SBValue] Add a method GetNumChildren(uint32_t max)

Summary:
Along with this, support for an optional argument to the "num_children"
method of a Python synthetic child provider has also been added. These have
been added with the following use case in mind:

Synthetic child providers currently have a method "has_children" and
"num_children". While the former is good enough to know if there are
children, it does not give any insight into how many children there are.
Though the latter serves this purpose, calculating the number for children
of a data structure could be an O(N) operation if the data structure has N
children. The new method added in this change provide a middle ground.
One can call GetNumChildren(K) to know if a child exists at an index K
which can be as large as the callers tolerance can be. If the caller wants
to know about children beyond K, it can make an other call with 2K. If the
synthetic child provider maintains state about it counting till K
previosly, then the next call is only an O(K) operation. Infact, all
calls made progressively with steps of K will be O(K) operations.

Reviewers: vharron, clayborg, granata.enrico

Subscribers: labath, lldb-commits

Differential Revision: http://reviews.llvm.org/D13778

llvm-svn: 250930
This commit is contained in:
Siva Chandra
2015-10-21 19:28:08 +00:00
parent c8a8a5e2ae
commit 9ac7a6c51f
31 changed files with 189 additions and 61 deletions

View File

@@ -2199,7 +2199,7 @@ ScriptInterpreterPython::WatchpointCallbackFunction
}
size_t
ScriptInterpreterPython::CalculateNumChildren(const StructuredData::ObjectSP &implementor_sp)
ScriptInterpreterPython::CalculateNumChildren(const StructuredData::ObjectSP &implementor_sp, uint32_t max)
{
if (!implementor_sp)
return 0;
@@ -2217,7 +2217,7 @@ ScriptInterpreterPython::CalculateNumChildren(const StructuredData::ObjectSP &im
{
Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
ret_val = g_swig_calc_children (implementor);
ret_val = g_swig_calc_children (implementor, max);
}
return ret_val;