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/Dwarf/abi.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/Dwarf/abi.zig')
| -rw-r--r-- | lib/std/debug/Dwarf/abi.zig | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/std/debug/Dwarf/abi.zig b/lib/std/debug/Dwarf/abi.zig index f153a10ba4..b2c4cb9536 100644 --- a/lib/std/debug/Dwarf/abi.zig +++ b/lib/std/debug/Dwarf/abi.zig @@ -5,6 +5,31 @@ const mem = std.mem; const posix = std.posix; const Arch = std.Target.Cpu.Arch; +/// Tells whether unwinding for this target is supported by the Dwarf standard. +/// +/// See also `std.debug.SelfInfo.supportsUnwinding` which tells whether the Zig +/// standard library has a working implementation of unwinding for this target. +pub fn supportsUnwinding(target: std.Target) bool { + return switch (target.cpu.arch) { + .amdgcn, + .nvptx, + .nvptx64, + .spirv, + .spirv32, + .spirv64, + .spu_2, + => false, + + // Enabling this causes relocation errors such as: + // error: invalid relocation type R_RISCV_SUB32 at offset 0x20 + .riscv64, .riscv32 => false, + + // Conservative guess. Feel free to update this logic with any targets + // that are known to not support Dwarf unwinding. + else => true, + }; +} + /// Returns `null` for CPU architectures without an instruction pointer register. pub fn ipRegNum(arch: Arch) ?u8 { return switch (arch) { |
