Skip to content

Commit cccff1a

Browse files
committed
Implement CDB visualizers
1 parent 703fc31 commit cccff1a

File tree

2 files changed

+72
-73
lines changed

2 files changed

+72
-73
lines changed

src/etc/natvis/liballoc.natvis

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -73,117 +73,116 @@
7373
-->
7474
<!-- alloc::rc::Rc<T> -->
7575
<Type Name="alloc::rc::Rc&lt;*&gt;">
76-
<DisplayString Optional="true">{ptr.pointer->value}</DisplayString>
76+
<DisplayString Optional="true">{*raw_rc.weak.ptr.pointer}</DisplayString>
7777
<Expand>
7878
<!-- thin -->
79-
<ExpandedItem Optional="true">ptr.pointer->value</ExpandedItem>
80-
<Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
81-
<Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>
79+
<ExpandedItem Optional="true">*raw_rc.weak.ptr.pointer</ExpandedItem>
80+
<Item Name="[Reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer - 1)->strong</Item>
81+
<Item Name="[Weak reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer - 1)->weak</Item>
8282

8383
<!-- dyn -->
84-
<Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
85-
<Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
84+
<Item Name="[Reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer.pointer - 1)->strong</Item>
85+
<Item Name="[Weak reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer.pointer - 1)->weak</Item>
8686
</Expand>
8787
</Type>
8888

8989
<!-- alloc::rc::Rc<[T]> -->
9090
<Type Name="alloc::rc::Rc&lt;slice2$&lt;*&gt;,*&gt;">
91-
<DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
91+
<DisplayString>{{ len={raw_rc.weak.ptr.pointer.length} }}</DisplayString>
9292
<Expand>
93-
<Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
94-
<Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
95-
<Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
93+
<Item Name="[Length]" ExcludeView="simple">raw_rc.weak.ptr.pointer.length</Item>
94+
<Item Name="[Reference count]">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer.data_ptr - 1)->strong</Item>
95+
<Item Name="[Weak reference count]">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer.data_ptr - 1)->weak</Item>
9696
<ArrayItems>
97-
<Size>ptr.pointer.length</Size>
98-
<!-- We add +2 to the data_ptr in order to skip the ref count fields in the RcInner -->
99-
<ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
97+
<Size>raw_rc.weak.ptr.pointer.length</Size>
98+
<ValuePointer>($T1*)raw_rc.weak.ptr.pointer.data_ptr</ValuePointer>
10099
</ArrayItems>
101100
</Expand>
102101
</Type>
103102

104103
<!-- alloc::rc::Weak<T> -->
105104
<Type Name="alloc::rc::Weak&lt;*&gt;">
106-
<DisplayString Optional="true">{ptr.pointer->value}</DisplayString>
105+
<DisplayString Optional="true">{*raw_weak.ptr.pointer}</DisplayString>
107106
<Expand>
108107
<!-- thin -->
109-
<ExpandedItem Optional="true">ptr.pointer->value</ExpandedItem>
110-
<Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
111-
<Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>
108+
<ExpandedItem Optional="true">*raw_weak.ptr.pointer</ExpandedItem>
109+
<Item Name="[Reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer - 1)->strong</Item>
110+
<Item Name="[Weak reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer - 1)->weak</Item>
112111

113112
<!-- dyn -->
114-
<Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
115-
<Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
113+
<Item Name="[Reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer.pointer - 1)->strong</Item>
114+
<Item Name="[Weak reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer.pointer - 1)->weak</Item>
116115
</Expand>
117116
</Type>
118117

119118
<!-- alloc::rc::Weak<[T]> -->
120119
<Type Name="alloc::rc::Weak&lt;slice2$&lt;*&gt;,*&gt;">
121-
<DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
120+
<DisplayString>{{ len={raw_weak.ptr.pointer.length} }}</DisplayString>
122121
<Expand>
123-
<Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
124-
<Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
125-
<Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
122+
<Item Name="[Length]" ExcludeView="simple">raw_weak.ptr.pointer.length</Item>
123+
<Item Name="[Reference count]">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer.data_ptr - 1)->strong</Item>
124+
<Item Name="[Weak reference count]">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer.data_ptr - 1)->weak</Item>
126125
<ArrayItems>
127-
<Size>ptr.pointer.length</Size>
128-
<ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
126+
<Size>raw_weak.ptr.pointer.length</Size>
127+
<ValuePointer>($T1*)raw_weak.ptr.pointer.data_ptr</ValuePointer>
129128
</ArrayItems>
130129
</Expand>
131130
</Type>
132131

133132
<!-- alloc::sync::Arc<T> -->
134133
<Type Name="alloc::sync::Arc&lt;*&gt;">
135-
<DisplayString Optional="true">{ptr.pointer->data}</DisplayString>
134+
<DisplayString Optional="true">{*raw_rc.weak.ptr.pointer}</DisplayString>
136135
<Expand>
137136
<!-- thin -->
138-
<ExpandedItem Optional="true">ptr.pointer->data</ExpandedItem>
139-
<Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
140-
<Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>
137+
<ExpandedItem Optional="true">*raw_rc.weak.ptr.pointer</ExpandedItem>
138+
<Item Name="[Reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer - 1)->strong</Item>
139+
<Item Name="[Weak reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer - 1)->weak</Item>
141140

142141
<!-- dyn -->
143-
<Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
144-
<Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
142+
<Item Name="[Reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer.pointer - 1)->strong</Item>
143+
<Item Name="[Weak reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer.pointer - 1)->weak</Item>
145144
</Expand>
146145
</Type>
147146

148147
<!-- alloc::sync::Arc<[T]> -->
149148
<Type Name="alloc::sync::Arc&lt;slice2$&lt;*&gt;,*&gt;">
150-
<DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
149+
<DisplayString>{{ len={raw_rc.weak.ptr.pointer.length} }}</DisplayString>
151150
<Expand>
152-
<Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
153-
<Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
154-
<Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
151+
<Item Name="[Length]" ExcludeView="simple">raw_rc.weak.ptr.pointer.length</Item>
152+
<Item Name="[Reference count]">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer.data_ptr - 1)->strong</Item>
153+
<Item Name="[Weak reference count]">((alloc::raw_rc::RefCounts *)raw_rc.weak.ptr.pointer.data_ptr - 1)->weak</Item>
155154
<ArrayItems>
156-
<Size>ptr.pointer.length</Size>
157-
<ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
155+
<Size>raw_rc.weak.ptr.pointer.length</Size>
156+
<ValuePointer>($T1*)raw_rc.weak.ptr.pointer.data_ptr</ValuePointer>
158157
</ArrayItems>
159158
</Expand>
160159
</Type>
161160

162161
<!-- alloc::sync::Weak<T> -->
163162
<Type Name="alloc::sync::Weak&lt;*&gt;">
164-
<DisplayString Optional="true">{ptr.pointer->data}</DisplayString>
163+
<DisplayString Optional="true">{*raw_weak.ptr.pointer}</DisplayString>
165164
<Expand>
166165
<!-- thin -->
167-
<ExpandedItem Optional="true">ptr.pointer->data</ExpandedItem>
168-
<Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
169-
<Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>
166+
<ExpandedItem Optional="true">*raw_weak.ptr.pointer</ExpandedItem>
167+
<Item Name="[Reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer - 1)->strong</Item>
168+
<Item Name="[Weak reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer - 1)->weak</Item>
170169

171170
<!-- dyn -->
172-
<Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
173-
<Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
171+
<Item Name="[Reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer.pointer - 1)->strong</Item>
172+
<Item Name="[Weak reference count]" Optional="true">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer.pointer - 1)->weak</Item>
174173
</Expand>
175174
</Type>
176175

177176
<!-- alloc::sync::Weak<[T]> -->
178177
<Type Name="alloc::sync::Weak&lt;slice2$&lt;*&gt;,*&gt;">
179-
<DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
178+
<DisplayString>{{ len={raw_weak.ptr.pointer.length} }}</DisplayString>
180179
<Expand>
181-
<Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
182-
<Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
183-
<Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
180+
<Item Name="[Length]" ExcludeView="simple">raw_weak.ptr.pointer.length</Item>
181+
<Item Name="[Reference count]">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer.data_ptr - 1)->strong</Item>
182+
<Item Name="[Weak reference count]">((alloc::raw_rc::RefCounts *)raw_weak.ptr.pointer.data_ptr - 1)->weak</Item>
184183
<ArrayItems>
185-
<Size>ptr.pointer.length</Size>
186-
<ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
184+
<Size>raw_weak.ptr.pointer.length</Size>
185+
<ValuePointer>($T1*)raw_weak.ptr.pointer.data_ptr</ValuePointer>
187186
</ArrayItems>
188187
</Expand>
189188
</Type>

tests/debuginfo/rc_arc.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,76 +27,76 @@
2727

2828
// cdb-command:dx rc,d
2929
// cdb-check:rc,d : 111 [Type: alloc::rc::Rc<i32,alloc::alloc::Global>]
30-
// cdb-check: [Reference count] : 11 [Type: core::cell::Cell<usize>]
31-
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
30+
// cdb-check: [Reference count] : 11 [Type: core::cell::UnsafeCell<usize>]
31+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
3232

3333
// cdb-command:dx weak_rc,d
3434
// cdb-check:weak_rc,d : 111 [Type: alloc::rc::Weak<i32,alloc::alloc::Global>]
35-
// cdb-check: [Reference count] : 11 [Type: core::cell::Cell<usize>]
36-
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
35+
// cdb-check: [Reference count] : 11 [Type: core::cell::UnsafeCell<usize>]
36+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
3737

3838
// cdb-command:dx arc,d
3939
// cdb-check:arc,d : 222 [Type: alloc::sync::Arc<i32,alloc::alloc::Global>]
40-
// cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize]
41-
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
40+
// cdb-check: [Reference count] : 21 [Type: core::cell::UnsafeCell<usize>]
41+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
4242

4343
// cdb-command:dx weak_arc,d
4444
// cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak<i32,alloc::alloc::Global>]
45-
// cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize]
46-
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
45+
// cdb-check: [Reference count] : 21 [Type: core::cell::UnsafeCell<usize>]
46+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
4747

4848
// cdb-command:dx dyn_rc,d
4949
// cdb-check:dyn_rc,d [Type: alloc::rc::Rc<dyn$<core::fmt::Debug>,alloc::alloc::Global>]
50-
// cdb-check: [Reference count] : 31 [Type: core::cell::Cell<usize>]
51-
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
50+
// cdb-check: [Reference count] : 31 [Type: core::cell::UnsafeCell<usize>]
51+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
5252

5353
// cdb-command:dx dyn_rc_weak,d
5454
// cdb-check:dyn_rc_weak,d [Type: alloc::rc::Weak<dyn$<core::fmt::Debug>,alloc::alloc::Global>]
55-
// cdb-check: [Reference count] : 31 [Type: core::cell::Cell<usize>]
56-
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
55+
// cdb-check: [Reference count] : 31 [Type: core::cell::UnsafeCell<usize>]
56+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
5757

5858
// cdb-command:dx slice_rc,d
5959
// cdb-check:slice_rc,d : { len=3 } [Type: alloc::rc::Rc<slice2$<u32>,alloc::alloc::Global>]
6060
// cdb-check: [Length] : 3 [Type: [...]]
61-
// cdb-check: [Reference count] : 41 [Type: core::cell::Cell<usize>]
62-
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
61+
// cdb-check: [Reference count] : 41 [Type: core::cell::UnsafeCell<usize>]
62+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
6363
// cdb-check: [0] : 1 [Type: u32]
6464
// cdb-check: [1] : 2 [Type: u32]
6565
// cdb-check: [2] : 3 [Type: u32]
6666

6767
// cdb-command:dx slice_rc_weak,d
6868
// cdb-check:slice_rc_weak,d : { len=3 } [Type: alloc::rc::Weak<slice2$<u32>,alloc::alloc::Global>]
6969
// cdb-check: [Length] : 3 [Type: [...]]
70-
// cdb-check: [Reference count] : 41 [Type: core::cell::Cell<usize>]
71-
// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>]
70+
// cdb-check: [Reference count] : 41 [Type: core::cell::UnsafeCell<usize>]
71+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
7272
// cdb-check: [0] : 1 [Type: u32]
7373
// cdb-check: [1] : 2 [Type: u32]
7474
// cdb-check: [2] : 3 [Type: u32]
7575

7676
// cdb-command:dx dyn_arc,d
7777
// cdb-check:dyn_arc,d [Type: alloc::sync::Arc<dyn$<core::fmt::Debug>,alloc::alloc::Global>]
78-
// cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize]
79-
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
78+
// cdb-check: [Reference count] : 51 [Type: core::cell::UnsafeCell<usize>]
79+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
8080

8181
// cdb-command:dx dyn_arc_weak,d
8282
// cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak<dyn$<core::fmt::Debug>,alloc::alloc::Global>]
83-
// cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize]
84-
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
83+
// cdb-check: [Reference count] : 51 [Type: core::cell::UnsafeCell<usize>]
84+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
8585

8686
// cdb-command:dx slice_arc,d
8787
// cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc<slice2$<u32>,alloc::alloc::Global>]
8888
// cdb-check: [Length] : 3 [Type: [...]]
89-
// cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize]
90-
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
89+
// cdb-check: [Reference count] : 61 [Type: core::cell::UnsafeCell<usize>]
90+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
9191
// cdb-check: [0] : 4 [Type: u32]
9292
// cdb-check: [1] : 5 [Type: u32]
9393
// cdb-check: [2] : 6 [Type: u32]
9494

9595
// cdb-command:dx slice_arc_weak,d
9696
// cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak<slice2$<u32>,alloc::alloc::Global>]
9797
// cdb-check: [Length] : 3 [Type: [...]]
98-
// cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize]
99-
// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize]
98+
// cdb-check: [Reference count] : 61 [Type: core::cell::UnsafeCell<usize>]
99+
// cdb-check: [Weak reference count] : 2 [Type: core::cell::UnsafeCell<usize>]
100100
// cdb-check: [0] : 4 [Type: u32]
101101
// cdb-check: [1] : 5 [Type: u32]
102102
// cdb-check: [2] : 6 [Type: u32]

0 commit comments

Comments
 (0)