aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2023-07-12 21:45:26 -0400
committerkcbanner <kcbanner@gmail.com>2023-07-20 22:58:16 -0400
commit9549b4acf67ec7dfcebf5373c11cdc7af3d41aae (patch)
tree21be3422b4beaad769b9eab11992f10fb2327fbc /lib
parent06bf2e048b24dcba28bcb7b00236b3cdb2504cc4 (diff)
downloadzig-9549b4acf67ec7dfcebf5373c11cdc7af3d41aae.tar.gz
zig-9549b4acf67ec7dfcebf5373c11cdc7af3d41aae.zip
debug: fixup an inconsistency in the getcontext implementation on aarch64-macos
Diffstat (limited to 'lib')
-rw-r--r--lib/std/debug.zig10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 6083939bde..13dd03d16d 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -190,7 +190,15 @@ pub inline fn getContext(context: *ThreadContext) bool {
}
const result = have_getcontext and os.system.getcontext(context) == 0;
- if (native_os == .macos) assert(context.mcsize == @sizeOf(std.c.mcontext_t));
+ if (native_os == .macos) {
+ assert(context.mcsize == @sizeOf(std.c.mcontext_t));
+
+ // On aarch64-macos, the system getcontext doesn't write anything into the pc
+ // register slot, it only writes lr. This makes the context consistent with
+ // other aarch64 getcontext implementations which write the current lr
+ // (where getcontext will return to) into both the lr and pc slot of the context.
+ if (native_arch == .aarch64) context.mcontext.ss.pc = context.mcontext.ss.lr;
+ }
return result;
}