| ... | @@ -366,8 +366,18 @@ pub const StackIterator = struct { | ... | @@ -366,8 +366,18 @@ pub const StackIterator = struct { |
| 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 |
| 367 | // slot where the previous frame pointer is saved. | 367 | // slot where the previous frame pointer is saved. |
| 368 | 2 * @sizeOf(usize) | 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 | else | 372 | else |
| 370 | 0; | 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 | // Positive offset of the saved PC wrt the frame pointer. | 381 | // Positive offset of the saved PC wrt the frame pointer. |
| 372 | const pc_offset = if (builtin.arch == .powerpc64le) | 382 | const pc_offset = if (builtin.arch == .powerpc64le) |
| 373 | 2 * @sizeOf(usize) | 383 | 2 * @sizeOf(usize) |
| ... | @@ -394,7 +404,7 @@ pub const StackIterator = struct { | ... | @@ -394,7 +404,7 @@ pub const StackIterator = struct { |
| 394 | if (fp == 0 or !mem.isAligned(fp, @alignOf(usize))) | 404 | if (fp == 0 or !mem.isAligned(fp, @alignOf(usize))) |
| 395 | return null; | 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 | // Sanity check: the stack grows down thus all the parent frames must be | 409 | // Sanity check: the stack grows down thus all the parent frames must be |
| 400 | // be at addresses that are greater (or equal) than the previous one. | 410 | // be at addresses that are greater (or equal) than the previous one. |