diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 6d705f3c86..7d0990ae00 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -1276,6 +1276,7 @@ pub const have_segfault_handling_support = switch (native_os) { .windows, .freebsd, .openbsd, + .serenity, => true, else => false, @@ -1359,7 +1360,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa } const addr: usize = switch (native_os) { .linux => @intFromPtr(info.fields.sigfault.addr), - .freebsd, .macos => @intFromPtr(info.addr), + .freebsd, .macos, .serenity => @intFromPtr(info.addr), .netbsd => @intFromPtr(info.info.reason.fault.addr), .openbsd => @intFromPtr(info.data.fault.addr), .solaris, .illumos => @intFromPtr(info.reason.fault.addr), diff --git a/lib/std/debug/SelfInfo/Elf.zig b/lib/std/debug/SelfInfo/Elf.zig index 9772ec0aac..c31af53cd6 100644 --- a/lib/std/debug/SelfInfo/Elf.zig +++ b/lib/std/debug/SelfInfo/Elf.zig @@ -114,6 +114,11 @@ pub const can_unwind: bool = s: { .x86, .x86_64, }, + .serenity => &.{ + .x86_64, + .aarch64, + .riscv64, + }, else => unreachable, }; for (archs) |a| { diff --git a/lib/std/debug/cpu_context.zig b/lib/std/debug/cpu_context.zig index 0e25d00480..121245ac7b 100644 --- a/lib/std/debug/cpu_context.zig +++ b/lib/std/debug/cpu_context.zig @@ -57,7 +57,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native { .r15 = uc.mcontext.gregs[std.posix.REG.R15], .rip = uc.mcontext.gregs[std.posix.REG.RIP], }) }, - .freebsd => .{ .gprs = .init(.{ + .freebsd, .serenity => .{ .gprs = .init(.{ .rax = uc.mcontext.rax, .rdx = uc.mcontext.rdx, .rcx = uc.mcontext.rcx, @@ -174,6 +174,11 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native { .sp = uc.mcontext.sp, .pc = uc.mcontext.pc, }, + .serenity => .{ + .x = uc.mcontext.x, + .sp = uc.mcontext.sp, + .pc = uc.mcontext.pc, + }, else => null, }, .loongarch64 => switch (builtin.os.tag) { @@ -188,6 +193,10 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native { .r = [1]usize{0} ++ uc.mcontext.gregs[1..].*, // r0 position is used for pc; replace with zero .pc = uc.mcontext.gregs[0], }, + .serenity => if (native_arch == .riscv32) null else .{ + .r = [1]u64{0} ++ uc.mcontext.x, + .pc = uc.mcontext.pc, + }, else => null, }, .s390x => switch (builtin.os.tag) {