@@ -470,6 +470,8 @@ def get_child_at_index(self, index):
470
470
# type: (int) -> SBValue
471
471
pairs_start = self .data_ptr .GetValueAsUnsigned ()
472
472
idx = self .valid_indices [index ]
473
+ if self .new_layout :
474
+ idx = - (idx + 1 )
473
475
address = pairs_start + idx * self .pair_type_size
474
476
element = self .data_ptr .CreateValueFromAddress ("[%s]" % index , address , self .pair_type )
475
477
if self .show_values :
@@ -480,26 +482,43 @@ def get_child_at_index(self, index):
480
482
481
483
def update (self ):
482
484
# type: () -> None
483
- table = self .valobj . GetChildMemberWithName ( "base" ). GetChildMemberWithName ( " table" )
485
+ table = self .table ( )
484
486
capacity = table .GetChildMemberWithName ("bucket_mask" ).GetValueAsUnsigned () + 1
485
487
ctrl = table .GetChildMemberWithName ("ctrl" ).GetChildAtIndex (0 )
486
488
487
489
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 ()
490
491
self .pair_type_size = self .pair_type .GetByteSize ()
491
492
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
+
492
499
u8_type = self .valobj .GetTarget ().GetBasicType (eBasicTypeUnsignedChar )
493
500
u8_type_size = self .valobj .GetTarget ().GetBasicType (eBasicTypeUnsignedChar ).GetByteSize ()
494
501
495
502
self .valid_indices = []
496
503
for idx in range (capacity ):
497
504
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 ()
499
507
is_present = value & 128 == 0
500
508
if is_present :
501
509
self .valid_indices .append (idx )
502
510
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
+
503
522
def has_children (self ):
504
523
# type: () -> bool
505
524
return True
0 commit comments