authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-18 22:51:52-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-20 22:58:16-04:00
log6d87bb370a6d9075b2b6628f5f8c09171f25e4e9
tree31c2c2e894f0ad2de17b68b8e58bc73d49e043c9
parent253e6971ad77a9665348fd6a2085b2ffd8c84219

debug: disable the new unwinder on aarch64-macos


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

lib/std/debug.zig+15-9
...@@ -521,13 +521,19 @@ pub const StackIterator = struct {...@@ -521,13 +521,19 @@ pub const StackIterator = struct {
521 }521 }
522522
523 pub fn initWithContext(first_address: ?usize, debug_info: *DebugInfo, context: *const os.ucontext_t) !StackIterator {523 pub fn initWithContext(first_address: ?usize, debug_info: *DebugInfo, context: *const os.ucontext_t) !StackIterator {
524 var iterator = init(first_address, null);524 // The implementation of DWARF unwinding on aarch64-macos is not complete. However, Apple mandates that
525 iterator.unwind_state = .{525 // the frame pointer register is always used, so on this platform we can safely use the FP-based unwinder.
526 .debug_info = debug_info,526 if (comptime builtin.target.isDarwin() and native_arch == .aarch64) {
527 .dwarf_context = try DW.UnwindContext.init(debug_info.allocator, context, &isValidMemory),527 return init(first_address, context.mcontext.ss.fp);
528 };528 } else {
529 var iterator = init(first_address, null);
530 iterator.unwind_state = .{
531 .debug_info = debug_info,
532 .dwarf_context = try DW.UnwindContext.init(debug_info.allocator, context, &isValidMemory),
533 };
529534
530 return iterator;535 return iterator;
536 }
531 }537 }
532538
533 pub fn deinit(self: *StackIterator) void {539 pub fn deinit(self: *StackIterator) void {
...@@ -663,15 +669,15 @@ pub const StackIterator = struct {...@@ -663,15 +669,15 @@ pub const StackIterator = struct {
663 if (!unwind_state.failed) {669 if (!unwind_state.failed) {
664 if (unwind_state.dwarf_context.pc == 0) return null;670 if (unwind_state.dwarf_context.pc == 0) return null;
665 if (self.next_unwind()) |return_address| {671 if (self.next_unwind()) |return_address| {
672 self.fp = unwind_state.dwarf_context.getFp() catch 0;
666 return return_address;673 return return_address;
667 } else |err| {674 } else |err| {
668 unwind_state.last_error = err;675 unwind_state.last_error = err;
669 unwind_state.failed = true;676 unwind_state.failed = true;
670677
671 // Fall back to fp-based unwinding on the first failure.678 // Fall back to fp-based unwinding on the first failure.
672 // We can't attempt it for other modules later in the679 // We can't attempt it again for other modules higher in the
673 // stack because the full register state won't be unwound.680 // stack because the full register state won't have been unwound.
674 self.fp = unwind_state.dwarf_context.getFp() catch 0;
675 }681 }
676 }682 }
677 }683 }
lib/std/dwarf.zig+2-2
...@@ -1782,7 +1782,7 @@ pub const DwarfInfo = struct {...@@ -1782,7 +1782,7 @@ pub const DwarfInfo = struct {
1782 };1782 };
17831783
1784 var update_tail: ?*RegisterUpdate = null;1784 var update_tail: ?*RegisterUpdate = null;
1785 var has_return_address= true;1785 var has_return_address = true;
1786 for (context.vm.rowColumns(row)) |column| {1786 for (context.vm.rowColumns(row)) |column| {
1787 if (column.register) |register| {1787 if (column.register) |register| {
1788 if (register == cie.return_address_register) {1788 if (register == cie.return_address_register) {
...@@ -1871,7 +1871,7 @@ pub const UnwindContext = struct {...@@ -1871,7 +1871,7 @@ pub const UnwindContext = struct {
1871 }1871 }
18721872
1873 pub fn getFp(self: *const UnwindContext) !usize {1873 pub fn getFp(self: *const UnwindContext) !usize {
1874 return mem.readIntSliceNative(usize, try abi.regBytes(self.thread_context, abi.fpRegNum(self.reg_context), self.reg_context));1874 return (try abi.regValueNative(usize, self.thread_context, abi.fpRegNum(self.reg_context), self.reg_context)).*;
1875 }1875 }
1876};1876};
18771877