`std::backtrace::Backtrace`'s short display mode?

Recent digging into how default panic hook and std::backtrace::Backtrace work shows that they behave quite differently in terms of displaying.

Default hook indeed reads its mode from RUST_BACKTRACE (obviously) and prints either full backtrace or short one, between __rust_end_short_backtrace and __rust_end_short_backtrace marker frames.

However, std::backtrace::Backtrace treats short vs full mode quite differently. It simply thinks that "short" mode omits anything before actual capture function (usually Backtrace::capture`), which is just 1-2 insignificant frames.

Question: is there any way to get short-like mode for arbitrary backtrace object on stable? I'm aware of BacktraceFrame, yet they're still experimental :shrug:
Or, maybe such ability (Backtrace::display(&self, BacktraceStyle) -> impl Display + '_) should be even considered as possible RFC?

Thanks

Something like the code here might be helpful. This issue of merging and improving Backtrace is long-standing and I'm not perfectly clear why but it looks like the code I linked is also a attempted fix which hasn't been implemented fully yet but which also is not being tracked in the parent tracking issue.

1 Like

:thinking:
Thanks, this might get me somewhere. ATM there's experimental support for backtrace style, though it still influences only default printer. I guess I'll have to start separate discussion on each of two topics.