Add documentation about Microsoft provided debuggers and CodeView/PDB… (#1406)

Co-authored-by: Yuki Okushi <jtitor@2k36.org>
Co-authored-by: Ridwan Abdilahi <riabdila@microsoft.com>
This commit is contained in:
ridwanabdillahi 2022-07-25 15:33:58 -07:00 committed by GitHub
parent bcc1166bf6
commit c7637def78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 1 deletions

View File

@ -3,7 +3,7 @@
<!-- toc --> <!-- toc -->
This document explains the state of debugging tools support in the Rust compiler (rustc). This document explains the state of debugging tools support in the Rust compiler (rustc).
It gives an overview of GDB, LLDB, It gives an overview of GDB, LLDB, WinDbg/CDB,
as well as infrastructure around Rust compiler to debug Rust code. as well as infrastructure around Rust compiler to debug Rust code.
If you want to learn how to debug the Rust compiler itself, If you want to learn how to debug the Rust compiler itself,
see [Debugging the Compiler]. see [Debugging the Compiler].
@ -42,6 +42,15 @@ Debugging Information Entry (DIE) which stores the information as "tags" to deno
variables etc., e.g., `DW_TAG_variable`, `DW_TAG_pointer_type`, `DW_TAG_subprogram` etc. variables etc., e.g., `DW_TAG_variable`, `DW_TAG_pointer_type`, `DW_TAG_subprogram` etc.
You can also invent your own tags and attributes. You can also invent your own tags and attributes.
### CodeView/PDB
[PDB] (Program Database) is a file format created by Microsoft that contains debug information.
PDBs can be consumed by debuggers such as WinDbg/CDB and other tools to display debug information.
A PDB contains multiple streams that describe debug information about a specific binary such
as types, symbols, and source files used to compile the given binary. CodeView is another
format which defines the structure of [symbol records] and [type records] that appear within
PDB streams.
## Supported debuggers ## Supported debuggers
### GDB ### GDB
@ -104,6 +113,27 @@ LLDB has Rust-like value and type output.
* LLDB has a plugin architecture but that does not work for language support. * LLDB has a plugin architecture but that does not work for language support.
* GDB generally works better on Linux. * GDB generally works better on Linux.
### WinDbg/CDB
Microsoft provides [Windows Debugging Tools] such as the Windows Debugger (WinDbg) and
the Console Debugger (CDB) which both support debugging programs written in Rust. These
debuggers parse the debug info for a binary from the `PDB`, if available, to construct a
visualization to serve up in the debugger.
#### Natvis
Both WinDbg and CDB support defining and viewing custom visualizations for any given type
within the debugger using the Natvis framework. The Rust compiler defines a set of Natvis
files that define custom visualizations for a subset of types in the standard libraries such
as, `std, core and alloc`. These Natvis files are embedded into `PDBs` generated by the
`*-pc-windows-msvc` target triples to automatically enable these custom visualizations when
debugging. This default can be overridden by setting the `strip` rustc flag to either `debuginfo`
or `symbols`.
Rust has support for embedding Natvis files for crates outside of the standard libraries by
using the `#[debugger_visualizer]` attribute. For more details on how to embed debugger visualizers
please refer to the `#[debugger_visualizer]` attribute in [the unstable book](https://doc.rust-lang.org/unstable-book/language-features/debugger-visualizer.html).
## DWARF and `rustc` ## DWARF and `rustc`
[DWARF] is the standard way compilers generate debugging information that debuggers read. [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.
[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 [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
[https://github.com/rust-lang/lldb]: https://github.com/rust-lang/lldb [https://github.com/rust-lang/lldb]: https://github.com/rust-lang/lldb
[https://github.com/rust-lang/llvm-project]: https://github.com/rust-lang/llvm-project [https://github.com/rust-lang/llvm-project]: https://github.com/rust-lang/llvm-project
[PDB]: https://llvm.org/docs/PDB/index.html
[symbol records]: https://llvm.org/docs/PDB/CodeViewSymbols.html
[type records]: https://llvm.org/docs/PDB/CodeViewTypes.html
[Windows Debugging Tools]: https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/