Skip to content

Commit b0f280f

Browse files
committed
std.debug: Add unwind support for serenity
1 parent a76851b commit b0f280f

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

lib/std/debug.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,7 @@ pub const have_segfault_handling_support = switch (native_os) {
12761276
.windows,
12771277
.freebsd,
12781278
.openbsd,
1279+
.serenity,
12791280
=> true,
12801281

12811282
else => false,
@@ -1359,7 +1360,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa
13591360
}
13601361
const addr: usize = switch (native_os) {
13611362
.linux => @intFromPtr(info.fields.sigfault.addr),
1362-
.freebsd, .macos => @intFromPtr(info.addr),
1363+
.freebsd, .macos, .serenity => @intFromPtr(info.addr),
13631364
.netbsd => @intFromPtr(info.info.reason.fault.addr),
13641365
.openbsd => @intFromPtr(info.data.fault.addr),
13651366
.solaris, .illumos => @intFromPtr(info.reason.fault.addr),

lib/std/debug/SelfInfo/Elf.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ pub const can_unwind: bool = s: {
114114
.x86,
115115
.x86_64,
116116
},
117+
.serenity => &.{
118+
.x86_64,
119+
.aarch64,
120+
.riscv64,
121+
},
117122
else => unreachable,
118123
};
119124
for (archs) |a| {

lib/std/debug/cpu_context.zig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
5757
.r15 = uc.mcontext.gregs[std.posix.REG.R15],
5858
.rip = uc.mcontext.gregs[std.posix.REG.RIP],
5959
}) },
60-
.freebsd => .{ .gprs = .init(.{
60+
.freebsd, .serenity => .{ .gprs = .init(.{
6161
.rax = uc.mcontext.rax,
6262
.rdx = uc.mcontext.rdx,
6363
.rcx = uc.mcontext.rcx,
@@ -174,6 +174,11 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
174174
.sp = uc.mcontext.sp,
175175
.pc = uc.mcontext.pc,
176176
},
177+
.serenity => .{
178+
.x = uc.mcontext.x,
179+
.sp = uc.mcontext.sp,
180+
.pc = uc.mcontext.pc,
181+
},
177182
else => null,
178183
},
179184
.loongarch64 => switch (builtin.os.tag) {
@@ -188,6 +193,10 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
188193
.r = [1]usize{0} ++ uc.mcontext.gregs[1..].*, // r0 position is used for pc; replace with zero
189194
.pc = uc.mcontext.gregs[0],
190195
},
196+
.serenity => if (native_arch == .riscv32) null else .{
197+
.r = [1]u64{0} ++ uc.mcontext.x,
198+
.pc = uc.mcontext.pc,
199+
},
191200
else => null,
192201
},
193202
.s390x => switch (builtin.os.tag) {

0 commit comments

Comments
 (0)