diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-08-02 12:35:49 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-08-02 14:15:03 -0700 |
| commit | 6d606cc38b4df2b20af9d77367f8ab22bbbea092 (patch) | |
| tree | fd00a5a549afccf68b6b50cb1f693dc4251eb4a9 /lib/std/debug/SelfInfo.zig | |
| parent | 975c185b92a7d470ea705b28f46a8004bdda3c60 (diff) | |
| download | zig-6d606cc38b4df2b20af9d77367f8ab22bbbea092.tar.gz zig-6d606cc38b4df2b20af9d77367f8ab22bbbea092.zip | |
reintroduce std.Dwarf.abi.supportsUnwinding
There are two concepts here: one for whether dwarf supports unwinding on
that target, and another for whether the Zig standard library
implements it yet.
Diffstat (limited to 'lib/std/debug/SelfInfo.zig')
| -rw-r--r-- | lib/std/debug/SelfInfo.zig | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/std/debug/SelfInfo.zig b/lib/std/debug/SelfInfo.zig index b1679a224b..c27f466fb3 100644 --- a/lib/std/debug/SelfInfo.zig +++ b/lib/std/debug/SelfInfo.zig @@ -1982,7 +1982,42 @@ fn spRegNum(reg_context: Dwarf.abi.RegisterContext) u8 { } const ip_reg_num = Dwarf.abi.ipRegNum(native_arch).?; -pub const supports_unwinding = Dwarf.supportsUnwinding(builtin.target); + +/// Tells whether unwinding for the host is implemented. +pub const supports_unwinding = supportsUnwinding(builtin.target); + +comptime { + if (supports_unwinding) assert(Dwarf.abi.supportsUnwinding(builtin.target)); +} + +/// Tells whether unwinding for this target is *implemented* here in the Zig +/// standard library. +/// +/// See also `Dwarf.abi.supportsUnwinding` which tells whether Dwarf supports +/// unwinding on that target *in theory*. +pub fn supportsUnwinding(target: std.Target) bool { + return switch (target.cpu.arch) { + .x86 => switch (target.os.tag) { + .linux, .netbsd, .solaris, .illumos => true, + else => false, + }, + .x86_64 => switch (target.os.tag) { + .linux, .netbsd, .freebsd, .openbsd, .macos, .ios, .solaris, .illumos => true, + else => false, + }, + .arm => switch (target.os.tag) { + .linux => true, + else => false, + }, + .aarch64 => switch (target.os.tag) { + .linux, .netbsd, .freebsd, .macos, .ios => true, + else => false, + }, + // Unwinding is possible on other targets but this implementation does + // not support them...yet! + else => false, + }; +} fn unwindFrameMachODwarf( context: *UnwindContext, |
