Skip to content

Commit

Permalink
Update ILToNativeMap event to include IL version (dotnet#71479)
Browse files Browse the repository at this point in the history
* Update eventtrace.cpp

* Add native code ID and IL code ID
  • Loading branch information
davmason committed Jul 7, 2022
1 parent 34383d1 commit 32ca998
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/inc/eventtracebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ namespace ETW
BOOL fGetCodeIds);
static VOID SendEventsForNgenMethods(Module *pModule, DWORD dwEventOptions);
static VOID SendMethodJitStartEvent(MethodDesc *pMethodDesc, SString *namespaceOrClassName=NULL, SString *methodName=NULL, SString *methodSignature=NULL);
static VOID SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWORD dwEventOptions, PCODE pNativeCodeStartAddress, ReJITID ilCodeId);
static VOID SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWORD dwEventOptions, PCODE pNativeCodeStartAddress, DWORD nativeCodeId, ReJITID ilCodeId);
static VOID SendMethodEvent(MethodDesc *pMethodDesc, DWORD dwEventOptions, BOOL bIsJit, SString *namespaceOrClassName=NULL, SString *methodName=NULL, SString *methodSignature=NULL, PCODE pNativeCodeStartAddress = 0, PrepareCodeConfig *pConfig = NULL);
static VOID SendHelperEvent(ULONGLONG ullHelperStartAddress, ULONG ulHelperSize, LPCWSTR pHelperName);
static VOID SendMethodDetailsEvent(MethodDesc *pMethodDesc);
Expand Down
63 changes: 63 additions & 0 deletions src/coreclr/vm/ClrEtwAll.man
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,27 @@
</UserData>
</template>

<template tid="MethodILToNativeMap_V1">
<data name="MethodID" inType="win:UInt64" outType="win:HexInt64" />
<data name="ReJITID" inType="win:UInt64" outType="win:HexInt64" />
<data name="MethodExtent" inType="win:UInt8" />
<data name="CountOfMapEntries" inType="win:UInt16" />
<data name="ILOffsets" count="CountOfMapEntries" inType="win:UInt32" />
<data name="NativeOffsets" count="CountOfMapEntries" inType="win:UInt32" />
<data name="ClrInstanceID" inType="win:UInt16" />
<data name="ILVersionID" inType="win:UInt64" />
<UserData>
<MethodILToNativeMap xmlns="myNs">
<MethodID> %1 </MethodID>
<ReJITID> %2 </ReJITID>
<MethodExtent> %3 </MethodExtent>
<CountOfMapEntries> %4 </CountOfMapEntries>
<ClrInstanceID> %5 </ClrInstanceID>
<ILVersionID> %6 </ILVersionID>
</MethodILToNativeMap>
</UserData>
</template>

<template tid="ClrStackWalk">
<data name="ClrInstanceID" inType="win:UInt16" />
<data name="Reserved1" inType="win:UInt8" />
Expand Down Expand Up @@ -3821,6 +3842,12 @@
symbol="MethodILToNativeMap"
message="$(string.RuntimePublisher.MethodILToNativeMapEventMessage)"/>

<event value="190" version="1" level="win:Verbose" template="MethodILToNativeMap_V1"
keywords ="JittedMethodILToNativeMapKeyword" opcode="MethodILToNativeMap"
task="CLRMethod"
symbol="MethodILToNativeMap_V1"
message="$(string.RuntimePublisher.MethodILToNativeMapEventMessage_V1)"/>

<event value="191" version="0" level="win:Verbose" template="MethodJitTailCallFailed"
keywords ="JitTracingKeyword" opcode="JitTailCallFailed"
task="CLRMethod"
Expand Down Expand Up @@ -4755,6 +4782,27 @@
</UserData>
</template>

<template tid="MethodILToNativeMapRundown_V1">
<data name="MethodID" inType="win:UInt64" outType="win:HexInt64" />
<data name="ReJITID" inType="win:UInt64" outType="win:HexInt64" />
<data name="MethodExtent" inType="win:UInt8" />
<data name="CountOfMapEntries" inType="win:UInt16" />
<data name="ILOffsets" count="CountOfMapEntries" inType="win:UInt32" />
<data name="NativeOffsets" count="CountOfMapEntries" inType="win:UInt32" />
<data name="ClrInstanceID" inType="win:UInt16" />
<data name="ILVersionID" inType="win:UInt64" />
<UserData>
<MethodILToNativeMap_V1 xmlns="myNs">
<MethodID> %1 </MethodID>
<ReJITID> %2 </ReJITID>
<MethodExtent> %3 </MethodExtent>
<CountOfMapEntries> %4 </CountOfMapEntries>
<ClrInstanceID> %5 </ClrInstanceID>
<ILVersionID> %6 </ILVersionID>
</MethodILToNativeMap_V1>
</UserData>
</template>

<template tid="DCStartEnd">
<data name="ClrInstanceID" inType="win:UInt16" />

Expand Down Expand Up @@ -4955,12 +5003,24 @@
symbol="MethodDCStartILToNativeMap"
message="$(string.RundownPublisher.MethodDCStartILToNativeMapEventMessage)"/>

<event value="149" version="1" level="win:Verbose" template="MethodILToNativeMapRundown_V1"
keywords ="JittedMethodILToNativeMapRundownKeyword" opcode="MethodDCStartILToNativeMap"
task="CLRMethodRundown"
symbol="MethodDCStartILToNativeMap_V1"
message="$(string.RundownPublisher.MethodDCStartILToNativeMapEventMessage_V1)"/>

<event value="150" version="0" level="win:Verbose" template="MethodILToNativeMapRundown"
keywords ="JittedMethodILToNativeMapRundownKeyword" opcode="MethodDCEndILToNativeMap"
task="CLRMethodRundown"
symbol="MethodDCEndILToNativeMap"
message="$(string.RundownPublisher.MethodDCEndILToNativeMapEventMessage)"/>

<event value="150" version="1" level="win:Verbose" template="MethodILToNativeMapRundown_V1"
keywords ="JittedMethodILToNativeMapRundownKeyword" opcode="MethodDCEndILToNativeMap"
task="CLRMethodRundown"
symbol="MethodDCEndILToNativeMap_V1"
message="$(string.RundownPublisher.MethodDCEndILToNativeMapEventMessage_V1)"/>

<!-- CLR Loader Rundown Events -->
<event value="151" version="0" level="win:Informational" template="DomainModuleLoadUnloadRundown"
keywords ="LoaderRundownKeyword" opcode="DomainModuleDCStart"
Expand Down Expand Up @@ -8362,6 +8422,7 @@
<string id="RuntimePublisher.MethodJittingStartedEventMessage" value="MethodID=%1;%nModuleID=%2;%nMethodToken=%3;%nMethodILSize=%4;%nMethodNamespace=%5;%nMethodName=%6;%nMethodSignature=%7" />
<string id="RuntimePublisher.MethodJittingStarted_V1EventMessage" value="MethodID=%1;%nModuleID=%2;%nMethodToken=%3;%nMethodILSize=%4;%nMethodNamespace=%5;%nMethodName=%6;%nMethodSignature=%7;%nClrInstanceID=%8" />
<string id="RuntimePublisher.MethodILToNativeMapEventMessage" value="MethodID=%1;%nReJITID=%2;%nMethodExtent=%3;%nCountOfMapEntries=%4;%nClrInstanceID=%5" />
<string id="RuntimePublisher.MethodILToNativeMapEventMessage_V1" value="MethodID=%1;%nReJITID=%2;%nMethodExtent=%3;%nCountOfMapEntries=%4;%nClrInstanceID=%5;%nILVersionID=%6" />
<string id="RuntimePublisher.DomainModuleLoadEventMessage" value="ModuleID=%1;%nAssemblyID=%2;%nAppDomainID=%3;%nModuleFlags=%4;%nModuleILPath=%5;ModuleNativePath=%6" />
<string id="RuntimePublisher.DomainModuleLoad_V1EventMessage" value="ModuleID=%1;%nAssemblyID=%2;%nAppDomainID=%3;%nModuleFlags=%4;%nModuleILPath=%5;ModuleNativePath=%6;%nClrInstanceID=%7" />
<string id="RuntimePublisher.DomainModuleUnloadEventMessage" value="ModuleID=%1;%nAssemblyID=%2;%nAppDomainID=%3;%nModuleFlags=%4;%nModuleILPath=%5;ModuleNativePath=%6" />
Expand Down Expand Up @@ -8438,7 +8499,9 @@
<string id="RundownPublisher.MethodDCEndVerbose_V1EventMessage" value="MethodID=%1;%nModuleID=%2;%nMethodStartAddress=%3;%nMethodSize=%4;%nMethodToken=%5;%nMethodFlags=%6;%nMethodNamespace=%7;%nMethodName=%8;%nMethodSignature=%9;%nClrInstanceID=%10" />
<string id="RundownPublisher.MethodDCEndVerbose_V2EventMessage" value="MethodID=%1;%nModuleID=%2;%nMethodStartAddress=%3;%nMethodSize=%4;%nMethodToken=%5;%nMethodFlags=%6;%nMethodNamespace=%7;%nMethodName=%8;%nMethodSignature=%9;%nClrInstanceID=%10;%nReJITID=%11" />
<string id="RundownPublisher.MethodDCStartILToNativeMapEventMessage" value="MethodID=%1;%nReJITID=%2;%nMethodExtent=%3;%nCountOfMapEntries=%4;%nClrInstanceID=%5" />
<string id="RundownPublisher.MethodDCStartILToNativeMapEventMessage_V1" value="MethodID=%1;%nReJITID=%2;%nMethodExtent=%3;%nCountOfMapEntries=%4;%nClrInstanceID=%5;%nILVersionID=%6" />
<string id="RundownPublisher.MethodDCEndILToNativeMapEventMessage" value="MethodID=%1;%nReJITID=%2;%nMethodExtent=%3;%nCountOfMapEntries=%4;%nClrInstanceID=%5" />
<string id="RundownPublisher.MethodDCEndILToNativeMapEventMessage_V1" value="MethodID=%1;%nReJITID=%2;%nMethodExtent=%3;%nCountOfMapEntries=%4;%nClrInstanceID=%5;%nILVersionID=%6" />
<string id="RundownPublisher.DomainModuleDCStartEventMessage" value="ModuleID=%1;%nAssemblyID=%2;%nAppDomainID=%3;%nModuleFlags=%4;ModuleILPath=%5;ModuleNativePath=%6" />
<string id="RundownPublisher.DomainModuleDCStart_V1EventMessage" value="ModuleID=%1;%nAssemblyID=%2;%nAppDomainID=%3;%nModuleFlags=%4;ModuleILPath=%5;ModuleNativePath=%6;%nClrInstanceID=%7" />
<string id="RundownPublisher.DomainModuleDCEndEventMessage" value="ModuleID=%1;%nAssemblyID=%2;%nAppDomainID=%3;%nModuleFlags=%4;ModuleILPath=%5;ModuleNativePath=%6" />
Expand Down
23 changes: 15 additions & 8 deletions src/coreclr/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5521,7 +5521,11 @@ VOID ETW::MethodLog::MethodJitted(MethodDesc *pMethodDesc, SString *namespaceOrC
_ASSERTE(g_pDebugInterface != NULL);
g_pDebugInterface->InitializeLazyDataIfNecessary();

ETW::MethodLog::SendMethodILToNativeMapEvent(pMethodDesc, ETW::EnumerationLog::EnumerationStructs::JitMethodILToNativeMap, pNativeCodeStartAddress, pConfig->GetCodeVersion().GetILCodeVersionId());
ETW::MethodLog::SendMethodILToNativeMapEvent(pMethodDesc,
ETW::EnumerationLog::EnumerationStructs::JitMethodILToNativeMap,
pNativeCodeStartAddress,
pConfig->GetCodeVersion().GetVersionId(),
pConfig->GetCodeVersion().GetILCodeVersionId());
}

} EX_CATCH { } EX_END_CATCH(SwallowAllExceptions);
Expand Down Expand Up @@ -6843,7 +6847,7 @@ VOID ETW::MethodLog::SendMethodEvent(MethodDesc *pMethodDesc, DWORD dwEventOptio
//

// static
VOID ETW::MethodLog::SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWORD dwEventOptions, PCODE pNativeCodeStartAddress, ReJITID ilCodeId)
VOID ETW::MethodLog::SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWORD dwEventOptions, PCODE pNativeCodeStartAddress, DWORD nativeCodeId, ReJITID ilCodeId)
{
CONTRACTL
{
Expand Down Expand Up @@ -6890,15 +6894,16 @@ VOID ETW::MethodLog::SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWOR
// choosing to fire the event
if ((dwEventOptions & ETW::EnumerationLog::EnumerationStructs::JitMethodILToNativeMap) != 0)
{
FireEtwMethodILToNativeMap(
FireEtwMethodILToNativeMap_V1(
ullMethodIdentifier,
ilCodeId,
nativeCodeId,
0, // Extent: This event is only sent for JITted (not NGENd) methods, and
// currently there is only one extent (hot) for JITted methods.
cMap,
rguiILOffset,
rguiNativeOffset,
GetClrInstanceId());
GetClrInstanceId(),
ilCodeId);
}

// Rundown provider
Expand All @@ -6910,9 +6915,9 @@ VOID ETW::MethodLog::SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWOR
//
// (for an explanation of the parameters see the FireEtwMethodILToNativeMap call above)
if ((dwEventOptions & ETW::EnumerationLog::EnumerationStructs::MethodDCStartILToNativeMap) != 0)
FireEtwMethodDCStartILToNativeMap(ullMethodIdentifier, 0, 0, cMap, rguiILOffset, rguiNativeOffset, GetClrInstanceId());
FireEtwMethodDCStartILToNativeMap_V1(ullMethodIdentifier, nativeCodeId, 0, cMap, rguiILOffset, rguiNativeOffset, GetClrInstanceId(), ilCodeId);
if ((dwEventOptions & ETW::EnumerationLog::EnumerationStructs::MethodDCEndILToNativeMap) != 0)
FireEtwMethodDCEndILToNativeMap(ullMethodIdentifier, 0, 0, cMap, rguiILOffset, rguiNativeOffset, GetClrInstanceId());
FireEtwMethodDCEndILToNativeMap_V1(ullMethodIdentifier, nativeCodeId, 0, cMap, rguiILOffset, rguiNativeOffset, GetClrInstanceId(), ilCodeId);
}


Expand Down Expand Up @@ -7001,6 +7006,7 @@ VOID ETW::MethodLog::SendEventsForJitMethodsHelper(LoaderAllocator *pLoaderAlloc
// allocators, we don't support code versioning so we need to short circuit the call.
// This also allows our caller to avoid having to pre-enter the relevant locks.
// see code:#TableLockHolder
DWORD nativeCodeVersionId = 0;
ReJITID ilCodeId = 0;
NativeCodeVersion nativeCodeVersion;
#ifdef FEATURE_CODE_VERSIONING
Expand All @@ -7018,6 +7024,7 @@ VOID ETW::MethodLog::SendEventsForJitMethodsHelper(LoaderAllocator *pLoaderAlloc
}
else
{
nativeCodeVersionId = nativeCodeVersion.GetVersionId();
ilCodeId = nativeCodeVersion.GetILCodeVersionId();
}
}
Expand Down Expand Up @@ -7052,7 +7059,7 @@ VOID ETW::MethodLog::SendEventsForJitMethodsHelper(LoaderAllocator *pLoaderAlloc

// Send any supplemental events requested for this MethodID
if (fSendILToNativeMapEvent)
ETW::MethodLog::SendMethodILToNativeMapEvent(pMD, dwEventOptions, codeStart, ilCodeId);
ETW::MethodLog::SendMethodILToNativeMapEvent(pMD, dwEventOptions, codeStart, nativeCodeVersionId, ilCodeId);

// When we're called to announce unloads, then the methodunload event itself must
// come after any supplemental events, so that the method unload event is the
Expand Down

0 comments on commit 32ca998

Please sign in to comment.