]>
Commit | Line | Data |
---|---|---|
60c5eb7d XL |
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... | |
1b1a35ee | 8 | hashbrown::set::HashSet<K, S> is implemented in terms of... |
60c5eb7d XL |
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<*,*,*>"> | |
6a06907d | 29 | <DisplayString>{{ len={base.table.table.items} }}</DisplayString> |
60c5eb7d | 30 | <Expand> |
6a06907d XL |
31 | <Item Name="[len]">base.table.table.items</Item> |
32 | <Item Name="[capacity]">base.table.table.items + base.table.table.growth_left</Item> | |
3dfed10e | 33 | <Item Name="[state]">base.hash_builder</Item> |
60c5eb7d XL |
34 | |
35 | <CustomListItems> | |
36 | <Variable Name="i" InitialValue="0" /> | |
6a06907d XL |
37 | <Variable Name="n" InitialValue="base.table.table.items" /> |
38 | <Size>base.table.table.items</Size> | |
60c5eb7d XL |
39 | <Loop> |
40 | <Break Condition="n == 0" /> | |
6a06907d | 41 | <If Condition="(base.table.table.ctrl.pointer[i] & 0x80) == 0"> |
60c5eb7d XL |
42 | <!-- Bucket is populated --> |
43 | <Exec>n--</Exec> | |
5099ac24 | 44 | <Item Name="{((tuple$<$T1,$T2>*)base.table.table.ctrl.pointer)[-(i + 1)].__0}">((tuple$<$T1,$T2>*)base.table.table.ctrl.pointer)[-(i + 1)].__1</Item> |
60c5eb7d XL |
45 | </If> |
46 | <Exec>i++</Exec> | |
47 | </Loop> | |
48 | </CustomListItems> | |
49 | </Expand> | |
50 | </Type> | |
51 | ||
52 | <Type Name="std::collections::hash::set::HashSet<*,*>"> | |
6a06907d | 53 | <DisplayString>{{ len={base.map.table.table.items} }}</DisplayString> |
60c5eb7d | 54 | <Expand> |
6a06907d XL |
55 | <Item Name="[len]">base.map.table.table.items</Item> |
56 | <Item Name="[capacity]">base.map.table.table.items + base.map.table.table.growth_left</Item> | |
1b1a35ee | 57 | <Item Name="[state]">base.map.hash_builder</Item> |
60c5eb7d XL |
58 | |
59 | <CustomListItems> | |
60 | <Variable Name="i" InitialValue="0" /> | |
6a06907d XL |
61 | <Variable Name="n" InitialValue="base.map.table.table.items" /> |
62 | <Size>base.map.table.table.items</Size> | |
60c5eb7d XL |
63 | <Loop> |
64 | <Break Condition="n == 0" /> | |
6a06907d | 65 | <If Condition="(base.map.table.table.ctrl.pointer[i] & 0x80) == 0"> |
60c5eb7d XL |
66 | <!-- Bucket is populated --> |
67 | <Exec>n--</Exec> | |
6a06907d | 68 | <Item>(($T1*)base.map.table.table.ctrl.pointer)[-(i + 1)]</Item> |
60c5eb7d XL |
69 | </If> |
70 | <Exec>i++</Exec> | |
71 | </Loop> | |
72 | </CustomListItems> | |
73 | </Expand> | |
74 | </Type> | |
6a06907d XL |
75 | |
76 | <Type Name="std::ffi::c_str::CString"> | |
136023e0 | 77 | <DisplayString>{(char*)inner.data_ptr}</DisplayString> |
6a06907d XL |
78 | <Expand> |
79 | <Synthetic Name="[chars]"> | |
136023e0 | 80 | <DisplayString>{(char*)inner.data_ptr}</DisplayString> |
6a06907d XL |
81 | <Expand> |
82 | <ArrayItems> | |
83 | <Size>inner.length</Size> | |
84 | <ValuePointer>(char*)inner.data_ptr</ValuePointer> | |
85 | </ArrayItems> | |
86 | </Expand> | |
87 | </Synthetic> | |
88 | </Expand> | |
89 | </Type> | |
90 | ||
91 | <Type Name="std::ffi::c_str::CStr"> | |
92 | <DisplayString>{(char*) inner}</DisplayString> | |
93 | <Expand> | |
94 | <Synthetic Name="[chars]"> | |
95 | <DisplayString>{(char*) inner}</DisplayString> | |
96 | <Expand> | |
97 | <ArrayItems> | |
98 | <Size>strlen((char *) inner) + 1</Size> | |
99 | <ValuePointer>(char*)inner</ValuePointer> | |
100 | </ArrayItems> | |
101 | </Expand> | |
102 | </Synthetic> | |
103 | </Expand> | |
104 | </Type> | |
136023e0 XL |
105 | |
106 | <Type Name="std::ffi::os_str::OsString"> | |
107 | <DisplayString>{(char*)inner.inner.bytes.buf.ptr.pointer,[inner.inner.bytes.len]}</DisplayString> | |
108 | <Expand> | |
109 | <Synthetic Name="[chars]"> | |
110 | <DisplayString>{(char*)inner.inner.bytes.buf.ptr.pointer,[inner.inner.bytes.len]}</DisplayString> | |
111 | <Expand> | |
112 | <ArrayItems> | |
113 | <Size>inner.inner.bytes.len</Size> | |
114 | <ValuePointer>(char*)inner.inner.bytes.buf.ptr.pointer</ValuePointer> | |
115 | </ArrayItems> | |
116 | </Expand> | |
117 | </Synthetic> | |
118 | </Expand> | |
119 | </Type> | |
60c5eb7d | 120 | </AutoVisualizer> |