forked from OSchip/llvm-project
<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 llvm-svn: 166506
This commit is contained in:
parent
afaee3c3da
commit
91fe01753d
|
@ -13,6 +13,12 @@ class MaskedData_SyntheticChildrenProvider:
|
|||
# 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
|
||||
|
|
|
@ -132,6 +132,27 @@ class StdListSynthProvider:
|
|||
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 @@ class StdVectorSynthProvider:
|
|||
self.count = 0
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def has_children(self):
|
||||
return self.num_children() > 0
|
||||
|
||||
|
||||
class StdMapSynthProvider:
|
||||
|
@ -408,6 +433,8 @@ class StdMapSynthProvider:
|
|||
x = y;
|
||||
return x;
|
||||
|
||||
def has_children(self):
|
||||
return self.num_children() > 0
|
||||
|
||||
_map_capping_size = 255
|
||||
_list_capping_size = 255
|
||||
|
|
|
@ -124,6 +124,10 @@ class stdvector_SynthProvider:
|
|||
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 @@ class stdlist_SynthProvider:
|
|||
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 @@ class stdmap_SynthProvider:
|
|||
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 @@ class stddeque_SynthProvider:
|
|||
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 @@ class stdsharedptr_SynthProvider:
|
|||
def num_children(self):
|
||||
return 1
|
||||
|
||||
def has_children(self):
|
||||
return True
|
||||
|
||||
def get_child_index(self,name):
|
||||
if name=="__ptr_":
|
||||
return 0
|
||||
|
|
|
@ -776,7 +776,9 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd::Update()
|
|||
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 @@ lldb_private::formatters::NSArrayISyntheticFrontEnd::Update()
|
|||
bool
|
||||
lldb_private::formatters::NSArrayISyntheticFrontEnd::MightHaveChildren ()
|
||||
{
|
||||
return CalculateNumChildren() > 0;
|
||||
if (!m_data_ptr)
|
||||
Update ();
|
||||
return CalculateNumChildren();
|
||||
}
|
||||
|
||||
lldb::ValueObjectSP
|
||||
|
@ -1186,7 +1190,9 @@ lldb_private::formatters::NSDictionaryISyntheticFrontEnd::Update()
|
|||
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 @@ lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::Update()
|
|||
bool
|
||||
lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::MightHaveChildren ()
|
||||
{
|
||||
return CalculateNumChildren() > 0;
|
||||
if (!m_data_32 && !m_data_64)
|
||||
Update ();
|
||||
return CalculateNumChildren();
|
||||
}
|
||||
|
||||
lldb::ValueObjectSP
|
||||
|
|
Loading…
Reference in New Issue