diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index 727723e259cb13..91fa136d8a8b2a 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -553,6 +553,13 @@ PCODE Thread::VirtualUnwindCallFrame(T_CONTEXT* pContext, UINT_PTR uImageBase; PT_RUNTIME_FUNCTION pFunctionEntry; +#if !defined(TARGET_UNIX) && defined(CONTEXT_UNWOUND_TO_CALL) + if ((pContext->ContextFlags & CONTEXT_UNWOUND_TO_CALL) != 0) + { + uControlPc -= STACKWALK_CONTROLPC_ADJUST_OFFSET; + } +#endif // !TARGET_UNIX && CONTEXT_UNWOUND_TO_CALL + if (pCodeInfo == NULL) { #ifndef TARGET_UNIX @@ -592,7 +599,23 @@ PCODE Thread::VirtualUnwindCallFrame(T_CONTEXT* pContext, if (pFunctionEntry) { - uControlPc = VirtualUnwindNonLeafCallFrame(pContext, pContextPointers, pFunctionEntry, uImageBase); + #ifdef HOST_64BIT + UINT64 EstablisherFrame; + #else // HOST_64BIT + DWORD EstablisherFrame; + #endif // HOST_64BIT + PVOID HandlerData; + + RtlVirtualUnwind(0, + uImageBase, + uControlPc, + pFunctionEntry, + pContext, + &HandlerData, + &EstablisherFrame, + pContextPointers); + + uControlPc = GetIP(pContext); } else { @@ -661,54 +684,6 @@ PCODE Thread::VirtualUnwindLeafCallFrame(T_CONTEXT* pContext) return uControlPc; } -// static -PCODE Thread::VirtualUnwindNonLeafCallFrame(T_CONTEXT* pContext, KNONVOLATILE_CONTEXT_POINTERS* pContextPointers, - PT_RUNTIME_FUNCTION pFunctionEntry, UINT_PTR uImageBase) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(pContext, NULL_NOT_OK)); - PRECONDITION(CheckPointer(pContextPointers, NULL_OK)); - PRECONDITION(CheckPointer(pFunctionEntry, NULL_OK)); - } - CONTRACTL_END; - - PCODE uControlPc = GetIP(pContext); -#ifdef HOST_64BIT - UINT64 EstablisherFrame; -#else // HOST_64BIT - DWORD EstablisherFrame; -#endif // HOST_64BIT - PVOID HandlerData; - - if (NULL == pFunctionEntry) - { -#ifndef TARGET_UNIX - pFunctionEntry = RtlLookupFunctionEntry(uControlPc, - ARM_ONLY((DWORD*))(&uImageBase), - NULL); -#endif - if (NULL == pFunctionEntry) - { - return (PCODE)NULL; - } - } - - RtlVirtualUnwind(0, - uImageBase, - uControlPc, - pFunctionEntry, - pContext, - &HandlerData, - &EstablisherFrame, - pContextPointers); - - uControlPc = GetIP(pContext); - return uControlPc; -} - extern void* g_hostingApiReturnAddress; // static diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index d95b90c6c28911..c84fd8a4dec3be 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -2369,8 +2369,6 @@ class Thread static UINT_PTR VirtualUnwindCallFrame(PREGDISPLAY pRD, EECodeInfo * pCodeInfo = NULL); #ifndef DACCESS_COMPILE static PCODE VirtualUnwindLeafCallFrame(T_CONTEXT* pContext); - static PCODE VirtualUnwindNonLeafCallFrame(T_CONTEXT* pContext, T_KNONVOLATILE_CONTEXT_POINTERS* pContextPointers = NULL, - PT_RUNTIME_FUNCTION pFunctionEntry = NULL, UINT_PTR uImageBase = 0); static UINT_PTR VirtualUnwindToFirstManagedCallFrame(T_CONTEXT* pContext); #endif // DACCESS_COMPILE #endif // FEATURE_EH_FUNCLETS