| ... | @@ -1696,6 +1696,7 @@ fn getDebugInfoAllocator() *mem.Allocator { | ... | @@ -1696,6 +1696,7 @@ fn getDebugInfoAllocator() *mem.Allocator { |
| 1696 | pub const have_segfault_handling_support = switch (builtin.os.tag) { | 1696 | pub const have_segfault_handling_support = switch (builtin.os.tag) { |
| 1697 | .linux, .netbsd => true, | 1697 | .linux, .netbsd => true, |
| 1698 | .windows => true, | 1698 | .windows => true, |
| | 1699 | .freebsd => @hasDecl(os, "ucontext_t"), |
| 1699 | else => false, | 1700 | else => false, |
| 1700 | }; | 1701 | }; |
| 1701 | pub const enable_segfault_handler: bool = if (@hasDecl(root, "enable_segfault_handler")) | 1702 | pub const enable_segfault_handler: bool = if (@hasDecl(root, "enable_segfault_handler")) |
| ... | @@ -1757,6 +1758,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v | ... | @@ -1757,6 +1758,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v |
| 1757 | | 1758 | |
| 1758 | const addr = switch (builtin.os.tag) { | 1759 | const addr = switch (builtin.os.tag) { |
| 1759 | .linux => @ptrToInt(info.fields.sigfault.addr), | 1760 | .linux => @ptrToInt(info.fields.sigfault.addr), |
| | 1761 | .freebsd => @ptrToInt(info.addr), |
| 1760 | .netbsd => @ptrToInt(info.info.reason.fault.addr), | 1762 | .netbsd => @ptrToInt(info.info.reason.fault.addr), |
| 1761 | else => unreachable, | 1763 | else => unreachable, |
| 1762 | }; | 1764 | }; |
| ... | @@ -1781,8 +1783,16 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v | ... | @@ -1781,8 +1783,16 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v |
| 1781 | }, | 1783 | }, |
| 1782 | .x86_64 => { | 1784 | .x86_64 => { |
| 1783 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); | 1785 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); |
| 1784 | const ip = @intCast(usize, ctx.mcontext.gregs[os.REG_RIP]); | 1786 | const ip = switch (builtin.os.tag) { |
| 1785 | const bp = @intCast(usize, ctx.mcontext.gregs[os.REG_RBP]); | 1787 | .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RIP]), |
| | 1788 | .freebsd => @intCast(usize, ctx.mcontext.rip), |
| | 1789 | else => unreachable, |
| | 1790 | }; |
| | 1791 | const bp = switch (builtin.os.tag) { |
| | 1792 | .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RBP]), |
| | 1793 | .freebsd => @intCast(usize, ctx.mcontext.rbp), |
| | 1794 | else => unreachable, |
| | 1795 | }; |
| 1786 | dumpStackTraceFromBase(bp, ip); | 1796 | dumpStackTraceFromBase(bp, ip); |
| 1787 | }, | 1797 | }, |
| 1788 | .arm => { | 1798 | .arm => { |