Skip to content

Support hiding specific stackframes from backtrace by marking on the original functions. #68336

Description

@crlf0710

Recently #[track_caller] usages has landed on nightly channel, which is really great! However i want to request a little more here. Currently

fn main() {
    panic!("foo");
}

output is:

thread 'main' panicked at 'foo', src/main.rs:2:5
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1057
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:472
  11: std::panicking::begin_panic
             at /rustc/689fca01c5a1eac2d240bf08aa728171a28f2285/src/libstd/panicking.rs:399
  12: playground::main
             at src/main.rs:2
  13: std::rt::lang_start::{{closure}}
             at /rustc/689fca01c5a1eac2d240bf08aa728171a28f2285/src/libstd/rt.rs:67
  14: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  15: std::panicking::try::do_call
             at src/libstd/panicking.rs:305
  16: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  17: std::panicking::try
             at src/libstd/panicking.rs:281
  18: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  19: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  20: std::rt::lang_start
             at /rustc/689fca01c5a1eac2d240bf08aa728171a28f2285/src/libstd/rt.rs:67
  21: main
  22: __libc_start_main

However, of the 22 stack frames, only 3 or 4 is meaningful to user. It would be great if rest of the functions can be marked with a special attribute, and maybe marked somehow in the mangled symbol, then be excluded from the default display of backtrace.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-backtraceArea: BacktracesC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions