summaryrefslogtreecommitdiffstats
path: root/src/etc/natvis/liballoc.natvis
blob: 00c17d83322a8394b8c6fd2026ca768aab3948b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="alloc::vec::Vec&lt;*&gt;">
    <DisplayString>{{ len={len} }}</DisplayString>
    <Expand>
      <Item Name="[len]" ExcludeView="simple">len</Item>
      <Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
      <ArrayItems>
        <Size>len</Size>
        <ValuePointer>buf.ptr.pointer.pointer</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>
  <Type Name="alloc::collections::vec_deque::VecDeque&lt;*&gt;">
    <DisplayString>{{ len={len} }}</DisplayString>
    <Expand>
      <Item Name="[len]" ExcludeView="simple">len</Item>
      <Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
      <CustomListItems>
        <Variable Name="i" InitialValue="0" />
        <Size>len</Size>
        <Loop>
          <If Condition="i == len">
            <Break/>
          </If>
          <Item>buf.ptr.pointer.pointer[(i + head) % buf.cap]</Item>
          <Exec>i = i + 1</Exec>
        </Loop>
      </CustomListItems>
    </Expand>
  </Type>
  <Type Name="alloc::collections::linked_list::LinkedList&lt;*&gt;">
    <DisplayString>{{ len={len} }}</DisplayString>
    <Expand>
      <LinkedListItems>
        <Size>len</Size>
        <HeadPointer>*(alloc::collections::linked_list::Node&lt;$T1&gt; **)&amp;head</HeadPointer>
        <NextPointer>*(alloc::collections::linked_list::Node&lt;$T1&gt; **)&amp;next</NextPointer>
        <ValueNode>element</ValueNode>
      </LinkedListItems>
    </Expand>
  </Type>
  <Type Name="alloc::string::String">
    <DisplayString>{(char*)vec.buf.ptr.pointer.pointer,[vec.len]s8}</DisplayString>
    <StringView>(char*)vec.buf.ptr.pointer.pointer,[vec.len]s8</StringView>
    <Expand>
      <Item Name="[len]" ExcludeView="simple">vec.len</Item>
      <Item Name="[capacity]" ExcludeView="simple">vec.buf.cap</Item>
      <Synthetic Name="[chars]">
        <DisplayString>{(char*)vec.buf.ptr.pointer.pointer,[vec.len]s8}</DisplayString>
        <Expand>
          <ArrayItems>
            <Size>vec.len</Size>
            <ValuePointer>(char*)vec.buf.ptr.pointer.pointer</ValuePointer>
          </ArrayItems>
        </Expand>
      </Synthetic>
    </Expand>
  </Type>

  <!--
      The display string for Rc, Arc, etc is optional because the expression cannot be evaluated
      if the pointee is unsized (i.e. if `ptr.pointer` is a fat pointer).

      There are also two versions for the reference count fields, one for sized and one for
      dyn pointees.

      Rc<[T]> and Arc<[T]> are handled separately altogether so we can actually show
      the slice values. These visualizers have a second wildcard `foo&lt;slice2$&lt;*&gt;, *&gt;`
      which accounts for the allocator parameter. This isn't needed for the other visualizers since
      their inner `*` eats the type parameter but since the slice ones match part of the type params
      it is necessary for them.
  -->
  <!-- alloc::rc::Rc<T> -->
  <Type Name="alloc::rc::Rc&lt;*&gt;">
    <DisplayString Optional="true">{ptr.pointer->value}</DisplayString>
    <Expand>
      <!-- thin -->
      <ExpandedItem Optional="true">ptr.pointer->value</ExpandedItem>
      <Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>

      <!-- dyn -->
      <Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
    </Expand>
  </Type>

  <!-- alloc::rc::Rc<[T]> -->
  <Type Name="alloc::rc::Rc&lt;slice2$&lt;*&gt;,*&gt;">
    <DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
    <Expand>
      <Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
      <Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
      <Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
      <ArrayItems>
        <Size>ptr.pointer.length</Size>
        <!-- We add +2 to the data_ptr in order to skip the ref count fields in the RcBox -->
        <ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>

  <!-- alloc::rc::Weak<T> -->
  <Type Name="alloc::rc::Weak&lt;*&gt;">
    <DisplayString Optional="true">{ptr.pointer->value}</DisplayString>
    <Expand>
      <!-- thin -->
      <ExpandedItem Optional="true">ptr.pointer->value</ExpandedItem>
      <Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>

      <!-- dyn -->
      <Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
    </Expand>
  </Type>

  <!-- alloc::rc::Weak<[T]> -->
  <Type Name="alloc::rc::Weak&lt;slice2$&lt;*&gt;,*&gt;">
    <DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
    <Expand>
      <Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
      <Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
      <Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
      <ArrayItems>
        <Size>ptr.pointer.length</Size>
        <ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>

  <!-- alloc::sync::Arc<T> -->
  <Type Name="alloc::sync::Arc&lt;*&gt;">
    <DisplayString Optional="true">{ptr.pointer->data}</DisplayString>
    <Expand>
      <!-- thin -->
      <ExpandedItem Optional="true">ptr.pointer->data</ExpandedItem>
      <Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>

      <!-- dyn -->
      <Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
    </Expand>
  </Type>

  <!-- alloc::sync::Arc<[T]> -->
  <Type Name="alloc::sync::Arc&lt;slice2$&lt;*&gt;,*&gt;">
    <DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
    <Expand>
      <Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
      <Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
      <Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
      <ArrayItems>
        <Size>ptr.pointer.length</Size>
        <ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>

  <!-- alloc::sync::Weak<T> -->
  <Type Name="alloc::sync::Weak&lt;*&gt;">
    <DisplayString Optional="true">{ptr.pointer->data}</DisplayString>
    <Expand>
      <!-- thin -->
      <ExpandedItem Optional="true">ptr.pointer->data</ExpandedItem>
      <Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>

      <!-- dyn -->
      <Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
    </Expand>
  </Type>

  <!-- alloc::sync::Weak<[T]> -->
  <Type Name="alloc::sync::Weak&lt;slice2$&lt;*&gt;,*&gt;">
    <DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
    <Expand>
      <Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
      <Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
      <Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
      <ArrayItems>
        <Size>ptr.pointer.length</Size>
        <ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>
</AutoVisualizer>