| ... | @@ -336,6 +336,13 @@ pub const StackIterator = struct { | ... | @@ -336,6 +336,13 @@ pub const StackIterator = struct { |
| 336 | fp: usize, | 336 | fp: usize, |
| 337 | | 337 | |
| 338 | pub fn init(first_address: ?usize, fp: ?usize) StackIterator { | 338 | pub fn init(first_address: ?usize, fp: ?usize) StackIterator { |
| | 339 | if (builtin.arch == .sparcv9) { |
| | 340 | // Flush all the register windows on stack. |
| | 341 | asm volatile ( |
| | 342 | \\ flushw |
| | 343 | ::: "memory"); |
| | 344 | } |
| | 345 | |
| 339 | return StackIterator{ | 346 | return StackIterator{ |
| 340 | .first_address = first_address, | 347 | .first_address = first_address, |
| 341 | .fp = fp orelse @frameAddress(), | 348 | .fp = fp orelse @frameAddress(), |
| ... | @@ -343,18 +350,18 @@ pub const StackIterator = struct { | ... | @@ -343,18 +350,18 @@ pub const StackIterator = struct { |
| 343 | } | 350 | } |
| 344 | | 351 | |
| 345 | // Offset of the saved BP wrt the frame pointer. | 352 | // Offset of the saved BP wrt the frame pointer. |
| 346 | const fp_offset = if (builtin.arch.isRISCV()) | 353 | const fp_offset = if (comptime builtin.arch.isRISCV()) |
| 347 | // On RISC-V the frame pointer points to the top of the saved register | 354 | // On RISC-V the frame pointer points to the top of the saved register |
| 348 | // area, on pretty much every other architecture it points to the stack | 355 | // area, on pretty much every other architecture it points to the stack |
| 349 | // slot where the previous frame pointer is saved. | 356 | // slot where the previous frame pointer is saved. |
| 350 | 2 * @sizeOf(usize) | 357 | 2 * @sizeOf(usize) |
| 351 | else if (builtin.arch.isSPARC()) | 358 | else if (comptime builtin.arch.isSPARC()) |
| 352 | // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS. | 359 | // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS. |
| 353 | 14 * @sizeOf(usize) | 360 | 14 * @sizeOf(usize) |
| 354 | else | 361 | else |
| 355 | 0; | 362 | 0; |
| 356 | | 363 | |
| 357 | const fp_bias = if (builtin.arch.isSPARC()) | 364 | const fp_bias = if (comptime builtin.arch.isSPARC()) |
| 358 | // On SPARC frame pointers are biased by a constant. | 365 | // On SPARC frame pointers are biased by a constant. |
| 359 | 2047 | 366 | 2047 |
| 360 | else | 367 | else |
| ... | @@ -380,7 +387,7 @@ pub const StackIterator = struct { | ... | @@ -380,7 +387,7 @@ pub const StackIterator = struct { |
| 380 | } | 387 | } |
| 381 | | 388 | |
| 382 | fn next_internal(self: *StackIterator) ?usize { | 389 | fn next_internal(self: *StackIterator) ?usize { |
| 383 | const fp = if (builtin.arch.isSPARC()) | 390 | const fp = if (comptime builtin.arch.isSPARC()) |
| 384 | // On SPARC the offset is positive. (!) | 391 | // On SPARC the offset is positive. (!) |
| 385 | math.add(usize, self.fp, fp_offset) catch return null | 392 | math.add(usize, self.fp, fp_offset) catch return null |
| 386 | else | 393 | else |