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
The following [attributes] are used for enhancing the debugging experience when using third-party debuggers like GDB or LLDB.
3
+
The following [attributes] are used for enhancing the debugging experience when using third-party debuggers like GDB or WinDbg.
4
4
5
5
## The `debugger_visualizer` attribute
6
6
7
-
The `debugger_visualizer` attribute can be used to embed a debugger visualizer file into the debug information generated by `rustc`.
8
-
This enables an improved debugger experience for types outside of Rust's standard library.
7
+
The *`debugger_visualizer` attribute* can be used to embed a debugger visualizer file into the debug information.
8
+
This enables an improved debugger experience for displaying values in the debugger.
9
+
It uses the [_MetaListNameValueStr_] syntax to specify its inputs, and must be specified as a crate attribute.
9
10
10
11
### Using `debugger_visualizer` with Natvis
11
12
12
13
Natvis is an XML-based framework for Microsoft debuggers (such as Visual Studio and WinDbg) that uses declarative rules to customize the display of types.
13
-
A Natvis file is embedded using the `natvis-file` meta item.
14
14
For detailed information on the Natvis format, refer to Microsoft's [Natvis documentation].
15
15
16
-
<divclass="warning">
17
-
Currently, this attribute only supports embedding Natvis files on `-windows-msvc` targets.
18
-
</div>
16
+
This attribute only supports embedding Natvis files on `-windows-msvc` targets.
19
17
20
-
Consider a crate with this directory structure:
21
-
22
-
```text
23
-
/Cargo.toml
24
-
/Rectangle.natvis
25
-
+-- src
26
-
+-- main.rs
27
-
```
28
-
29
-
Where `main.rs` contains:
18
+
The path to the Natvis file is specified with the `natvis_file` key, which is a path relative to the crate source file:
30
19
20
+
<!-- ignore: requires external files, and msvc -->
@@ -82,55 +63,38 @@ When viewed under WinDbg, the `fancy_rect` variable would be shown as follows:
82
63
83
64
```text
84
65
> Variables:
85
-
> fancy_rect: (10, 10) + (5, 5)
86
-
> LowerLeft: (10, 10)
87
-
> UpperLeft: (10, 15)
88
-
> UpperRight: (15, 15)
89
-
> LowerRight: (15, 10)
66
+
> fancy_rect: (10.0, 10.0) + (5.0, 5.0)
67
+
> LowerLeft: (10.0, 10.0)
68
+
> UpperLeft: (10.0, 15.0)
69
+
> UpperRight: (15.0, 15.0)
70
+
> LowerRight: (15.0, 10.0)
90
71
```
91
72
92
73
### Using `debugger_visualizer` with GDB
93
74
94
75
GDB supports the use of a structured Python script, called a *pretty printer*, that describes how a type should be visualized in the debugger view.
95
-
These scripts are embedded using the `gdb_script_file` meta item.
96
-
For detailed information on pretty printers, refer to GDB's [pretty print documentation].
76
+
For detailed information on pretty printers, refer to GDB's [pretty printing documentation].
97
77
98
78
Embedded pretty printers are not automatically loaded when debugging a binary under GDB.
99
79
There are two ways to enable auto-loading embedded pretty printers:
100
-
1. Launch GDB with extra arguments to explicitly add a directory or binary to the auto-load safe path: `gdb -iex "set auto-load safe-path path/to/binary" path/to/binary` (For more information, see GDB's [auto-loading documentation])
80
+
1. Launch GDB with extra arguments to explicitly add a directory or binary to the auto-load safe path: `gdb -iex "add-auto-load-safe-path safe-path path/to/binary" path/to/binary`
81
+
For more information, see GDB's [auto-loading documentation].
101
82
1. Create a file named `gdbinit` under `$HOME/.config/gdb` (you may need to create the directory if it doesn't already exist). Add the following line to that file: `add-auto-load-safe-path path/to/binary`.
102
83
103
-
Consider a crate called `PersonPrinter` with this directory structure:
104
-
105
-
```text
106
-
/Cargo.toml
107
-
/printer.py
108
-
+-- src
109
-
+-- main.rs
110
-
```
111
-
112
-
Where `main.rs` contains:
84
+
These scripts are embedded using the `gdb_script_file` key, which is a path relative to the crate source file.
0 commit comments