diff options
| author | Sébastien Marie <semarie@online.fr> | 2020-12-23 12:39:20 +0000 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2020-12-23 20:47:06 +0200 |
| commit | 6e2622661cdf9dd48cf962e5d6902324b15468c3 (patch) | |
| tree | 18375a45631eaf93c9249c4f9429969adf88f5f6 /lib/std/debug.zig | |
| parent | 588e8287594803fdc06b6dfc3d7591075b88ff1e (diff) | |
| download | zig-6e2622661cdf9dd48cf962e5d6902324b15468c3.tar.gz zig-6e2622661cdf9dd48cf962e5d6902324b15468c3.zip | |
openbsd: implement segfault handling on openbsd x86_64
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index e93143c598..7284237cb2 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -1696,7 +1696,7 @@ fn getDebugInfoAllocator() *mem.Allocator { pub const have_segfault_handling_support = switch (builtin.os.tag) { .linux, .netbsd => true, .windows => true, - .freebsd => @hasDecl(os, "ucontext_t"), + .freebsd, .openbsd => @hasDecl(os, "ucontext_t"), else => false, }; pub const enable_segfault_handler: bool = if (@hasDecl(root, "enable_segfault_handler")) @@ -1760,6 +1760,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v .linux => @ptrToInt(info.fields.sigfault.addr), .freebsd => @ptrToInt(info.addr), .netbsd => @ptrToInt(info.info.reason.fault.addr), + .openbsd => @ptrToInt(info.data.fault.addr), else => unreachable, }; @@ -1786,10 +1787,12 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v const ip = switch (builtin.os.tag) { .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RIP]), .freebsd => @intCast(usize, ctx.mcontext.rip), + .openbsd => @intCast(usize, ctx.sc_rip), else => unreachable, }; const bp = switch (builtin.os.tag) { .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RBP]), + .openbsd => @intCast(usize, ctx.sc_rbp), .freebsd => @intCast(usize, ctx.mcontext.rbp), else => unreachable, }; |
