solenv: gdb: adapt ItemSetPrinter to unordered_map
(regression from commit 290c8f6e04)
Change-Id: I85f3dd2a719d13f35cf7246e0787604ddb9f47fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170685
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
This commit is contained in:
@@ -33,48 +33,27 @@ class ItemSetPrinter(object):
|
||||
return whiches
|
||||
|
||||
def children(self):
|
||||
whichranges = self.which_ranges()
|
||||
size = 0
|
||||
whichids = []
|
||||
for (whichfrom, whichto) in whichranges:
|
||||
size += whichto - whichfrom + 1
|
||||
whichids += [which for which in range(whichfrom, whichto+1)]
|
||||
return self._iterator(self.value['m_ppItems'], size, whichids)
|
||||
return self._iterator(self.value['m_aPoolItemMap'])
|
||||
|
||||
class _iterator(six.Iterator):
|
||||
|
||||
def __init__(self, data, count, whichids):
|
||||
self.data = data
|
||||
self.whichids = whichids
|
||||
self.count = count
|
||||
self.pos = 0
|
||||
self._check_invariant()
|
||||
def __init__(self, data):
|
||||
self.iter = gdb.default_visualizer(data).children()
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
if self.pos == self.count:
|
||||
raise StopIteration()
|
||||
# unordered_map iter is rather weird?
|
||||
(_, key) = self.iter.__next__()
|
||||
(_, elem) = self.iter.__next__()
|
||||
|
||||
which = self.whichids[self.pos]
|
||||
elem = self.data[self.pos]
|
||||
self.pos = self.pos + 1
|
||||
|
||||
self._check_invariant()
|
||||
if (elem == -1):
|
||||
elem = "(Invalid)"
|
||||
elif (elem != 0):
|
||||
# let's try how well that works...
|
||||
elem = elem.cast(elem.dynamic_type).dereference()
|
||||
return (str(which), elem)
|
||||
|
||||
def _check_invariant(self):
|
||||
assert self.count >= 0
|
||||
assert self.data
|
||||
assert self.pos >= 0
|
||||
assert self.pos <= self.count
|
||||
assert len(self.whichids) == self.count
|
||||
return ("[" + str(key) + "]", elem)
|
||||
|
||||
printer = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user