You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generate DW_AT_RUST_short_backtrace attributes for DISubprogram nodes
The Rust standard library has two [styles](https://doc.rust-lang.org/stable/std/panic/enum.BacktraceStyle.html) for printing backtraces at runtime:
1. Full backtraces. These work in the obvious way.
2. Short backtraces. These filter out "unimportant" frames that are likely not related to the developer's bug. For example, frames like `__libc_start_main`, `_Unwind_Resume`, and rust runtime internals like `std::rt::lang_start` are filtered out.
Currently, the Rust runtime determines "unimportant" frames by looking directly at un-mangled symbol names of generated functions. This is not extensible, and involves a state machine that requires the frames to be present at runtime; in particular the frames must be marked `noinline`, impeding optimizations.
This extends LLVM to encode short backtrace metadata in DWARF debuginfo. It currently does not attempt to add debuginfo to PDB, which was not designed to be extensible.
See rust-lang/compiler-team#818 for more background.
- Add a new category for Rust DWARF vendor extensions
- Add a new `enum ShortBacktraceAttr { SkipFrame, StartFrame, EndFrame }`. StartFrame and EndFrame correspond to the existing `__rust_start_short_backtrace` and `__rust_end_short_backtrace` symbols. SkipFrame currently has no analogue. Each of these values is mutually exclusive with the others, and generating multiple for the same function is a logical error.
- Update all callsites of `DISubprogram::getImpl` to pass in a `std::optional<ShortBacktraceAttr>`
- Emit `ShortBacktraceAttr` when creating DWARF debuginfo. Note that this also generates debuginfo in more cases than before: When using line-tables-only debuginfo, LLVM attempts to skip functions with 0 lexical scopes. But some shims in the Rust standard library, such as `std::ops::Fn::call`, are shims that never appear in Rust source code but still appear in the backtrace. Generate info for these functions if they have a short backtrace attribute, so that they are correctly skipped in backtraces.
- Parse and serialize the new attribute in .ll files
- Add a regression test
0 commit comments