summaryrefslogtreecommitdiff
path: root/src/inc
diff options
context:
space:
mode:
authorJonghyun Park <parjong@gmail.com>2017-01-11 09:48:43 +0900
committerJan Vorlicek <janvorli@microsoft.com>2017-01-11 01:48:43 +0100
commit2fc44782c783f363c1a98e0767f6fa65b5548c95 (patch)
treee188a27a929664f93481f395ca7c4b18c794167d /src/inc
parent09c95bfa26420b7f29d04b5d47a06cf52f430ffe (diff)
downloadcoreclr-2fc44782c783f363c1a98e0767f6fa65b5548c95.tar.gz
coreclr-2fc44782c783f363c1a98e0767f6fa65b5548c95.tar.bz2
coreclr-2fc44782c783f363c1a98e0767f6fa65b5548c95.zip
[x86/Linux] Fix WIN64EXCEPTIONS build error (#8629)
* Move GetUnwindInfo and GetNumberOfUnwindInfos into the real code header This commit fixes #8342. * Use WIN64EXCEPTIONS instead of _TARGET_X86_ * Revise FaultingExceptionFrame This commit revises FaultingExceptionFrame to support WIN64EXCEPTIONS in x86/Linux port. * Add RUNTIME_FUNCTION__EndAddress as NYI * Revise regdisp.h * Revise eetwain.h * Comment out exinfo.cpp if WIN64EXCEPTIONS is defined * Revises excep.cpp * Fix mistmatch in ThrowControlForThread defintion * Revises cgenx86.cpp * Disable SEH-based exception handlers when WIN64EXCEPTIONS is defined * Revise stackwalk.cpp * Revise jitinterface.cpp * Revise readytorun.h * Revise dbgipcevents.h * Revise zapcode.cpp * Revise clrnt.h * Fix Windows build error * Mark FaultingExceptionFrame::UpdateRegDisplay as NYI * Revise per feedback * Revert #if defined(..) as #ifdef * Fix style changes * Fix style changes * Remove #undef _TARGET_X86_ * 2nd attempt to fix Windows build error * Revise per feedback * Revert the chagnes in clrdefinitions.cmake and add BIT32 in CMakeLists.txt * Use !BIT64 instead of BIT32 * Include exceptionhandling.cpp and gcinfodecoder.cpp in build This commit includes exceptionhandling.cpp and gcinfodecoder.cpp in build, and fixes related compile errors. * Fix COMPlus_EndCatch undefined reference * Fix build error * Fix GcInfoDecoder-related undefined references * Fix AdjustContextForVirtualStub undefined reference * Fix GetCallerSP undefined reference * Fix ResetThreadAbortState undefined reference * Attempt to fix Windows build error * Fix CLRNoCatchHandler undefined reference * Another attemp to fix Windows build error * Fix GetXXXFromRedirectedStubStackFrame undefined references * Fix Windows Build Error * Add RtlpGetFunctionEndAddress and RtlVirtualUnwind as NYI * Fix undefined references on JIT helpers * Enable Dummy Application Run with WIN64EXCEPTIONS * Revert "Move GetUnwindInfo and GetNumberOfUnwindInfos into the real code header" This reverts commit c2bad85ac1136be3c6fb6ad7eedc5b3814b2ab29. * Use indirect code header when WIN64EXCEPTIONS is enabled * Port 'SyncRegDisplayToCurrentContext' and 'FillRegDisplay' * Revise style 'RUNTIME_FUNCTION__SetUnwindInfoAddress' * Extract out HandlerData from #ifdef region * Add UNIXTODO * Add UNIXTODO * Port 'GetRegdisplayReturnValue' * Fix incorrect comment * Remove messages that mentions WIN32EXCEPTIONS * Revise AdjustContextForWriteBarrier * Port 'FaultingExceptionFrame::UpdateRegDisplay' * Extract out 'AdjustContextForVirtualStub' and 'CLRNoCatchHandler' from #ifdef region * Merge two #ifdef regions * Set WIN64EXCEPTIONS as a default for x86/Linux * Remove unnecessary #ifdef from ThrowControlForThread * Remove unnecessary stubs * Add Dependency Check between Compile Flags * Revise per feedback
Diffstat (limited to 'src/inc')
-rw-r--r--src/inc/clrnt.h44
-rw-r--r--src/inc/corcompile.h14
-rw-r--r--src/inc/eetwain.h2
-rw-r--r--src/inc/gcinfodecoder.h2
-rw-r--r--src/inc/jithelpers.h3
-rw-r--r--src/inc/readytorun.h2
-rw-r--r--src/inc/regdisp.h164
-rw-r--r--src/inc/switches.h2
8 files changed, 140 insertions, 93 deletions
diff --git a/src/inc/clrnt.h b/src/inc/clrnt.h
index 0e082c79d5..9a4601ebaf 100644
--- a/src/inc/clrnt.h
+++ b/src/inc/clrnt.h
@@ -837,6 +837,13 @@ RtlVirtualUnwind_Unsafe(
#ifdef _TARGET_X86_
#ifndef FEATURE_PAL
+//
+// x86 ABI does not define RUNTIME_FUNCTION. Define our own to allow unification between x86 and other platforms.
+//
+typedef struct _RUNTIME_FUNCTION {
+ DWORD BeginAddress;
+ DWORD UnwindData;
+} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
typedef struct _DISPATCHER_CONTEXT {
_EXCEPTION_REGISTRATION_RECORD* RegistrationPointer;
@@ -845,6 +852,43 @@ typedef struct _DISPATCHER_CONTEXT {
#endif // !FEATURE_PAL
#define RUNTIME_FUNCTION__BeginAddress(prf) (prf)->BeginAddress
+#define RUNTIME_FUNCTION__SetBeginAddress(prf,addr) ((prf)->BeginAddress = (addr))
+
+#ifdef WIN64EXCEPTIONS
+EXTERN_C ULONG
+RtlpGetFunctionEndAddress (
+ __in PT_RUNTIME_FUNCTION FunctionEntry,
+ __in ULONG ImageBase
+ );
+
+#define RUNTIME_FUNCTION__EndAddress(prf, ImageBase) RtlpGetFunctionEndAddress(prf, ImageBase)
+
+#define RUNTIME_FUNCTION__GetUnwindInfoAddress(prf) (prf)->UnwindData
+#define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf, addr) do { (prf)->UnwindData = (addr); } while(0)
+
+#define UNW_FLAG_NHANDLER 0x0 /* any handler */
+#define UNW_FLAG_EHANDLER 0x1 /* filter handler */
+#define UNW_FLAG_UHANDLER 0x2 /* unwind handler */
+
+typedef struct _UNWIND_INFO {
+ // dummy
+} UNWIND_INFO, *PUNWIND_INFO;
+
+EXTERN_C
+NTSYSAPI
+PEXCEPTION_ROUTINE
+NTAPI
+RtlVirtualUnwind (
+ __in DWORD HandlerType,
+ __in DWORD ImageBase,
+ __in DWORD ControlPc,
+ __in PRUNTIME_FUNCTION FunctionEntry,
+ __inout PT_CONTEXT ContextRecord,
+ __out PVOID *HandlerData,
+ __out PDWORD EstablisherFrame,
+ __inout_opt PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers
+ );
+#endif // WIN64EXCEPTIONS
#endif // _TARGET_X86_
diff --git a/src/inc/corcompile.h b/src/inc/corcompile.h
index 3b517ae212..73463146c6 100644
--- a/src/inc/corcompile.h
+++ b/src/inc/corcompile.h
@@ -22,11 +22,11 @@
#error FEATURE_PREJIT is required for this file
#endif // FEATURE_PREJIT
-#if !defined(_TARGET_X86_)
+#if !defined(_TARGET_X86_) || defined(FEATURE_PAL)
#ifndef WIN64EXCEPTIONS
#define WIN64EXCEPTIONS
#endif
-#endif // !_TARGET_X86_
+#endif // !_TARGET_X86_ || FEATURE_PAL
#include <cor.h>
#include <corhdr.h>
@@ -72,16 +72,6 @@ typedef DPTR(struct CORCOMPILE_IMPORT_SECTION)
PTR_CORCOMPILE_IMPORT_SECTION;
#ifdef _TARGET_X86_
-#ifndef FEATURE_PAL
-//
-// x86 ABI does not define RUNTIME_FUNCTION. Define our own to allow unification between x86 and other platforms.
-//
-typedef struct _RUNTIME_FUNCTION {
- DWORD BeginAddress;
- DWORD UnwindData;
-} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
-
-#endif // !FEATURE_PAL
typedef DPTR(RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION;
diff --git a/src/inc/eetwain.h b/src/inc/eetwain.h
index 502d181962..55cc905576 100644
--- a/src/inc/eetwain.h
+++ b/src/inc/eetwain.h
@@ -602,7 +602,7 @@ HRESULT FixContextForEnC(PCONTEXT pCtx,
#endif // #ifndef DACCESS_COMPILE
-#ifndef _TARGET_X86_
+#ifdef WIN64EXCEPTIONS
static void EnsureCallerContextIsValid( PREGDISPLAY pRD, StackwalkCacheEntry* pCacheEntry, EECodeInfo * pCodeInfo = NULL );
static size_t GetCallerSp( PREGDISPLAY pRD );
#endif
diff --git a/src/inc/gcinfodecoder.h b/src/inc/gcinfodecoder.h
index 6d4850ad67..5151616229 100644
--- a/src/inc/gcinfodecoder.h
+++ b/src/inc/gcinfodecoder.h
@@ -451,6 +451,7 @@ private:
GcSlotDesc* m_pLastSlot;
};
+#ifdef USE_GC_INFO_DECODER
class GcInfoDecoder
{
public:
@@ -678,6 +679,7 @@ private:
}
}
};
+#endif // USE_GC_INFO_DECODER
#endif // _GC_INFO_DECODER_
diff --git a/src/inc/jithelpers.h b/src/inc/jithelpers.h
index f84db9142d..89d4be7efc 100644
--- a/src/inc/jithelpers.h
+++ b/src/inc/jithelpers.h
@@ -135,7 +135,8 @@
JITHELPER(CORINFO_HELP_FIELD_ACCESS_EXCEPTION,JIT_ThrowFieldAccessException, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_CLASS_ACCESS_EXCEPTION,JIT_ThrowClassAccessException, CORINFO_HELP_SIG_REG_ONLY)
-#ifdef WIN64EXCEPTIONS
+// UNIXTODO: Disable JIT_EndCatch after revising the jitter not to use this (for x86/Linux)
+#ifndef _TARGET_X86_
JITHELPER(CORINFO_HELP_ENDCATCH, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB)
#else
JITHELPER(CORINFO_HELP_ENDCATCH, JIT_EndCatch, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB)
diff --git a/src/inc/readytorun.h b/src/inc/readytorun.h
index 9204862e17..ebc557b6f1 100644
--- a/src/inc/readytorun.h
+++ b/src/inc/readytorun.h
@@ -279,7 +279,7 @@ enum ReadyToRunHelper
READYTORUN_HELPER_DblRound = 0xE2,
READYTORUN_HELPER_FltRound = 0xE3,
-#ifndef _TARGET_X86_
+#ifdef WIN64EXCEPTIONS
// Personality rountines
READYTORUN_HELPER_PersonalityRoutine = 0xF0,
READYTORUN_HELPER_PersonalityRoutineFilterFunclet = 0xF1,
diff --git a/src/inc/regdisp.h b/src/inc/regdisp.h
index 09a6a38f62..81143466cd 100644
--- a/src/inc/regdisp.h
+++ b/src/inc/regdisp.h
@@ -18,10 +18,33 @@ struct REGDISPLAY {
// returned by GetContext or provided
// at exception time.
+#ifndef WIN64EXCEPTIONS
// TODO: Unify with pCurrentContext / pCallerContext used on 64-bit
PCONTEXT pContextForUnwind; // scratch context for unwinding
// used to preserve context saved in the frame that
// could be otherwise wiped by the unwinding
+#else // !WIN64EXCEPTIONS
+ PT_CONTEXT pCurrentContext; // [trashed] points to current Context of stackwalk
+ PT_CONTEXT pCallerContext; // [trashed] points to the Context of the caller during stackwalk -- used for GC crawls
+
+ // [trashed] points to current context pointers of stackwalk
+ T_KNONVOLATILE_CONTEXT_POINTERS *pCurrentContextPointers;
+ // [trashed] points to the context pointers of the caller during stackwalk -- used for GC crawls
+ T_KNONVOLATILE_CONTEXT_POINTERS *pCallerContextPointers;
+
+ BOOL IsCallerContextValid; // TRUE if pCallerContext really contains the caller's context
+ BOOL IsCallerSPValid; // Don't add usage of this field. This is only temporary.
+
+ T_CONTEXT ctxOne; // used by stackwalk
+ T_CONTEXT ctxTwo; // used by stackwalk
+
+ T_KNONVOLATILE_CONTEXT_POINTERS ctxPtrsOne; // used by stackwalk
+ T_KNONVOLATILE_CONTEXT_POINTERS ctxPtrsTwo; // used by stackwalk
+
+#ifdef DEBUG_REGDISPLAY
+ Thread *_pThread;
+#endif // DEBUG_REGDISPLAY
+#endif // !WIN64EXCEPTIONS
DWORD * pEdi;
DWORD * pEsi;
@@ -166,18 +189,6 @@ inline PCODE GetControlPC(REGDISPLAY *display) {
void CheckRegDisplaySP (REGDISPLAY *pRD);
#endif // DEBUG_REGDISPLAY
-inline void SyncRegDisplayToCurrentContext(REGDISPLAY* pRD)
-{
- LIMITED_METHOD_CONTRACT;
-
- pRD->SP = (INT_PTR)GetSP(pRD->pCurrentContext);
-
-#ifdef DEBUG_REGDISPLAY
- CheckRegDisplaySP(pRD);
-#endif // DEBUG_REGDISPLAY
-
- pRD->ControlPC = INT_PTR(GetIP(pRD->pCurrentContext));
-}
// This function tells us if the given stack pointer is in one of the frames of the functions called by the given frame
inline BOOL IsInCalleesFrames(REGDISPLAY *display, LPVOID stackPointer)
@@ -204,20 +215,6 @@ inline TADDR GetRegdisplayStackMark(REGDISPLAY *display)
#endif // _TARGET_AMD64_
}
-// This needs to be implemented for platforms that have funclets.
-inline LPVOID GetRegdisplayReturnValue(REGDISPLAY *display)
-{
- LIMITED_METHOD_CONTRACT;
-
-#if defined(_TARGET_AMD64_)
- return (LPVOID)display->pCurrentContext->Rax;
-#elif defined(_TARGET_ARM64_)
- return (LPVOID)display->pCurrentContext->X0;
-#else
- PORTABILITY_ASSERT("GetRegdisplayReturnValue NYI for this platform (Regdisp.h)");
- return NULL;
-#endif
-}
#elif defined(_TARGET_ARM_)
@@ -307,20 +304,7 @@ inline TADDR GetRegdisplayStackMark(REGDISPLAY *display) {
return GetSP(display->pCallerContext);
}
-inline void SyncRegDisplayToCurrentContext(REGDISPLAY* pRD)
-{
- LIMITED_METHOD_CONTRACT;
- pRD->SP = (DWORD)GetSP(pRD->pCurrentContext);
- pRD->ControlPC = (DWORD)GetIP(pRD->pCurrentContext);
-}
-
-// This needs to be implemented for platforms that have funclets.
-inline LPVOID GetRegdisplayReturnValue(REGDISPLAY *display)
-{
- LIMITED_METHOD_CONTRACT;
- return (LPVOID)display->pCurrentContext->R0;
-}
#else // none of the above processors
@@ -359,6 +343,50 @@ inline LPVOID GetRegdisplayStackMark(REGDISPLAY *display) {
#endif
+#if defined(_WIN64) || defined(_TARGET_ARM_) || (defined(_TARGET_X86_) && defined(WIN64EXCEPTIONS))
+// This needs to be implemented for platforms that have funclets.
+inline LPVOID GetRegdisplayReturnValue(REGDISPLAY *display)
+{
+ LIMITED_METHOD_CONTRACT;
+
+#if defined(_TARGET_AMD64_)
+ return (LPVOID)display->pCurrentContext->Rax;
+#elif defined(_TARGET_ARM64_)
+ return (LPVOID)display->pCurrentContext->X0;
+#elif defined(_TARGET_ARM_)
+ return (LPVOID)display->pCurrentContext->R0;
+#elif defined(_TARGET_X86_)
+ return (LPVOID)display->pCurrentContext->Eax;
+#else
+ PORTABILITY_ASSERT("GetRegdisplayReturnValue NYI for this platform (Regdisp.h)");
+ return NULL;
+#endif
+}
+
+inline void SyncRegDisplayToCurrentContext(REGDISPLAY* pRD)
+{
+ LIMITED_METHOD_CONTRACT;
+
+#if defined(_WIN64)
+ pRD->SP = (INT_PTR)GetSP(pRD->pCurrentContext);
+
+#ifdef DEBUG_REGDISPLAY
+ CheckRegDisplaySP(pRD);
+#endif // DEBUG_REGDISPLAY
+
+ pRD->ControlPC = INT_PTR(GetIP(pRD->pCurrentContext));
+#elif defined(_TARGET_ARM_) // _WIN64
+ pRD->SP = (DWORD)GetSP(pRD->pCurrentContext);
+ pRD->ControlPC = (DWORD)GetIP(pRD->pCurrentContext);
+#elif defined(_TARGET_X86_) // _TARGET_ARM_
+ pRD->Esp = (DWORD)GetSP(pRD->pCurrentContext);
+ pRD->ControlPC = (DWORD)GetIP(pRD->pCurrentContext);
+#else // _TARGET_X86_
+ PORTABILITY_ASSERT("SyncRegDisplayToCurrentContext");
+#endif // _TARGET_ARM_ || _TARGET_X86_
+}
+#endif // _WIN64 || _TARGET_ARM_ || (_TARGET_X86_ && WIN64EXCEPTIONS)
+
typedef REGDISPLAY *PREGDISPLAY;
@@ -368,6 +396,7 @@ inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pC
SUPPORTS_DAC;
+#ifndef WIN64EXCEPTIONS
#ifdef _TARGET_X86_
pRD->pContext = pctx;
pRD->pContextForUnwind = NULL;
@@ -381,57 +410,38 @@ inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pC
pRD->Esp = pctx->Esp;
pRD->ControlPC = (PCODE)(pctx->Eip);
pRD->PCTAddr = (UINT_PTR)&(pctx->Eip);
-#elif defined(_WIN64)
+#else // _TARGET_X86_
+ PORTABILITY_ASSERT("FillRegDisplay");
+#endif // _TARGET_???_ (ELSE)
+
+#else // !WIN64EXCEPTIONS
pRD->pContext = pctx;
#ifdef _TARGET_AMD64_
for (int i = 0; i < 16; i++)
{
*(&pRD->ctxPtrsOne.Rax + i) = (&pctx->Rax + i);
}
-#elif defined(_TARGET_ARM64_)
+#elif defined(_TARGET_ARM64_) // _TARGET_AMD64_
for (int i = 0; i < 12; i++)
{
*(&pRD->ctxPtrsOne.X19 + i) = (&pctx->X19 + i);
}
-#endif // _TARGET_AMD64_
-
- pRD->pCurrentContextPointers = &pRD->ctxPtrsOne;
- pRD->pCallerContextPointers = &pRD->ctxPtrsTwo;
-
- pRD->pCurrentContext = &(pRD->ctxOne);
- pRD->pCallerContext = &(pRD->ctxTwo);
-
- // copy the active context to initialize our stackwalk
- *(pRD->pCurrentContext) = *(pctx);
-
- // copy the caller context as well if it's specified
- if (pCallerCtx == NULL)
- {
- pRD->IsCallerContextValid = FALSE;
- pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary.
- }
- else
- {
- *(pRD->pCallerContext) = *(pCallerCtx);
- pRD->IsCallerContextValid = TRUE;
- pRD->IsCallerSPValid = TRUE; // Don't add usage of this field. This is only temporary.
- }
-
-#ifdef DEBUG_REGDISPLAY
- pRD->_pThread = NULL;
-#endif // DEBUG_REGDISPLAY
-
- SyncRegDisplayToCurrentContext(pRD);
-#elif defined(_TARGET_ARM_)
- pRD->pContext = pctx;
-
+#elif defined(_TARGET_ARM_) // _TARGET_ARM64_
// Copy over the nonvolatile integer registers (R4-R11)
for (int i = 0; i < 8; i++)
{
*(&pRD->ctxPtrsOne.R4 + i) = (&pctx->R4 + i);
}
- pRD->ctxPtrsOne.Lr = &pctx->Lr;
+ pRD->ctxPtrsOne.Lr = &pctx->Lr;
+#elif defined(_TARGET_X86_) // _TARGET_ARM_
+ for (int i = 0; i < 4; ++i)
+ {
+ *(&pRD->ctxPtrsOne.Ebx + i) = (&pctx->Ebx + i);
+ }
+#else // _TARGET_X86_
+ PORTABILITY_ASSERT("FillRegDisplay");
+#endif // _TARGET_???_ (ELSE)
// Setup the references
pRD->pCurrentContextPointers = &pRD->ctxPtrsOne;
@@ -456,7 +466,9 @@ inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pC
pRD->IsCallerSPValid = TRUE; // Don't add usage of this field. This is only temporary.
}
+#ifdef _TARGET_ARM_
pRD->pPC = &pRD->pCurrentContext->Pc;
+#endif
#ifdef DEBUG_REGDISPLAY
pRD->_pThread = NULL;
@@ -464,9 +476,7 @@ inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pC
// This will setup the PC and SP
SyncRegDisplayToCurrentContext(pRD);
-#else
- PORTABILITY_ASSERT("@NYI Platform - InitRegDisplay (Threads.cpp)");
-#endif
+#endif // !WIN64EXCEPTIONS
}
// Initialize a new REGDISPLAY/CONTEXT pair from an existing valid REGDISPLAY.
diff --git a/src/inc/switches.h b/src/inc/switches.h
index f52f24bc67..bb3ca28e12 100644
--- a/src/inc/switches.h
+++ b/src/inc/switches.h
@@ -37,7 +37,7 @@
#define LOGGING
#endif
-#if !defined(_TARGET_X86_)
+#if !defined(_TARGET_X86_) || defined(FEATURE_PAL)
#define WIN64EXCEPTIONS
#endif