From 30fb27bec72052e4812b91905d35aada2eab1cca Mon Sep 17 00:00:00 2001 From: David Mason Date: Fri, 17 Nov 2017 11:07:31 -0800 Subject: [PATCH] fix for il to native mapping etw events (#15038) After investigation the failures look unrelated to my changes. Thanks Jan and Noah. --- src/debug/ee/debugger.cpp | 7 ++++--- src/debug/ee/debugger.h | 5 +++-- src/inc/eventtracebase.h | 2 +- src/vm/dbginterface.h | 5 +++-- src/vm/eventtrace.cpp | 7 ++++--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp index f41ce63..aa53155 100644 --- a/src/debug/ee/debugger.cpp +++ b/src/debug/ee/debugger.cpp @@ -3029,7 +3029,7 @@ DebuggerMethodInfo *Debugger::GetOrCreateMethodInfo(Module *pModule, mdMethodDef * structs will be returned, and some of the ilOffsets in this array * may be the values specified in CorDebugIlToNativeMappingTypes. ******************************************************************************/ -HRESULT Debugger::GetILToNativeMapping(UINT_PTR pNativeCodeStartAddress, ULONG32 cMap, +HRESULT Debugger::GetILToNativeMapping(PCODE pNativeCodeStartAddress, ULONG32 cMap, ULONG32 *pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]) { CONTRACTL @@ -3133,7 +3133,8 @@ HRESULT Debugger::GetILToNativeMapping(UINT_PTR pNativeCodeStartAddress, ULONG32 // HRESULT Debugger::GetILToNativeMappingIntoArrays( - MethodDesc * pMD, + MethodDesc * pMethodDesc, + PCODE pCode, USHORT cMapMax, USHORT * pcMap, UINT ** prguiILOffset, @@ -3157,7 +3158,7 @@ HRESULT Debugger::GetILToNativeMappingIntoArrays( // Get the JIT info by functionId. - DebuggerJitInfo * pDJI = GetLatestJitInfoFromMethodDesc(pMD); + DebuggerJitInfo * pDJI = GetJitInfo(pMethodDesc, (const BYTE *)pCode); // Dunno what went wrong if (pDJI == NULL) diff --git a/src/debug/ee/debugger.h b/src/debug/ee/debugger.h index 2ea7330..af278ed 100644 --- a/src/debug/ee/debugger.h +++ b/src/debug/ee/debugger.h @@ -2025,11 +2025,12 @@ public: DebuggerJitInfo *GetLatestJitInfoFromMethodDesc(MethodDesc * pMethodDesc); - HRESULT GetILToNativeMapping(UINT_PTR pNativeCodeStartAddress, ULONG32 cMap, ULONG32 *pcMap, + HRESULT GetILToNativeMapping(PCODE pNativeCodeStartAddress, ULONG32 cMap, ULONG32 *pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]); HRESULT GetILToNativeMappingIntoArrays( - MethodDesc * pMD, + MethodDesc * pMethodDesc, + PCODE pCode, USHORT cMapMax, USHORT * pcMap, UINT ** prguiILOffset, diff --git a/src/inc/eventtracebase.h b/src/inc/eventtracebase.h index ad6f973..d19e3e9 100644 --- a/src/inc/eventtracebase.h +++ b/src/inc/eventtracebase.h @@ -547,7 +547,7 @@ namespace ETW BOOL fGetReJitIDs); 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, ReJITID rejitID); + static VOID SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWORD dwEventOptions, SIZE_T pCode, ReJITID rejitID); static VOID SendMethodEvent(MethodDesc *pMethodDesc, DWORD dwEventOptions, BOOL bIsJit, SString *namespaceOrClassName=NULL, SString *methodName=NULL, SString *methodSignature=NULL, SIZE_T pCode = 0, ReJITID rejitID = 0); static VOID SendHelperEvent(ULONGLONG ullHelperStartAddress, ULONG ulHelperSize, LPCWSTR pHelperName); public: diff --git a/src/vm/dbginterface.h b/src/vm/dbginterface.h index 9d2c4c9..cea4c88 100644 --- a/src/vm/dbginterface.h +++ b/src/vm/dbginterface.h @@ -279,13 +279,14 @@ public: DWORD nativeOffset, DWORD *ilOffset) = 0; - virtual HRESULT GetILToNativeMapping(UINT_PTR pNativeCodeStartAddress, + virtual HRESULT GetILToNativeMapping(PCODE pNativeCodeStartAddress, ULONG32 cMap, ULONG32 *pcMap, COR_DEBUG_IL_TO_NATIVE_MAP map[]) = 0; virtual HRESULT GetILToNativeMappingIntoArrays( - MethodDesc * pMD, + MethodDesc * pMethodDesc, + PCODE pCode, USHORT cMapMax, USHORT * pcMap, UINT ** prguiILOffset, diff --git a/src/vm/eventtrace.cpp b/src/vm/eventtrace.cpp index 6325edb..72503d6 100644 --- a/src/vm/eventtrace.cpp +++ b/src/vm/eventtrace.cpp @@ -5253,7 +5253,7 @@ VOID ETW::MethodLog::MethodJitted(MethodDesc *pMethodDesc, SString *namespaceOrC _ASSERTE(g_pDebugInterface != NULL); g_pDebugInterface->InitializeLazyDataIfNecessary(); - ETW::MethodLog::SendMethodILToNativeMapEvent(pMethodDesc, ETW::EnumerationLog::EnumerationStructs::JitMethodILToNativeMap, rejitID); + ETW::MethodLog::SendMethodILToNativeMapEvent(pMethodDesc, ETW::EnumerationLog::EnumerationStructs::JitMethodILToNativeMap, pCode, rejitID); } } EX_CATCH { } EX_END_CATCH(SwallowAllExceptions); @@ -6664,7 +6664,7 @@ VOID ETW::MethodLog::SendMethodEvent(MethodDesc *pMethodDesc, DWORD dwEventOptio // // static -VOID ETW::MethodLog::SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWORD dwEventOptions, ReJITID rejitID) +VOID ETW::MethodLog::SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWORD dwEventOptions, SIZE_T pCode, ReJITID rejitID) { CONTRACTL { @@ -6698,6 +6698,7 @@ VOID ETW::MethodLog::SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWOR HRESULT hr = g_pDebugInterface->GetILToNativeMappingIntoArrays( pMethodDesc, + pCode, kMapEntriesMax, &cMap, &rguiILOffset, @@ -6871,7 +6872,7 @@ VOID ETW::MethodLog::SendEventsForJitMethodsHelper(BaseDomain *pDomainFilter, // Send any supplemental events requested for this MethodID if (fSendILToNativeMapEvent) - ETW::MethodLog::SendMethodILToNativeMapEvent(pMD, dwEventOptions, rejitID); + ETW::MethodLog::SendMethodILToNativeMapEvent(pMD, dwEventOptions, codeStart, rejitID); // 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 -- 2.7.4