Skip to content

Commit

Permalink
Fix iteration and union display in phmap_lldb.py - issue #204
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Jul 30, 2023
1 parent 77cab81 commit df7935a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions phmap_lldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,17 @@ def get_child_at_index(self, index):
return None
real_idx = -1
for idx in range(min(self.capacity_ + 3, _MAX_CTRL_INDEX)):
ctrl = self.ctrl_.GetChildAtIndex(idx).GetValueAsSigned()
ctrl = self.ctrl_.GetChildAtIndex(idx, True, True).GetValueAsSigned()
if ctrl >= -1:
real_idx += 1
if real_idx == index:
return self.slots_.CreateChildAtOffset(f'[{index}]', idx * self.slot_size, self.slot_type)
slot = self.slots_.CreateChildAtOffset(f'', idx * self.slot_size, self.slot_type)
print(slot.type.name)
if "MapPolicy" in slot.type.name:
val = slot.GetChildAtIndex(0, True, True)
else:
val = slot
return val.CreateChildAtOffset(f'[{index}]', 0, val.type)
except BaseException as ex:
print(f"{_get_function_name(self)} -> {ex}")
return None
Expand All @@ -160,7 +166,7 @@ def _get_size_and_capacity(valobj):
buckets = sets.GetChildMemberWithName('_M_elems')
size = capacity = 0
for idx in range(n_buckets):
bucket = buckets.GetChildAtIndex(idx).GetChildMemberWithName('set_')
bucket = buckets.GetChildAtIndex(idx, True, True).GetChildMemberWithName('set_')
size += bucket.GetChildMemberWithName('size_').GetValueAsUnsigned()
capacity += bucket.GetChildMemberWithName('capacity_').GetValueAsUnsigned()
return size, capacity, n_buckets
Expand Down Expand Up @@ -210,17 +216,22 @@ def get_child_at_index(self, index):
real_idx = -1
total_idx = 0
for idx in range(self.n_buckets_):
bucket = self.buckets.GetChildAtIndex(idx).GetChildMemberWithName('set_')
bucket = self.buckets.GetChildAtIndex(idx, True, True).GetChildMemberWithName('set_')
size = bucket.GetChildMemberWithName("size_").GetValueAsUnsigned()
if size:
slots_ = bucket.GetChildMemberWithName("slots_")
ctrl_ = bucket.GetChildMemberWithName("ctrl_")
for jdx in range(size):
ctrl = ctrl_.GetChildAtIndex(jdx).GetValueAsSigned()
ctrl = ctrl_.GetChildAtIndex(jdx, True, True).GetValueAsSigned()
if ctrl >= -1:
real_idx += 1
if real_idx == index:
return slots_.CreateChildAtOffset(f'[{index}]', jdx * self.slot_size, self.slot_type)
slot = slots_.CreateChildAtOffset(f'[{index}]', jdx * self.slot_size, self.slot_type)
if "MapPolicy" in slot.type.name:
val = slot.GetChildAtIndex(0, True, True)
else:
val = slot
return val.CreateChildAtOffset(f'[{index}]', 0, val.type)
total_idx += size
if total_idx > _MAX_CHILDREN:
return None
Expand Down

0 comments on commit df7935a

Please sign in to comment.