Closed
Description
This section should talk about the various tips and tricks for debugging the compiler, as well as perhaps some amount of "debug log conventions". It doesn't necessarily have to be a super long section, but here are some of the things I can think of:
- How to use
RUST_LOG
andconfig.toml
first and foremost (overlaps with "How to build the compiler and run what you built" #8) - Some of the handy
-Zflags
:- example:
-Ztreat-err-as-bug
, which causes errors to be reported as bugs. Useful when you are debugging an error that should not be happening because you can useRUST_BACKTRACE=1
then to get a backtrace of where the error was reported; also avoids dumping out more logs than you need. - example:
-Zunpretty=hir-tree
, which will dump out the HIR - example:
-Zverbose
, which dumps out extra - see
-Zhelp
for more
- example:
- Conventions for logs ("loosely followed")
- Use
{:?}
most of the time in debug logs - I tend to use
debug!("foo(...)")
at the start of a functionfoo
anddebug!("foo: ...")
or logs within that function (- nikomatsakis)
- Use
- Options to try and correlate node-ids and def-ids with the source
- e.g.,
--pretty expanded,identified
- e.g.,
- Options to dump the MIR
-
-Zdump-mir
and-Zdump-mir-graphviz
-