From 5b1a9fbb45128fdab615d7af5e93fa037e5d7749 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 26 Sep 2024 20:25:09 -0700 Subject: update crash report to the new panic interface --- src/crash_report.zig | 14 +++++++++++++- src/main.zig | 3 +-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/crash_report.zig b/src/crash_report.zig index 99264c8409..d9f8bac350 100644 --- a/src/crash_report.zig +++ b/src/crash_report.zig @@ -13,11 +13,23 @@ const Sema = @import("Sema.zig"); const InternPool = @import("InternPool.zig"); const Zir = std.zig.Zir; const Decl = Zcu.Decl; +const dev = @import("dev.zig"); /// To use these crash report diagnostics, publish this panic in your main file /// and add `pub const enable_segfault_handler = false;` to your `std_options`. /// You will also need to call initialize() on startup, preferably as the very first operation in your program. -pub const panic = if (build_options.enable_debug_extensions) compilerPanic else std.debug.defaultPanic; +pub const Panic = if (build_options.enable_debug_extensions) struct { + pub const call = compilerPanic; + pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch; + pub const unwrapError = std.debug.FormattedPanic.unwrapError; + pub const outOfBounds = std.debug.FormattedPanic.outOfBounds; + pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd; + pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField; + pub const messages = std.debug.FormattedPanic.messages; +} else if (dev.env == .bootstrap) + std.debug.SimplePanic +else + std.debug.FormattedPanic; /// Install signal handlers to identify crashes and report diagnostics. pub fn initialize() void { diff --git a/src/main.zig b/src/main.zig index b08acf568c..684217c36c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -44,8 +44,7 @@ pub const std_options = .{ }, }; -// Crash report needs to override the panic handler -pub const panic = crash_report.panic; +pub const Panic = crash_report.Panic; var wasi_preopens: fs.wasi.Preopens = undefined; pub fn wasi_cwd() std.os.wasi.fd_t { -- cgit v1.2.3