authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-14 09:52:10+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-15 13:59:17+02:00
log912fed338019487ec025ecbe3cd27134d75fe6e4
tree226f6e8a89b28dd99f6b1b77aa6e9b4ef7838d60
parent6de2d61a0cbcf535b455770b4d7397d580eac6c6
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.debug: use the SP as the initial FP on SPARC

The FP would point to the register save area for the previous frame, while the SP points to the register save area for the current frame. So use the latter.

1 files changed, 13 insertions(+), 2 deletions(-)

lib/std/debug.zig+13-2
......@@ -825,8 +825,19 @@ const StackIterator = union(enum) {
825825 // in our caller's frame and above.
826826 return .{ .di = .init(&.current()) };
827827 }
828 flushSparcWindows();
829 return .{ .fp = @frameAddress() };
828 return .{
829 // On SPARC, the frame pointer will point to the previous frame's save area,
830 // meaning we will read the previous return address and thus miss a frame.
831 // Instead, start at the stack pointer so we get the return address from the
832 // current frame's save area. The addition of the stack bias cannot fail here
833 // since we know we have a valid stack pointer.
834 .fp = if (native_arch.isSPARC()) sp: {
835 flushSparcWindows();
836 break :sp asm (""
837 : [_] "={o6}" (-> usize),
838 ) + stack_bias;
839 } else @frameAddress(),
840 };
830841 }
831842 fn deinit(si: *StackIterator) void {
832843 switch (si.*) {