Skip to content

Commit 2dc8975

Browse files
al45tairahoppen
authored andcommitted
[Backtracing] Fix ARM64e build failure.
Accessing the thread context structures is complicated because their member variables change name depending on various macros. This caused a build failure for ARM64e. rdar://118402226
1 parent 61f4b78 commit 2dc8975

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

stdlib/public/runtime/CrashHandlerMacOS.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,24 @@ handle_fatal_signal(int signum,
231231
void *pc = 0;
232232
ucontext_t *ctx = (ucontext_t *)uctx;
233233

234-
#ifdef __DARWIN_UNIX03
234+
#if defined(__arm64__) && __DARWIN_OPAQUE_ARM_THREAD_STATE64
235+
#define THREAD_STATE_MEMBER(x) __opaque_##x
236+
#elif __DARWIN_UNIX03
237+
#define THREAD_STATE_MEMBER(x) __##x
238+
#else
239+
#define THREAD_STATE_MEMBER(x) x
240+
#endif
241+
242+
#if __DARWIN_UNIX03
235243
#define CTX_MEMBER(x) __##x
236244
#else
237245
#define CTX_MEMBER(x) x
238246
#endif
239247

240248
#if defined(__x86_64__)
241-
pc = (void *)(ctx->uc_mcontext->CTX_MEMBER(ss).CTX_MEMBER(rip));
249+
pc = (void *)(ctx->uc_mcontext->CTX_MEMBER(ss).THREAD_STATE_MEMBER(rip));
242250
#elif defined(__arm64__)
243-
pc = (void *)(ctx->uc_mcontext->CTX_MEMBER(ss).CTX_MEMBER(pc));
251+
pc = (void *)(ctx->uc_mcontext->CTX_MEMBER(ss).THREAD_STATE_MEMBER(pc));
244252
#endif
245253

246254
_swift_displayCrashMessage(signum, pc);

0 commit comments

Comments
 (0)