aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-04-01 11:03:36 +0200
committerLemonBoy <thatlemon@gmail.com>2020-04-01 12:11:19 +0200
commit070ace4b22810116f7816eeccbc1ce600be5b2a2 (patch)
tree28a88e7a1aa8567d3549c4a92548ec9e11dd23cf /lib/std/debug.zig
parenta5af78c376fc41424b81ea83766b38a0a1d17870 (diff)
downloadzig-070ace4b22810116f7816eeccbc1ce600be5b2a2.tar.gz
zig-070ace4b22810116f7816eeccbc1ce600be5b2a2.zip
std: Fix more NetBSD bits
Fix some more libc definitions.
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 11d808a17d..9e14d132a8 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -1666,7 +1666,11 @@ fn getDebugInfoAllocator() *mem.Allocator {
}
/// Whether or not the current target can print useful debug information when a segfault occurs.
-pub const have_segfault_handling_support = builtin.os.tag == .linux or builtin.os.tag == .windows;
+pub const have_segfault_handling_support = switch (builtin.os.tag) {
+ .linux, .netbsd => true,
+ .windows => true,
+ else => false,
+};
pub const enable_segfault_handler: bool = if (@hasDecl(root, "enable_segfault_handler"))
root.enable_segfault_handler
else
@@ -1718,13 +1722,17 @@ fn resetSegfaultHandler() void {
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 {
// Reset to the default handler so that if a segfault happens in this handler it will crash
// the process. Also when this handler returns, the original instruction will be repeated
// and the resulting segfault will crash the process rather than continually dump stack traces.
resetSegfaultHandler();
- const addr = @ptrToInt(info.fields.sigfault.addr);
+ const addr = switch (builtin.os.tag) {
+ .linux => @ptrToInt(info.fields.sigfault.addr),
+ .netbsd => @ptrToInt(info.info.reason.fault.addr),
+ else => unreachable,
+ };
switch (sig) {
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}),