Skip to content

Commit 8c2d506

Browse files
ridwanabdillahiJohnTitorRidwan Abdilahi
authored
Add documentation about Microsoft provided debuggers and CodeView/PDB… (rust-lang#1406)
Co-authored-by: Yuki Okushi <jtitor@2k36.org> Co-authored-by: Ridwan Abdilahi <riabdila@microsoft.com>
1 parent 5325fb3 commit 8c2d506

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/doc/rustc-dev-guide/src/debugging-support-in-rustc.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- toc -->
44

55
This document explains the state of debugging tools support in the Rust compiler (rustc).
6-
It gives an overview of GDB, LLDB,
6+
It gives an overview of GDB, LLDB, WinDbg/CDB,
77
as well as infrastructure around Rust compiler to debug Rust code.
88
If you want to learn how to debug the Rust compiler itself,
99
see [Debugging the Compiler].
@@ -42,6 +42,15 @@ Debugging Information Entry (DIE) which stores the information as "tags" to deno
4242
variables etc., e.g., `DW_TAG_variable`, `DW_TAG_pointer_type`, `DW_TAG_subprogram` etc.
4343
You can also invent your own tags and attributes.
4444

45+
### CodeView/PDB
46+
47+
[PDB] (Program Database) is a file format created by Microsoft that contains debug information.
48+
PDBs can be consumed by debuggers such as WinDbg/CDB and other tools to display debug information.
49+
A PDB contains multiple streams that describe debug information about a specific binary such
50+
as types, symbols, and source files used to compile the given binary. CodeView is another
51+
format which defines the structure of [symbol records] and [type records] that appear within
52+
PDB streams.
53+
4554
## Supported debuggers
4655

4756
### GDB
@@ -104,6 +113,27 @@ LLDB has Rust-like value and type output.
104113
* LLDB has a plugin architecture but that does not work for language support.
105114
* GDB generally works better on Linux.
106115

116+
### WinDbg/CDB
117+
118+
Microsoft provides [Windows Debugging Tools] such as the Windows Debugger (WinDbg) and
119+
the Console Debugger (CDB) which both support debugging programs written in Rust. These
120+
debuggers parse the debug info for a binary from the `PDB`, if available, to construct a
121+
visualization to serve up in the debugger.
122+
123+
#### Natvis
124+
125+
Both WinDbg and CDB support defining and viewing custom visualizations for any given type
126+
within the debugger using the Natvis framework. The Rust compiler defines a set of Natvis
127+
files that define custom visualizations for a subset of types in the standard libraries such
128+
as, `std, core and alloc`. These Natvis files are embedded into `PDBs` generated by the
129+
`*-pc-windows-msvc` target triples to automatically enable these custom visualizations when
130+
debugging. This default can be overridden by setting the `strip` rustc flag to either `debuginfo`
131+
or `symbols`.
132+
133+
Rust has support for embedding Natvis files for crates outside of the standard libraries by
134+
using the `#[debugger_visualizer]` attribute. For more details on how to embed debugger visualizers
135+
please refer to the `#[debugger_visualizer]` attribute in [the unstable book](https://doc.rust-lang.org/unstable-book/language-features/debugger-visualizer.html).
136+
107137
## DWARF and `rustc`
108138

109139
[DWARF] is the standard way compilers generate debugging information that debuggers read.
@@ -316,3 +346,7 @@ but may have to add some mode to let the compiler understand some extensions.
316346
[Apple developer documentation for System Integrity Protection]: https://developer.apple.com/library/archive/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_11.html#//apple_ref/doc/uid/TP40016227-SW11
317347
[https://github.com/rust-lang/lldb]: https://github.com/rust-lang/lldb
318348
[https://github.com/rust-lang/llvm-project]: https://github.com/rust-lang/llvm-project
349+
[PDB]: https://llvm.org/docs/PDB/index.html
350+
[symbol records]: https://llvm.org/docs/PDB/CodeViewSymbols.html
351+
[type records]: https://llvm.org/docs/PDB/CodeViewTypes.html
352+
[Windows Debugging Tools]: https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/

0 commit comments

Comments
 (0)