diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-14 09:37:51 +0200 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-15 13:59:17 +0200 |
| commit | 3d3aff0da9ef2af703a81097b9ca73de9b89adae (patch) | |
| tree | f280c510738d150a9797b52eb95ce86d6cf5c956 /lib/std/debug.zig | |
| parent | f21a78b5a31b13d5b6bb84c23c4a35e64402d0e0 (diff) | |
| download | zig-3d3aff0da9ef2af703a81097b9ca73de9b89adae.tar.gz zig-3d3aff0da9ef2af703a81097b9ca73de9b89adae.zip | |
std.debug: flush SPARC register windows from a new window
flushw and ta 3 flush all windows *except* the current one. So we need to do
this in a new register window to get all of the ones we care about.
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 7ac6c45903..3f694bec1c 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -807,14 +807,7 @@ const StackIterator = union(enum) { /// `@frameAddress` and `cpu_context.Native.current` as the caller's stack frame and /// our own are one and the same. inline fn init(opt_context_ptr: ?CpuContextPtr) error{CannotUnwindFromContext}!StackIterator { - if (builtin.cpu.arch.isSPARC()) { - // Flush all the register windows on stack. - if (builtin.cpu.has(.sparc, .v9)) { - asm volatile ("flushw" ::: .{ .memory = true }); - } else { - asm volatile ("ta 3" ::: .{ .memory = true }); // ST_FLUSH_WINDOWS - } - } + flushSparcWindows(); if (opt_context_ptr) |context_ptr| { if (SelfInfo == void or !SelfInfo.can_unwind) return error.CannotUnwindFromContext; // Use `di_first` here so we report the PC in the context before unwinding any further. @@ -842,6 +835,15 @@ const StackIterator = union(enum) { } } + noinline fn flushSparcWindows() void { + // Flush all register windows except the current one (hence `noinline`). This ensures that + // we actually see meaningful data on the stack when we walk the frame chain. + if (comptime builtin.target.cpu.has(.sparc, .v9)) + asm volatile ("flushw" ::: .{ .memory = true }) + else + asm volatile ("ta 3" ::: .{ .memory = true }); // ST_FLUSH_WINDOWS + } + const FpUsability = enum { /// FP unwinding is impractical on this target. For example, due to its very silly ABI /// design decisions, it's not possible to do generic FP unwinding on MIPS without a |
