Skip to content

"Debugging the compiler" #11

Closed
@nikomatsakis

Description

@nikomatsakis

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 and config.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 use RUST_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
  • Conventions for logs ("loosely followed")
    • Use {:?} most of the time in debug logs
    • I tend to use debug!("foo(...)") at the start of a function foo and debug!("foo: ...") or logs within that function (- nikomatsakis)
  • Options to try and correlate node-ids and def-ids with the source
    • e.g., --pretty expanded,identified
  • Options to dump the MIR
    • -Zdump-mir and -Zdump-mir-graphviz

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyDifficulty: might be a good place for a beginner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions