Skip to content

Commit b737f79

Browse files
richkadeltshepang
authored andcommitted
Adds documentation to cover spanview output
Documents the feature introduced in #76074.
1 parent 2924b69 commit b737f79

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/compiler-debugging.md

+18
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,24 @@ $ dot -T pdf maybe_init_suffix.dot > maybe_init_suffix.pdf
260260
$ firefox maybe_init_suffix.pdf # Or your favorite pdf viewer
261261
```
262262
263+
## Viewing Spanview output (.html files)
264+
[viewing-spanview-output]: #viewing-spanview-output
265+
266+
In addition to [graphviz output](#formatting-graphviz-output), MIR debugging
267+
flags include an option to generate a MIR representation called `Spanview` that
268+
uses HTML to highlight code regions in the original source code and display
269+
compiler metadata associated with each region.
270+
[`-Zdump-mir-spanview`](./mir/debugging.md), for example, highlights spans
271+
associated with each MIR `Statement`, `Terminator`, and/or `BasicBlock`.
272+
273+
These `.html` files use CSS features to dynamically expand spans obscured by
274+
overlapping spans, and native tooltips (based on the HTML `title` attribute) to
275+
reveal the actual MIR elements, as text.
276+
277+
To view these files, simply use a modern browser, or a CSS-capable HTML preview
278+
feature in a modern IDE. (The default HTML preview pane in *VS Code* is known to
279+
work, for instance.
280+
263281
## Narrowing (Bisecting) Regressions
264282
265283
The [cargo-bisect-rustc][bisect] tool can be used as a quick and easy way to

src/mir/debugging.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# MIR Debugging
22

3-
The `-Zdump-mir` flag can be used to dump a text representation of the MIR. The
4-
`-Zdump-mir-graphviz` flag can be used to dump a `.dot` file that represents
5-
MIR as a control-flow graph.
3+
The `-Zdump-mir` flag can be used to dump a text representation of the MIR.
4+
The following optional flags, used in combination with `-Zdump-mir`, enable
5+
additional output formats, including:
6+
7+
* `-Zdump-mir-graphviz` - dumps a `.dot` file that represents MIR as a
8+
control-flow graph
9+
* `-Zdump-mir-spanview` - dumps an `.html` file that highlights the source
10+
spans associated with MIR elements (including mouse-over actions to reveal
11+
elements obscured by overlaps, and tooltips to view the MIR statements).
12+
This flag takes an optional value: `statement` (the default), `terminator`, or
13+
`block`, to generate span highlights with different levels of granulatity.
614

715
`-Zdump-mir=F` is a handy compiler options that will let you view the MIR for
816
each function at each stage of compilation. `-Zdump-mir` takes a **filter** `F`

0 commit comments

Comments
 (0)