diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-09-26 20:25:09 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-09-26 20:25:09 -0700 |
| commit | 5b1a9fbb45128fdab615d7af5e93fa037e5d7749 (patch) | |
| tree | a7d6570c811d7ae3b7f7ba59380e6c8c72090df7 /src | |
| parent | 37d1da5beda9857611fd3120c5e9b0d7cbba546e (diff) | |
| download | zig-5b1a9fbb45128fdab615d7af5e93fa037e5d7749.tar.gz zig-5b1a9fbb45128fdab615d7af5e93fa037e5d7749.zip | |
update crash report to the new panic interface
Diffstat (limited to 'src')
| -rw-r--r-- | src/crash_report.zig | 14 | ||||
| -rw-r--r-- | src/main.zig | 3 |
2 files changed, 14 insertions, 3 deletions
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 { |
