Skip to content

Commit

Permalink
Fix Apple where libunwind doesn't provide context pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
janvorli committed Mar 26, 2024
1 parent add6b2f commit 790fa1c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/coreclr/vm/stackwalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 790fa1c

Please sign in to comment.