Skip to content

Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger#85269

Merged
bors merged 3 commits intorust-lang:masterfrom
dpaoliello:dpaoliello/DebugSymbols
Jul 2, 2021
Merged

Improve debug symbol names to avoid ambiguity and work better with MSVC's debugger#85269
bors merged 3 commits intorust-lang:masterfrom
dpaoliello:dpaoliello/DebugSymbols

Conversation

@dpaoliello
Copy link
Copy Markdown
Contributor

@dpaoliello dpaoliello commented May 13, 2021

There are several cases where names of types and functions in the debug info are either ambiguous, or not helpful, such as including ambiguous placeholders (e.g., {{impl}}, {{closure}} or dyn _') or dropping qualifications (e.g., for dynamic types).

Instead, each debug symbol name should be unique and useful:

  • Include disambiguators for anonymous DefPathDataName (closures and generators), and unify their formatting when used as a path-qualifier vs item being qualified.
  • Qualify the principal trait for dynamic types.
  • If there is no principal trait for a dynamic type, emit all other traits instead.
  • Respect the qualified argument when emitting ref and pointer types.
  • For implementations, emit the disambiguator.
  • Print const generics when emitting generic parameters or arguments.

Additionally, when targeting MSVC, its debugger treats many command arguments as C++ expressions, even when the argument is defined to be a symbol name. As such names in the debug info need to be more C++-like to be parsed correctly:

  • Avoid characters with special meaning (#, [, ", +).
  • Never start a name with < or { as this is treated as an operator.
  • >> is always treated as a right-shift, even when parsing generic arguments (so add a space to avoid this).
  • Emit function declarations using C/C++ style syntax (e.g., leading return type).
  • Emit arrays as a synthetic array$<type, size> type.
  • Include a $ in all synthetic types as this is a legal character for C++, but not Rust (thus we avoid collisions with user types).

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.