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(
5555 };
5656 };
5757 const both_pie = switch (target.result.os.tag) {
58 .fuchsia, .openbsd => false,
58 .fuchsia => false,
5959 else => true,
6060 };
6161 const both_libc = switch (target.result.os.tag) {
......@@ -63,8 +63,30 @@ fn addCaseTarget(
6363 else => !target.result.requiresLibC(),
6464 };
6565
66 // On aarch64-macos, FP unwinding is blessed by Apple to always be reliable, and std.debug knows this.
67 const fp_unwind_is_safe = target.result.cpu.arch == .aarch64 and target.result.os.tag.isDarwin();
66 // See `std.debug.StackIterator.fp_usability` logic.
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 };
6890 const supports_unwind_tables = switch (target.result.os.tag) {
6991 // x86-windows just has no way to do stack unwinding other then using frame pointers.
7092 .windows => target.result.cpu.arch != .x86,
......@@ -86,10 +108,24 @@ fn addCaseTarget(
86108 const only_fp: @This() = .{ .tables = false, .fp = true };
87109 };
88110 const unwind_info_vals: []const UnwindInfo = switch (config.unwind) {
89 .none => &.{.none},
90 .any => &.{ .only_tables, .only_fp, .both },
91 .safe => if (fp_unwind_is_safe) &.{ .only_tables, .only_fp, .both } else &.{ .only_tables, .both },
92 .no_safe => if (fp_unwind_is_safe) &.{.none} else &.{ .none, .only_fp },
111 .none => switch (fp_usability) {
112 .useless => &.{ .none, .only_fp },
113 .unsafe, .safe => &.{.none},
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 },
93129 };
94130
95131 for (use_llvm_vals) |use_llvm| {