From cad42e0d330d8d3476f2217fe4f14f2f5e34e691 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Tue, 29 Jun 2021 15:32:03 -0400 Subject: [PATCH] Add natvis for cell types --- src/etc/natvis/libcore.natvis | 34 +++++++++++++ src/test/debuginfo/mutable-locs.rs | 77 +++++++++++++++++++++++++----- src/test/debuginfo/rwlock-read.rs | 6 +-- 3 files changed, 102 insertions(+), 15 deletions(-) diff --git a/src/etc/natvis/libcore.natvis b/src/etc/natvis/libcore.natvis index b5899cf9319..96459adb6b8 100644 --- a/src/etc/natvis/libcore.natvis +++ b/src/etc/natvis/libcore.natvis @@ -1,5 +1,39 @@ + + {value.value} + + value.value + + + + {value} + + value + + + + {value} + + value + + + + {value.value} + + "Unborrowed",sb + "Immutably borrowed",sb + "Mutably borrowed",sb + value.value + + + + {value} + + value + + + {__0} diff --git a/src/test/debuginfo/mutable-locs.rs b/src/test/debuginfo/mutable-locs.rs index 428a7e8d9c0..688483e43e4 100644 --- a/src/test/debuginfo/mutable-locs.rs +++ b/src/test/debuginfo/mutable-locs.rs @@ -9,26 +9,64 @@ // cdb-command: g // cdb-command:dx static_c,d -// cdb-check:static_c,d [Type: core::cell::Cell] -// cdb-check: [...] value [Type: core::cell::UnsafeCell] +// cdb-check:static_c,d : 10 [Type: core::cell::Cell] +// cdb-check: [] [Type: core::cell::Cell] // cdb-command: dx static_c.value,d -// cdb-check:static_c.value,d [Type: core::cell::UnsafeCell] -// cdb-check: [...] value : 10 [Type: int] +// cdb-check:static_c.value,d : 10 [Type: core::cell::UnsafeCell] +// cdb-check: [] [Type: core::cell::UnsafeCell] // cdb-command: dx dynamic_c,d -// cdb-check:dynamic_c,d [Type: core::cell::RefCell] -// cdb-check: [...] borrow [Type: core::cell::Cell] -// cdb-check: [...] value [Type: core::cell::UnsafeCell] +// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +// cdb-check: [] [Type: core::cell::RefCell] +// cdb-check: [Borrow state] : Unborrowed // cdb-command: dx dynamic_c.value,d -// cdb-check:dynamic_c.value,d [Type: core::cell::UnsafeCell] -// cdb-check: [...] value : 15 [Type: int] +// cdb-check:dynamic_c.value,d : 15 [Type: core::cell::UnsafeCell] +// cdb-check: [] [Type: core::cell::UnsafeCell] // cdb-command: dx b,d -// cdb-check:b,d [Type: core::cell::RefMut] -// cdb-check: [...] value : [...] : 42 [Type: int *] -// cdb-check: [...] borrow [Type: core::cell::BorrowRefMut] +// cdb-check:b,d : 42 [Type: core::cell::RefMut] +// cdb-check: [] [Type: core::cell::RefMut] +// cdb-check: 42 [Type: int] + +// cdb-command: g + +// cdb-command: dx dynamic_c,d +// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +// cdb-check: [] [Type: core::cell::RefCell] +// cdb-check: [Borrow state] : Immutably borrowed + +// cdb-command: dx r_borrow,d +// cdb-check:r_borrow,d : 15 [Type: core::cell::Ref] +// cdb-check: [] [Type: core::cell::Ref] +// cdb-check: 15 [Type: int] + +// cdb-command: g + +// cdb-command: dx dynamic_c,d +// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +// cdb-check: [] [Type: core::cell::RefCell] +// cdb-check: [Borrow state] : Unborrowed + +// cdb-command: g + +// cdb-command: dx dynamic_c,d +// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +// cdb-check: [] [Type: core::cell::RefCell] +// cdb-check: [Borrow state] : Mutably borrowed + +// cdb-command: dx r_borrow_mut,d +// cdb-check:r_borrow_mut,d : 15 [Type: core::cell::RefMut] +// cdb-check: [] [Type: core::cell::RefMut] +// cdb-check: 15 [Type: int] + +// cdb-command: g + +// cdb-command: dx dynamic_c,d +// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +// cdb-check: [] [Type: core::cell::RefCell] +// cdb-check: [Borrow state] : Unborrowed #![allow(unused_variables)] @@ -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() {()} diff --git a/src/test/debuginfo/rwlock-read.rs b/src/test/debuginfo/rwlock-read.rs index ac652c8ccf4..e1c10a4d37f 100644 --- a/src/test/debuginfo/rwlock-read.rs +++ b/src/test/debuginfo/rwlock-read.rs @@ -11,15 +11,15 @@ // cdb-command:dx l // cdb-check:l [Type: std::sync::rwlock::RwLock] // cdb-check: [...] poison [Type: std::sync::poison::Flag] -// cdb-check: [...] data [Type: core::cell::UnsafeCell] +// cdb-check: [...] data : 0 [Type: core::cell::UnsafeCell] // // cdb-command:dx r // cdb-check:r [Type: std::sync::rwlock::RwLockReadGuard] // cdb-check: [...] lock : [...] [Type: std::sync::rwlock::RwLock *] // // cdb-command:dx r.lock->data,d -// cdb-check:r.lock->data,d [Type: core::cell::UnsafeCell] -// cdb-check: [...] value : 0 [Type: int] +// cdb-check:r.lock->data,d : 0 [Type: core::cell::UnsafeCell] +// cdb-check: [] [Type: core::cell::UnsafeCell] #[allow(unused_variables)]