From 17dab6549b72d115bdc2b75e400b136077c597b9 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Tue, 26 Mar 2024 21:18:25 +0100 Subject: [PATCH] Fix Apple where libunwind doesn't provide context pointers --- src/coreclr/vm/stackwalk.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index 1bb11b8b876f4f..bbddd391d4a401 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -1581,21 +1581,26 @@ void StackFrameIterator::SkipTo(StackFrameIterator *pOtherStackFrameIterator) *pRD->pCurrentContextPointers = *pOtherRD->pCurrentContextPointers; SetIP(pRD->pCurrentContext, GetIP(pOtherRD->pCurrentContext)); SetSP(pRD->pCurrentContext, GetSP(pOtherRD->pCurrentContext)); -#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = *pRD->pCurrentContextPointers->regname; + +#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = (pRD->pCurrentContextPointers->regname == NULL) ? pOtherRD->pCurrentContext->regname : *pRD->pCurrentContextPointers->regname; 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)); -#define CALLEE_SAVED_REGISTER(regname) pRD->pCallerContext->regname = *pRD->pCallerContextPointers->regname; + +#define CALLEE_SAVED_REGISTER(regname) pRD->pCallerContext->regname = (pRD->pCallerContextPointers->regname == NULL) ? pOtherRD->pCallerContext->regname : *pRD->pCallerContextPointers->regname; 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