authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-26 20:25:09-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-26 20:25:09-07:00
log5b1a9fbb45128fdab615d7af5e93fa037e5d7749
treea7d6570c811d7ae3b7f7ba59380e6c8c72090df7
parent37d1da5beda9857611fd3120c5e9b0d7cbba546e

update crash report to the new panic interface


2 files changed, 14 insertions(+), 3 deletions(-)

src/crash_report.zig+13-1
......@@ -13,11 +13,23 @@ const Sema = @import("Sema.zig");
1313const InternPool = @import("InternPool.zig");
1414const Zir = std.zig.Zir;
1515const Decl = Zcu.Decl;
16const dev = @import("dev.zig");
1617
1718/// To use these crash report diagnostics, publish this panic in your main file
1819/// and add `pub const enable_segfault_handler = false;` to your `std_options`.
1920/// You will also need to call initialize() on startup, preferably as the very first operation in your program.
20pub const panic = if (build_options.enable_debug_extensions) compilerPanic else std.debug.defaultPanic;
21pub const Panic = if (build_options.enable_debug_extensions) struct {
22 pub const call = compilerPanic;
23 pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch;
24 pub const unwrapError = std.debug.FormattedPanic.unwrapError;
25 pub const outOfBounds = std.debug.FormattedPanic.outOfBounds;
26 pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd;
27 pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField;
28 pub const messages = std.debug.FormattedPanic.messages;
29} else if (dev.env == .bootstrap)
30 std.debug.SimplePanic
31else
32 std.debug.FormattedPanic;
2133
2234/// Install signal handlers to identify crashes and report diagnostics.
2335pub fn initialize() void {
src/main.zig+1-2
......@@ -44,8 +44,7 @@ pub const std_options = .{
4444 },
4545};
4646
47// Crash report needs to override the panic handler
48pub const panic = crash_report.panic;
47pub const Panic = crash_report.Panic;
4948
5049var wasi_preopens: fs.wasi.Preopens = undefined;
5150pub fn wasi_cwd() std.os.wasi.fd_t {