NatVis files describe how to display types in some Windows debuggers, such as Visual Studio, WinDbg, and VS Code. This commit makes several improvements: * Adds visualizers for Rc<T>, Weak<T>, and Arc<T>. * Changes [size] to [len], for consistency with the Rust API. Visualizers often use [size] to mirror the size() method on C++ STL collections. * Several visualizers used the PVOID and ULONG typedefs. These are part of the Windows API; they are not guaranteed to always be defined in a pure Rust DLL/EXE. I converted PVOID to `void*` and `ULONG` to `unsigned long`. * Cosmetic change: Removed {} braces around the visualized display for `Option` types. They now display simply as `Some(value)` or `None`, which reflects what is written in source code. * The visualizer for `alloc::string::String` makes assumptions about the layout of `String` (it casts `String*` to another type), rather than using symbolic expressions. This commit changes the visualizer so that it simply uses symbolic expressions to access the string data and string length.
79 lines
2.8 KiB
XML
79 lines
2.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
|
<Type Name="alloc::vec::Vec<*>">
|
|
<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</ValuePointer>
|
|
</ArrayItems>
|
|
</Expand>
|
|
</Type>
|
|
<Type Name="alloc::collections::vec_deque::VecDeque<*>">
|
|
<DisplayString>{{ len={tail <= head ? head - tail : buf.cap - tail + head} }}</DisplayString>
|
|
<Expand>
|
|
<Item Name="[len]" ExcludeView="simple">tail <= head ? head - tail : buf.cap - tail + head</Item>
|
|
<Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
|
|
<CustomListItems>
|
|
<Variable Name="i" InitialValue="tail" />
|
|
|
|
<Size>tail <= head ? head - tail : buf.cap - tail + head</Size>
|
|
<Loop>
|
|
<If Condition="i == head">
|
|
<Break/>
|
|
</If>
|
|
<Item>buf.ptr.pointer[i]</Item>
|
|
<Exec>i = (i + 1 == buf.cap ? 0 : i + 1)</Exec>
|
|
</Loop>
|
|
</CustomListItems>
|
|
</Expand>
|
|
</Type>
|
|
<Type Name="alloc::collections::linked_list::LinkedList<*>">
|
|
<DisplayString>{{ len={len} }}</DisplayString>
|
|
<Expand>
|
|
<LinkedListItems>
|
|
<Size>len</Size>
|
|
<HeadPointer>*(alloc::collections::linked_list::Node<$T1> **)&head</HeadPointer>
|
|
<NextPointer>*(alloc::collections::linked_list::Node<$T1> **)&next</NextPointer>
|
|
<ValueNode>element</ValueNode>
|
|
</LinkedListItems>
|
|
</Expand>
|
|
</Type>
|
|
<Type Name="alloc::string::String">
|
|
<DisplayString>{(char*)vec.buf.ptr.pointer,[vec.len]s8}</DisplayString>
|
|
<StringView>(char*)vec.buf.ptr.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]">
|
|
<Expand>
|
|
<ArrayItems>
|
|
<Size>vec.len</Size>
|
|
<ValuePointer>(char*)vec.buf.ptr.pointer</ValuePointer>
|
|
</ArrayItems>
|
|
</Expand>
|
|
</Synthetic>
|
|
</Expand>
|
|
</Type>
|
|
<Type Name="alloc::rc::Rc<*>">
|
|
<DisplayString>{ptr.pointer->value}</DisplayString>
|
|
<Expand>
|
|
<ExpandedItem>ptr.pointer->value</ExpandedItem>
|
|
</Expand>
|
|
</Type>
|
|
<Type Name="alloc::sync::Arc<*>">
|
|
<DisplayString>{ptr.pointer->data}</DisplayString>
|
|
<Expand>
|
|
<ExpandedItem>ptr.pointer->data</ExpandedItem>
|
|
</Expand>
|
|
</Type>
|
|
<Type Name="alloc::sync::Weak<*>">
|
|
<DisplayString>{ptr.pointer->data}</DisplayString>
|
|
<Expand>
|
|
<ExpandedItem>ptr.pointer->data</ExpandedItem>
|
|
</Expand>
|
|
</Type>
|
|
</AutoVisualizer>
|