From: Jonghyun Park Date: Wed, 22 Feb 2017 14:43:30 +0000 (+0900) Subject: Clean up ClrUnwindEx (dotnet/coreclr#9482) X-Git-Tag: submit/tizen/20210909.063632~11030^2~8008 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f52fa07e39b004793ebc75899579e4d51f2fa291;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Clean up ClrUnwindEx (dotnet/coreclr#9482) * Clean up ClrUnwindEx Commit migrated from https://github.com/dotnet/coreclr/commit/1f5cae07e65d646fd57fdca7376d4b2f1dccad00 --- diff --git a/src/coreclr/src/debug/ee/debugger.cpp b/src/coreclr/src/debug/ee/debugger.cpp index b19ae9a..0967c56 100644 --- a/src/coreclr/src/debug/ee/debugger.cpp +++ b/src/coreclr/src/debug/ee/debugger.cpp @@ -8134,8 +8134,7 @@ LONG Debugger::NotifyOfCHFFilter(EXCEPTION_POINTERS* pExceptionPointers, PVOID p pExState->GetFlags()->SetDebugCatchHandlerFound(); #ifdef DEBUGGING_SUPPORTED - - +#ifdef DEBUGGER_EXCEPTION_INTERCEPTION_SUPPORTED if ( (pThread != NULL) && (pThread->IsExceptionInProgress()) && (pThread->GetExceptionState()->GetFlags()->DebuggerInterceptInfo()) ) @@ -8146,6 +8145,7 @@ LONG Debugger::NotifyOfCHFFilter(EXCEPTION_POINTERS* pExceptionPointers, PVOID p // ClrDebuggerDoUnwindAndIntercept(X86_FIRST_ARG(EXCEPTION_CHAIN_END) pExceptionPointers->ExceptionRecord); } +#endif // DEBUGGER_EXCEPTION_INTERCEPTION_SUPPORTED #endif // DEBUGGING_SUPPORTED return EXCEPTION_CONTINUE_SEARCH; diff --git a/src/coreclr/src/vm/excep.cpp b/src/coreclr/src/vm/excep.cpp index a9c38ee..6c42739 100644 --- a/src/coreclr/src/vm/excep.cpp +++ b/src/coreclr/src/vm/excep.cpp @@ -4003,6 +4003,7 @@ LONG NotifyDebuggerLastChance(Thread *pThread, UNINSTALL_NESTED_EXCEPTION_HANDLER(); +#ifdef DEBUGGER_EXCEPTION_INTERCEPTION_SUPPORTED EX_TRY { // if the debugger wants to intercept the unhandled exception then we immediately unwind without returning @@ -4022,6 +4023,7 @@ LONG NotifyDebuggerLastChance(Thread *pThread, { } EX_END_CATCH(SwallowAllExceptions); +#endif // DEBUGGER_EXCEPTION_INTERCEPTION_SUPPORTED return retval; } diff --git a/src/coreclr/src/vm/excep.h b/src/coreclr/src/vm/excep.h index 13d8a3b..4c75293 100644 --- a/src/coreclr/src/vm/excep.h +++ b/src/coreclr/src/vm/excep.h @@ -745,9 +745,16 @@ bool IsInterceptableException(Thread *pThread); // perform simple checking to see if the current exception is intercepted bool CheckThreadExceptionStateForInterception(); +#ifndef FEATURE_PAL +// Currently, only Windows supports ClrUnwindEx (used inside ClrDebuggerDoUnwindAndIntercept) +#define DEBUGGER_EXCEPTION_INTERCEPTION_SUPPORTED +#endif // !FEATURE_PAL + +#ifdef DEBUGGER_EXCEPTION_INTERCEPTION_SUPPORTED // Intercept the current exception and start an unwind. This function may never return. EXCEPTION_DISPOSITION ClrDebuggerDoUnwindAndIntercept(X86_FIRST_ARG(EXCEPTION_REGISTRATION_RECORD *pEstablisherFrame) EXCEPTION_RECORD *pExceptionRecord); +#endif // DEBUGGER_EXCEPTION_INTERCEPTION_SUPPORTED LONG NotifyDebuggerLastChance(Thread *pThread, EXCEPTION_POINTERS *pExceptionInfo, diff --git a/src/coreclr/src/vm/exceptionhandling.cpp b/src/coreclr/src/vm/exceptionhandling.cpp index 29906c5..1e51467 100644 --- a/src/coreclr/src/vm/exceptionhandling.cpp +++ b/src/coreclr/src/vm/exceptionhandling.cpp @@ -79,12 +79,6 @@ static void DoEHLog(DWORD lvl, __in_z const char *fmt, ...); TrackerAllocator g_theTrackerAllocator; -void __declspec(noinline) -ClrUnwindEx(EXCEPTION_RECORD* pExceptionRecord, - UINT_PTR ReturnValue, - UINT_PTR TargetIP, - UINT_PTR TargetFrameSp); - bool FixNonvolatileRegisters(UINT_PTR uOriginalSP, Thread* pThread, CONTEXT* pContextRecord, @@ -4112,6 +4106,7 @@ void ExceptionTracker::MakeCallbacksRelatedToHandler( } } +#ifdef DEBUGGER_EXCEPTION_INTERCEPTION_SUPPORTED //--------------------------------------------------------------------------------------- // // This function is called by DefaultCatchHandler() to intercept an exception and start an unwind. @@ -4148,6 +4143,7 @@ EXCEPTION_DISPOSITION ClrDebuggerDoUnwindAndIntercept(X86_FIRST_ARG(EXCEPTION_RE UNREACHABLE(); } +#endif // DEBUGGER_EXCEPTION_INTERCEPTION_SUPPORTED #endif // DEBUGGING_SUPPORTED #ifdef _DEBUG @@ -5116,9 +5112,9 @@ BOOL HandleHardwareException(PAL_SEHException* ex) #endif // FEATURE_PAL +#ifndef FEATURE_PAL void ClrUnwindEx(EXCEPTION_RECORD* pExceptionRecord, UINT_PTR ReturnValue, UINT_PTR TargetIP, UINT_PTR TargetFrameSp) { -#ifndef FEATURE_PAL PVOID TargetFrame = (PVOID)TargetFrameSp; CONTEXT ctx; @@ -5129,13 +5125,10 @@ void ClrUnwindEx(EXCEPTION_RECORD* pExceptionRecord, UINT_PTR ReturnValue, UINT_ &ctx, NULL); // HistoryTable -#else // !FEATURE_PAL - PORTABILITY_ASSERT("UNIXTODO: Implement unwinding for PAL"); -#endif // !FEATURE_PAL - // doesn't return UNREACHABLE(); } +#endif // !FEATURE_PAL void TrackerAllocator::Init() { diff --git a/src/coreclr/src/vm/exceptionhandling.h b/src/coreclr/src/vm/exceptionhandling.h index c6fe35a..71bcab7 100644 --- a/src/coreclr/src/vm/exceptionhandling.h +++ b/src/coreclr/src/vm/exceptionhandling.h @@ -26,11 +26,13 @@ ProcessCLRException(IN PEXCEPTION_RECORD pExceptionRecord IN OUT PT_DISPATCHER_CONTEXT pDispatcherContext); +#ifndef FEATURE_PAL void __declspec(noinline) ClrUnwindEx(EXCEPTION_RECORD* pExceptionRecord, UINT_PTR ReturnValue, UINT_PTR TargetIP, UINT_PTR TargetFrameSp); +#endif // !FEATURE_PAL typedef DWORD_PTR (HandlerFn)(UINT_PTR uStackFrame, Object* pExceptionObj);