fork/rust
git clone https://git.julia.blue/fork/rust
5e1a799842b
1.41.0
1<?xml version="1.0" encoding="utf-8"?> 2<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> 3 <!-- 4 std::collection::Hash* container visualizers 5 6 Current std impls: 7 std::collections::hash::set::HashSet<K, S> is implemented in terms of... 8 std::collections::hash::map::HashMap<K, V, S> is implemented in terms of... 9 hashbrown::map::HashMap<K, V, S> is implemented in terms of... 10 hashbrown::raw::RawTable<(K, V)> 11 12 Ideally, we'd teach rustc to scan dependencies/crates for .natvis files so 13 the bulk of this could live alongside the hashbrown crate implementation, 14 and std would just forward using e.g. <ExpandedItem>base</ExpandedItem>. 15 16 However, Given that std...Hash*Set* is currently implemented in terms of 17 hashbrown...Hash*Map*, which would visualize poorly, we want to customize the 18 look/feel at the std type level *anyways*... 19 20 References: 21 https://github.com/rust-lang/rust/blob/master/src/libstd/collections/hash/map.rs 22 https://github.com/rust-lang/rust/blob/master/src/libstd/collections/hash/set.rs 23 https://github.com/rust-lang/hashbrown/blob/master/src/map.rs 24 https://github.com/rust-lang/hashbrown/blob/master/src/set.rs 25 https://github.com/rust-lang/hashbrown/blob/master/src/raw/mod.rs 26 --> 27 28 <Type Name="std::collections::hash::map::HashMap<*,*,*>"> 29 <DisplayString>{{ size={base.table.items} }}</DisplayString> 30 <Expand> 31 <Item Name="[size]">base.table.items</Item> 32 <Item Name="[capacity]">base.table.items + base.table.growth_left</Item> 33 34 <CustomListItems> 35 <Variable Name="i" InitialValue="0" /> 36 <Variable Name="n" InitialValue="base.table.items" /> 37 <Size>base.table.items</Size> 38 <Loop> 39 <Break Condition="n == 0" /> 40 <If Condition="(base.table.ctrl.pointer[i] & 0x80) == 0"> 41 <!-- Bucket is populated --> 42 <Exec>n--</Exec> 43 <Item Name="{base.table.data.pointer[i].__0}">base.table.data.pointer[i].__1</Item> 44 </If> 45 <Exec>i++</Exec> 46 </Loop> 47 </CustomListItems> 48 </Expand> 49 </Type> 50 51 <Type Name="std::collections::hash::set::HashSet<*,*>"> 52 <DisplayString>{{ size={map.base.table.items} }}</DisplayString> 53 <Expand> 54 <Item Name="[size]">map.base.table.items</Item> 55 <Item Name="[capacity]">map.base.table.items + map.base.table.growth_left</Item> 56 57 <CustomListItems> 58 <Variable Name="i" InitialValue="0" /> 59 <Variable Name="n" InitialValue="map.base.table.items" /> 60 <Size>map.base.table.items</Size> 61 <Loop> 62 <Break Condition="n == 0" /> 63 <If Condition="(map.base.table.ctrl.pointer[i] & 0x80) == 0"> 64 <!-- Bucket is populated --> 65 <Exec>n--</Exec> 66 <Item>map.base.table.data.pointer[i].__0</Item> 67 </If> 68 <Exec>i++</Exec> 69 </Loop> 70 </CustomListItems> 71 </Expand> 72 </Type> 73 74 <Type Name="hashbrown::raw::RawTable<*>"> 75 <!-- RawTable has a nice and simple layout. 76 items Number of *populated* values in the RawTable (less than the size of ctrl.pointer / data.pointer) 77 growth_left Remaining capacity before growth 78 ctrl.pointer[i] & 0x80 Indicates the bucket is empty / should be skipped / doesn't count towards items. 79 data.pointer[i] The (K,V) tuple, if not empty. 80 --> 81 <DisplayString>{{ size={items} }}</DisplayString> 82 <Expand> 83 <Item Name="[size]">items</Item> 84 <Item Name="[capacity]">items + growth_left</Item> 85 86 <CustomListItems> 87 <Variable Name="i" InitialValue="0" /> 88 <Variable Name="n" InitialValue="items" /> 89 <Size>items</Size> 90 <Loop> 91 <Break Condition="n == 0" /> 92 <If Condition="(ctrl.pointer[i] & 0x80) == 0"> 93 <!-- Bucket is populated --> 94 <Exec>n--</Exec> 95 <Item>data.pointer[i]</Item> 96 </If> 97 <Exec>i++</Exec> 98 </Loop> 99 </CustomListItems> 100 </Expand> 101 </Type> 102</AutoVisualizer>