@@ -2841,8 +2841,6 @@ HRESULT Debugger::GetILToNativeMapping(PCODE pNativeCodeStartAddress, ULONG32 cM
28412841 }
28422842 CONTRACTL_END;
28432843
2844- _ASSERTE(pNativeCodeStartAddress != NULL);
2845-
28462844#ifdef PROFILING_SUPPORTED
28472845 // At this point, we're pulling in the debugger.
28482846 if (!HasLazyData())
@@ -3009,7 +3007,6 @@ HRESULT Debugger::GetILToNativeMappingIntoArrays(
30093007 _ASSERTE(pcMap != NULL);
30103008 _ASSERTE(prguiILOffset != NULL);
30113009 _ASSERTE(prguiNativeOffset != NULL);
3012- _ASSERTE(pNativeCodeStartAddress != NULL);
30133010
30143011 // Any caller of GetILToNativeMappingIntoArrays had better call
30153012 // InitializeLazyDataIfNecessary first!
@@ -5414,6 +5411,28 @@ void Debugger::ReleaseAllRuntimeThreads(AppDomain *pAppDomain)
54145411 g_pEEInterface->ResumeFromDebug(pAppDomain);
54155412}
54165413
5414+ // Given a method, get's its EnC version number. 1 if the method is not EnCed.
5415+ // Note that MethodDescs are reused between versions so this will give us
5416+ // the most recent EnC number.
5417+ int Debugger::GetMethodEncNumber(MethodDesc * pMethod)
5418+ {
5419+ CONTRACTL
5420+ {
5421+ THROWS;
5422+ GC_NOTRIGGER;
5423+ }
5424+ CONTRACTL_END;
5425+
5426+ DebuggerJitInfo * dji = GetLatestJitInfoFromMethodDesc(pMethod);
5427+ if (dji == NULL)
5428+ {
5429+ // If there's no DJI, couldn't have been EnCed.
5430+ return 1;
5431+ }
5432+ return (int) dji->m_encVersion;
5433+ }
5434+
5435+
54175436bool Debugger::IsJMCMethod(Module* pModule, mdMethodDef tkMethod)
54185437{
54195438 CONTRACTL
@@ -6200,6 +6219,25 @@ void Debugger::LockAndSendEnCRemapCompleteEvent(MethodDesc *pMD)
62006219 Thread *thread = g_pEEInterface->GetThread();
62016220 // Note that the debugger lock is reentrant, so we may or may not hold it already.
62026221 SENDIPCEVENT_BEGIN(this, thread);
6222+
6223+ EX_TRY
6224+ {
6225+ // Ensure the DJI for the latest version of this method has been pre-created.
6226+ // It's not clear whether this is necessary or not, but it shouldn't hurt since
6227+ // we're going to need to create it anyway since we'll be debugging inside it.
6228+ DebuggerJitInfo *dji = g_pDebugger->GetLatestJitInfoFromMethodDesc(pMD);
6229+ (void)dji; //prevent "unused variable" error from GCC
6230+ _ASSERTE( dji != NULL );
6231+ }
6232+ EX_CATCH
6233+ {
6234+ // GetLatestJitInfo could throw on OOM, but the debugger isn't resiliant to OOM.
6235+ // I'm not aware of any other legitimate reason why it may throw, so we'll ASSERT
6236+ // if it fails.
6237+ _ASSERTE(!"Unexpected exception from Debugger::GetLatestJitInfoFromMethodDesc on EnC remap complete");
6238+ }
6239+ EX_END_CATCH(RethrowTerminalExceptions);
6240+
62036241 // Send an EnC remap complete event to the Right Side.
62046242 DebuggerIPCEvent* ipce = m_pRCThread->GetIPCEventSendBuffer();
62056243 InitIPCEvent(ipce,
@@ -7827,7 +7865,6 @@ void Debugger::FirstChanceManagedExceptionCatcherFound(Thread *pThread,
78277865 // Implements DebugInterface
78287866 // Call by EE/exception. Must be on managed thread
78297867 _ASSERTE(GetThreadNULLOk() != NULL);
7830- _ASSERTE(pMethodAddr != NULL);
78317868
78327869 // Quick check.
78337870 if (!CORDebuggerAttached())
@@ -10461,7 +10498,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
1046110498 DebuggerJitInfo * pDJI = NULL;
1046210499 if ((pMethodDesc != NULL) && (pDMI != NULL))
1046310500 {
10464- pDJI = pDMI->FindOrCreateInitAndAddJitInfo(pMethodDesc, PINSTRToPCODE(dac_cast<TADDR>(pEvent->BreakpointData.codeStartAddress)) );
10501+ pDJI = pDMI->FindOrCreateInitAndAddJitInfo(pMethodDesc, NULL /* startAddr */ );
1046510502 }
1046610503
1046710504 {
@@ -12588,7 +12625,7 @@ DWORD Debugger::GetThreadIdHelper(Thread *pThread)
1258812625// does not own the memory provided via vars outparameter.
1258912626//-----------------------------------------------------------------------------
1259012627void Debugger::GetVarInfo(MethodDesc * fd, // [IN] method of interest
12591- CORDB_ADDRESS nativeCodeAddress , // [IN] which edit version
12628+ void *DebuggerVersionToken , // [IN] which edit version
1259212629 SIZE_T * cVars, // [OUT] size of 'vars'
1259312630 const ICorDebugInfo::NativeVarInfo **vars // [OUT] map telling where local vars are stored
1259412631 )
@@ -12600,7 +12637,7 @@ void Debugger::GetVarInfo(MethodDesc * fd, // [IN] method of interest
1260012637 }
1260112638 CONTRACTL_END;
1260212639
12603- DebuggerJitInfo * ji = g_pDebugger->GetJitInfo(fd, (const BYTE *)nativeCodeAddress) ;
12640+ DebuggerJitInfo * ji = (DebuggerJitInfo *)DebuggerVersionToken ;
1260412641
1260512642 // If we didn't supply a DJI, then we're asking for the most recent version.
1260612643 if (ji == NULL)
@@ -12924,11 +12961,6 @@ HRESULT Debugger::UpdateFunction(MethodDesc* pMD, SIZE_T encVersion)
1292412961
1292512962 // For each offset in the IL->Native map, set a new EnC breakpoint on the
1292612963 // ones that we know could be remap points.
12927-
12928- // Depending on which DJI was picked, the code might compute different IL offsets. The JIT may not guarantee it produces
12929- // the same set of sequence points for every generic instantiation.
12930- // Inside ENCSequencePointHelper there is logic that skips IL offsets that map to the same native offset.
12931- // Its possible that one version of the code maps two IL offsets to the same native offset but another version of the code maps them to different offsets.
1293212964 PTR_DebuggerILToNativeMap seqMap = pJitInfo->GetSequenceMap();
1293312965 for (unsigned int i = 0; i < pJitInfo->GetSequenceMapCount(); i++)
1293412966 {
0 commit comments