authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-04 04:10:00+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-05 07:18:50+02:00
loge6e4792a585d4fb462749d78fa73d1403c97caf0
treee943d5eb8cd5e8e50bcae3c5534acb367f3559a3
parent30f5258fe60cd5209fdfb44bd060f36435cb47b0

std.debug: completely disable FP-based unwinding on mips


1 files changed, 20 insertions(+), 1 deletions(-)

lib/std/debug.zig+20-1
...@@ -855,6 +855,18 @@ const StackIterator = union(enum) {...@@ -855,6 +855,18 @@ const StackIterator = union(enum) {
855 }855 }
856 }856 }
857857
858 /// Some architectures make FP unwinding too impractical. For example, due to its very silly ABI
859 /// design decisions, it's not possible to do generic FP unwinding on MIPS; we would need to do
860 /// a complicated code scanning algorithm instead. At that point, we may as well just use DWARF.
861 const fp_unwind_is_impossible = switch (builtin.cpu.arch) {
862 .mips,
863 .mipsel,
864 .mips64,
865 .mips64el,
866 => true,
867 else => false,
868 };
869
858 /// <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers>870 /// <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers>
859 const fp_unwind_is_safe = builtin.cpu.arch == .aarch64 and builtin.os.tag.isDarwin();871 const fp_unwind_is_safe = builtin.cpu.arch == .aarch64 and builtin.os.tag.isDarwin();
860872
...@@ -879,7 +891,14 @@ const StackIterator = union(enum) {...@@ -879,7 +891,14 @@ const StackIterator = union(enum) {
879 // immediately regardless of anything. But FPs could also be omitted from a different891 // immediately regardless of anything. But FPs could also be omitted from a different
880 // linked object, so it's not guaranteed to be safe, unless the target specifically892 // linked object, so it's not guaranteed to be safe, unless the target specifically
881 // requires it.893 // requires it.
882 .fp => abi_requires_backchain or (!builtin.omit_frame_pointer and (fp_unwind_is_safe or allow_unsafe)),894 .fp => s: {
895 if (fp_unwind_is_impossible) break :s false;
896 if (abi_requires_backchain) break :s true;
897 if (builtin.omit_frame_pointer) break :s false;
898 if (fp_unwind_is_safe) break :s true;
899 if (allow_unsafe) break :s true;
900 break :s false;
901 },
883 };902 };
884 }903 }
885904