diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index 1bb11b8b876f4f..b86b85716ed0b9 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -1581,21 +1581,35 @@ void StackFrameIterator::SkipTo(StackFrameIterator *pOtherStackFrameIterator) *pRD->pCurrentContextPointers = *pOtherRD->pCurrentContextPointers; SetIP(pRD->pCurrentContext, GetIP(pOtherRD->pCurrentContext)); SetSP(pRD->pCurrentContext, GetSP(pOtherRD->pCurrentContext)); + +#ifdef __APPLE__ +// Apple libunwind doesn't provide context pointers +#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = pOtherRD->pCurrentContext->regname; +#else #define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = *pRD->pCurrentContextPointers->regname; +#endif ENUM_CALLEE_SAVED_REGISTERS(); #undef CALLEE_SAVED_REGISTER + #define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = pOtherRD->pCurrentContext->regname; ENUM_FP_CALLEE_SAVED_REGISTERS(); #undef CALLEE_SAVED_REGISTER + pRD->IsCallerContextValid = pOtherRD->IsCallerContextValid; if (pRD->IsCallerContextValid) { *pRD->pCallerContextPointers = *pOtherRD->pCallerContextPointers; SetIP(pRD->pCallerContext, GetIP(pOtherRD->pCallerContext)); SetSP(pRD->pCallerContext, GetSP(pOtherRD->pCallerContext)); + +#ifdef __APPLE__ +#define CALLEE_SAVED_REGISTER(regname) pRD->pCallerContext->regname = pOtherRD->pCallerContext->regname; +#else #define CALLEE_SAVED_REGISTER(regname) pRD->pCallerContext->regname = *pRD->pCallerContextPointers->regname; +#endif ENUM_CALLEE_SAVED_REGISTERS(); #undef CALLEE_SAVED_REGISTER + #define CALLEE_SAVED_REGISTER(regname) pRD->pCallerContext->regname = pOtherRD->pCallerContext->regname; ENUM_FP_CALLEE_SAVED_REGISTERS(); #undef CALLEE_SAVED_REGISTER