@@ -470,6 +470,8 @@ def get_child_at_index(self, index):
470470 # type: (int) -> SBValue
471471 pairs_start = self .data_ptr .GetValueAsUnsigned ()
472472 idx = self .valid_indices [index ]
473+ if self .new_layout :
474+ idx = - (idx + 1 )
473475 address = pairs_start + idx * self .pair_type_size
474476 element = self .data_ptr .CreateValueFromAddress ("[%s]" % index , address , self .pair_type )
475477 if self .show_values :
@@ -480,26 +482,43 @@ def get_child_at_index(self, index):
480482
481483 def update (self ):
482484 # type: () -> None
483- table = self .valobj . GetChildMemberWithName ( "base" ). GetChildMemberWithName ( " table" )
485+ table = self .table ( )
484486 capacity = table .GetChildMemberWithName ("bucket_mask" ).GetValueAsUnsigned () + 1
485487 ctrl = table .GetChildMemberWithName ("ctrl" ).GetChildAtIndex (0 )
486488
487489 self .size = table .GetChildMemberWithName ("items" ).GetValueAsUnsigned ()
488- self .data_ptr = table .GetChildMemberWithName ("data" ).GetChildAtIndex (0 )
489- self .pair_type = self .data_ptr .Dereference ().GetType ()
490+ self .pair_type = table .type .template_args [0 ].GetTypedefedType ()
490491 self .pair_type_size = self .pair_type .GetByteSize ()
491492
493+ self .new_layout = not table .GetChildMemberWithName ("data" ).IsValid ()
494+ if self .new_layout :
495+ self .data_ptr = ctrl .Cast (self .pair_type .GetPointerType ())
496+ else :
497+ self .data_ptr = table .GetChildMemberWithName ("data" ).GetChildAtIndex (0 )
498+
492499 u8_type = self .valobj .GetTarget ().GetBasicType (eBasicTypeUnsignedChar )
493500 u8_type_size = self .valobj .GetTarget ().GetBasicType (eBasicTypeUnsignedChar ).GetByteSize ()
494501
495502 self .valid_indices = []
496503 for idx in range (capacity ):
497504 address = ctrl .GetValueAsUnsigned () + idx * u8_type_size
498- value = ctrl .CreateValueFromAddress ("ctrl[%s]" % idx , address , u8_type ).GetValueAsUnsigned ()
505+ value = ctrl .CreateValueFromAddress ("ctrl[%s]" % idx , address ,
506+ u8_type ).GetValueAsUnsigned ()
499507 is_present = value & 128 == 0
500508 if is_present :
501509 self .valid_indices .append (idx )
502510
511+ def table (self ):
512+ # type: () -> SBValue
513+ if self .show_values :
514+ hashbrown_hashmap = self .valobj .GetChildMemberWithName ("base" )
515+ else :
516+ # BACKCOMPAT: rust 1.47
517+ # HashSet wraps either std HashMap or hashbrown::HashSet, which both
518+ # wrap hashbrown::HashMap, so either way we "unwrap" twice.
519+ hashbrown_hashmap = self .valobj .GetChildAtIndex (0 ).GetChildAtIndex (0 )
520+ return hashbrown_hashmap .GetChildMemberWithName ("table" )
521+
503522 def has_children (self ):
504523 # type: () -> bool
505524 return True
0 commit comments