blob: 90cbcd7c70b1cf85ad3e630d88bac4ff53b9f0e0 [file] [log] [blame]
Enrico Granata217f91f2011-08-17 19:07:52 +00001import re
Enrico Granata85ce21c2012-04-25 16:32:39 +00002import lldb.formatters.Logger
Enrico Granata217f91f2011-08-17 19:07:52 +00003
4# C++ STL formatters for LLDB
Enrico Granata5a61fc0d2011-08-22 16:10:25 +00005# These formatters are based upon the version of the GNU libstdc++
Enrico Granata114bb192012-08-27 17:42:50 +00006# as it ships with Mac OS X 10.6.8 thru 10.8.0
Enrico Granata5a61fc0d2011-08-22 16:10:25 +00007# You are encouraged to look at the STL implementation for your platform
8# before relying on these formatters to do the right thing for your setup
Enrico Granata217f91f2011-08-17 19:07:52 +00009
10class StdListSynthProvider:
11
12 def __init__(self, valobj, dict):
Enrico Granata7d222212012-04-25 17:53:41 +000013 logger = lldb.formatters.Logger.Logger()
Enrico Granata217f91f2011-08-17 19:07:52 +000014 self.valobj = valobj
Enrico Granatacb50d342012-04-10 00:11:03 +000015 self.count = None
16 logger >> "Providing synthetic children for a map named " + str(valobj.GetName())
Enrico Granata217f91f2011-08-17 19:07:52 +000017
Enrico Granata9d60f602012-03-09 03:09:58 +000018 def next_node(self,node):
Enrico Granata7d222212012-04-25 17:53:41 +000019 logger = lldb.formatters.Logger.Logger()
Enrico Granata9d60f602012-03-09 03:09:58 +000020 return node.GetChildMemberWithName('_M_next')
21
22 def is_valid(self,node):
Enrico Granata7d222212012-04-25 17:53:41 +000023 logger = lldb.formatters.Logger.Logger()
Enrico Granata9d60f602012-03-09 03:09:58 +000024 return self.value(self.next_node(node)) != self.node_address
25
26 def value(self,node):
Enrico Granata7d222212012-04-25 17:53:41 +000027 logger = lldb.formatters.Logger.Logger()
Enrico Granata9d60f602012-03-09 03:09:58 +000028 return node.GetValueAsUnsigned()
29
30 # Floyd's cyle-finding algorithm
31 # try to detect if this list has a loop
32 def has_loop(self):
Enrico Granatad50f18b2012-03-29 19:29:45 +000033 global _list_uses_loop_detector
Enrico Granata7d222212012-04-25 17:53:41 +000034 logger = lldb.formatters.Logger.Logger()
Enrico Granatad50f18b2012-03-29 19:29:45 +000035 if _list_uses_loop_detector == False:
36 logger >> "Asked not to use loop detection"
37 return False
Enrico Granata9d60f602012-03-09 03:09:58 +000038 slow = self.next
39 fast1 = self.next
40 fast2 = self.next
41 while self.is_valid(slow):
42 slow_value = self.value(slow)
43 fast1 = self.next_node(fast2)
44 fast2 = self.next_node(fast1)
45 if self.value(fast1) == slow_value or self.value(fast2) == slow_value:
46 return True
47 slow = self.next_node(slow)
48 return False
49
Enrico Granata217f91f2011-08-17 19:07:52 +000050 def num_children(self):
Enrico Granatad50f18b2012-03-29 19:29:45 +000051 global _list_capping_size
Enrico Granata7d222212012-04-25 17:53:41 +000052 logger = lldb.formatters.Logger.Logger()
Enrico Granata9d60f602012-03-09 03:09:58 +000053 if self.count == None:
54 self.count = self.num_children_impl()
Enrico Granatad50f18b2012-03-29 19:29:45 +000055 if self.count > _list_capping_size:
56 self.count = _list_capping_size
Enrico Granata9d60f602012-03-09 03:09:58 +000057 return self.count
58
59 def num_children_impl(self):
Enrico Granata7d222212012-04-25 17:53:41 +000060 logger = lldb.formatters.Logger.Logger()
Enrico Granatad50f18b2012-03-29 19:29:45 +000061 global _list_capping_size
Enrico Granata5a61fc0d2011-08-22 16:10:25 +000062 try:
63 next_val = self.next.GetValueAsUnsigned(0)
64 prev_val = self.prev.GetValueAsUnsigned(0)
65 # After a std::list has been initialized, both next and prev will be non-NULL
66 if next_val == 0 or prev_val == 0:
67 return 0
68 if next_val == self.node_address:
69 return 0
70 if next_val == prev_val:
71 return 1
Enrico Granata9d60f602012-03-09 03:09:58 +000072 if self.has_loop():
73 return 0
Enrico Granata5a61fc0d2011-08-22 16:10:25 +000074 size = 2
75 current = self.next
76 while current.GetChildMemberWithName('_M_next').GetValueAsUnsigned(0) != self.node_address:
77 size = size + 1
78 current = current.GetChildMemberWithName('_M_next')
Enrico Granatad50f18b2012-03-29 19:29:45 +000079 if size > _list_capping_size:
80 return _list_capping_size
Enrico Granata5a61fc0d2011-08-22 16:10:25 +000081 return (size - 1)
82 except:
83 return 0;
Enrico Granata217f91f2011-08-17 19:07:52 +000084
85 def get_child_index(self,name):
Enrico Granata7d222212012-04-25 17:53:41 +000086 logger = lldb.formatters.Logger.Logger()
Enrico Granata5a61fc0d2011-08-22 16:10:25 +000087 try:
88 return int(name.lstrip('[').rstrip(']'))
89 except:
90 return -1
Enrico Granata217f91f2011-08-17 19:07:52 +000091
92 def get_child_at_index(self,index):
Enrico Granata7d222212012-04-25 17:53:41 +000093 logger = lldb.formatters.Logger.Logger()
Enrico Granata22fe3172012-03-30 16:07:08 +000094 logger >> "Fetching child " + str(index)
Enrico Granata5a61fc0d2011-08-22 16:10:25 +000095 if index < 0:
96 return None;
Enrico Granata217f91f2011-08-17 19:07:52 +000097 if index >= self.num_children():
98 return None;
Enrico Granata5a61fc0d2011-08-22 16:10:25 +000099 try:
100 offset = index
101 current = self.next
102 while offset > 0:
103 current = current.GetChildMemberWithName('_M_next')
104 offset = offset - 1
105 return current.CreateChildAtOffset('['+str(index)+']',2*current.GetType().GetByteSize(),self.data_type)
106 except:
Enrico Granata23e578c2011-08-22 16:38:44 +0000107 return None
Enrico Granata217f91f2011-08-17 19:07:52 +0000108
Enrico Granata4cee9e52012-02-03 18:11:52 +0000109 def extract_type(self):
Enrico Granata7d222212012-04-25 17:53:41 +0000110 logger = lldb.formatters.Logger.Logger()
Enrico Granata4cee9e52012-02-03 18:11:52 +0000111 list_type = self.valobj.GetType().GetUnqualifiedType()
Enrico Granatac5bc4122012-03-27 02:35:13 +0000112 if list_type.IsReferenceType():
113 list_type = list_type.GetDereferencedType()
Enrico Granata4cee9e52012-02-03 18:11:52 +0000114 if list_type.GetNumberOfTemplateArguments() > 0:
115 data_type = list_type.GetTemplateArgumentType(0)
116 else:
117 data_type = None
118 return data_type
Enrico Granata217f91f2011-08-17 19:07:52 +0000119
120 def update(self):
Enrico Granata7d222212012-04-25 17:53:41 +0000121 logger = lldb.formatters.Logger.Logger()
Enrico Granata79c1baf2012-03-31 00:15:24 +0000122 # preemptively setting this to None - we might end up changing our mind later
123 self.count = None
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000124 try:
125 impl = self.valobj.GetChildMemberWithName('_M_impl')
126 node = impl.GetChildMemberWithName('_M_node')
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000127 self.node_address = self.valobj.AddressOf().GetValueAsUnsigned(0)
128 self.next = node.GetChildMemberWithName('_M_next')
129 self.prev = node.GetChildMemberWithName('_M_prev')
Enrico Granata4cee9e52012-02-03 18:11:52 +0000130 self.data_type = self.extract_type()
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000131 self.data_size = self.data_type.GetByteSize()
132 except:
133 pass
Enrico Granata217f91f2011-08-17 19:07:52 +0000134
Enrico Granata91fe0172012-10-23 21:54:53 +0000135 def has_children(self):
Enrico Granata91fe0172012-10-23 21:54:53 +0000136 return True
137
Enrico Granata217f91f2011-08-17 19:07:52 +0000138class StdVectorSynthProvider:
139
Siva Chandra8d88d082015-03-17 21:23:17 +0000140 class StdVectorImplementation(object):
141 def __init__(self, valobj):
142 self.valobj = valobj
143 self.count = None
144
145 def num_children(self):
146 if self.count == None:
147 self.count = self.num_children_impl()
148 return self.count
149
150 def num_children_impl(self):
151 try:
152 start_val = self.start.GetValueAsUnsigned(0)
153 finish_val = self.finish.GetValueAsUnsigned(0)
154 end_val = self.end.GetValueAsUnsigned(0)
155 # Before a vector has been constructed, it will contain bad values
156 # so we really need to be careful about the length we return since
157 # unitialized data can cause us to return a huge number. We need
158 # to also check for any of the start, finish or end of storage values
159 # being zero (NULL). If any are, then this vector has not been
160 # initialized yet and we should return zero
161
162 # Make sure nothing is NULL
163 if start_val == 0 or finish_val == 0 or end_val == 0:
164 return 0
165 # Make sure start is less than finish
166 if start_val >= finish_val:
167 return 0
168 # Make sure finish is less than or equal to end of storage
169 if finish_val > end_val:
170 return 0
171
172 # if we have a struct (or other data type that the compiler pads to native word size)
173 # this check might fail, unless the sizeof() we get is itself incremented to take the
174 # padding bytes into account - on current clang it looks like this is the case
175 num_children = (finish_val-start_val)
176 if (num_children % self.data_size) != 0:
177 return 0
178 else:
179 num_children = num_children/self.data_size
180 return num_children
181 except:
182 return 0;
183
184 def get_child_at_index(self, index):
185 logger = lldb.formatters.Logger.Logger()
186 logger >> "Retrieving child " + str(index)
187 if index < 0:
188 return None;
189 if index >= self.num_children():
190 return None;
191 try:
192 offset = index * self.data_size
193 return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type)
194 except:
195 return None
196
197 def update(self):
198 # preemptively setting this to None - we might end up changing our mind later
199 self.count = None
200 try:
201 impl = self.valobj.GetChildMemberWithName('_M_impl')
202 self.start = impl.GetChildMemberWithName('_M_start')
203 self.finish = impl.GetChildMemberWithName('_M_finish')
204 self.end = impl.GetChildMemberWithName('_M_end_of_storage')
205 self.data_type = self.start.GetType().GetPointeeType()
206 self.data_size = self.data_type.GetByteSize()
207 # if any of these objects is invalid, it means there is no point in trying to fetch anything
208 if self.start.IsValid() and self.finish.IsValid() and self.end.IsValid() and self.data_type.IsValid():
209 self.count = None
210 else:
211 self.count = 0
212 except:
213 pass
214 return True
215
216 class StdVBoolImplementation(object):
217 def __init__(self, valobj, bool_type):
218 self.valobj = valobj
219 self.bool_type = bool_type
220 self.valid = False
221
222 def num_children(self):
223 if self.valid:
224 start = self.start_p.GetValueAsUnsigned(0)
225 finish = self.finish_p.GetValueAsUnsigned(0)
226 offset = self.offset.GetValueAsUnsigned(0)
227 if finish >= start:
228 return (finish - start) * 8 + offset
229 return 0
230
231 def get_child_at_index(self, index):
232 if index >= self.num_children():
233 return None
234 byte_offset = index / 8
235 bit_offset = index % 8
Tamas Berghammer639e8ad2015-03-25 10:59:12 +0000236 element_size = self.start_p.GetType().GetPointeeType().GetByteSize()
237 data = self.start_p.GetPointeeData(byte_offset / element_size)
238 bit = data.GetUnsignedInt8(lldb.SBError(), byte_offset % element_size) & (1 << bit_offset)
Siva Chandra8d88d082015-03-17 21:23:17 +0000239 if bit != 0:
240 value_expr = "(bool)true"
241 else:
242 value_expr = "(bool)false"
243 return self.valobj.CreateValueFromExpression("[%d]" % index, value_expr)
244
245 def update(self):
246 try:
247 m_impl = self.valobj.GetChildMemberWithName('_M_impl')
248 self.m_start = m_impl.GetChildMemberWithName('_M_start')
249 self.m_finish = m_impl.GetChildMemberWithName('_M_finish')
250 self.start_p = self.m_start.GetChildMemberWithName('_M_p')
251 self.finish_p = self.m_finish.GetChildMemberWithName('_M_p')
252 self.offset = self.m_finish.GetChildMemberWithName('_M_offset')
253 self.valid = True
254 except:
255 self.valid = False
256 return True
257
Enrico Granata217f91f2011-08-17 19:07:52 +0000258 def __init__(self, valobj, dict):
Enrico Granata7d222212012-04-25 17:53:41 +0000259 logger = lldb.formatters.Logger.Logger()
Siva Chandra8d88d082015-03-17 21:23:17 +0000260 first_template_arg_type = valobj.GetType().GetTemplateArgumentType(0)
261 if str(first_template_arg_type.GetName()) == "bool":
262 self.impl = self.StdVBoolImplementation(valobj, first_template_arg_type)
263 else:
264 self.impl = self.StdVectorImplementation(valobj)
Siva Chandra3b360382015-03-16 23:02:03 +0000265 logger >> "Providing synthetic children for a vector named " + str(valobj.GetName())
Enrico Granata217f91f2011-08-17 19:07:52 +0000266
267 def num_children(self):
Siva Chandra8d88d082015-03-17 21:23:17 +0000268 return self.impl.num_children()
Enrico Granata217f91f2011-08-17 19:07:52 +0000269
270 def get_child_index(self,name):
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000271 try:
272 return int(name.lstrip('[').rstrip(']'))
273 except:
274 return -1
Enrico Granata217f91f2011-08-17 19:07:52 +0000275
Siva Chandra8d88d082015-03-17 21:23:17 +0000276 def get_child_at_index(self, index):
277 return self.impl.get_child_at_index(index)
Enrico Granata217f91f2011-08-17 19:07:52 +0000278
279 def update(self):
Siva Chandra8d88d082015-03-17 21:23:17 +0000280 return self.impl.update()
Enrico Granata91fe0172012-10-23 21:54:53 +0000281
282 def has_children(self):
Enrico Granataecbabe62012-12-10 19:55:53 +0000283 return True
Enrico Granata217f91f2011-08-17 19:07:52 +0000284
285
286class StdMapSynthProvider:
287
288 def __init__(self, valobj, dict):
Enrico Granata7d222212012-04-25 17:53:41 +0000289 logger = lldb.formatters.Logger.Logger()
Enrico Granata217f91f2011-08-17 19:07:52 +0000290 self.valobj = valobj;
Enrico Granatacb50d342012-04-10 00:11:03 +0000291 self.count = None
Enrico Granatad50f18b2012-03-29 19:29:45 +0000292 logger >> "Providing synthetic children for a map named " + str(valobj.GetName())
Enrico Granata4cee9e52012-02-03 18:11:52 +0000293
294 # we need this function as a temporary workaround for rdar://problem/10801549
295 # which prevents us from extracting the std::pair<K,V> SBType out of the template
296 # arguments for _Rep_Type _M_t in the map itself - because we have to make up the
297 # typename and then find it, we may hit the situation were std::string has multiple
298 # names but only one is actually referenced in the debug information. hence, we need
299 # to replace the longer versions of std::string with the shorter one in order to be able
300 # to find the type name
301 def fixup_class_name(self, class_name):
Enrico Granata7d222212012-04-25 17:53:41 +0000302 logger = lldb.formatters.Logger.Logger()
Enrico Granata4cee9e52012-02-03 18:11:52 +0000303 if class_name == 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >':
Enrico Granatac5bc4122012-03-27 02:35:13 +0000304 return 'std::basic_string<char>',True
Enrico Granata4cee9e52012-02-03 18:11:52 +0000305 if class_name == 'basic_string<char, std::char_traits<char>, std::allocator<char> >':
Enrico Granatac5bc4122012-03-27 02:35:13 +0000306 return 'std::basic_string<char>',True
307 if class_name == 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >':
308 return 'std::basic_string<char>',True
309 if class_name == 'basic_string<char, std::char_traits<char>, std::allocator<char> >':
310 return 'std::basic_string<char>',True
311 return class_name,False
Enrico Granata217f91f2011-08-17 19:07:52 +0000312
313 def update(self):
Enrico Granata7d222212012-04-25 17:53:41 +0000314 logger = lldb.formatters.Logger.Logger()
Enrico Granata79c1baf2012-03-31 00:15:24 +0000315 # preemptively setting this to None - we might end up changing our mind later
316 self.count = None
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000317 try:
Enrico Granatad50f18b2012-03-29 19:29:45 +0000318 # we will set this to True if we find out that discovering a node in the map takes more steps than the overall size of the RB tree
319 # if this gets set to True, then we will merrily return None for any child from that moment on
320 self.garbage = False
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000321 self.Mt = self.valobj.GetChildMemberWithName('_M_t')
322 self.Mimpl = self.Mt.GetChildMemberWithName('_M_impl')
323 self.Mheader = self.Mimpl.GetChildMemberWithName('_M_header')
Enrico Granata4cee9e52012-02-03 18:11:52 +0000324
Enrico Granatac5bc4122012-03-27 02:35:13 +0000325 map_type = self.valobj.GetType()
326 if map_type.IsReferenceType():
Enrico Granata22fe3172012-03-30 16:07:08 +0000327 logger >> "Dereferencing type"
Enrico Granatac5bc4122012-03-27 02:35:13 +0000328 map_type = map_type.GetDereferencedType()
Siva Chandra05fd66d2015-03-18 22:01:45 +0000329
330 # Get the type of std::pair<key, value>. It is the first template
331 # argument type of the 4th template argument to std::map.
332 allocator_type = map_type.GetTemplateArgumentType(3)
333 self.data_type = allocator_type.GetTemplateArgumentType(0)
334 if not self.data_type:
335 # GCC does not emit DW_TAG_template_type_parameter for
336 # std::allocator<...>. For such a case, get the type of
337 # std::pair from a member of std::map.
338 rep_type = self.valobj.GetChildMemberWithName('_M_t').GetType()
339 self.data_type = rep_type.GetTypedefedType().GetTemplateArgumentType(1)
Enrico Granata22fe3172012-03-30 16:07:08 +0000340
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000341 # from libstdc++ implementation of _M_root for rbtree
342 self.Mroot = self.Mheader.GetChildMemberWithName('_M_parent')
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000343 self.data_size = self.data_type.GetByteSize()
344 self.skip_size = self.Mheader.GetType().GetByteSize()
345 except:
346 pass
Enrico Granata217f91f2011-08-17 19:07:52 +0000347
Enrico Granata217f91f2011-08-17 19:07:52 +0000348 def num_children(self):
Enrico Granatad50f18b2012-03-29 19:29:45 +0000349 global _map_capping_size
Enrico Granata7d222212012-04-25 17:53:41 +0000350 logger = lldb.formatters.Logger.Logger()
Enrico Granatad50f18b2012-03-29 19:29:45 +0000351 if self.count == None:
352 self.count = self.num_children_impl()
353 if self.count > _map_capping_size:
354 self.count = _map_capping_size
355 return self.count
356
357 def num_children_impl(self):
Enrico Granata7d222212012-04-25 17:53:41 +0000358 logger = lldb.formatters.Logger.Logger()
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000359 try:
360 root_ptr_val = self.node_ptr_value(self.Mroot)
361 if root_ptr_val == 0:
362 return 0;
Enrico Granatad50f18b2012-03-29 19:29:45 +0000363 count = self.Mimpl.GetChildMemberWithName('_M_node_count').GetValueAsUnsigned(0)
364 logger >> "I have " + str(count) + " children available"
365 return count
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000366 except:
Enrico Granata217f91f2011-08-17 19:07:52 +0000367 return 0;
Enrico Granata217f91f2011-08-17 19:07:52 +0000368
369 def get_child_index(self,name):
Enrico Granata7d222212012-04-25 17:53:41 +0000370 logger = lldb.formatters.Logger.Logger()
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000371 try:
372 return int(name.lstrip('[').rstrip(']'))
373 except:
374 return -1
Enrico Granata217f91f2011-08-17 19:07:52 +0000375
376 def get_child_at_index(self,index):
Enrico Granata7d222212012-04-25 17:53:41 +0000377 logger = lldb.formatters.Logger.Logger()
Enrico Granatad50f18b2012-03-29 19:29:45 +0000378 logger >> "Being asked to fetch child[" + str(index) + "]"
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000379 if index < 0:
380 return None
Enrico Granata217f91f2011-08-17 19:07:52 +0000381 if index >= self.num_children():
382 return None;
Enrico Granatad50f18b2012-03-29 19:29:45 +0000383 if self.garbage:
384 logger >> "Returning None since we are a garbage tree"
385 return None
Enrico Granata5a61fc0d2011-08-22 16:10:25 +0000386 try:
387 offset = index
388 current = self.left(self.Mheader);
389 while offset > 0:
390 current = self.increment_node(current)
391 offset = offset - 1;
392 # skip all the base stuff and get at the data
393 return current.CreateChildAtOffset('['+str(index)+']',self.skip_size,self.data_type)
394 except:
395 return None
Enrico Granata217f91f2011-08-17 19:07:52 +0000396
397 # utility functions
398 def node_ptr_value(self,node):
Enrico Granata7d222212012-04-25 17:53:41 +0000399 logger = lldb.formatters.Logger.Logger()
Enrico Granata217f91f2011-08-17 19:07:52 +0000400 return node.GetValueAsUnsigned(0)
401
402 def right(self,node):
Enrico Granata7d222212012-04-25 17:53:41 +0000403 logger = lldb.formatters.Logger.Logger()
Enrico Granata217f91f2011-08-17 19:07:52 +0000404 return node.GetChildMemberWithName("_M_right");
405
406 def left(self,node):
Enrico Granata7d222212012-04-25 17:53:41 +0000407 logger = lldb.formatters.Logger.Logger()
Enrico Granata217f91f2011-08-17 19:07:52 +0000408 return node.GetChildMemberWithName("_M_left");
409
410 def parent(self,node):
Enrico Granata7d222212012-04-25 17:53:41 +0000411 logger = lldb.formatters.Logger.Logger()
Enrico Granata217f91f2011-08-17 19:07:52 +0000412 return node.GetChildMemberWithName("_M_parent");
413
414 # from libstdc++ implementation of iterator for rbtree
415 def increment_node(self,node):
Enrico Granata7d222212012-04-25 17:53:41 +0000416 logger = lldb.formatters.Logger.Logger()
Enrico Granatad50f18b2012-03-29 19:29:45 +0000417 max_steps = self.num_children()
Enrico Granata217f91f2011-08-17 19:07:52 +0000418 if self.node_ptr_value(self.right(node)) != 0:
419 x = self.right(node);
Enrico Granatad50f18b2012-03-29 19:29:45 +0000420 max_steps -= 1
Enrico Granata217f91f2011-08-17 19:07:52 +0000421 while self.node_ptr_value(self.left(x)) != 0:
422 x = self.left(x);
Enrico Granatad50f18b2012-03-29 19:29:45 +0000423 max_steps -= 1
424 logger >> str(max_steps) + " more to go before giving up"
425 if max_steps <= 0:
426 self.garbage = True
427 return None
Enrico Granata217f91f2011-08-17 19:07:52 +0000428 return x;
429 else:
430 x = node;
431 y = self.parent(x)
Enrico Granatad50f18b2012-03-29 19:29:45 +0000432 max_steps -= 1
Enrico Granata217f91f2011-08-17 19:07:52 +0000433 while(self.node_ptr_value(x) == self.node_ptr_value(self.right(y))):
434 x = y;
435 y = self.parent(y);
Enrico Granatad50f18b2012-03-29 19:29:45 +0000436 max_steps -= 1
437 logger >> str(max_steps) + " more to go before giving up"
438 if max_steps <= 0:
439 self.garbage = True
440 return None
Enrico Granata217f91f2011-08-17 19:07:52 +0000441 if self.node_ptr_value(self.right(x)) != self.node_ptr_value(y):
442 x = y;
443 return x;
444
Enrico Granata91fe0172012-10-23 21:54:53 +0000445 def has_children(self):
Enrico Granataecbabe62012-12-10 19:55:53 +0000446 return True
Enrico Granatad50f18b2012-03-29 19:29:45 +0000447
448_map_capping_size = 255
449_list_capping_size = 255
450_list_uses_loop_detector = True