|
1 | 1 | # Debugger attributes |
2 | 2 |
|
3 | | -The following [attributes] are used for enhancing the debugging experience when using third-party debuggers like GDB or LLDB. |
| 3 | +he following [attributes] are used for enhancing the debugging experience when using third-party debuggers like GDB or LLDB. |
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`. |
| 7 | +The `debugger_visualizer` attribute can be used to embed a debugger visualizer file into the debug information generated by `rustc`. |
8 | 8 | This enables an improved debugger experience for types outside of Rust's standard library. |
9 | 9 |
|
10 | 10 | ### Using `debugger_visualizer` with Natvis |
11 | 11 |
|
12 | 12 | 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. |
| 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 | 16 | <div class="warning"> |
17 | | -Currently, this attribute only supports embedding Natvis files on `-windows-msvc` targets. |
| 17 | +Currently, this attribute only supports embedding Natvis files on `-windows-msvc` targets. |
18 | 18 | </div> |
19 | 19 |
|
20 | 20 | Consider a crate with this directory structure: |
21 | 21 |
|
22 | 22 | ```text |
23 | 23 | /Cargo.toml |
24 | | -/Rectangle.natvis |
| 24 | +/Rectangle.natvis |
25 | 25 | +-- src |
26 | 26 | +-- main.rs |
27 | 27 | ``` |
@@ -81,14 +81,14 @@ When viewed under WinDbg, the `fancy_rect` variable would be shown as follows: |
81 | 81 |
|
82 | 82 | ### Using `debugger_visualizer` with GDB |
83 | 83 |
|
84 | | -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. |
85 | | -These scripts are embedded using the `gdb_script_file` meta item. |
| 84 | +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. |
| 85 | +These scripts are embedded using the `gdb_script_file` meta item. |
86 | 86 | For detailed information on pretty printers, refer to GDB's [pretty print documentation]. |
87 | 87 |
|
88 | 88 | Embedded pretty printers are not automatically loaded when debugging a binary under GDB. |
89 | 89 | There are two ways to enable auto-loading embedded pretty printers: |
90 | 90 | 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]) |
91 | | -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`. |
| 91 | +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`. |
92 | 92 |
|
93 | 93 | Consider a crate called `foobar` with this directory structure: |
94 | 94 |
|
@@ -148,7 +148,7 @@ gdb.current_objfile().pretty_printers.append(lookup) |
148 | 148 |
|
149 | 149 | When the crate's debug executable is passed into GDB, `print bob` will display: |
150 | 150 |
|
151 | | -``` |
| 151 | +```text |
152 | 152 | "Bob" is 10 years old. |
153 | 153 | ``` |
154 | 154 |
|
|
0 commit comments