@@ -2841,6 +2841,8 @@ HRESULT Debugger::GetILToNativeMapping(PCODE pNativeCodeStartAddress, ULONG32 cM
28412841 }
28422842 CONTRACTL_END;
28432843
2844+ _ASSERTE(pNativeCodeStartAddress != NULL);
2845+
28442846#ifdef PROFILING_SUPPORTED
28452847 // At this point, we're pulling in the debugger.
28462848 if (!HasLazyData())
@@ -3007,6 +3009,7 @@ HRESULT Debugger::GetILToNativeMappingIntoArrays(
30073009 _ASSERTE(pcMap != NULL);
30083010 _ASSERTE(prguiILOffset != NULL);
30093011 _ASSERTE(prguiNativeOffset != NULL);
3012+ _ASSERTE(pNativeCodeStartAddress != NULL);
30103013
30113014 // Any caller of GetILToNativeMappingIntoArrays had better call
30123015 // InitializeLazyDataIfNecessary first!
@@ -5411,28 +5414,6 @@ void Debugger::ReleaseAllRuntimeThreads(AppDomain *pAppDomain)
54115414 g_pEEInterface->ResumeFromDebug(pAppDomain);
54125415}
54135416
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-
54365417bool Debugger::IsJMCMethod(Module* pModule, mdMethodDef tkMethod)
54375418{
54385419 CONTRACTL
@@ -6219,25 +6200,6 @@ void Debugger::LockAndSendEnCRemapCompleteEvent(MethodDesc *pMD)
62196200 Thread *thread = g_pEEInterface->GetThread();
62206201 // Note that the debugger lock is reentrant, so we may or may not hold it already.
62216202 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-
62416203 // Send an EnC remap complete event to the Right Side.
62426204 DebuggerIPCEvent* ipce = m_pRCThread->GetIPCEventSendBuffer();
62436205 InitIPCEvent(ipce,
@@ -7865,6 +7827,7 @@ void Debugger::FirstChanceManagedExceptionCatcherFound(Thread *pThread,
78657827 // Implements DebugInterface
78667828 // Call by EE/exception. Must be on managed thread
78677829 _ASSERTE(GetThreadNULLOk() != NULL);
7830+ _ASSERTE(pMethodAddr != NULL);
78687831
78697832 // Quick check.
78707833 if (!CORDebuggerAttached())
@@ -10498,7 +10461,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
1049810461 DebuggerJitInfo * pDJI = NULL;
1049910462 if ((pMethodDesc != NULL) && (pDMI != NULL))
1050010463 {
10501- pDJI = pDMI->FindOrCreateInitAndAddJitInfo(pMethodDesc, NULL /* startAddr */ );
10464+ pDJI = pDMI->FindOrCreateInitAndAddJitInfo(pMethodDesc, PINSTRToPCODE(dac_cast<TADDR>(pEvent->BreakpointData.codeStartAddress)) );
1050210465 }
1050310466
1050410467 {
@@ -12625,7 +12588,7 @@ DWORD Debugger::GetThreadIdHelper(Thread *pThread)
1262512588// does not own the memory provided via vars outparameter.
1262612589//-----------------------------------------------------------------------------
1262712590void Debugger::GetVarInfo(MethodDesc * fd, // [IN] method of interest
12628- void *DebuggerVersionToken , // [IN] which edit version
12591+ CORDB_ADDRESS nativeCodeAddress , // [IN] which edit version
1262912592 SIZE_T * cVars, // [OUT] size of 'vars'
1263012593 const ICorDebugInfo::NativeVarInfo **vars // [OUT] map telling where local vars are stored
1263112594 )
@@ -12637,7 +12600,7 @@ void Debugger::GetVarInfo(MethodDesc * fd, // [IN] method of interest
1263712600 }
1263812601 CONTRACTL_END;
1263912602
12640- DebuggerJitInfo * ji = (DebuggerJitInfo *)DebuggerVersionToken ;
12603+ DebuggerJitInfo * ji = g_pDebugger->GetJitInfo(fd, (const BYTE *)nativeCodeAddress) ;
1264112604
1264212605 // If we didn't supply a DJI, then we're asking for the most recent version.
1264312606 if (ji == NULL)
@@ -12961,6 +12924,11 @@ HRESULT Debugger::UpdateFunction(MethodDesc* pMD, SIZE_T encVersion)
1296112924
1296212925 // For each offset in the IL->Native map, set a new EnC breakpoint on the
1296312926 // 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.
1296412932 PTR_DebuggerILToNativeMap seqMap = pJitInfo->GetSequenceMap();
1296512933 for (unsigned int i = 0; i < pJitInfo->GetSequenceMapCount(); i++)
1296612934 {
0 commit comments