zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 9b25bee42c9c86d47ff21580a0ee58e8e14d3989 (tree)
parent e5aa2bb2246e79f47c39c281d51cc9b5a6d89d04
Author: kcbanner <kcbanner@gmail.com>
Date:   Tue, 11 Jul 2023 01:06:41 -0400

debug: fixup have_getcontext

Diffstat:
Mlib/std/debug.zig | 28++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/lib/std/debug.zig b/lib/std/debug.zig @@ -171,8 +171,10 @@ pub fn relocateContext(context: *ThreadContext) void { pub const have_getcontext = @hasDecl(os.system, "getcontext") and (builtin.os.tag != .linux or switch (builtin.cpu.arch) { - .x86, .x86_64 => true, - else => false, + .x86, + .x86_64, + => true, + else => builtin.link_libc and !builtin.target.isMusl(), }); /// Capture the current context. The register values in the context will reflect the @@ -652,18 +654,16 @@ pub const StackIterator = struct { if (self.unwind_state) |*unwind_state| { if (!unwind_state.failed) { if (unwind_state.dwarf_context.pc == 0) return null; - if (unwind_state.last_error == null) { - if (self.next_unwind()) |return_address| { - return return_address; - } else |err| { - unwind_state.last_error = err; - unwind_state.failed = true; - - // Fall back to fp-based unwinding on the first failure. - // We can't attempt it for other modules later in the - // stack because the full register state won't be unwound. - self.fp = unwind_state.dwarf_context.getFp() catch 0; - } + if (self.next_unwind()) |return_address| { + return return_address; + } else |err| { + unwind_state.last_error = err; + unwind_state.failed = true; + + // Fall back to fp-based unwinding on the first failure. + // We can't attempt it for other modules later in the + // stack because the full register state won't be unwound. + self.fp = unwind_state.dwarf_context.getFp() catch 0; } } }