You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0000-debugger-visualizer.md
+51-76Lines changed: 51 additions & 76 deletions
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ With Natvis applied, WinDbg results in the following:
65
65
```
66
66
67
67
Currently, Rust provides visualizations for a handful of types defined in its
68
-
standard library via `.natvis` files or pretty printers via python scripts.
68
+
standard library via Natvis files or pretty printers via python scripts.
69
69
However, this support is inflexible; updating it requires modifying the Rust
70
70
toolchain itself, and either using a local build of the toolchain or waiting
71
71
for a new upstream build of the toolchain. It is not feasible for developers of
@@ -197,23 +197,20 @@ The Natvis files provide patterns, which match type names, and for matching
197
197
types, a description of how to display those types. This allows for some
198
198
limited support for generic types.
199
199
200
-
Rust developers can add one or more `.natvis` files to their crate. Through
201
-
the use of a new Rust attribute, `#[debugger_visualizer]`, the compiler will
202
-
encode the contents of the `.natvis` file in the crate metadata if the target
200
+
Rust developers can add one or more Natvis files to their crate. Through
201
+
the use of a new Rust attribute, `#![debugger_visualizer]`, the compiler will
202
+
encode the contents of the Natvis file in the crate metadata if the target
203
203
is an `rlib`. If the target is a `dll` or `exe`, the `/NATVIS` MSVC linker flag is
204
-
set for each `.natvis` file which will embed the Natvis visualizations into the PDB.
204
+
set for each Natvis file which will embed the Natvis visualizations into the PDB.
205
205
206
-
To provide Natvis files, developers create a file with the `.natvis` file
207
-
extension.
206
+
To provide Natvis files, developers create a file using the Natvis XML syntax
207
+
and reference it via the new `#![debugger_visualizer]` attribute that this RFC proposes.
208
208
209
-
See the below example for how rustc would embed these Natvis files in the
210
-
debuginfo for a binary.
211
-
212
-
As an example, consider a crate `foo` with this directory structure:
209
+
As an example for how to use this attribute, consider a crate `foo` with this directory structure:
213
210
214
211
```text
215
212
/Cargo.toml
216
-
/Foo.natvis (Note: the .natvis file does not have to match the name of the crate.)
213
+
/Foo.natvis (Note: the Natvis file does not have to match the name of the crate.)
217
214
+-- src
218
215
+-- main.rs
219
216
```
@@ -283,14 +280,12 @@ The pretty printers provide patterns, which match type names, and for matching
283
280
types, descibe how to display those types. (For writing a pretty printer, see: https://sourceware.org/gdb/onlinedocs/gdb/Writing-a-Pretty_002dPrinter.html#Writing-a-Pretty_002dPrinter).
284
281
285
282
Rust developers can add one or more pretty printers to their crate. This is done
286
-
in the Rust compiler via `.py` python scripts. Through the use of a new Rust attribute,
287
-
`#[debugger_visualizer]`, the compiler will encode the contents of the `.py` file in
288
-
the crate metadata if the target is an `rlib`. If the target is an executable, the
289
-
`.debug_gdb_scripts` section will include a reference to the pretty printer specified
290
-
by embedding the contents of the pretty printer directly into this section.
283
+
in the Rust compiler via python scripts. Through the use of the new Rust attribute
284
+
this RFC proposes, `#![debugger_visualizer]`, the compiler will encode the contents
285
+
of the pretty printer in the `.debug_gdb_scripts` section of the `ELF` generated.
291
286
292
-
To provide pretty printers, developers create a file with the `.py` file
293
-
extension and reference it via the `#[debugger_visualizer]` attribute as follows:
287
+
To provide pretty printers, developers create a pretty printer using the syntax provided
288
+
above and reference it via the `#![debugger_visualizer]` attribute as follows:
0 commit comments