Skip to content

Commit 8500274

Browse files
committed
Add visualizer for OsString and fixup other string visualizers
1 parent a6a82c6 commit 8500274

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/etc/natvis/intrinsic.natvis

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
33
<Type Name="str">
4-
<DisplayString>{data_ptr,[length]s8}</DisplayString>
5-
<StringView>data_ptr,[length]s8</StringView>
4+
<DisplayString>{(char*)data_ptr,[length]s8}</DisplayString>
5+
<StringView>(char*)data_ptr,[length]s8</StringView>
66
<Expand>
77
<Item Name="[len]" ExcludeView="simple">length</Item>
88
<Synthetic Name="[chars]">

src/etc/natvis/libstd.natvis

+15-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</Type>
7575

7676
<Type Name="std::ffi::c_str::CString">
77-
<DisplayString>{inner.data_ptr,s}</DisplayString>
77+
<DisplayString>{(char*)inner.data_ptr}</DisplayString>
7878
<Expand>
7979
<Synthetic Name="[chars]">
8080
<Expand>
@@ -101,4 +101,18 @@
101101
</Synthetic>
102102
</Expand>
103103
</Type>
104+
105+
<Type Name="std::ffi::os_str::OsString">
106+
<DisplayString>{(char*)inner.inner.bytes.buf.ptr.pointer,[inner.inner.bytes.len]}</DisplayString>
107+
<Expand>
108+
<Synthetic Name="[chars]">
109+
<Expand>
110+
<ArrayItems>
111+
<Size>inner.inner.bytes.len</Size>
112+
<ValuePointer>(char*)inner.inner.bytes.buf.ptr.pointer</ValuePointer>
113+
</ArrayItems>
114+
</Expand>
115+
</Synthetic>
116+
</Expand>
117+
</Type>
104118
</AutoVisualizer>

src/test/debuginfo/pretty-std.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@
111111
// cdb-check: [11] : 33 '!' [Type: char]
112112

113113
// cdb-command: dx os_string
114-
// cdb-check:os_string [Type: [...]::OsString]
115-
// NOTE: OsString doesn't have a .natvis entry yet.
114+
// cdb-check:os_string : "IAMA OS string 😃" [Type: std::ffi::os_str::OsString]
115+
// cdb-check: [<Raw View>] [Type: std::ffi::os_str::OsString]
116+
// cdb-check: [chars]
116117

117118
// cdb-command: dx some
118119
// cdb-check:some : Some [Type: enum$<core::option::Option<i16> >]

0 commit comments

Comments
 (0)