zig icon indicating copy to clipboard operation
zig copied to clipboard

std.debug: allow fp unwind from context

Open mlugg opened this issue 6 months ago • 2 comments

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

mlugg avatar Nov 08 '25 11:11 mlugg

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 avatar Nov 09 '25 05:11 alexrp

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;
    }

alexrp avatar Nov 10 '25 12:11 alexrp