| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | #target=x86_64-linux-selfhosted |
| 2 | #target=x86_64-linux-cbe |
| 3 | #target=x86_64-windows-cbe |
| 4 | #update=initial version |
| 5 | #file=main.zig |
| 6 | pub fn main() !u8 { |
| 7 | var a: u8 = undefined; |
| 8 | a = 255; |
| 9 | _ = a + 1; |
| 10 | return 1; |
| 11 | } |
| 12 | pub const Panic = struct { |
| 13 | pub const call = myPanic; |
| 14 | pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch; |
| 15 | pub const unwrapError = std.debug.FormattedPanic.unwrapError; |
| 16 | pub const outOfBounds = std.debug.FormattedPanic.outOfBounds; |
| 17 | pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd; |
| 18 | pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField; |
| 19 | pub const messages = std.debug.FormattedPanic.messages; |
| 20 | }; |
| 21 | fn myPanic(msg: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn { |
| 22 | std.io.getStdOut().writer().print("panic message: {s}\n", .{msg}) catch {}; |
| 23 | std.process.exit(0); |
| 24 | } |
| 25 | const std = @import("std"); |
| 26 | #expect_stdout="panic message: integer overflow\n" |
| 27 | |
| 28 | #update=change the panic handler body |
| 29 | #file=main.zig |
| 30 | pub fn main() !u8 { |
| 31 | var a: u8 = undefined; |
| 32 | a = 255; |
| 33 | _ = a + 1; |
| 34 | return 1; |
| 35 | } |
| 36 | pub const Panic = struct { |
| 37 | pub const call = myPanic; |
| 38 | pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch; |
| 39 | pub const unwrapError = std.debug.FormattedPanic.unwrapError; |
| 40 | pub const outOfBounds = std.debug.FormattedPanic.outOfBounds; |
| 41 | pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd; |
| 42 | pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField; |
| 43 | pub const messages = std.debug.FormattedPanic.messages; |
| 44 | }; |
| 45 | fn myPanic(msg: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn { |
| 46 | std.io.getStdOut().writer().print("new panic message: {s}\n", .{msg}) catch {}; |
| 47 | std.process.exit(0); |
| 48 | } |
| 49 | const std = @import("std"); |
| 50 | #expect_stdout="new panic message: integer overflow\n" |
| 51 | |
| 52 | #update=change the panic handler function value |
| 53 | #file=main.zig |
| 54 | pub fn main() !u8 { |
| 55 | var a: u8 = undefined; |
| 56 | a = 255; |
| 57 | _ = a + 1; |
| 58 | return 1; |
| 59 | } |
| 60 | pub const Panic = struct { |
| 61 | pub const call = myPanicNew; |
| 62 | pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch; |
| 63 | pub const unwrapError = std.debug.FormattedPanic.unwrapError; |
| 64 | pub const outOfBounds = std.debug.FormattedPanic.outOfBounds; |
| 65 | pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd; |
| 66 | pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField; |
| 67 | pub const messages = std.debug.FormattedPanic.messages; |
| 68 | }; |
| 69 | fn myPanicNew(msg: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn { |
| 70 | std.io.getStdOut().writer().print("third panic message: {s}\n", .{msg}) catch {}; |
| 71 | std.process.exit(0); |
| 72 | } |
| 73 | const std = @import("std"); |
| 74 | #expect_stdout="third panic message: integer overflow\n" |