| ... | @@ -360,7 +360,7 @@ pub const StackIterator = struct { | ... | @@ -360,7 +360,7 @@ pub const StackIterator = struct { |
| 360 | }; | 360 | }; |
| 361 | } | 361 | } |
| 362 | | 362 | |
| 363 | // Negative offset of the saved BP wrt the frame pointer. | 363 | // Offset of the saved BP wrt the frame pointer. |
| 364 | const fp_offset = if (builtin.arch.isRISCV()) | 364 | const fp_offset = if (builtin.arch.isRISCV()) |
| 365 | // On RISC-V the frame pointer points to the top of the saved register | 365 | // On RISC-V the frame pointer points to the top of the saved register |
| 366 | // area, on pretty much every other architecture it points to the stack | 366 | // area, on pretty much every other architecture it points to the stack |
| ... | @@ -398,7 +398,11 @@ pub const StackIterator = struct { | ... | @@ -398,7 +398,11 @@ pub const StackIterator = struct { |
| 398 | } | 398 | } |
| 399 | | 399 | |
| 400 | fn next_internal(self: *StackIterator) ?usize { | 400 | 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; |
| 402 | | 406 | |
| 403 | // Sanity check. | 407 | // Sanity check. |
| 404 | if (fp == 0 or !mem.isAligned(fp, @alignOf(usize))) | 408 | if (fp == 0 or !mem.isAligned(fp, @alignOf(usize))) |