diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-14 09:52:10 +0200 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-15 13:59:17 +0200 |
| commit | 912fed338019487ec025ecbe3cd27134d75fe6e4 (patch) | |
| tree | 226f6e8a89b28dd99f6b1b77aa6e9b4ef7838d60 /lib/std/debug.zig | |
| parent | 6de2d61a0cbcf535b455770b4d7397d580eac6c6 (diff) | |
| download | zig-912fed338019487ec025ecbe3cd27134d75fe6e4.tar.gz zig-912fed338019487ec025ecbe3cd27134d75fe6e4.zip | |
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.
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 5c6043c8c3..5e44214753 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -825,8 +825,19 @@ const StackIterator = union(enum) { // in our caller's frame and above. return .{ .di = .init(&.current()) }; } - flushSparcWindows(); - return .{ .fp = @frameAddress() }; + return .{ + // On SPARC, the frame pointer will point to the previous frame's save area, + // meaning we will read the previous return address and thus miss a frame. + // Instead, start at the stack pointer so we get the return address from the + // current frame's save area. The addition of the stack bias cannot fail here + // since we know we have a valid stack pointer. + .fp = if (native_arch.isSPARC()) sp: { + flushSparcWindows(); + break :sp asm ("" + : [_] "={o6}" (-> usize), + ) + stack_bias; + } else @frameAddress(), + }; } fn deinit(si: *StackIterator) void { switch (si.*) { |
