| ... | ... | @@ -366,8 +366,18 @@ pub const StackIterator = struct { |
| 366 | 366 | // area, on pretty much every other architecture it points to the stack |
| 367 | 367 | // slot where the previous frame pointer is saved. |
| 368 | 368 | 2 * @sizeOf(usize) |
| 369 | else if (builtin.arch.isSPARC()) |
| 370 | // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS. |
| 371 | 14 * @sizeOf(usize) |
| 369 | 372 | else |
| 370 | 373 | 0; |
| 374 | |
| 375 | const fp_bias = if (builtin.arch.isSPARC()) |
| 376 | // On SPARC frame pointers are biased by a constant. |
| 377 | 2047 |
| 378 | else |
| 379 | 0; |
| 380 | |
| 371 | 381 | // Positive offset of the saved PC wrt the frame pointer. |
| 372 | 382 | const pc_offset = if (builtin.arch == .powerpc64le) |
| 373 | 383 | 2 * @sizeOf(usize) |
| ... | ... | @@ -394,7 +404,7 @@ pub const StackIterator = struct { |
| 394 | 404 | if (fp == 0 or !mem.isAligned(fp, @alignOf(usize))) |
| 395 | 405 | return null; |
| 396 | 406 | |
| 397 | | const new_fp = @intToPtr(*const usize, fp).*; |
| 407 | const new_fp = math.add(usize, @intToPtr(*const usize, fp).*, fp_bias) catch return null; |
| 398 | 408 | |
| 399 | 409 | // Sanity check: the stack grows down thus all the parent frames must be |
| 400 | 410 | // be at addresses that are greater (or equal) than the previous one. |