authorgravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2025-10-03 22:37:05+01:00
committergravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2025-10-03 22:59:40+01:00
logb0f280f4a4f3b1f804d84cc71c3e1be54d6e05a8
tree62e9fb17157f6f8fd1f199535a89445c9da3fc83
parenta76851b2ef8f22fb318573b33c973cf768423b5e

std.debug: Add unwind support for serenity


3 files changed, 17 insertions(+), 2 deletions(-)

lib/std/debug.zig+2-1
...@@ -1276,6 +1276,7 @@ pub const have_segfault_handling_support = switch (native_os) {...@@ -1276,6 +1276,7 @@ pub const have_segfault_handling_support = switch (native_os) {
1276 .windows,1276 .windows,
1277 .freebsd,1277 .freebsd,
1278 .openbsd,1278 .openbsd,
1279 .serenity,
1279 => true,1280 => true,
12801281
1281 else => false,1282 else => false,
...@@ -1359,7 +1360,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa...@@ -1359,7 +1360,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa
1359 }1360 }
1360 const addr: usize = switch (native_os) {1361 const addr: usize = switch (native_os) {
1361 .linux => @intFromPtr(info.fields.sigfault.addr),1362 .linux => @intFromPtr(info.fields.sigfault.addr),
1362 .freebsd, .macos => @intFromPtr(info.addr),1363 .freebsd, .macos, .serenity => @intFromPtr(info.addr),
1363 .netbsd => @intFromPtr(info.info.reason.fault.addr),1364 .netbsd => @intFromPtr(info.info.reason.fault.addr),
1364 .openbsd => @intFromPtr(info.data.fault.addr),1365 .openbsd => @intFromPtr(info.data.fault.addr),
1365 .solaris, .illumos => @intFromPtr(info.reason.fault.addr),1366 .solaris, .illumos => @intFromPtr(info.reason.fault.addr),
lib/std/debug/SelfInfo/Elf.zig+5
...@@ -114,6 +114,11 @@ pub const can_unwind: bool = s: {...@@ -114,6 +114,11 @@ pub const can_unwind: bool = s: {
114 .x86,114 .x86,
115 .x86_64,115 .x86_64,
116 },116 },
117 .serenity => &.{
118 .x86_64,
119 .aarch64,
120 .riscv64,
121 },
117 else => unreachable,122 else => unreachable,
118 };123 };
119 for (archs) |a| {124 for (archs) |a| {
lib/std/debug/cpu_context.zig+10-1
...@@ -57,7 +57,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {...@@ -57,7 +57,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
57 .r15 = uc.mcontext.gregs[std.posix.REG.R15],57 .r15 = uc.mcontext.gregs[std.posix.REG.R15],
58 .rip = uc.mcontext.gregs[std.posix.REG.RIP],58 .rip = uc.mcontext.gregs[std.posix.REG.RIP],
59 }) },59 }) },
60 .freebsd => .{ .gprs = .init(.{60 .freebsd, .serenity => .{ .gprs = .init(.{
61 .rax = uc.mcontext.rax,61 .rax = uc.mcontext.rax,
62 .rdx = uc.mcontext.rdx,62 .rdx = uc.mcontext.rdx,
63 .rcx = uc.mcontext.rcx,63 .rcx = uc.mcontext.rcx,
...@@ -174,6 +174,11 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {...@@ -174,6 +174,11 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
174 .sp = uc.mcontext.sp,174 .sp = uc.mcontext.sp,
175 .pc = uc.mcontext.pc,175 .pc = uc.mcontext.pc,
176 },176 },
177 .serenity => .{
178 .x = uc.mcontext.x,
179 .sp = uc.mcontext.sp,
180 .pc = uc.mcontext.pc,
181 },
177 else => null,182 else => null,
178 },183 },
179 .loongarch64 => switch (builtin.os.tag) {184 .loongarch64 => switch (builtin.os.tag) {
...@@ -188,6 +193,10 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {...@@ -188,6 +193,10 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
188 .r = [1]usize{0} ++ uc.mcontext.gregs[1..].*, // r0 position is used for pc; replace with zero193 .r = [1]usize{0} ++ uc.mcontext.gregs[1..].*, // r0 position is used for pc; replace with zero
189 .pc = uc.mcontext.gregs[0],194 .pc = uc.mcontext.gregs[0],
190 },195 },
196 .serenity => if (native_arch == .riscv32) null else .{
197 .r = [1]u64{0} ++ uc.mcontext.x,
198 .pc = uc.mcontext.pc,
199 },
191 else => null,200 else => null,
192 },201 },
193 .s390x => switch (builtin.os.tag) {202 .s390x => switch (builtin.os.tag) {