diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 2515ef351d9217..d510519874a91a 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -109,6 +109,7 @@ if(CLR_CMAKE_TARGET_WIN32) ${STATIC_MT_CRT_LIB} ${STATIC_MT_VCRT_LIB} kernel32.lib + ntdll.lib advapi32.lib ole32.lib oleaut32.lib diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index d9ab0c0c0d5326..57e76f0cf1bf45 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -778,8 +778,6 @@ void EEStartupHelper() IfFailGoLog(EnsureRtlFunctions()); #endif // !TARGET_UNIX - UnwindInfoTable::Initialize(); - // Fire the runtime information ETW event ETW::InfoLog::RuntimeInformation(ETW::InfoLog::InfoStructs::Normal); diff --git a/src/coreclr/vm/codeman.cpp b/src/coreclr/vm/codeman.cpp index ae20106e1a7cd1..a9e7eb3c486ae9 100644 --- a/src/coreclr/vm/codeman.cpp +++ b/src/coreclr/vm/codeman.cpp @@ -92,21 +92,6 @@ unsigned ExecutionManager::m_LCG_JumpStubBlockFullCount; #if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(DACCESS_COMPILE) -// Support for new style unwind information (to allow OS to stack crawl JIT compiled code). - -typedef NTSTATUS (WINAPI* RtlAddGrowableFunctionTableFnPtr) ( - PVOID *DynamicTable, PRUNTIME_FUNCTION FunctionTable, ULONG EntryCount, - ULONG MaximumEntryCount, ULONG_PTR rangeStart, ULONG_PTR rangeEnd); -typedef VOID (WINAPI* RtlGrowFunctionTableFnPtr) (PVOID DynamicTable, ULONG NewEntryCount); -typedef VOID (WINAPI* RtlDeleteGrowableFunctionTableFnPtr) (PVOID DynamicTable); - -// OS entry points (only exist on Win8 and above) -static RtlAddGrowableFunctionTableFnPtr pRtlAddGrowableFunctionTable; -static RtlGrowFunctionTableFnPtr pRtlGrowFunctionTable; -static RtlDeleteGrowableFunctionTableFnPtr pRtlDeleteGrowableFunctionTable; - -static bool s_publishingActive; // Publishing to ETW is turned on - namespace { // Uses unsigned subtraction to handle sequence counter wrapping correctly. @@ -199,40 +184,6 @@ namespace } } -/****************************************************************************/ -// initialize the entry points for new win8 unwind info publishing functions. -// return true if the initialize is successful (the functions exist) -bool InitUnwindFtns() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - HINSTANCE hNtdll = GetModuleHandle(W("ntdll.dll")); - if (hNtdll != NULL) - { - void* growFunctionTable = GetProcAddress(hNtdll, "RtlGrowFunctionTable"); - void* deleteGrowableFunctionTable = GetProcAddress(hNtdll, "RtlDeleteGrowableFunctionTable"); - void* addGrowableFunctionTable = GetProcAddress(hNtdll, "RtlAddGrowableFunctionTable"); - - // All or nothing AddGroableFunctionTable is last (marker) - if (growFunctionTable != NULL && - deleteGrowableFunctionTable != NULL && - addGrowableFunctionTable != NULL) - { - pRtlGrowFunctionTable = (RtlGrowFunctionTableFnPtr) growFunctionTable; - pRtlDeleteGrowableFunctionTable = (RtlDeleteGrowableFunctionTableFnPtr) deleteGrowableFunctionTable; - pRtlAddGrowableFunctionTable = (RtlAddGrowableFunctionTableFnPtr) addGrowableFunctionTable; - } - // Don't call FreeLibrary(hNtdll) because GetModuleHandle did *NOT* increment the reference count! - } - - return (pRtlAddGrowableFunctionTable != NULL); -} - /****************************************************************************/ UnwindInfoTable::UnwindInfoTable(ULONG_PTR rangeStart, ULONG_PTR rangeEnd) : m_publishLock(CrstUnwindInfoTablePublishLock) @@ -272,7 +223,6 @@ UnwindInfoTable::~UnwindInfoTable() NOTHROW; GC_NOTRIGGER; } CONTRACTL_END; - _ASSERTE(s_publishingActive); // We do this lock free to because too many places still want no-trigger. It should be OK // It would be cleaner if we could take the lock (we did not have to be GC_NOTRIGGER) @@ -285,7 +235,7 @@ UnwindInfoTable::~UnwindInfoTable() void UnwindInfoTable::Register() { // Caller holds m_publishLock. - NTSTATUS ret = pRtlAddGrowableFunctionTable(&hHandle, pTable, cTableCurCount, cTableMaxCount, iRangeStart, iRangeEnd); + NTSTATUS ret = RtlAddGrowableFunctionTable(&hHandle, pTable, cTableCurCount, cTableMaxCount, iRangeStart, iRangeEnd); if (ret != STATUS_SUCCESS) { _ASSERTE(!"Failed to publish UnwindInfo (ignorable)"); @@ -307,7 +257,7 @@ void UnwindInfoTable::UnRegister() if (handle != 0) { STRESS_LOG3(LF_JIT, LL_INFO100, "UnwindInfoTable::UnRegister Handle: %p [%p, %p]\n", handle, iRangeStart, iRangeEnd); - pRtlDeleteGrowableFunctionTable(handle); + RtlDeleteGrowableFunctionTable(handle); } } @@ -324,8 +274,6 @@ void UnwindInfoTable::AddToUnwindInfoTable(PT_RUNTIME_FUNCTION data, int count) } CONTRACTL_END; - _ASSERTE(s_publishingActive); - if (m_registrationFailed) return; @@ -408,7 +356,7 @@ LONG UnwindInfoTable::FlushPendingEntriesUnderGate() if (hHandle != NULL) { - pRtlGrowFunctionTable(hHandle, cTableCurCount); + RtlGrowFunctionTable(hHandle, cTableCurCount); } else { @@ -562,9 +510,6 @@ void UnwindInfoTable::FlushPendingEntries(LONG waitForSeq) CONTRACTL_END; _ASSERTE(unwindInfoPtr != NULL); - if (!s_publishingActive) - return; - UnwindInfoTable* unwindInfo = VolatileLoad(unwindInfoPtr); if (unwindInfo == NULL) return; @@ -617,8 +562,6 @@ void UnwindInfoTable::FlushPendingEntries(LONG waitForSeq) /* static */ void UnwindInfoTable::PublishUnwindInfoForMethod(TADDR baseAddress, PT_RUNTIME_FUNCTION methodUnwindData, int methodUnwindDataCount) { STANDARD_VM_CONTRACT; - if (!s_publishingActive) - return; TADDR entry = baseAddress + methodUnwindData->BeginAddress; RangeSection * pRS = ExecutionManager::FindCodeRange(entry, ExecutionManager::GetScanFlags()); @@ -653,9 +596,6 @@ void UnwindInfoTable::FlushPendingEntries(LONG waitForSeq) } CONTRACTL_END; - if (!s_publishingActive) - return; - RangeSection * pRS = ExecutionManager::FindCodeRange(entryPoint, ExecutionManager::GetScanFlags()); _ASSERTE(pRS != NULL); if (pRS != NULL) @@ -672,28 +612,6 @@ void UnwindInfoTable::FlushPendingEntries(LONG waitForSeq) } } -/*****************************************************************************/ -// We only do this on Windows x64 (other platforms use frame-based stack crawling), -// We want good stack traces so we need to publish unwind information so ETW can -// walk the stack. -/* static */ void UnwindInfoTable::Initialize() -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - _ASSERTE(!s_publishingActive); - - // If we don't have the APIs we need, give up - if (!InitUnwindFtns()) - return; - - s_publishingActive = true; -} - #else /* static */ void UnwindInfoTable::PublishUnwindInfoForMethod(TADDR baseAddress, T_RUNTIME_FUNCTION* methodUnwindData, int methodUnwindDataCount) { @@ -705,11 +623,6 @@ void UnwindInfoTable::FlushPendingEntries(LONG waitForSeq) LIMITED_METHOD_CONTRACT; } -/* static */ void UnwindInfoTable::Initialize() -{ - LIMITED_METHOD_CONTRACT; -} - #endif // defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(DACCESS_COMPILE) #if !defined(DACCESS_COMPILE) diff --git a/src/coreclr/vm/codeman.h b/src/coreclr/vm/codeman.h index 93292ca11a3568..5fffee92256cfd 100644 --- a/src/coreclr/vm/codeman.h +++ b/src/coreclr/vm/codeman.h @@ -593,9 +593,7 @@ class LoaderCodeHeap final : public CodeHeap typedef DPTR(class UnwindInfoTable) PTR_UnwindInfoTable; // On Windows x64, publish OS UnwindInfo (accessed from RUNTIME_FUNCTION -// structures) to support the ability unwind the stack. Unfortunately the pre-Win8 -// APIs defined a callback API for publishing this data dynamically that ETW does -// not use (and really can't because the walk happens in the kernel). In Win8 +// structures) to support the ability to unwind the stack. In Win8 and above // new APIs were defined that allow incremental publishing via a table. // // UnwindInfoTable is a class that wraps the OS APIs that we use to publish @@ -615,8 +613,6 @@ class UnwindInfoTable final static void PublishUnwindInfoForMethod(TADDR baseAddress, T_RUNTIME_FUNCTION* methodUnwindData, int methodUnwindDataCount); static void UnpublishUnwindInfoForMethod(TADDR entryPoint); - static void Initialize(); - #if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) private: // These are lower level functions that assume you have found the list of UnwindInfoTable entries