Commit be2eeb1
authored
Rollup merge of rust-lang#86983 - wesleywiser:natvis_std_types, r=michaelwoerister
Add or improve natvis definitions for common standard library types
Natvis definitions are used by Windows debuggers to provide a better experience when inspecting a value for types with natvis definitions. Many of our standard library types and intrinsic Rust types like slices and `str` already have natvis definitions.
This PR adds natvis definitions for missing types (like all of the `Atomic*` types) and improves some of the existing ones (such as showing the ref count on `Arc<T>` and `Rc<T>` and showing the borrow state of `RefCell<T>`). I've also added cdb tests to cover these definitions and updated existing tests with the new visualizations.
With this PR, the following types now visualize in a much more intuitive way:
### Type: `NonZero{I,U}{8,16,32,64,128,size}`, `Atomic{I,U}{8,16,32,64,size}`, `AtomicBool` and `Wrapping<T>`
<details><summary>Example:</summary>
```rust
let a_u32 = AtomicU32::new(32i32);
```
```
0:000> dx a_u32
a_u32 : 32 [Type: core::sync::atomic::AtomicU32]
[<Raw View>] [Type: core::sync::atomic::AtomicU32]
```
</details>
### Type: `Cell<T>` and `UnsafeCell<T>`
<details><summary>Example:</summary>
```rust
let cell = Cell::new(123u8);
let unsafecell = UnsafeCell::new((42u16, 30u16));
```
```
0:000> dx cell
cell : 123 [Type: core::cell::Cell<u8>]
[<Raw View>] [Type: core::cell::Cell<u8>]
0:000> dx unsafecell
unsafecell : (42, 30) [Type: core::cell::UnsafeCell<tuple<u16, u16>>]
[<Raw View>] [Type: core::cell::UnsafeCell<tuple<u16, u16>>]
[0] : 42 [Type: unsigned short]
[1] : 30 [Type: unsigned short]
```
</details>
### Type: `RefCell<T>`
<details><summary>Example:</summary>
```rust
let refcell = RefCell::new((123u16, 456u32));
```
```
0:000> dx refcell
refcell : (123, 456) [Type: core::cell::RefCell<tuple<u16, u32>>]
[<Raw View>] [Type: core::cell::RefCell<tuple<u16, u32>>]
[Borrow state] : Unborrowed
[0] : 123 [Type: unsigned short]
[1] : 456 [Type: unsigned int]
```
</details>
### Type: `NonNull<T>` and `Unique<T>`
<details><summary>Example:</summary>
```rust
let nonnull: NonNull<_> = (&(10, 20)).into();
```
```
0:000> dx nonnull
nonnull : NonNull(0x7ff6a5d9c390: (10, 20)) [Type: core::ptr::non_null::NonNull<tuple<i32, i32>>]
[<Raw View>] [Type: core::ptr::non_null::NonNull<tuple<i32, i32>>]
[0] : 10 [Type: int]
[1] : 20 [Type: int]
```
</details>
### Type: `Range<T>`, `RangeFrom<T>`, `RangeInclusive<T>`, `RangeTo<T>` and `RangeToInclusive<T>`
<details><summary>Example:</summary>
```rust
let range = (1..12);
let rangefrom = (9..);
let rangeinclusive = (32..=80);
let rangeto = (..42);
let rangetoinclusive = (..=120);
```
```
0:000> dx range
range : (1..12) [Type: core::ops::range::Range<i32>]
[<Raw View>] [Type: core::ops::range::Range<i32>]
0:000> dx rangefrom
rangefrom : (9..) [Type: core::ops::range::RangeFrom<i32>]
[<Raw View>] [Type: core::ops::range::RangeFrom<i32>]
0:000> dx rangeinclusive
rangeinclusive : (32..=80) [Type: core::ops::range::RangeInclusive<i32>]
[<Raw View>] [Type: core::ops::range::RangeInclusive<i32>]
0:000> dx rangeto
rangeto : (..42) [Type: core::ops::range::RangeTo<i32>]
[<Raw View>] [Type: core::ops::range::RangeTo<i32>]
0:000> dx rangetoinclusive
rangetoinclusive : (..=120) [Type: core::ops::range::RangeToInclusive<i32>]
[<Raw View>] [Type: core::ops::range::RangeToInclusive<i32>]
```
</details>
### Type: `Duration`
<details><summary>Example:</summary>
```rust
let duration = Duration::new(5, 12);
```
```
0:000> dx duration
duration : 5s 12ns [Type: core::time::Duration]
[<Raw View>] [Type: core::time::Duration]
seconds : 5 [Type: unsigned __int64]
nanoseconds : 12 [Type: unsigned int]
```
</details>
### Type: `ManuallyDrop<T>`
<details><summary>Example:</summary>
```rust
let manuallydrop = ManuallyDrop::new((123, 456));
```
```
0:000> dx manuallydrop
manuallydrop : (123, 456) [Type: core::mem::manually_drop::ManuallyDrop<tuple<i32, i32>>]
[<Raw View>] [Type: core::mem::manually_drop::ManuallyDrop<tuple<i32, i32>>]
[0] : 123 [Type: int]
[1] : 456 [Type: int]
```
</details>
### Type: `Pin<T>`
<details><summary>Example:</summary>
```rust
let mut s = "this".to_string();
let pin = Pin::new(&mut s);
```
```
0:000> dx pin
pin : Pin(0x11a0ff6f0: "this") [Type: core::pin::Pin<mut alloc::string::String*>]
[<Raw View>] [Type: core::pin::Pin<mut alloc::string::String*>]
[len] : 4 [Type: unsigned __int64]
[capacity] : 4 [Type: unsigned __int64]
[chars]
```
</details>
### Type: `Rc<T>` and `Arc<T>`
<details><summary>Example:</summary>
```rust
let rc = Rc::new(42i8);
let rc_weak = Rc::downgrade(&rc);
```
```
0:000> dx rc
rc : 42 [Type: alloc::rc::Rc<i8>]
[<Raw View>] [Type: alloc::rc::Rc<i8>]
[Reference count] : 1 [Type: core::cell::Cell<usize>]
0:000> dx rc_weak
rc_weak : 42 [Type: alloc::rc::Weak<i8>]
[<Raw View>] [Type: alloc::rc::Weak<i8>]
```
</details>
r? `@michaelwoerister`
cc `@nanguye2496`File tree
12 files changed
+596
-49
lines changed- src
- etc/natvis
- test/debuginfo
12 files changed
+596
-49
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
66 | 79 | | |
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
| 83 | + | |
| 84 | + | |
70 | 85 | | |
71 | 86 | | |
72 | 87 | | |
73 | 88 | | |
74 | 89 | | |
75 | 90 | | |
| 91 | + | |
| 92 | + | |
76 | 93 | | |
77 | 94 | | |
78 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
7 | 34 | | |
8 | 35 | | |
9 | 36 | | |
10 | | - | |
11 | | - | |
| 37 | + | |
| 38 | + | |
12 | 39 | | |
13 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
14 | 105 | | |
15 | 106 | | |
16 | 107 | | |
17 | 108 | | |
18 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
19 | 158 | | |
20 | | - | |
| 159 | + | |
| 160 | + | |
21 | 161 | | |
22 | 162 | | |
23 | | - | |
| 163 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
104 | 120 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
0 commit comments