Skip to content

Conversation

@mlugg
Copy link
Member

@mlugg mlugg commented Nov 8, 2025

It's easy to do FP unwinding from a CPU context: you just report the captured ip/pc value first, and then unwind from the captured fp value. All this really needed was a couple of new functions on the std.debug.cpu_context implementations so that we don't need to rely on std.debug.Dwarf to access the captured registers.

Resolves: #25576

It's easy to do FP unwinding from a CPU context: you just report the
captured ip/pc value first, and then unwind from the captured fp value.
All this really needed was a couple of new functions on the
`std.debug.cpu_context` implementations so that we don't need to rely on
`std.debug.Dwarf` to access the captured registers.

Resolves: ziglang#25576
@mlugg mlugg requested a review from alexrp November 8, 2025 11:26
@alexrp
Copy link
Member

alexrp commented Nov 9, 2025

The CI failures are happening because of a mismatch between register size and pointer size for N32 and x32. You can just @truncate the values at the getFp/getPc call sites; after all, the whole point of these ABIs is that pointers are only 32 bits wide.

Alternatively, I guess there's an argument to be made for @intCast since it would be a debugging aid in weird situations where a pointer in a register has somehow gotten wider than 32 bits.

@alexrp
Copy link
Member

alexrp commented Nov 10, 2025

Since it looks like it'll land first, note that #25886 adds std.debug.cpu_context.Kvx which will need getFp/getPc functions:

    pub fn getFp(ctx: *const Kvx) u64 {
        return ctx.r[14];
    }
    pub fn getPc(ctx: *const Kvx) u64 {
        return ctx.pc;
    }

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

std.debug: support FP unwinding from the segfault handler even if !SelfInfo.can_unwind

2 participants