[Lldb-commits] [lldb] r166506 - in /lldb/trunk: examples/synthetic/bitfield/example.py examples/synthetic/gnu_libstdcpp.py examples/synthetic/libcxx.py source/Core/CXXFormatterFunctions.cpp
Enrico Granata
egranata at apple.com
Tue Oct 23 14:54:53 PDT 2012
Author: enrico
Date: Tue Oct 23 16:54:53 2012
New Revision: 166506
URL: http://llvm.org/viewvc/llvm-project?rev=166506&view=rev
Log:
<rdar://problem/12523238> Commit 2 of 3
Adding the new has_children (or MightHaveChildren() in C++) for the existing synthetic children providers
In a few cases, the new call is going to be much more efficient than the previous num_children > 0 check
When the optimization was marginal (e.g. std::vector<>), the choice was to use num_children in order to keep
implementation details in one function instead of duplicating code
Next step is to provide test cases
Modified:
lldb/trunk/examples/synthetic/bitfield/example.py
lldb/trunk/examples/synthetic/gnu_libstdcpp.py
lldb/trunk/examples/synthetic/libcxx.py
lldb/trunk/source/Core/CXXFormatterFunctions.cpp
Modified: lldb/trunk/examples/synthetic/bitfield/example.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/bitfield/example.py?rev=166506&r1=166505&r2=166506&view=diff
==============================================================================
--- lldb/trunk/examples/synthetic/bitfield/example.py (original)
+++ lldb/trunk/examples/synthetic/bitfield/example.py Tue Oct 23 16:54:53 2012
@@ -13,6 +13,12 @@
# answer questions about N children
return 4
+ def has_children(self):
+ # we simply say True here because we know we have 4 children
+ # in general, you want to make this calculation as simple as possible
+ # and return True if in doubt (you can always return num_children == 0 later)
+ return True
+
def get_child_index(self,name):
# given a name, return its index
# you can return None if you don't know the answer for a given name
Modified: lldb/trunk/examples/synthetic/gnu_libstdcpp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/gnu_libstdcpp.py?rev=166506&r1=166505&r2=166506&view=diff
==============================================================================
--- lldb/trunk/examples/synthetic/gnu_libstdcpp.py (original)
+++ lldb/trunk/examples/synthetic/gnu_libstdcpp.py Tue Oct 23 16:54:53 2012
@@ -132,6 +132,27 @@
except:
pass
+ def has_children(self):
+ logger = lldb.formatters.Logger.Logger()
+ if self.count == None:
+ self.update ()
+ try:
+ next_val = self.next.GetValueAsUnsigned(0)
+ prev_val = self.prev.GetValueAsUnsigned(0)
+ if next_val == 0 or prev_val == 0:
+ return False
+ if next_val == self.node_address:
+ return False
+ # skip all the advanced logic to detect the exact count of children
+ # in the interest of speed from this point on, we MIGHT have children
+ # our loop detection logic will still make nothing show up :)
+ return True
+ except:
+ return False
+ if self.count == 0:
+ return False
+ return True
+
class StdVectorSynthProvider:
def __init__(self, valobj, dict):
@@ -225,6 +246,10 @@
self.count = 0
except:
pass
+
+
+ def has_children(self):
+ return self.num_children() > 0
class StdMapSynthProvider:
@@ -408,6 +433,8 @@
x = y;
return x;
+ def has_children(self):
+ return self.num_children() > 0
_map_capping_size = 255
_list_capping_size = 255
Modified: lldb/trunk/examples/synthetic/libcxx.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/libcxx.py?rev=166506&r1=166505&r2=166506&view=diff
==============================================================================
--- lldb/trunk/examples/synthetic/libcxx.py (original)
+++ lldb/trunk/examples/synthetic/libcxx.py Tue Oct 23 16:54:53 2012
@@ -124,6 +124,10 @@
except:
pass
+ def has_children(self):
+ # retrieving the count is quick enough on a std::vector
+ return self.num_children() > 0
+
# Just an example: the actual summary is produced by a summary string: size=${svar%#}
def stdvector_SummaryProvider(valobj,dict):
prov = stdvector_SynthProvider(valobj,None)
@@ -317,6 +321,28 @@
except:
pass
+ def has_children(self):
+ logger = lldb.formatters.Logger.Logger()
+ if self.count == None:
+ self.update()
+ try:
+ next_val = self.head.GetValueAsUnsigned(0)
+ prev_val = self.tail.GetValueAsUnsigned(0)
+ if next_val == 0 or prev_val == 0:
+ return False
+ if next_val == self.node_address:
+ return False
+ # skip all the advanced logic to detect the exact count of children
+ # in the interest of speed from this point on, we MIGHT have children
+ # our loop detection logic will still make nothing show up :)
+ return True
+ except:
+ return 0;
+ if self.count == 0:
+ return False
+ return True
+
+
# Just an example: the actual summary is produced by a summary string: size=${svar%#}
def stdlist_SummaryProvider(valobj,dict):
prov = stdlist_SynthProvider(valobj,None)
@@ -477,6 +503,9 @@
except:
return 0;
+ def has_children(self):
+ return self.num_children_impl() > 0
+
def get_data_type(self):
logger = lldb.formatters.Logger.Logger()
if self.data_type == None or self.data_size == None:
@@ -599,6 +628,11 @@
return 0
return min(self.count, _deque_capping_size)
+ def has_children(self):
+ if self.cont is None:
+ self.update()
+ return self.count > 0
+
def get_child_index(self,name):
logger = lldb.formatters.Logger.Logger()
try:
@@ -702,6 +736,9 @@
def num_children(self):
return 1
+ def has_children(self):
+ return True
+
def get_child_index(self,name):
if name=="__ptr_":
return 0
Modified: lldb/trunk/source/Core/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/CXXFormatterFunctions.cpp?rev=166506&r1=166505&r2=166506&view=diff
==============================================================================
--- lldb/trunk/source/Core/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/Core/CXXFormatterFunctions.cpp Tue Oct 23 16:54:53 2012
@@ -776,7 +776,9 @@
bool
lldb_private::formatters::NSArrayMSyntheticFrontEnd::MightHaveChildren ()
{
- return CalculateNumChildren() > 0;
+ if (!m_data_32 && !m_data_64)
+ Update ();
+ return CalculateNumChildren();
}
static uint32_t
@@ -891,7 +893,9 @@
bool
lldb_private::formatters::NSArrayISyntheticFrontEnd::MightHaveChildren ()
{
- return CalculateNumChildren() > 0;
+ if (!m_data_ptr)
+ Update ();
+ return CalculateNumChildren();
}
lldb::ValueObjectSP
@@ -1186,7 +1190,9 @@
bool
lldb_private::formatters::NSDictionaryISyntheticFrontEnd::MightHaveChildren ()
{
- return CalculateNumChildren() > 0;
+ if (!m_data_32 && !m_data_64)
+ Update ();
+ return CalculateNumChildren();
}
lldb::ValueObjectSP
@@ -1333,7 +1339,9 @@
bool
lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::MightHaveChildren ()
{
- return CalculateNumChildren() > 0;
+ if (!m_data_32 && !m_data_64)
+ Update ();
+ return CalculateNumChildren();
}
lldb::ValueObjectSP
More information about the lldb-commits
mailing list