authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-02-02 11:24:42+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-03 20:19:15+01:00
log2fce12b42a3662e018ad30ca874f4e7cfcdf33d2
treebd96d9fed89b3971dfecb811951a24136e2bbb6d
parente5e4602b181360d20bbba56e9f15734c929d2a2f

test: improve logic for generating stack trace test combinations


1 files changed, 43 insertions(+), 7 deletions(-)

test/src/StackTrace.zig+43-7
...@@ -55,7 +55,7 @@ fn addCaseTarget(...@@ -55,7 +55,7 @@ fn addCaseTarget(
55 };55 };
56 };56 };
57 const both_pie = switch (target.result.os.tag) {57 const both_pie = switch (target.result.os.tag) {
58 .fuchsia, .openbsd => false,58 .fuchsia => false,
59 else => true,59 else => true,
60 };60 };
61 const both_libc = switch (target.result.os.tag) {61 const both_libc = switch (target.result.os.tag) {
...@@ -63,8 +63,30 @@ fn addCaseTarget(...@@ -63,8 +63,30 @@ fn addCaseTarget(
63 else => !target.result.requiresLibC(),63 else => !target.result.requiresLibC(),
64 };64 };
6565
66 // On aarch64-macos, FP unwinding is blessed by Apple to always be reliable, and std.debug knows this.66 // See `std.debug.StackIterator.fp_usability` logic.
67 const fp_unwind_is_safe = target.result.cpu.arch == .aarch64 and target.result.os.tag.isDarwin();67 const fp_usability: enum { useless, unsafe, safe, ideal } = switch (target.result.cpu.arch) {
68 .alpha,
69 .csky,
70 .microblaze,
71 .microblazeel,
72 .mips,
73 .mipsel,
74 .mips64,
75 .mips64el,
76 .sh,
77 .sheb,
78 => .useless,
79 .hexagon,
80 .powerpc,
81 .powerpcle,
82 .powerpc64,
83 .powerpc64le,
84 .sparc,
85 .sparc64,
86 => .ideal,
87 .aarch64 => if (target.result.os.tag.isDarwin()) .safe else .unsafe,
88 else => .unsafe,
89 };
68 const supports_unwind_tables = switch (target.result.os.tag) {90 const supports_unwind_tables = switch (target.result.os.tag) {
69 // x86-windows just has no way to do stack unwinding other then using frame pointers.91 // x86-windows just has no way to do stack unwinding other then using frame pointers.
70 .windows => target.result.cpu.arch != .x86,92 .windows => target.result.cpu.arch != .x86,
...@@ -86,10 +108,24 @@ fn addCaseTarget(...@@ -86,10 +108,24 @@ fn addCaseTarget(
86 const only_fp: @This() = .{ .tables = false, .fp = true };108 const only_fp: @This() = .{ .tables = false, .fp = true };
87 };109 };
88 const unwind_info_vals: []const UnwindInfo = switch (config.unwind) {110 const unwind_info_vals: []const UnwindInfo = switch (config.unwind) {
89 .none => &.{.none},111 .none => switch (fp_usability) {
90 .any => &.{ .only_tables, .only_fp, .both },112 .useless => &.{ .none, .only_fp },
91 .safe => if (fp_unwind_is_safe) &.{ .only_tables, .only_fp, .both } else &.{ .only_tables, .both },113 .unsafe, .safe => &.{.none},
92 .no_safe => if (fp_unwind_is_safe) &.{.none} else &.{ .none, .only_fp },114 .ideal => &.{},
115 },
116 .any => switch (fp_usability) {
117 .useless => &.{ .only_tables, .both },
118 .unsafe, .safe, .ideal => &.{ .only_tables, .only_fp, .both },
119 },
120 .safe => switch (fp_usability) {
121 .useless, .unsafe => &.{ .only_tables, .both },
122 .safe, .ideal => &.{ .only_tables, .only_fp, .both },
123 },
124 .no_safe => switch (fp_usability) {
125 .useless, .unsafe => &.{ .none, .only_fp },
126 .safe => &.{.none},
127 .ideal => &.{},
128 },
93 };129 };
94130
95 for (use_llvm_vals) |use_llvm| {131 for (use_llvm_vals) |use_llvm| {