diff --git a/src/compiler-debugging.md b/src/compiler-debugging.md index ead9b020b..fce579253 100644 --- a/src/compiler-debugging.md +++ b/src/compiler-debugging.md @@ -260,6 +260,24 @@ $ dot -T pdf maybe_init_suffix.dot > maybe_init_suffix.pdf $ firefox maybe_init_suffix.pdf # Or your favorite pdf viewer ``` +## Viewing Spanview output (.html files) +[viewing-spanview-output]: #viewing-spanview-output + +In addition to [graphviz output](#formatting-graphviz-output), MIR debugging +flags include an option to generate a MIR representation called `Spanview` that +uses HTML to highlight code regions in the original source code and display +compiler metadata associated with each region. +[`-Zdump-mir-spanview`](./mir/debugging.md), for example, highlights spans +associated with each MIR `Statement`, `Terminator`, and/or `BasicBlock`. + +These `.html` files use CSS features to dynamically expand spans obscured by +overlapping spans, and native tooltips (based on the HTML `title` attribute) to +reveal the actual MIR elements, as text. + +To view these files, simply use a modern browser, or a CSS-capable HTML preview +feature in a modern IDE. (The default HTML preview pane in *VS Code* is known to +work, for instance. + ## Narrowing (Bisecting) Regressions The [cargo-bisect-rustc][bisect] tool can be used as a quick and easy way to diff --git a/src/mir/debugging.md b/src/mir/debugging.md index 93a79076c..edb68ca72 100644 --- a/src/mir/debugging.md +++ b/src/mir/debugging.md @@ -1,8 +1,16 @@ # MIR Debugging -The `-Zdump-mir` flag can be used to dump a text representation of the MIR. The -`-Zdump-mir-graphviz` flag can be used to dump a `.dot` file that represents -MIR as a control-flow graph. +The `-Zdump-mir` flag can be used to dump a text representation of the MIR. +The following optional flags, used in combination with `-Zdump-mir`, enable +additional output formats, including: + +* `-Zdump-mir-graphviz` - dumps a `.dot` file that represents MIR as a +control-flow graph +* `-Zdump-mir-spanview` - dumps an `.html` file that highlights the source +spans associated with MIR elements (including mouse-over actions to reveal +elements obscured by overlaps, and tooltips to view the MIR statements). +This flag takes an optional value: `statement` (the default), `terminator`, or +`block`, to generate span highlights with different levels of granulatity. `-Zdump-mir=F` is a handy compiler options that will let you view the MIR for each function at each stage of compilation. `-Zdump-mir` takes a **filter** `F`