authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2021-02-05 00:28:07+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2021-02-05 00:28:07+07:00
log448a28325c7517e6cd62ba7932a4b6c836250757
tree9454b6a4e89007fdc67a75a0d1e8baf8dc4af7b7
parentd23dfdeab9358f0f026990e4d0f1da0ddaa6b177

Fix previous %fp calculation


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

lib/std/debug.zig+6-2
......@@ -360,7 +360,7 @@ pub const StackIterator = struct {
360360 };
361361 }
362362
363 // Negative offset of the saved BP wrt the frame pointer.
363 // Offset of the saved BP wrt the frame pointer.
364364 const fp_offset = if (builtin.arch.isRISCV())
365365 // On RISC-V the frame pointer points to the top of the saved register
366366 // area, on pretty much every other architecture it points to the stack
......@@ -398,7 +398,11 @@ pub const StackIterator = struct {
398398 }
399399
400400 fn next_internal(self: *StackIterator) ?usize {
401 const fp = math.sub(usize, self.fp, fp_offset) catch return null;
401 const fp = if (builtin.arch.isSPARC())
402 // On SPARC the offset is positive. (!)
403 math.add(usize, self.fp, fp_offset) catch return null
404 else
405 math.sub(usize, self.fp, fp_offset) catch return null;
402406
403407 // Sanity check.
404408 if (fp == 0 or !mem.isAligned(fp, @alignOf(usize)))