Skip to content
Merged
122 changes: 112 additions & 10 deletions src/etc/natvis/libcore.natvis
Original file line number Diff line number Diff line change
@@ -1,23 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="core::ptr::Unique&lt;*&gt;">
<DisplayString>{{ Unique {pointer} }}</DisplayString>
<Type Name="core::cell::Cell&lt;*&gt;">
<DisplayString>{value.value}</DisplayString>
<Expand>
<Item Name="[ptr]">pointer</Item>
<ExpandedItem>value.value</ExpandedItem>
</Expand>
</Type>

<Type Name="core::ptr::Shared&lt;*&gt;">
<DisplayString>{{ Shared {pointer} }}</DisplayString>
<Type Name="core::cell::Ref&lt;*&gt;">
<DisplayString>{value}</DisplayString>
<Expand>
<ExpandedItem>value</ExpandedItem>
</Expand>
</Type>
<Type Name="core::cell::RefMut&lt;*&gt;">
<DisplayString>{value}</DisplayString>
<Expand>
<Item Name="[ptr]">pointer</Item>
<ExpandedItem>value</ExpandedItem>
</Expand>
</Type>
<Type Name="core::cell::RefCell&lt;*&gt;">
<DisplayString>{value.value}</DisplayString>
<Expand>
<Item Name="[Borrow state]" Condition="borrow.value.value == 0">"Unborrowed",sb</Item>
<Item Name="[Borrow state]" Condition="borrow.value.value &gt; 0">"Immutably borrowed",sb</Item>
<Item Name="[Borrow state]" Condition="borrow.value.value &lt; 0">"Mutably borrowed",sb</Item>
<ExpandedItem>value.value</ExpandedItem>
</Expand>
</Type>
<Type Name="core::cell::UnsafeCell&lt;*&gt;">
<DisplayString>{value}</DisplayString>
<Expand>
<ExpandedItem>value</ExpandedItem>
</Expand>
</Type>

<Type Name="core::num::nonzero::NonZeroI8">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroI16">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroI32">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroI64">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroI128">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroIsize">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU8">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU16">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU32">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU64">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroU128">
<DisplayString>{__0}</DisplayString>
</Type>
<Type Name="core::num::nonzero::NonZeroUsize">
<DisplayString>{__0}</DisplayString>
</Type>

<Type Name="core::num::wrapping::Wrapping&lt;*&gt;">
<DisplayString>{__0}</DisplayString>
</Type>

<Type Name="core::ptr::non_null::NonNull&lt;*&gt;">
<DisplayString>{(void*) pointer}</DisplayString>
<DisplayString>NonNull({(void*) pointer}: {pointer})</DisplayString>
<Expand>
<ExpandedItem>pointer</ExpandedItem>
</Expand>
</Type>

<Type Name="core::ptr::unique::Unique&lt;*&gt;">
<DisplayString>Unique({(void*)pointer}: {pointer})</DisplayString>
<Expand>
<Item Name="[value]">*pointer</Item>
<ExpandedItem>pointer</ExpandedItem>
</Expand>
</Type>
</AutoVisualizer>

<Type Name="core::sync::atomic::AtomicBool">
<DisplayString>{(bool)v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicI8">
<DisplayString>{v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicI16">
<DisplayString>{v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicI32">
<DisplayString>{v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicI64">
<DisplayString>{v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicIsize">
<DisplayString>{v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicU8">
<DisplayString>{v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicU16">
<DisplayString>{v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicU32">
<DisplayString>{v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicU64">
<DisplayString>{v.value}</DisplayString>
</Type>
<Type Name="core::sync::atomic::AtomicUsize">
<DisplayString>{v.value}</DisplayString>
</Type>
</AutoVisualizer>
21 changes: 21 additions & 0 deletions src/test/debuginfo/marker-types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// only-cdb
// compile-flags:-g

// === CDB TESTS ==================================================================================

// cdb-command: g

// cdb-command: dx nonnull
// cdb-check:nonnull : NonNull(0x[...]: 0xc) [Type: core::ptr::non_null::NonNull<u32>]
// cdb-check: [<Raw View>] [Type: core::ptr::non_null::NonNull<u32>]
// cdb-checK: 0xc [Type: unsigned int]

use std::ptr::NonNull;

fn main() {
let nonnull: NonNull<_> = (&12u32).into();

zzz(); // #break
}

fn zzz() { }
77 changes: 65 additions & 12 deletions src/test/debuginfo/mutable-locs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,64 @@
// cdb-command: g

// cdb-command:dx static_c,d
// cdb-check:static_c,d [Type: core::cell::Cell<i32>]
// cdb-check: [...] value [Type: core::cell::UnsafeCell<i32>]
// cdb-check:static_c,d : 10 [Type: core::cell::Cell<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::Cell<i32>]

// cdb-command: dx static_c.value,d
// cdb-check:static_c.value,d [Type: core::cell::UnsafeCell<i32>]
// cdb-check: [...] value : 10 [Type: int]
// cdb-check:static_c.value,d : 10 [Type: core::cell::UnsafeCell<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::UnsafeCell<i32>]

// cdb-command: dx dynamic_c,d
// cdb-check:dynamic_c,d [Type: core::cell::RefCell<i32>]
// cdb-check: [...] borrow [Type: core::cell::Cell<isize>]
// cdb-check: [...] value [Type: core::cell::UnsafeCell<i32>]
// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
// cdb-check: [Borrow state] : Unborrowed

// cdb-command: dx dynamic_c.value,d
// cdb-check:dynamic_c.value,d [Type: core::cell::UnsafeCell<i32>]
// cdb-check: [...] value : 15 [Type: int]
// cdb-check:dynamic_c.value,d : 15 [Type: core::cell::UnsafeCell<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::UnsafeCell<i32>]

// cdb-command: dx b,d
// cdb-check:b,d [Type: core::cell::RefMut<i32>]
// cdb-check: [...] value : [...] : 42 [Type: int *]
// cdb-check: [...] borrow [Type: core::cell::BorrowRefMut]
// cdb-check:b,d : 42 [Type: core::cell::RefMut<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::RefMut<i32>]
// cdb-check: 42 [Type: int]

// cdb-command: g

// cdb-command: dx dynamic_c,d
// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
// cdb-check: [Borrow state] : Immutably borrowed

// cdb-command: dx r_borrow,d
// cdb-check:r_borrow,d : 15 [Type: core::cell::Ref<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::Ref<i32>]
// cdb-check: 15 [Type: int]

// cdb-command: g

// cdb-command: dx dynamic_c,d
// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
// cdb-check: [Borrow state] : Unborrowed

// cdb-command: g

// cdb-command: dx dynamic_c,d
// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
// cdb-check: [Borrow state] : Mutably borrowed

// cdb-command: dx r_borrow_mut,d
// cdb-check:r_borrow_mut,d : 15 [Type: core::cell::RefMut<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::RefMut<i32>]
// cdb-check: 15 [Type: int]

// cdb-command: g

// cdb-command: dx dynamic_c,d
// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
// cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
// cdb-check: [Borrow state] : Unborrowed

#![allow(unused_variables)]

Expand All @@ -46,6 +84,21 @@ fn main() {
*b = 42;

zzz(); // #break

// Check that `RefCell`'s borrow state visualizes correctly
{
let r_borrow = dynamic_c.borrow();
zzz(); // #break
}

zzz(); // #break

{
let r_borrow_mut = dynamic_c.borrow_mut();
zzz(); // #break
}

zzz(); // #break
}

fn zzz() {()}
Loading