diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index 4450a7df8384ef..1c874152bf706d 100644 --- a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp @@ -297,12 +297,20 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::UnwindStackWalkFrame(StackWalkHan } else if (pIter->GetFrameState() == StackFrameIterator::SFITER_FRAMELESS_METHOD) { - // Skip the new exception handling managed code, the debugger clients are not supposed to see them MethodDesc *pMD = pIter->m_crawl.GetFunction(); + MethodTable *pMT = pMD->GetMethodTable(); + // Skip the exception handling managed code, the debugger clients are not supposed to see them // EH.DispatchEx, EH.RhThrowEx, EH.RhThrowHwEx, ExceptionServices.InternalCalls.SfiInit, ExceptionServices.InternalCalls.SfiNext // and System.Runtime.StackFrameIterator.* - if (pMD->GetMethodTable() == g_pEHClass || pMD->GetMethodTable() == g_pExceptionServicesInternalCallsClass || pMD->GetMethodTable() == g_pStackFrameIteratorClass) + if (pMT == g_pEHClass || pMT == g_pExceptionServicesInternalCallsClass || pMT == g_pStackFrameIteratorClass) + { + continue; + } + + // Skip the runtime helper that invokes the main program entrypoint, the debuggers do not want to see it. + // Environment.CallEntryPoint + if (pMD == g_pEnvironmentCallEntryPointMethodDesc) { continue; } @@ -421,6 +429,11 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetStackWalkCurrentFrameInfo(Stac { ftResult = kManagedExceptionHandlingCodeFrame; } + // Environment.CallEntryPoint + else if (pMD == g_pEnvironmentCallEntryPointMethodDesc) + { + ftResult = kRuntimeEntryPointFrame; + } else { ftResult = kManagedStackFrame; diff --git a/src/coreclr/debug/di/rsstackwalk.cpp b/src/coreclr/debug/di/rsstackwalk.cpp index 23cf231eab5cbc..5a6e7cf629935f 100644 --- a/src/coreclr/debug/di/rsstackwalk.cpp +++ b/src/coreclr/debug/di/rsstackwalk.cpp @@ -602,6 +602,11 @@ HRESULT CordbStackWalk::GetFrameWorker(ICorDebugFrame ** ppFrame) STRESS_LOG1(LF_CORDB, LL_INFO1000, "CSW::GFW - managed exception handling code frame (%p)", this); return S_FALSE; } + else if (ft == IDacDbiInterface::kRuntimeEntryPointFrame) + { + STRESS_LOG1(LF_CORDB, LL_INFO1000, "CSW::GFW - runtime entry point frame (%p)", this); + return S_FALSE; + } else if (ft == IDacDbiInterface::kExplicitFrame) { STRESS_LOG1(LF_CORDB, LL_INFO1000, "CSW::GFW - explicit frame (%p)", this); diff --git a/src/coreclr/debug/ee/controller.cpp b/src/coreclr/debug/ee/controller.cpp index 72b0360c53c3d4..8c04187ee6fe60 100644 --- a/src/coreclr/debug/ee/controller.cpp +++ b/src/coreclr/debug/ee/controller.cpp @@ -6767,14 +6767,21 @@ bool DebuggerStepper::IsInterestingFrame(FrameInfo * pFrame) { LIMITED_METHOD_CONTRACT; - // Ignore managed exception handling frames if (pFrame->md != NULL) { MethodTable *pMT = pFrame->md->GetMethodTable(); + + // Ignore managed exception handling frames if ((pMT == g_pEHClass) || (pMT == g_pExceptionServicesInternalCallsClass)) { return false; } + + // Ignore the runtime helper that invokes the main program entrypoint + if (pFrame->md == g_pEnvironmentCallEntryPointMethodDesc) + { + return false; + } } return true; diff --git a/src/coreclr/debug/inc/dacdbiinterface.h b/src/coreclr/debug/inc/dacdbiinterface.h index 5660b92b11e05e..101670e207892d 100644 --- a/src/coreclr/debug/inc/dacdbiinterface.h +++ b/src/coreclr/debug/inc/dacdbiinterface.h @@ -1231,6 +1231,7 @@ IDacDbiInterface : public IUnknown kNativeStackFrame, kNativeRuntimeUnwindableStackFrame, kManagedExceptionHandlingCodeFrame, + kRuntimeEntryPointFrame, kAtEndOfStack, } FrameType; diff --git a/src/coreclr/inc/dacvars.h b/src/coreclr/inc/dacvars.h index e3265d520b9632..0b07ee0ceb0b15 100644 --- a/src/coreclr/inc/dacvars.h +++ b/src/coreclr/inc/dacvars.h @@ -125,6 +125,8 @@ DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pEHClass, ::g_pEHClass) DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pExceptionServicesInternalCallsClass, ::g_pExceptionServicesInternalCallsClass) DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pStackFrameIteratorClass, ::g_pStackFrameIteratorClass) +DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pEnvironmentCallEntryPointMethodDesc, ::g_pEnvironmentCallEntryPointMethodDesc) + DEFINE_DACVAR(PTR_SString, SString__s_Empty, SString::s_Empty) DEFINE_DACVAR(INT32, ArrayBase__s_arrayBoundsZero, ArrayBase::s_arrayBoundsZero) diff --git a/src/coreclr/vm/assembly.cpp b/src/coreclr/vm/assembly.cpp index 5d227d37f681b0..b2a28d7b7119af 100644 --- a/src/coreclr/vm/assembly.cpp +++ b/src/coreclr/vm/assembly.cpp @@ -1165,8 +1165,6 @@ struct Param bool captureException; } param; -MethodDesc* g_pEnvironmentCallEntryPointMethodDesc = nullptr; - #if defined(TARGET_BROWSER) extern "C" void SystemJS_ResolveMainPromise(int exitCode); #endif // TARGET_BROWSER diff --git a/src/coreclr/vm/debugdebugger.cpp b/src/coreclr/vm/debugdebugger.cpp index 9b11ac63280df3..e96abc4497b250 100644 --- a/src/coreclr/vm/debugdebugger.cpp +++ b/src/coreclr/vm/debugdebugger.cpp @@ -32,8 +32,6 @@ #ifndef DACCESS_COMPILE -extern MethodDesc* g_pEnvironmentCallEntryPointMethodDesc; - // // Notes: // If a managed debugger is attached, this should send the managed UserBreak event. diff --git a/src/coreclr/vm/eepolicy.cpp b/src/coreclr/vm/eepolicy.cpp index 24d3e9168fbd08..f756091105964e 100644 --- a/src/coreclr/vm/eepolicy.cpp +++ b/src/coreclr/vm/eepolicy.cpp @@ -23,8 +23,6 @@ #include "eventtrace.h" #undef ExitProcess -extern MethodDesc* g_pEnvironmentCallEntryPointMethodDesc; - void SafeExitProcess(UINT exitCode, ShutdownCompleteAction sca = SCA_ExitProcessWhenShutdownComplete) { STRESS_LOG2(LF_SYNC, LL_INFO10, "SafeExitProcess: exitCode = %d sca = %d\n", exitCode, sca); @@ -180,7 +178,7 @@ class CallStackLogger MethodDesc* pMD = pCF->GetFunction(); - // Skip Environment.CallEntryPoint so it doesn't appear in vanilla + // Skip Environment.CallEntryPoint so it doesn't appear in // unhandled exception experiences. if (pMD != nullptr && pMD == g_pEnvironmentCallEntryPointMethodDesc) { diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index 5b1a222ec0227d..00f6db4a17d612 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -18,7 +18,6 @@ #include "exinfo.h" #include "configuration.h" -extern MethodDesc* g_pEnvironmentCallEntryPointMethodDesc; extern MethodDesc* g_pThreadStartCallbackMethodDesc; extern MethodDesc* g_pGCRunFinalizersMethodDesc; diff --git a/src/coreclr/vm/vars.cpp b/src/coreclr/vm/vars.cpp index 02e97870b61671..a567a206749c62 100644 --- a/src/coreclr/vm/vars.cpp +++ b/src/coreclr/vm/vars.cpp @@ -112,6 +112,8 @@ GPTR_IMPL(MethodTable, g_pEHClass); GPTR_IMPL(MethodTable, g_pExceptionServicesInternalCallsClass); GPTR_IMPL(MethodTable, g_pStackFrameIteratorClass); +GPTR_IMPL(MethodDesc, g_pEnvironmentCallEntryPointMethodDesc); + GVAL_IMPL_INIT(PTR_WSTR, g_EntryAssemblyPath, NULL); #ifndef DACCESS_COMPILE diff --git a/src/coreclr/vm/vars.hpp b/src/coreclr/vm/vars.hpp index 7558c0882857da..c249db40571b90 100644 --- a/src/coreclr/vm/vars.hpp +++ b/src/coreclr/vm/vars.hpp @@ -381,6 +381,8 @@ GPTR_DECL(MethodTable, g_pEHClass); GPTR_DECL(MethodTable, g_pExceptionServicesInternalCallsClass); GPTR_DECL(MethodTable, g_pStackFrameIteratorClass); +GPTR_DECL(MethodDesc, g_pEnvironmentCallEntryPointMethodDesc); + // Full path to the managed entry assembly - stored for ease of identifying the entry asssembly for diagnostics GVAL_DECL(PTR_WSTR, g_EntryAssemblyPath);