Skip to content

Commit

Permalink
Handle new HashMap layout in GDB and LLDB
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Aug 7, 2020
1 parent d51b7b2 commit e3283e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/etc/gdb_providers.py
Expand Up @@ -352,8 +352,13 @@ def __init__(self, valobj, show_values=True):
ctrl = table["ctrl"]["pointer"]

self.size = int(table["items"])
self.data_ptr = table["data"]["pointer"]
self.pair_type = self.data_ptr.dereference().type
self.pair_type = table.type.template_argument(0)

self.new_layout = not table.type.has_key("data")
if self.new_layout:
self.data_ptr = ctrl.cast(self.pair_type.pointer())
else:
self.data_ptr = table["data"]["pointer"]

self.valid_indices = []
for idx in range(capacity):
Expand All @@ -374,6 +379,8 @@ def children(self):

for index in range(self.size):
idx = self.valid_indices[index]
if self.new_layout:
idx = -(idx + 1)
element = (pairs_start + idx).dereference()
if self.show_values:
yield "key{}".format(index), element[ZERO_FIELD]
Expand Down
11 changes: 9 additions & 2 deletions src/etc/lldb_providers.py
Expand Up @@ -514,6 +514,8 @@ def get_child_at_index(self, index):
# type: (int) -> SBValue
pairs_start = self.data_ptr.GetValueAsUnsigned()
idx = self.valid_indices[index]
if self.new_layout:
idx = -(idx + 1)
address = pairs_start + idx * self.pair_type_size
element = self.data_ptr.CreateValueFromAddress("[%s]" % index, address, self.pair_type)
if self.show_values:
Expand All @@ -529,10 +531,15 @@ def update(self):
ctrl = table.GetChildMemberWithName("ctrl").GetChildAtIndex(0)

self.size = table.GetChildMemberWithName("items").GetValueAsUnsigned()
self.data_ptr = table.GetChildMemberWithName("data").GetChildAtIndex(0)
self.pair_type = self.data_ptr.Dereference().GetType()
self.pair_type = table.type.template_args[0]
self.pair_type_size = self.pair_type.GetByteSize()

self.new_layout = not table.GetChildMemberWithName("data").IsValid()
if self.new_layout:
self.data_ptr = ctrl.Cast(self.pair_type.GetPointerType())
else:
self.data_ptr = table.GetChildMemberWithName("data").GetChildAtIndex(0)

u8_type = self.valobj.GetTarget().GetBasicType(eBasicTypeUnsignedChar)
u8_type_size = self.valobj.GetTarget().GetBasicType(eBasicTypeUnsignedChar).GetByteSize()

Expand Down

0 comments on commit e3283e0

Please sign in to comment.