Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
93 changes: 3 additions & 90 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
{
Comment thread
jkotas marked this conversation as resolved.
_ASSERTE(!"Failed to publish UnwindInfo (ignorable)");
Expand All @@ -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);
}
}

Expand All @@ -324,8 +274,6 @@ void UnwindInfoTable::AddToUnwindInfoTable(PT_RUNTIME_FUNCTION data, int count)
}
CONTRACTL_END;

_ASSERTE(s_publishingActive);

if (m_registrationFailed)
return;

Expand Down Expand Up @@ -408,7 +356,7 @@ LONG UnwindInfoTable::FlushPendingEntriesUnderGate()

if (hHandle != NULL)
{
pRtlGrowFunctionTable(hHandle, cTableCurCount);
RtlGrowFunctionTable(hHandle, cTableCurCount);
}
else
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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)
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/vm/codeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
jkotas marked this conversation as resolved.
//
// UnwindInfoTable is a class that wraps the OS APIs that we use to publish
Expand All @@ -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
Expand Down
Loading