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: {...@@ -84,12 +84,32 @@ pub const can_unwind: bool = s: {
84 // Notably, we are yet to support unwinding on ARM. There, unwinding is not done through84 // Notably, we are yet to support unwinding on ARM. There, unwinding is not done through
85 // `.eh_frame`, but instead with the `.ARM.exidx` section, which has a different format.85 // `.eh_frame`, but instead with the `.ARM.exidx` section, which has a different format.
86 const archs: []const std.Target.Cpu.Arch = switch (builtin.target.os.tag) {86 const archs: []const std.Target.Cpu.Arch = switch (builtin.target.os.tag) {
87 .linux => &.{ .x86, .x86_64, .aarch64, .aarch64_be },87 .linux => &.{
88 .netbsd => &.{ .x86, .x86_64, .aarch64, .aarch64_be },88 .aarch64,
89 .freebsd => &.{ .x86_64, .aarch64, .aarch64_be },89 .aarch64_be,
90 .openbsd => &.{.x86_64},90 .x86,
91 .solaris => &.{ .x86, .x86_64 },91 .x86_64,
92 .illumos => &.{ .x86, .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 },
93 else => unreachable,113 else => unreachable,
94 };114 };
95 for (archs) |a| {115 for (archs) |a| {
lib/std/debug/SelfInfo/MachO.zig+1-1
...@@ -371,7 +371,7 @@ fn unwindFrameInner(si: *SelfInfo, gpa: Allocator, context: *UnwindContext) !usi...@@ -371,7 +371,7 @@ fn unwindFrameInner(si: *SelfInfo, gpa: Allocator, context: *UnwindContext) !usi
371 return context.next(gpa, &rules);371 return context.next(gpa, &rules);
372 },372 },
373 },373 },
374 .aarch64, .aarch64_be => switch (encoding.mode.arm64) {374 .aarch64 => switch (encoding.mode.arm64) {
375 .OLD => return error.UnsupportedDebugInfo,375 .OLD => return error.UnsupportedDebugInfo,
376 .FRAMELESS => ip: {376 .FRAMELESS => ip: {
377 const sp = (try dwarfRegNative(&context.cpu_state, sp_reg_num)).*;377 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 {...@@ -88,7 +88,7 @@ pub const UnwindContext = struct {
88 .R15 = ctx.gprs.get(.r15),88 .R15 = ctx.gprs.get(.r15),
89 .Rip = ctx.gprs.get(.rip),89 .Rip = ctx.gprs.get(.rip),
90 }),90 }),
91 .aarch64, .aarch64_be => .{91 .aarch64 => .{
92 .ContextFlags = 0,92 .ContextFlags = 0,
93 .Cpsr = 0,93 .Cpsr = 0,
94 .DUMMYUNIONNAME = .{ .X = ctx.x },94 .DUMMYUNIONNAME = .{ .X = ctx.x },
lib/std/debug/cpu_context.zig+5-7
...@@ -21,7 +21,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {...@@ -21,7 +21,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
21 const uc: *const signal_ucontext_t = @ptrCast(@alignCast(ctx_ptr));21 const uc: *const signal_ucontext_t = @ptrCast(@alignCast(ctx_ptr));
22 return switch (native_arch) {22 return switch (native_arch) {
23 .x86 => switch (native_os) {23 .x86 => switch (native_os) {
24 .linux, .netbsd, .solaris, .illumos => .{ .gprs = .init(.{24 .linux, .netbsd, .illumos => .{ .gprs = .init(.{
25 .eax = uc.mcontext.gregs[std.posix.REG.EAX],25 .eax = uc.mcontext.gregs[std.posix.REG.EAX],
26 .ecx = uc.mcontext.gregs[std.posix.REG.ECX],26 .ecx = uc.mcontext.gregs[std.posix.REG.ECX],
27 .edx = uc.mcontext.gregs[std.posix.REG.EDX],27 .edx = uc.mcontext.gregs[std.posix.REG.EDX],
...@@ -92,7 +92,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {...@@ -92,7 +92,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
92 .r15 = @bitCast(uc.sc_r15),92 .r15 = @bitCast(uc.sc_r15),
93 .rip = @bitCast(uc.sc_rip),93 .rip = @bitCast(uc.sc_rip),
94 }) },94 }) },
95 .macos, .ios => .{ .gprs = .init(.{95 .driverkit, .macos, .ios => .{ .gprs = .init(.{
96 .rax = uc.mcontext.ss.rax,96 .rax = uc.mcontext.ss.rax,
97 .rdx = uc.mcontext.ss.rdx,97 .rdx = uc.mcontext.ss.rdx,
98 .rcx = uc.mcontext.ss.rcx,98 .rcx = uc.mcontext.ss.rcx,
...@@ -137,7 +137,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {...@@ -137,7 +137,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
137 else => null,137 else => null,
138 },138 },
139 .aarch64, .aarch64_be => switch (builtin.os.tag) {139 .aarch64, .aarch64_be => switch (builtin.os.tag) {
140 .macos, .ios, .tvos, .watchos, .visionos => .{140 .driverkit, .macos, .ios, .tvos, .watchos, .visionos => .{
141 .x = uc.mcontext.ss.regs ++ @as([2]u64, .{141 .x = uc.mcontext.ss.regs ++ @as([2]u64, .{
142 uc.mcontext.ss.fp, // x29 = fp142 uc.mcontext.ss.fp, // x29 = fp
143 uc.mcontext.ss.lr, // x30 = lr143 uc.mcontext.ss.lr, // x30 = lr
...@@ -209,7 +209,7 @@ pub fn fromWindowsContext(ctx: *const std.os.windows.CONTEXT) Native {...@@ -209,7 +209,7 @@ pub fn fromWindowsContext(ctx: *const std.os.windows.CONTEXT) Native {
209 .r15 = ctx.R15,209 .r15 = ctx.R15,
210 .rip = ctx.Rip,210 .rip = ctx.Rip,
211 }) },211 }) },
212 .aarch64, .aarch64_be => .{212 .aarch64 => .{
213 .x = ctx.DUMMYUNIONNAME.X[0..31].*,213 .x = ctx.DUMMYUNIONNAME.X[0..31].*,
214 .sp = ctx.Sp,214 .sp = ctx.Sp,
215 .pc = ctx.Pc,215 .pc = ctx.Pc,
...@@ -371,7 +371,6 @@ pub const Arm = struct {...@@ -371,7 +371,6 @@ pub const Arm = struct {
371 pub fn dwarfRegisterBytes(ctx: *Arm, register_num: u16) DwarfRegisterError![]u8 {371 pub fn dwarfRegisterBytes(ctx: *Arm, register_num: u16) DwarfRegisterError![]u8 {
372 // DWARF for the Arm(r) Architecture § 4.1 "DWARF register names"372 // DWARF for the Arm(r) Architecture § 4.1 "DWARF register names"
373 switch (register_num) {373 switch (register_num) {
374 // The order of `Gpr` intentionally matches DWARF's mappings.
375 0...15 => return @ptrCast(&ctx.r[register_num]),374 0...15 => return @ptrCast(&ctx.r[register_num]),
376375
377 64...95 => return error.UnsupportedRegister, // S0 - S31376 64...95 => return error.UnsupportedRegister, // S0 - S31
...@@ -444,7 +443,6 @@ pub const Aarch64 = extern struct {...@@ -444,7 +443,6 @@ pub const Aarch64 = extern struct {
444 pub fn dwarfRegisterBytes(ctx: *Aarch64, register_num: u16) DwarfRegisterError![]u8 {443 pub fn dwarfRegisterBytes(ctx: *Aarch64, register_num: u16) DwarfRegisterError![]u8 {
445 // DWARF for the Arm(r) 64-bit Architecture (AArch64) § 4.1 "DWARF register names"444 // DWARF for the Arm(r) 64-bit Architecture (AArch64) § 4.1 "DWARF register names"
446 switch (register_num) {445 switch (register_num) {
447 // The order of `Gpr` intentionally matches DWARF's mappings.
448 0...30 => return @ptrCast(&ctx.x[register_num]),446 0...30 => return @ptrCast(&ctx.x[register_num]),
449 31 => return @ptrCast(&ctx.sp),447 31 => return @ptrCast(&ctx.sp),
450 32 => return @ptrCast(&ctx.pc),448 32 => return @ptrCast(&ctx.pc),
...@@ -471,7 +469,7 @@ const signal_ucontext_t = switch (native_os) {...@@ -471,7 +469,7 @@ const signal_ucontext_t = switch (native_os) {
471 .linux => std.os.linux.ucontext_t,469 .linux => std.os.linux.ucontext_t,
472 .emscripten => std.os.emscripten.ucontext_t,470 .emscripten => std.os.emscripten.ucontext_t,
473 .freebsd => std.os.freebsd.ucontext_t,471 .freebsd => std.os.freebsd.ucontext_t,
474 .macos, .ios, .tvos, .watchos, .visionos => extern struct {472 .driverkit, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
475 onstack: c_int,473 onstack: c_int,
476 sigmask: std.c.sigset_t,474 sigmask: std.c.sigset_t,
477 stack: std.c.stack_t,475 stack: std.c.stack_t,