Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Native/Runtime/amd64/AsmOffsetsCpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,35 @@ PLAT_ASM_OFFSET(90, REGDISPLAY, Xmm)

#else // !UNIX_AMD64_ABI

#if defined(__APPLE__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could you please change the define to something like UNWIND_WORKAROUND that is defined for __APPLE__ so that all places related to this are easy to find?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Which header file would be the appropriate place to make this define?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src\Native\CMakeLists.txt may be a good place

PLAT_ASM_SIZEOF(1e8, ExInfo)
#else
PLAT_ASM_SIZEOF(198, ExInfo)
#endif
PLAT_ASM_OFFSET(0, ExInfo, m_pPrevExInfo)
PLAT_ASM_OFFSET(8, ExInfo, m_pExContext)
PLAT_ASM_OFFSET(10, ExInfo, m_exception)
PLAT_ASM_OFFSET(18, ExInfo, m_kind)
PLAT_ASM_OFFSET(19, ExInfo, m_passNumber)
PLAT_ASM_OFFSET(1c, ExInfo, m_idxCurClause)
PLAT_ASM_OFFSET(20, ExInfo, m_frameIter)
#if defined(__APPLE__)
PLAT_ASM_OFFSET(1e0, ExInfo, m_notifyDebuggerSP)
#else
PLAT_ASM_OFFSET(190, ExInfo, m_notifyDebuggerSP)
#endif

PLAT_ASM_OFFSET(0, PInvokeTransitionFrame, m_RIP)
PLAT_ASM_OFFSET(8, PInvokeTransitionFrame, m_FramePointer)
PLAT_ASM_OFFSET(10, PInvokeTransitionFrame, m_pThread)
PLAT_ASM_OFFSET(18, PInvokeTransitionFrame, m_dwFlags)
PLAT_ASM_OFFSET(20, PInvokeTransitionFrame, m_PreservedRegs)

#if defined(__APPLE__)
PLAT_ASM_SIZEOF(1c0, StackFrameIterator)
#else
PLAT_ASM_SIZEOF(170, StackFrameIterator)
#endif
PLAT_ASM_OFFSET(10, StackFrameIterator, m_FramePointer)
PLAT_ASM_OFFSET(18, StackFrameIterator, m_ControlPC)
PLAT_ASM_OFFSET(20, StackFrameIterator, m_RegDisplay)
Expand All @@ -105,7 +117,11 @@ PLAT_ASM_OFFSET(38, PAL_LIMITED_CONTEXT, R13)
PLAT_ASM_OFFSET(40, PAL_LIMITED_CONTEXT, R14)
PLAT_ASM_OFFSET(48, PAL_LIMITED_CONTEXT, R15)

#if defined(__APPLE__)
PLAT_ASM_SIZEOF(e0, REGDISPLAY)
#else
PLAT_ASM_SIZEOF(90, REGDISPLAY)
#endif
PLAT_ASM_OFFSET(78, REGDISPLAY, SP)

PLAT_ASM_OFFSET(18, REGDISPLAY, pRbx)
Expand Down
4 changes: 4 additions & 0 deletions src/Native/Runtime/regdisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ struct REGDISPLAY
PTR_PCODE pIP;
PCODE IP;

#if defined(__APPLE__)
PAL_LIMITED_CONTEXT PalLimitedContext;
#endif

#if defined(_TARGET_AMD64_) && !defined(UNIX_AMD64_ABI)
Fp128 Xmm[16-6]; // preserved xmm6..xmm15 regs for EH stackwalk
// these need to be unwound during a stack walk
Expand Down
23 changes: 23 additions & 0 deletions src/Native/Runtime/unix/UnixContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,29 @@ void UnwindCursorToRegDisplay(unw_cursor_t *cursor, unw_context_t *unwContext, R
#if defined(_ARM_) || defined(_ARM64_)
regDisplay->IP |= 1;
#endif

#if defined(__APPLE__)
regDisplay->pRax = &regDisplay->PalLimitedContext.Rax;
regDisplay->pRdx = &regDisplay->PalLimitedContext.Rdx;
regDisplay->pRbx = &regDisplay->PalLimitedContext.Rbx;
regDisplay->pRbp = &regDisplay->PalLimitedContext.Rbp;

regDisplay->pR12 = &regDisplay->PalLimitedContext.R12;
regDisplay->pR13 = &regDisplay->PalLimitedContext.R13;
regDisplay->pR14 = &regDisplay->PalLimitedContext.R14;
regDisplay->pR15 = &regDisplay->PalLimitedContext.R15;

unw_get_reg(cursor, UNW_X86_64_RAX, (unw_word_t *) &regDisplay->pRax);
unw_get_reg(cursor, UNW_X86_64_RDX, (unw_word_t *) &regDisplay->pRdx);
unw_get_reg(cursor, UNW_X86_64_RBX, (unw_word_t *) &regDisplay->pRbx);
unw_get_reg(cursor, UNW_X86_64_RBP, (unw_word_t *) &regDisplay->pRbp);

unw_get_reg(cursor, UNW_X86_64_R12, (unw_word_t *) &regDisplay->pR12);
unw_get_reg(cursor, UNW_X86_64_R13, (unw_word_t *) &regDisplay->pR13);
unw_get_reg(cursor, UNW_X86_64_R14, (unw_word_t *) &regDisplay->pR14);
unw_get_reg(cursor, UNW_X86_64_R15, (unw_word_t *) &regDisplay->pR15);
#endif

}

#if defined(_AMD64_)
Expand Down