mirror of
https://github.com/ziglang/zig.git
synced 2025-12-17 19:53:06 +00:00
debug: Show a nice error message on SIGBUS
This commit is contained in:
parent
786700249e
commit
be02616c86
@ -2256,6 +2256,7 @@ pub fn attachSegfaultHandler() void {
|
|||||||
|
|
||||||
os.sigaction(os.SIGSEGV, &act, null);
|
os.sigaction(os.SIGSEGV, &act, null);
|
||||||
os.sigaction(os.SIGILL, &act, null);
|
os.sigaction(os.SIGILL, &act, null);
|
||||||
|
os.sigaction(os.SIGBUS, &act, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resetSegfaultHandler() void {
|
fn resetSegfaultHandler() void {
|
||||||
@ -2273,6 +2274,7 @@ fn resetSegfaultHandler() void {
|
|||||||
};
|
};
|
||||||
os.sigaction(os.SIGSEGV, &act, null);
|
os.sigaction(os.SIGSEGV, &act, null);
|
||||||
os.sigaction(os.SIGILL, &act, null);
|
os.sigaction(os.SIGILL, &act, null);
|
||||||
|
os.sigaction(os.SIGBUS, &act, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_void) callconv(.C) noreturn {
|
fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_void) callconv(.C) noreturn {
|
||||||
@ -2285,6 +2287,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_vo
|
|||||||
switch (sig) {
|
switch (sig) {
|
||||||
os.SIGSEGV => std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr}),
|
os.SIGSEGV => std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr}),
|
||||||
os.SIGILL => std.debug.warn("Illegal instruction at address 0x{x}\n", .{addr}),
|
os.SIGILL => std.debug.warn("Illegal instruction at address 0x{x}\n", .{addr}),
|
||||||
|
os.SIGBUS => std.debug.warn("Bus error at address 0x{x}\n", .{addr}),
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
}
|
}
|
||||||
switch (builtin.arch) {
|
switch (builtin.arch) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user