authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-01 15:34:46+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-01 23:47:47+02:00
logb46867848e4a2e8ba9965d579d4474fba1ab3b10
treeaed1ca03e5532036c8145d683ce354f1ba4c96f3
parent771410cbf231e1a2b20e25f9d70c13d4ffeace9c
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.debug: some adjustments to target handling

* driverkit handling missing in a few places. * x86-solaris is a dead target. * aarch64_be does not exist on Darwin, FreeBSD, Windows.

4 files changed, 33 insertions(+), 15 deletions(-)

lib/std/debug/SelfInfo/Elf.zig+26-6
......@@ -84,12 +84,32 @@ pub const can_unwind: bool = s: {
8484 // Notably, we are yet to support unwinding on ARM. There, unwinding is not done through
8585 // `.eh_frame`, but instead with the `.ARM.exidx` section, which has a different format.
8686 const archs: []const std.Target.Cpu.Arch = switch (builtin.target.os.tag) {
87 .linux => &.{ .x86, .x86_64, .aarch64, .aarch64_be },
88 .netbsd => &.{ .x86, .x86_64, .aarch64, .aarch64_be },
89 .freebsd => &.{ .x86_64, .aarch64, .aarch64_be },
90 .openbsd => &.{.x86_64},
91 .solaris => &.{ .x86, .x86_64 },
92 .illumos => &.{ .x86, .x86_64 },
87 .linux => &.{
88 .aarch64,
89 .aarch64_be,
90 .x86,
91 .x86_64,
92 },
93 .netbsd => &.{
94 .aarch64,
95 .aarch64_be,
96 .x86,
97 .x86_64,
98 },
99 .freebsd => &.{
100 .x86_64,
101 .aarch64,
102 },
103 .openbsd => &.{
104 .x86_64,
105 },
106 .solaris => &.{
107 .x86_64,
108 },
109 .illumos => &.{
110 .x86,
111 .x86_64,
112 },
93113 else => unreachable,
94114 };
95115 for (archs) |a| {
lib/std/debug/SelfInfo/MachO.zig+1-1
......@@ -371,7 +371,7 @@ fn unwindFrameInner(si: *SelfInfo, gpa: Allocator, context: *UnwindContext) !usi
371371 return context.next(gpa, &rules);
372372 },
373373 },
374 .aarch64, .aarch64_be => switch (encoding.mode.arm64) {
374 .aarch64 => switch (encoding.mode.arm64) {
375375 .OLD => return error.UnsupportedDebugInfo,
376376 .FRAMELESS => ip: {
377377 const sp = (try dwarfRegNative(&context.cpu_state, sp_reg_num)).*;
lib/std/debug/SelfInfo/Windows.zig+1-1
......@@ -88,7 +88,7 @@ pub const UnwindContext = struct {
8888 .R15 = ctx.gprs.get(.r15),
8989 .Rip = ctx.gprs.get(.rip),
9090 }),
91 .aarch64, .aarch64_be => .{
91 .aarch64 => .{
9292 .ContextFlags = 0,
9393 .Cpsr = 0,
9494 .DUMMYUNIONNAME = .{ .X = ctx.x },
lib/std/debug/cpu_context.zig+5-7
......@@ -21,7 +21,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
2121 const uc: *const signal_ucontext_t = @ptrCast(@alignCast(ctx_ptr));
2222 return switch (native_arch) {
2323 .x86 => switch (native_os) {
24 .linux, .netbsd, .solaris, .illumos => .{ .gprs = .init(.{
24 .linux, .netbsd, .illumos => .{ .gprs = .init(.{
2525 .eax = uc.mcontext.gregs[std.posix.REG.EAX],
2626 .ecx = uc.mcontext.gregs[std.posix.REG.ECX],
2727 .edx = uc.mcontext.gregs[std.posix.REG.EDX],
......@@ -92,7 +92,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
9292 .r15 = @bitCast(uc.sc_r15),
9393 .rip = @bitCast(uc.sc_rip),
9494 }) },
95 .macos, .ios => .{ .gprs = .init(.{
95 .driverkit, .macos, .ios => .{ .gprs = .init(.{
9696 .rax = uc.mcontext.ss.rax,
9797 .rdx = uc.mcontext.ss.rdx,
9898 .rcx = uc.mcontext.ss.rcx,
......@@ -137,7 +137,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
137137 else => null,
138138 },
139139 .aarch64, .aarch64_be => switch (builtin.os.tag) {
140 .macos, .ios, .tvos, .watchos, .visionos => .{
140 .driverkit, .macos, .ios, .tvos, .watchos, .visionos => .{
141141 .x = uc.mcontext.ss.regs ++ @as([2]u64, .{
142142 uc.mcontext.ss.fp, // x29 = fp
143143 uc.mcontext.ss.lr, // x30 = lr
......@@ -209,7 +209,7 @@ pub fn fromWindowsContext(ctx: *const std.os.windows.CONTEXT) Native {
209209 .r15 = ctx.R15,
210210 .rip = ctx.Rip,
211211 }) },
212 .aarch64, .aarch64_be => .{
212 .aarch64 => .{
213213 .x = ctx.DUMMYUNIONNAME.X[0..31].*,
214214 .sp = ctx.Sp,
215215 .pc = ctx.Pc,
......@@ -371,7 +371,6 @@ pub const Arm = struct {
371371 pub fn dwarfRegisterBytes(ctx: *Arm, register_num: u16) DwarfRegisterError![]u8 {
372372 // DWARF for the Arm(r) Architecture § 4.1 "DWARF register names"
373373 switch (register_num) {
374 // The order of `Gpr` intentionally matches DWARF's mappings.
375374 0...15 => return @ptrCast(&ctx.r[register_num]),
376375
377376 64...95 => return error.UnsupportedRegister, // S0 - S31
......@@ -444,7 +443,6 @@ pub const Aarch64 = extern struct {
444443 pub fn dwarfRegisterBytes(ctx: *Aarch64, register_num: u16) DwarfRegisterError![]u8 {
445444 // DWARF for the Arm(r) 64-bit Architecture (AArch64) § 4.1 "DWARF register names"
446445 switch (register_num) {
447 // The order of `Gpr` intentionally matches DWARF's mappings.
448446 0...30 => return @ptrCast(&ctx.x[register_num]),
449447 31 => return @ptrCast(&ctx.sp),
450448 32 => return @ptrCast(&ctx.pc),
......@@ -471,7 +469,7 @@ const signal_ucontext_t = switch (native_os) {
471469 .linux => std.os.linux.ucontext_t,
472470 .emscripten => std.os.emscripten.ucontext_t,
473471 .freebsd => std.os.freebsd.ucontext_t,
474 .macos, .ios, .tvos, .watchos, .visionos => extern struct {
472 .driverkit, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
475473 onstack: c_int,
476474 sigmask: std.c.sigset_t,
477475 stack: std.c.stack_t,