update crash report to the new panic interface

This commit is contained in:
Andrew Kelley 2024-09-26 20:25:09 -07:00
parent 37d1da5bed
commit 5b1a9fbb45
2 changed files with 14 additions and 3 deletions

View File

@ -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 {

View File

@ -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 {