rust/src/test/debuginfo
Guillaume Gomez f4e47ba3f1
Rollup merge of #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```
2021-07-16 10:07:59 +02:00
..
auxiliary Moved issue tests to subdirs and normalised names. 2019-03-14 01:00:49 +00:00
associated-types.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
basic-types-globals-metadata.rs Remove licenses 2018-12-25 21:08:33 -07:00
basic-types-globals.rs Remove licenses 2018-12-25 21:08:33 -07:00
basic-types-metadata.rs Remove licenses 2018-12-25 21:08:33 -07:00
basic-types-mut-globals.rs Remove licenses 2018-12-25 21:08:33 -07:00
basic-types.rs Fix type name difference between i686 and x86_64 for test 2021-07-02 10:31:22 -04:00
borrowed-basic.rs Remove licenses 2018-12-25 21:08:33 -07:00
borrowed-c-style-enum.rs Remove licenses 2018-12-25 21:08:33 -07:00
borrowed-enum.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
borrowed-struct.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
borrowed-tuple.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
borrowed-unique-basic.rs Remove licenses 2018-12-25 21:08:33 -07:00
box.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
boxed-struct.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
by-value-non-immediate-argument.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
by-value-self-argument-in-trait-impl.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
c-style-enum-in-composite.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
c-style-enum.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
closure-in-generic-function.rs Remove licenses 2018-12-25 21:08:33 -07:00
constant-debug-locs.rs Remove licenses 2018-12-25 21:08:33 -07:00
constant-in-match-pattern.rs Remove licenses 2018-12-25 21:08:33 -07:00
cross-crate-spans.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
cross-crate-type-uniquing.rs Remove licenses 2018-12-25 21:08:33 -07:00
destructured-fn-argument.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
destructured-for-loop-variable.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
destructured-local.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
drop-locations.rs Remove licenses 2018-12-25 21:08:33 -07:00
duration-type.rs Respond to review feedback 2021-07-09 18:29:08 -04:00
empty-string.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
enum-thinlto.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
evec-in-struct.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
extern-c-fn.rs Fix failed tests related to pointer printing when using GDB 10 2021-04-27 23:07:36 +08:00
fixed-sized-array.rs Add debug info tests for range, fix-sized array, and cell types. 2021-06-25 14:07:06 -07:00
function-arg-initialization.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
function-arguments.rs Remove licenses 2018-12-25 21:08:33 -07:00
function-call.rs Add missing : after min-gdb-version 2020-07-19 09:29:11 +00:00
function-names.rs Handle non-integer const generic parameters in debuginfo type names. 2021-07-14 15:55:03 +02:00
function-prologue-stepping-regular.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
gdb-pretty-struct-and-enums.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
generator-locals.rs Add a resume type parameter to Generator 2020-02-02 13:20:57 +01:00
generator-objects.rs Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger 2021-06-30 11:10:29 -07:00
generic-enum-with-different-disr-sizes.rs Update the minimum external LLVM to 8 2020-04-14 12:44:41 -07:00
generic-function.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
generic-functions-nested.rs Remove licenses 2018-12-25 21:08:33 -07:00
generic-method-on-generic-struct.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
generic-static-method-on-struct-and-enum.rs Remove licenses 2018-12-25 21:08:33 -07:00
generic-struct-style-enum.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
generic-struct.rs Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger 2021-06-30 11:10:29 -07:00
generic-tuple-style-enum.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
include_string.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-7712.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-12886.rs rustc_codegen_ssa: only "spill" SSA-like values to the stack for debuginfo. 2020-02-09 16:39:23 +02:00
issue-13213.rs Add basic CDB support to debuginfo compiletest s, to help catch *.natvis regressions, like those fixed in #60687. 2019-05-19 17:10:48 -07:00
issue-14411.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-22656.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
issue-57822.rs Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger 2021-06-30 11:10:29 -07:00
lexical-scope-in-for-loop.rs Remove licenses 2018-12-25 21:08:33 -07:00
lexical-scope-in-if.rs Remove licenses 2018-12-25 21:08:33 -07:00
lexical-scope-in-match.rs Remove licenses 2018-12-25 21:08:33 -07:00
lexical-scope-in-parameterless-closure.rs Remove licenses 2018-12-25 21:08:33 -07:00
lexical-scope-in-stack-closure.rs Remove licenses 2018-12-25 21:08:33 -07:00
lexical-scope-in-unconditional-loop.rs Remove licenses 2018-12-25 21:08:33 -07:00
lexical-scope-in-unique-closure.rs Remove licenses 2018-12-25 21:08:33 -07:00
lexical-scope-in-while.rs Remove licenses 2018-12-25 21:08:33 -07:00
lexical-scope-with-macro.rs Remove licenses 2018-12-25 21:08:33 -07:00
lexical-scopes-in-block-expression.rs Remove licenses 2018-12-25 21:08:33 -07:00
limited-debuginfo.rs Remove licenses 2018-12-25 21:08:33 -07:00
macro-stepping.inc Remove licenses 2018-12-25 21:08:33 -07:00
macro-stepping.rs Remove licenses 2018-12-25 21:08:33 -07:00
marker-types.rs Fix tests for i686 2021-07-14 16:50:11 -04:00
method-on-enum.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
method-on-generic-struct.rs Remove licenses 2018-12-25 21:08:33 -07:00
method-on-struct.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
method-on-trait.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
method-on-tuple-struct.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
msvc-pretty-enums.rs Fix failing test on i686-pc-windows-msvc 2021-07-06 09:55:11 -04:00
multi-byte-chars.rs Stablize non_ascii_idents feature. 2021-04-08 02:52:00 +08:00
multi-cgu.rs Remove licenses 2018-12-25 21:08:33 -07:00
multiple-functions-equal-var-names.rs Remove licenses 2018-12-25 21:08:33 -07:00
multiple-functions.rs Remove licenses 2018-12-25 21:08:33 -07:00
mutable-locs.rs Add natvis for cell types 2021-07-08 12:55:49 -04:00
mutex.rs Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger 2021-06-30 11:10:29 -07:00
name-shadowing-and-scope-nesting.rs Remove licenses 2018-12-25 21:08:33 -07:00
numeric-types.rs Add natvis for Atomic types 2021-07-08 12:55:49 -04:00
option-like-enum.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
packed-struct-with-destructor.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
packed-struct.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
pretty-huge-vec.rs Support pretty printing slices using GDB 2021-07-03 23:42:07 +08:00
pretty-slices.rs Ignore Windows debugger pretty-printing tests 2021-07-08 01:04:59 +08:00
pretty-std-collections-hash.rs Update cdb tests for expected output 2021-07-01 14:26:20 -04:00
pretty-std-collections.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
pretty-std.rs Fix tests for i686 2021-07-14 16:50:11 -04:00
pretty-uninitialized-vec.rs Add missing : after min-gdb-version 2020-07-19 09:29:11 +00:00
range-types.rs Add natvis for Range types 2021-07-08 12:55:49 -04:00
rc_arc.rs Add test for Unique<T>, weak ref counts and ref counts for Weak<T> 2021-07-12 13:26:01 -04:00
recursive-enum.rs Remove licenses 2018-12-25 21:08:33 -07:00
recursive-struct.rs Update the minimum external LLVM to 8 2020-04-14 12:44:41 -07:00
result-types.rs Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger 2021-06-30 11:10:29 -07:00
rwlock-read.rs Add natvis for cell types 2021-07-08 12:55:49 -04:00
rwlock-write.rs Add debug info tests for range, fix-sized array, and cell types. 2021-06-25 14:07:06 -07:00
self-in-default-method.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
self-in-generic-default-method.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
shadowed-argument.rs Remove licenses 2018-12-25 21:08:33 -07:00
shadowed-variable.rs Remove licenses 2018-12-25 21:08:33 -07:00
should-fail.rs Add needs-run-enabled directive for should-fail tests 2021-04-30 04:12:37 +00:00
simd.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
simple-lexical-scope.rs Remove licenses 2018-12-25 21:08:33 -07:00
simple-struct.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
simple-tuple.rs Update cdb tests for expected output 2021-07-01 14:26:20 -04:00
static-method-on-struct-and-enum.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-in-enum.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
struct-in-struct.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
struct-namespace.rs Remove licenses 2018-12-25 21:08:33 -07:00
struct-style-enum.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
struct-with-destructor.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
text-to-include-1.txt Re-bork whitespace for text file (fixup #23385) 2015-03-17 16:00:39 +05:30
text-to-include-2.txt Re-bork whitespace for text file (fixup #23385) 2015-03-17 16:00:39 +05:30
text-to-include-3.txt Re-bork whitespace for text file (fixup #23385) 2015-03-17 16:00:39 +05:30
thread.rs Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger 2021-06-30 11:10:29 -07:00
trait-pointers.rs Remove licenses 2018-12-25 21:08:33 -07:00
tuple-in-struct.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
tuple-in-tuple.rs Update cdb tests for expected output 2021-07-01 14:26:20 -04:00
tuple-struct.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
tuple-style-enum.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
type-names.cdb.js Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger 2021-06-30 11:10:29 -07:00
type-names.rs Update cdb tests for expected output 2021-07-01 14:26:20 -04:00
union-smoke.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
unique-enum.rs Update the minimum external LLVM to 8 2020-04-14 12:44:41 -07:00
unreachable-locals.rs Remove double trailing newlines 2019-04-22 16:57:01 +01:00
unsized.rs Remove licenses 2018-12-25 21:08:33 -07:00
var-captured-in-nested-closure.rs Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger 2021-06-30 11:10:29 -07:00
var-captured-in-sendable-closure.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00
var-captured-in-stack-closure.rs Fix closed over variables not available in debuginfo for Windows MSVC 2021-04-08 14:08:56 -04:00
vec-slices.rs Remove redundant ignore-tidy-linelength annotations 2021-04-03 22:30:20 +02:00
vec.rs Implement new gdb/lldb pretty-printers 2020-06-09 16:13:11 +03:00