diff --git a/prettyPrinters/gdb_providers.py b/prettyPrinters/gdb_providers.py index c1166ff01bf..67217dba894 100644 --- a/prettyPrinters/gdb_providers.py +++ b/prettyPrinters/gdb_providers.py @@ -337,17 +337,23 @@ def __init__(self, valobj, show_values=True): self.show_values = show_values table = self.table() - capacity = int(table["bucket_mask"]) + 1 - ctrl = table["ctrl"]["pointer"] + # BACKCOMPAT: rust 1.51. Just drop `else` branch + if table.type.fields()[0].name == "table": + inner_table = table["table"] + else: + inner_table = table + + capacity = int(inner_table["bucket_mask"]) + 1 + ctrl = inner_table["ctrl"]["pointer"] - self.size = int(table["items"]) + self.size = int(inner_table["items"]) self.pair_type = table.type.template_argument(0).strip_typedefs() - self.new_layout = "data" not in table.type + self.new_layout = "data" not in inner_table.type if self.new_layout: self.data_ptr = ctrl.cast(self.pair_type.pointer()) else: - self.data_ptr = table["data"]["pointer"] + self.data_ptr = inner_table["data"]["pointer"] self.valid_indices = [] for idx in range(capacity): diff --git a/prettyPrinters/lldb_providers.py b/prettyPrinters/lldb_providers.py index 39712538223..150cb3ffe8a 100644 --- a/prettyPrinters/lldb_providers.py +++ b/prettyPrinters/lldb_providers.py @@ -377,18 +377,24 @@ def get_child_at_index(self, index): def update(self): # type: () -> None table = self.table() - capacity = table.GetChildMemberWithName("bucket_mask").GetValueAsUnsigned() + 1 - ctrl = table.GetChildMemberWithName("ctrl").GetChildAtIndex(0) + # BACKCOMPAT: rust 1.51. Just drop `else` branch + if table.GetChildMemberWithName("table").IsValid(): + inner_table = table.GetChildMemberWithName("table") + else: + inner_table = table + + capacity = inner_table.GetChildMemberWithName("bucket_mask").GetValueAsUnsigned() + 1 + ctrl = inner_table.GetChildMemberWithName("ctrl").GetChildAtIndex(0) - self.size = table.GetChildMemberWithName("items").GetValueAsUnsigned() + self.size = inner_table.GetChildMemberWithName("items").GetValueAsUnsigned() self.pair_type = table.type.template_args[0].GetTypedefedType() self.pair_type_size = self.pair_type.GetByteSize() - self.new_layout = not table.GetChildMemberWithName("data").IsValid() + self.new_layout = not inner_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) + self.data_ptr = inner_table.GetChildMemberWithName("data").GetChildAtIndex(0) u8_type = self.valobj.GetTarget().GetBasicType(eBasicTypeUnsignedChar) u8_type_size = self.valobj.GetTarget().GetBasicType(eBasicTypeUnsignedChar).GetByteSize() diff --git a/pretty_printers_tests/tests/hash_map.rs b/pretty_printers_tests/tests/hash_map.rs index dbe506fb483..ba1f0bc0aa8 100644 --- a/pretty_printers_tests/tests/hash_map.rs +++ b/pretty_printers_tests/tests/hash_map.rs @@ -1,5 +1,4 @@ // min-version: 1.33.0 -// max-version: 1.51.0 // === LLDB TESTS ==================================================================================