authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-18 22:49:08+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-18 22:49:08+02:00
log705a6b4efb7b19feb7d2ee86f2ac6e56653cb923
treeaee7300b340265badd4f57d5f1402b64f604e887
parent4812a98ce535e5c3f27c081b94153612cd4817ac
parent26500dafe53d1e4215adb411045d1680f75da685

Merge pull request '`std.debug.SelfInfo.MachO`: fix a few bugs' (#37318) from alexrp/zig:macos-unwind-stuff into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37318

2 files changed, 9 insertions(+), 7 deletions(-)

lib/std/debug/SelfInfo/MachO.zig+6-6
...@@ -417,7 +417,7 @@ fn unwindFrameInner(si: *SelfInfo, io: Io, context: *UnwindContext) !usize {...@@ -417,7 +417,7 @@ fn unwindFrameInner(si: *SelfInfo, io: Io, context: *UnwindContext) !usize {
417 const rules = try context.computeRules(gpa, dwarf, unwind.vmaddr_slide, encoding.value.arm64.dwarf);417 const rules = try context.computeRules(gpa, dwarf, unwind.vmaddr_slide, encoding.value.arm64.dwarf);
418 return context.next(gpa, &rules);418 return context.next(gpa, &rules);
419 },419 },
420 .FRAME => ip: {420 .FRAME, .FRAME_PAUTH_LR => ip: {
421 const frame = encoding.value.arm64.frame;421 const frame = encoding.value.arm64.frame;
422422
423 const fp = (try dwarfRegNative(&context.cpu_state, fp_reg_num)).*;423 const fp = (try dwarfRegNative(&context.cpu_state, fp_reg_num)).*;
...@@ -426,10 +426,10 @@ fn unwindFrameInner(si: *SelfInfo, io: Io, context: *UnwindContext) !usize {...@@ -426,10 +426,10 @@ fn unwindFrameInner(si: *SelfInfo, io: Io, context: *UnwindContext) !usize {
426 var reg_addr = fp - @sizeOf(usize);426 var reg_addr = fp - @sizeOf(usize);
427 inline for (@typeInfo(@TypeOf(frame.x_reg_pairs)).@"struct".field_names, 0..) |field_name, i| {427 inline for (@typeInfo(@TypeOf(frame.x_reg_pairs)).@"struct".field_names, 0..) |field_name, i| {
428 if (@field(frame.x_reg_pairs, field_name) != 0) {428 if (@field(frame.x_reg_pairs, field_name) != 0) {
429 (try dwarfRegNative(&context.cpu_state, 19 + i)).* = @as(*const usize, @ptrFromInt(reg_addr)).*;429 (try dwarfRegNative(&context.cpu_state, 19 + i * 2)).* = @as(*const usize, @ptrFromInt(reg_addr)).*;
430 reg_addr += @sizeOf(usize);430 reg_addr -= @sizeOf(usize);
431 (try dwarfRegNative(&context.cpu_state, 20 + i)).* = @as(*const usize, @ptrFromInt(reg_addr)).*;431 (try dwarfRegNative(&context.cpu_state, 20 + i * 2)).* = @as(*const usize, @ptrFromInt(reg_addr)).*;
432 reg_addr += @sizeOf(usize);432 reg_addr -= @sizeOf(usize);
433 }433 }
434 }434 }
435435
...@@ -437,7 +437,7 @@ fn unwindFrameInner(si: *SelfInfo, io: Io, context: *UnwindContext) !usize {...@@ -437,7 +437,7 @@ fn unwindFrameInner(si: *SelfInfo, io: Io, context: *UnwindContext) !usize {
437 // vector registers in the AArch64 `cpu_context` anyway, so there's no reason to437 // vector registers in the AArch64 `cpu_context` anyway, so there's no reason to
438 // fail a legitimate unwind just because we're asked to restore the registers here.438 // fail a legitimate unwind just because we're asked to restore the registers here.
439 // If some weird/broken unwind info tells us to read them later, we will fail then.439 // If some weird/broken unwind info tells us to read them later, we will fail then.
440 reg_addr += 16 * @as(usize, @popCount(@as(u4, @bitCast(frame.d_reg_pairs))));440 reg_addr -= 16 * @as(usize, @popCount(@as(u4, @bitCast(frame.d_reg_pairs))));
441441
442 const new_ip = @as(*const usize, @ptrFromInt(ip_ptr)).*;442 const new_ip = @as(*const usize, @ptrFromInt(ip_ptr)).*;
443 const new_fp = @as(*const usize, @ptrFromInt(fp)).*;443 const new_fp = @as(*const usize, @ptrFromInt(fp)).*;
lib/std/macho.zig+3-1
...@@ -2137,6 +2137,7 @@ pub const UNWIND_ARM64_MODE = enum(u4) {...@@ -2137,6 +2137,7 @@ pub const UNWIND_ARM64_MODE = enum(u4) {
2137 FRAMELESS = 2,2137 FRAMELESS = 2,
2138 DWARF = 3,2138 DWARF = 3,
2139 FRAME = 4,2139 FRAME = 4,
2140 FRAME_PAUTH_LR = 5,
2140};2141};
21412142
2142pub const UNWIND_ARM64_FRAME_X19_X20_PAIR: u32 = 0x00000001;2143pub const UNWIND_ARM64_FRAME_X19_X20_PAIR: u32 = 0x00000001;
...@@ -2189,13 +2190,14 @@ pub const CompactUnwindEncoding = packed struct(u32) {...@@ -2189,13 +2190,14 @@ pub const CompactUnwindEncoding = packed struct(u32) {
2189 x25_x26: u1,2190 x25_x26: u1,
2190 x27_x28: u1,2191 x27_x28: u1,
2191 },2192 },
2193 unused: u3 = 0,
2192 d_reg_pairs: packed struct(u4) {2194 d_reg_pairs: packed struct(u4) {
2193 d8_d9: u1,2195 d8_d9: u1,
2194 d10_d11: u1,2196 d10_d11: u1,
2195 d12_d13: u1,2197 d12_d13: u1,
2196 d14_d15: u1,2198 d14_d15: u1,
2197 },2199 },
2198 _: u15,2200 _: u12,
2199 },2201 },
2200 frameless: packed struct(u24) {2202 frameless: packed struct(u24) {
2201 _: u12 = 0,2203 _: u12 = 0,