aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorKoakuma <koachan@protonmail.com>2021-02-05 00:28:07 +0700
committerKoakuma <koachan@protonmail.com>2021-02-05 00:28:07 +0700
commit448a28325c7517e6cd62ba7932a4b6c836250757 (patch)
tree9454b6a4e89007fdc67a75a0d1e8baf8dc4af7b7 /lib/std/debug.zig
parentd23dfdeab9358f0f026990e4d0f1da0ddaa6b177 (diff)
downloadzig-448a28325c7517e6cd62ba7932a4b6c836250757.tar.gz
zig-448a28325c7517e6cd62ba7932a4b6c836250757.zip
Fix previous %fp calculation
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index b887899c7a..9d90dd5c4b 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -360,7 +360,7 @@ pub const StackIterator = struct {
};
}
- // Negative offset of the saved BP wrt the frame pointer.
+ // Offset of the saved BP wrt the frame pointer.
const fp_offset = if (builtin.arch.isRISCV())
// On RISC-V the frame pointer points to the top of the saved register
// area, on pretty much every other architecture it points to the stack
@@ -398,7 +398,11 @@ pub const StackIterator = struct {
}
fn next_internal(self: *StackIterator) ?usize {
- const fp = math.sub(usize, self.fp, fp_offset) catch return null;
+ const fp = if (builtin.arch.isSPARC())
+ // On SPARC the offset is positive. (!)
+ math.add(usize, self.fp, fp_offset) catch return null
+ else
+ math.sub(usize, self.fp, fp_offset) catch return null;
// Sanity check.
if (fp == 0 or !mem.isAligned(fp, @alignOf(usize)))