blob: 774b18bbfd2c4e905a64d9084313886dd18e5171 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#target=x86_64-linux-selfhosted
#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#update=initial version
#file=main.zig
pub fn main() !u8 {
var a: u8 = undefined;
a = 255;
_ = a + 1;
return 1;
}
const no_panic = std.debug.no_panic;
pub const panic = struct {
pub const call = myPanic;
pub fn integerOverflow() noreturn {
@panic("integer overflow");
}
pub const sentinelMismatch = no_panic.sentinelMismatch;
pub const unwrapError = no_panic.unwrapError;
pub const outOfBounds = no_panic.outOfBounds;
pub const startGreaterThanEnd = no_panic.startGreaterThanEnd;
pub const inactiveUnionField = no_panic.inactiveUnionField;
pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder;
pub const reachedUnreachable = no_panic.reachedUnreachable;
pub const unwrapNull = no_panic.unwrapNull;
pub const castToNull = no_panic.castToNull;
pub const incorrectAlignment = no_panic.incorrectAlignment;
pub const invalidErrorCode = no_panic.invalidErrorCode;
pub const integerOutOfBounds = no_panic.integerOutOfBounds;
pub const shlOverflow = no_panic.shlOverflow;
pub const shrOverflow = no_panic.shrOverflow;
pub const divideByZero = no_panic.divideByZero;
pub const exactDivisionRemainder = no_panic.exactDivisionRemainder;
pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds;
pub const corruptSwitch = no_panic.corruptSwitch;
pub const shiftRhsTooBig = no_panic.shiftRhsTooBig;
pub const invalidEnumValue = no_panic.invalidEnumValue;
pub const forLenMismatch = no_panic.forLenMismatch;
pub const copyLenMismatch = no_panic.copyLenMismatch;
pub const memcpyAlias = no_panic.memcpyAlias;
pub const noreturnReturned = no_panic.noreturnReturned;
};
fn myPanic(msg: []const u8, _: ?usize) noreturn {
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
stdout_writer.interface.print("panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
#expect_stdout="panic message: integer overflow\n"
#update=change the panic handler body
#file=main.zig
pub fn main() !u8 {
var a: u8 = undefined;
a = 255;
_ = a + 1;
return 1;
}
const no_panic = std.debug.no_panic;
pub const panic = struct {
pub const call = myPanic;
pub fn integerOverflow() noreturn {
@panic("integer overflow");
}
pub const sentinelMismatch = no_panic.sentinelMismatch;
pub const unwrapError = no_panic.unwrapError;
pub const outOfBounds = no_panic.outOfBounds;
pub const startGreaterThanEnd = no_panic.startGreaterThanEnd;
pub const inactiveUnionField = no_panic.inactiveUnionField;
pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder;
pub const reachedUnreachable = no_panic.reachedUnreachable;
pub const unwrapNull = no_panic.unwrapNull;
pub const castToNull = no_panic.castToNull;
pub const incorrectAlignment = no_panic.incorrectAlignment;
pub const invalidErrorCode = no_panic.invalidErrorCode;
pub const integerOutOfBounds = no_panic.integerOutOfBounds;
pub const shlOverflow = no_panic.shlOverflow;
pub const shrOverflow = no_panic.shrOverflow;
pub const divideByZero = no_panic.divideByZero;
pub const exactDivisionRemainder = no_panic.exactDivisionRemainder;
pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds;
pub const corruptSwitch = no_panic.corruptSwitch;
pub const shiftRhsTooBig = no_panic.shiftRhsTooBig;
pub const invalidEnumValue = no_panic.invalidEnumValue;
pub const forLenMismatch = no_panic.forLenMismatch;
pub const copyLenMismatch = no_panic.copyLenMismatch;
pub const memcpyAlias = no_panic.memcpyAlias;
pub const noreturnReturned = no_panic.noreturnReturned;
};
fn myPanic(msg: []const u8, _: ?usize) noreturn {
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
stdout_writer.interface.print("new panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
#expect_stdout="new panic message: integer overflow\n"
#update=change the panic handler function value
#file=main.zig
pub fn main() !u8 {
var a: u8 = undefined;
a = 255;
_ = a + 1;
return 1;
}
const no_panic = std.debug.no_panic;
pub const panic = struct {
pub const call = myPanicNew;
pub fn integerOverflow() noreturn {
@panic("integer overflow");
}
pub const sentinelMismatch = std.debug.no_panic.sentinelMismatch;
pub const unwrapError = std.debug.no_panic.unwrapError;
pub const outOfBounds = std.debug.no_panic.outOfBounds;
pub const startGreaterThanEnd = std.debug.no_panic.startGreaterThanEnd;
pub const inactiveUnionField = std.debug.no_panic.inactiveUnionField;
pub const sliceCastLenRemainder = no_panic.sliceCastLenRemainder;
pub const reachedUnreachable = no_panic.reachedUnreachable;
pub const unwrapNull = no_panic.unwrapNull;
pub const castToNull = no_panic.castToNull;
pub const incorrectAlignment = no_panic.incorrectAlignment;
pub const invalidErrorCode = no_panic.invalidErrorCode;
pub const integerOutOfBounds = no_panic.integerOutOfBounds;
pub const shlOverflow = no_panic.shlOverflow;
pub const shrOverflow = no_panic.shrOverflow;
pub const divideByZero = no_panic.divideByZero;
pub const exactDivisionRemainder = no_panic.exactDivisionRemainder;
pub const integerPartOutOfBounds = no_panic.integerPartOutOfBounds;
pub const corruptSwitch = no_panic.corruptSwitch;
pub const shiftRhsTooBig = no_panic.shiftRhsTooBig;
pub const invalidEnumValue = no_panic.invalidEnumValue;
pub const forLenMismatch = no_panic.forLenMismatch;
pub const copyLenMismatch = no_panic.copyLenMismatch;
pub const memcpyAlias = no_panic.memcpyAlias;
pub const noreturnReturned = no_panic.noreturnReturned;
};
fn myPanicNew(msg: []const u8, _: ?usize) noreturn {
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
stdout_writer.interface.print("third panic message: {s}\n", .{msg}) catch {};
std.process.exit(0);
}
const std = @import("std");
#expect_stdout="third panic message: integer overflow\n"
|