Repository: rust
Issue: Tracking Issue for short backtraces in the default panic hook
Labels: A-runtime,A-debuginfo,T-compiler,C-tracking-issue,T-libs,A-backtrace

This is a tracking issue for short backtraces in the default panic hook (https://github.com/rust-lang/compiler-team/issues/818). See [previous Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/233931-t-compiler.2Fmajor-changes/topic/Use.20debuginfo.20for.20short.20backtrace.20printing.20compiler-tea.2E.2E.2E).

### About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however *not* meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

### Steps

#### Compile-time
- [ ] Parse, validate, and emit the new `#[rustc_{skip,start,end}_short_backtrace]` attributes in rustc itself (https://github.com/rust-lang/rust/pull/134831). Currently blocked on everything else.
- [ ] Extend LLVM to emit the appropriate debuginfo (https://github.com/llvm/llvm-project/pull/123683)
  - [ ] Waiting on [pre-RFC](https://discourse.llvm.org/t/adding-short-backtrace-debuginfo/84187)
- [ ] Extend rustc_codegen_cranelift to emit the appropriate debuginfo (https://github.com/rust-lang/rust/pull/134831). Blocked.
- [ ] Extend rustc_codegen_gcc to emit the appropriate debuginfo. Waiting on me or Antoyo to implement it.

#### Runtime

- [ ] Extend either addr2line or gimli to give backtrace-rs a way to find the appropriate debuginfo (https://github.com/gimli-rs/gimli/pull/756). Waiting on me to rework the API in response to review comments.
- [ ] Update backtrace-rs to pass the debuginfo through to libstd (https://github.com/rust-lang/backtrace-rs/pull/693). Waiting on the gimli PR and for me to have time to debug this on macOS.
- [ ] Update the default panic hook to use the debuginfo (https://github.com/rust-lang/rust/pull/134831). Blocked on everything else.

[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs
[nightly-style-procedure]: https://github.com/rust-lang/style-team/blob/main/nightly-style-procedure.md 
[Style Guide]: https://github.com/rust-lang/rust/tree/master/src/doc/style-guide

### Unresolved Questions

- How should we represent the debuginfo at runtime? The current three-state enum doesn't allow both marking a frame as the end of a push/pop pair while also omitting it in the backtrace. **NOTE: please leave comments about this on [LLVM discourse](https://discourse.llvm.org/t/adding-short-backtrace-debuginfo/84187/7), not on this issue.**
- How can we extend this to PDB? Right now it only works for DWARF. Possibly we can [use `llvm.codeview.annotation`](https://rust-lang.zulipchat.com/#narrow/stream/317568-t-compiler.2Fwg-debugging/topic/extend.20PDB.3F)?

### Implementation history

See above.

@rustbot label T-compiler T-libs A-runtime A-backtrace A-debuginfo