Skip to content

Commit 912fed3

Browse files
committed
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 parent 6de2d61 commit 912fed3

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

lib/std/debug.zig

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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.*) {

0 commit comments

Comments
 (0)