authorgravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-04-10 22:38:32-07:00
committergravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-04-12 04:01:30-07:00
log9edbf00ddfb3f8316d82e191b7aca281a0939ac0
tree21a58743fb73aac3dc9048811d9262d556a89d75
parentf6a3a0ca723325b2b84e67b1f7ef78a8f69df650

Enables disabled error trace test on Windows


2 files changed, 54 insertions(+), 45 deletions(-)

test/error_traces.zig+49-38
...@@ -452,26 +452,37 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext, os: std.Target....@@ -452,26 +452,37 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext, os: std.Target.
452 },452 },
453 });453 });
454454
455 // TODO: the standard library has a bug in PDB parsing where given an address corresponding455 cases.addCase(.{
456 // to an inline call, the frame we see will be for the *caller*, not the *callee*. As a456 .name = "trace through inline call",
457 // result this test gives bogus results on Windows right now.457 .source =
458 // This is a part of https://codeberg.org/ziglang/zig/issues/30847.458 \\pub fn main() !void {
459 if (os != .windows) {459 \\ try foo();
460 cases.addCase(.{460 \\}
461 .name = "trace through inline call",461 \\inline fn foo() !void {
462 .source =462 \\ try bar();
463 \\pub fn main() !void {463 \\}
464 \\ try foo();464 \\fn bar() !void {
465 \\}465 \\ return error.ThisIsSoSad;
466 \\inline fn foo() !void {466 \\}
467 \\ try bar();467 ,
468 \\}468 .expect_error = "ThisIsSoSad",
469 \\fn bar() !void {469 .expect_trace =
470 switch (os) {
471 // LLVM doesn't emit column info in the binary annotations for inlinee callees in PDBs,
472 // so our expected result is slightly different for Windows than on other operating
473 // systems.
474 .windows =>
475 \\source.zig:8:5: [address] in bar
470 \\ return error.ThisIsSoSad;476 \\ return error.ThisIsSoSad;
471 \\}477 \\ ^
478 \\source.zig:5: [address] in foo
479 \\ try bar();
480 \\
481 \\source.zig:2:5: [address] in main
482 \\ try foo();
483 \\ ^
472 ,484 ,
473 .expect_error = "ThisIsSoSad",485 else =>
474 .expect_trace =
475 \\source.zig:8:5: [address] in bar486 \\source.zig:8:5: [address] in bar
476 \\ return error.ThisIsSoSad;487 \\ return error.ThisIsSoSad;
477 \\ ^488 \\ ^
...@@ -482,24 +493,24 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext, os: std.Target....@@ -482,24 +493,24 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext, os: std.Target.
482 \\ try foo();493 \\ try foo();
483 \\ ^494 \\ ^
484 ,495 ,
485 .disable_trace_optimized = &.{496 },
486 .{ .x86_64, .freebsd },497 .disable_trace_optimized = &.{
487 .{ .x86_64, .netbsd },498 .{ .x86_64, .freebsd },
488 .{ .x86_64, .linux },499 .{ .x86_64, .netbsd },
489 .{ .x86, .linux },500 .{ .x86_64, .linux },
490 .{ .aarch64, .freebsd },501 .{ .x86, .linux },
491 .{ .aarch64, .netbsd },502 .{ .aarch64, .freebsd },
492 .{ .aarch64, .linux },503 .{ .aarch64, .netbsd },
493 .{ .loongarch64, .linux },504 .{ .aarch64, .linux },
494 .{ .powerpc64le, .linux },505 .{ .loongarch64, .linux },
495 .{ .riscv64, .linux },506 .{ .powerpc64le, .linux },
496 .{ .s390x, .linux },507 .{ .riscv64, .linux },
497 .{ .x86_64, .openbsd },508 .{ .s390x, .linux },
498 .{ .x86_64, .windows },509 .{ .x86_64, .openbsd },
499 .{ .x86, .windows },510 .{ .x86_64, .windows },
500 .{ .x86_64, .macos },511 .{ .x86, .windows },
501 .{ .aarch64, .macos },512 .{ .x86_64, .macos },
502 },513 .{ .aarch64, .macos },
503 });514 },
504 }515 });
505}516}
test/stack_traces.zig+5-7
...@@ -238,9 +238,8 @@ pub fn addCases(cases: *@import("tests.zig").StackTracesContext, os: std.Target....@@ -238,9 +238,8 @@ pub fn addCases(cases: *@import("tests.zig").StackTracesContext, os: std.Target.
238 .unwind = .any,238 .unwind = .any,
239 .expect_panic = true,239 .expect_panic = true,
240 .expect = switch (os) {240 .expect = switch (os) {
241 // We use the information present in PDBs to resolve inlines when dumping stack traces241 // LLVM doesn't emit column info in the binary annotations for inlinee callees in PDBs,
242 // on Windows. Column numbers are missing as LLVM doesn't emit column info in the PDBs242 // so the first location has only a row.
243 // for inline functions.
244 .windows =>243 .windows =>
245 \\panic: oh no244 \\panic: oh no
246 \\source.zig:5: [address] in foo245 \\source.zig:5: [address] in foo
...@@ -251,7 +250,8 @@ pub fn addCases(cases: *@import("tests.zig").StackTracesContext, os: std.Target....@@ -251,7 +250,8 @@ pub fn addCases(cases: *@import("tests.zig").StackTracesContext, os: std.Target.
251 \\ ^250 \\ ^
252 \\251 \\
253 ,252 ,
254 // We don't yet resolve inlines on other platforms.253 // On all other platforms, we resolve the innermost inline callee but we don't yet
254 // resolve the inline callers.
255 else =>255 else =>
256 \\panic: oh no256 \\panic: oh no
257 \\source.zig:5:5: [address] in foo257 \\source.zig:5:5: [address] in foo
...@@ -294,9 +294,8 @@ pub fn addCases(cases: *@import("tests.zig").StackTracesContext, os: std.Target....@@ -294,9 +294,8 @@ pub fn addCases(cases: *@import("tests.zig").StackTracesContext, os: std.Target.
294 ,294 ,
295 .unwind = .any,295 .unwind = .any,
296 .expect_panic = true,296 .expect_panic = true,
297 // This switch serves a similar purpose as in "inline panic".
297 .expect = switch (os) {298 .expect = switch (os) {
298 // Similarly to "inline panic", we can resolve inlines from PDBs but LLVM doesn't emit
299 // column info for them.
300 .windows =>299 .windows =>
301 \\panic: oh no300 \\panic: oh no
302 \\source.zig:11: [address] in baz301 \\source.zig:11: [address] in baz
...@@ -313,7 +312,6 @@ pub fn addCases(cases: *@import("tests.zig").StackTracesContext, os: std.Target....@@ -313,7 +312,6 @@ pub fn addCases(cases: *@import("tests.zig").StackTracesContext, os: std.Target.
313 \\ ^312 \\ ^
314 \\313 \\
315 ,314 ,
316 // Similarly to "inline panic", we don't yet resolve inlines on other platforms.
317 else =>315 else =>
318 \\panic: oh no316 \\panic: oh no
319 \\source.zig:11:5: [address] in baz317 \\source.zig:11:5: [address] in baz