std.debug: Add unwind support for serenity

This commit is contained in:
Linus Groh 2025-10-03 22:37:05 +01:00
parent a76851b2ef
commit b0f280f4a4
3 changed files with 17 additions and 2 deletions

View File

@ -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),

View File

@ -114,6 +114,11 @@ pub const can_unwind: bool = s: {
.x86,
.x86_64,
},
.serenity => &.{
.x86_64,
.aarch64,
.riscv64,
},
else => unreachable,
};
for (archs) |a| {

View File

@ -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) {