aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2023-07-11 01:06:41 -0400
committerkcbanner <kcbanner@gmail.com>2023-07-20 22:58:15 -0400
commit9b25bee42c9c86d47ff21580a0ee58e8e14d3989 (patch)
tree1a282aced5207b095f0db5986cf3e76ac4b3c0dc /lib/std/debug.zig
parente5aa2bb2246e79f47c39c281d51cc9b5a6d89d04 (diff)
downloadzig-9b25bee42c9c86d47ff21580a0ee58e8e14d3989.tar.gz
zig-9b25bee42c9c86d47ff21580a0ee58e8e14d3989.zip
debug: fixup have_getcontext
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index e5be444c72..421c6f863e 100644
--- 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;
}
}
}