backtrace-rs icon indicating copy to clipboard operation
backtrace-rs copied to clipboard

Feature request: Expose dbghelp's `InlineFrameContext` somehow

Open ChrisDenton opened this issue 10 months ago • 0 comments

For https://github.com/rust-lang/rust/pull/135804 I want to make sure the backtrace is always making progress. On most platforms it's enough to check the stack pointer changes. However, on x86 msvc with debuginfo=line-tables-only we also need to check to see if InlineFrameContext changes. Internally we have Frame::inline_context for this. But it's msvc only and not public.

So my idea is to add a public API that looks roughly like this:

/// An opaque struct that can be compared for equality with other stack contexts from the same trace.
#[derive(Clone, Eq, PartialEq)]
struct StackContext { ... };

impl Frame {
    pub fn stack_context(&self) -> Option<StackContext>;
}

On most targets StackContext will simply be a wrapper around the stack pointer. But on i686 msvc it'll be the stack pointer plus InlineFrameContext. Users (in this case std) can call frame.stack_context() to determine if the backtrace is stuck by comparing it to the previous StackContext.

ChrisDenton avatar Jan 22 '25 05:01 ChrisDenton