about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/etc/gdb_lookup.py4
-rw-r--r--src/etc/gdb_providers.py14
-rw-r--r--src/etc/lldb_lookup.py2
-rw-r--r--src/etc/lldb_providers.py13
-rw-r--r--src/etc/natvis/libstd.natvis18
5 files changed, 37 insertions, 14 deletions
diff --git a/src/etc/gdb_lookup.py b/src/etc/gdb_lookup.py
index 2a46eaadad6..a5a1824c84e 100644
--- a/src/etc/gdb_lookup.py
+++ b/src/etc/gdb_lookup.py
@@ -69,9 +69,9 @@ def lookup(valobj):
         else:
             return StdOldHashMapProvider(valobj)
     if rust_type == RustType.STD_HASH_SET:
-        hash_map = valobj["map"]
+        hash_map = valobj[valobj.type.fields()[0]]
         if is_hashbrown_hashmap(hash_map):
-            return StdHashMapProvider(hash_map, show_values=False)
+            return StdHashMapProvider(valobj, show_values=False)
         else:
             return StdOldHashMapProvider(hash_map, show_values=False)
 
diff --git a/src/etc/gdb_providers.py b/src/etc/gdb_providers.py
index 67f99ec4e40..bae51e6f9ee 100644
--- a/src/etc/gdb_providers.py
+++ b/src/etc/gdb_providers.py
@@ -347,7 +347,7 @@ class StdHashMapProvider:
         self.valobj = valobj
         self.show_values = show_values
 
-        table = self.valobj["base"]["table"]
+        table = self.table()
         capacity = int(table["bucket_mask"]) + 1
         ctrl = table["ctrl"]["pointer"]
 
@@ -368,6 +368,18 @@ class StdHashMapProvider:
             if is_presented:
                 self.valid_indices.append(idx)
 
+    def table(self):
+        if self.show_values:
+            hashbrown_hashmap = self.valobj["base"]
+        elif self.valobj.type.fields()[0].name == "map":
+            # BACKCOMPAT: rust 1.47
+            # HashSet wraps std::collections::HashMap, which wraps hashbrown::HashMap
+            hashbrown_hashmap = self.valobj["map"]["base"]
+        else:
+            # HashSet wraps hashbrown::HashSet, which wraps hashbrown::HashMap
+            hashbrown_hashmap = self.valobj["base"]["map"]
+        return hashbrown_hashmap["table"]
+
     def to_string(self):
         if self.show_values:
             return "HashMap(size={})".format(self.size)
diff --git a/src/etc/lldb_lookup.py b/src/etc/lldb_lookup.py
index 13420fbaf0a..3cee51982ba 100644
--- a/src/etc/lldb_lookup.py
+++ b/src/etc/lldb_lookup.py
@@ -94,7 +94,7 @@ def synthetic_lookup(valobj, dict):
     if rust_type == RustType.STD_HASH_SET:
         hash_map = valobj.GetChildAtIndex(0)
         if is_hashbrown_hashmap(hash_map):
-            return StdHashMapSyntheticProvider(hash_map, dict, show_values=False)
+            return StdHashMapSyntheticProvider(valobj, dict, show_values=False)
         else:
             return StdOldHashMapSyntheticProvider(hash_map, dict, show_values=False)
 
diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py
index 19da75c35b4..64cb9837943 100644
--- a/src/etc/lldb_providers.py
+++ b/src/etc/lldb_providers.py
@@ -526,7 +526,7 @@ class StdHashMapSyntheticProvider:
 
     def update(self):
         # type: () -> None
-        table = self.valobj.GetChildMemberWithName("base").GetChildMemberWithName("table")
+        table = self.table()
         capacity = table.GetChildMemberWithName("bucket_mask").GetValueAsUnsigned() + 1
         ctrl = table.GetChildMemberWithName("ctrl").GetChildAtIndex(0)
 
@@ -552,6 +552,17 @@ class StdHashMapSyntheticProvider:
             if is_present:
                 self.valid_indices.append(idx)
 
+    def table(self):
+        # type: () -> SBValue
+        if self.show_values:
+            hashbrown_hashmap = self.valobj.GetChildMemberWithName("base")
+        else:
+            # BACKCOMPAT: rust 1.47
+            # HashSet wraps either std HashMap or hashbrown::HashSet, which both
+            # wrap hashbrown::HashMap, so either way we "unwrap" twice.
+            hashbrown_hashmap = self.valobj.GetChildAtIndex(0).GetChildAtIndex(0)
+        return hashbrown_hashmap.GetChildMemberWithName("table")
+
     def has_children(self):
         # type: () -> bool
         return True
diff --git a/src/etc/natvis/libstd.natvis b/src/etc/natvis/libstd.natvis
index f791979800f..9550c25f2fc 100644
--- a/src/etc/natvis/libstd.natvis
+++ b/src/etc/natvis/libstd.natvis
@@ -5,7 +5,7 @@
 
     Current std impls:
       std::collections::hash::set::HashSet<K, S>      is implemented in terms of...
-      std::collections::hash::map::HashMap<K, V, S>   is implemented in terms of...
+      hashbrown::set::HashSet<K, S>                   is implemented in terms of...
       hashbrown::map::HashMap<K, V, S>                is implemented in terms of...
       hashbrown::raw::RawTable<(K, V)>
 
@@ -50,22 +50,22 @@
   </Type>
 
   <Type Name="std::collections::hash::set::HashSet&lt;*,*&gt;">
-    <DisplayString>{{ size={map.base.table.items} }}</DisplayString>
+    <DisplayString>{{ size={base.map.table.items} }}</DisplayString>
     <Expand>
-      <Item Name="[size]">map.base.table.items</Item>
-      <Item Name="[capacity]">map.base.table.items + map.base.table.growth_left</Item>
-      <Item Name="[state]">map.base.hash_builder</Item>
+      <Item Name="[size]">base.map.table.items</Item>
+      <Item Name="[capacity]">base.map.table.items + base.map.table.growth_left</Item>
+      <Item Name="[state]">base.map.hash_builder</Item>
 
       <CustomListItems>
         <Variable Name="i" InitialValue="0" />
-        <Variable Name="n" InitialValue="map.base.table.items" />
-        <Size>map.base.table.items</Size>
+        <Variable Name="n" InitialValue="base.map.table.items" />
+        <Size>base.map.table.items</Size>
         <Loop>
           <Break Condition="n == 0" />
-          <If Condition="(map.base.table.ctrl.pointer[i] &amp; 0x80) == 0">
+          <If Condition="(base.map.table.ctrl.pointer[i] &amp; 0x80) == 0">
             <!-- Bucket is populated -->
             <Exec>n--</Exec>
-            <Item>(($T1*)map.base.table.ctrl.pointer)[-(i + 1)]</Item>
+            <Item>(($T1*)base.map.table.ctrl.pointer)[-(i + 1)]</Item>
           </If>
           <Exec>i++</Exec>
         </Loop>