@@ -2665,120 +2665,96 @@ DebuggerJitInfo *Debugger::GetJitInfo(MethodDesc *fd, const BYTE *pbAddr, Debugg
2665
2665
// Internal worker to GetJitInfo. Doesn't validate parameters.
2666
2666
DebuggerJitInfo *Debugger::GetJitInfoWorker(MethodDesc *fd, const BYTE *pbAddr, DebuggerMethodInfo **pMethInfo)
2667
2667
{
2668
+ CONTRACTL
2669
+ {
2670
+ THROWS;
2671
+ GC_NOTRIGGER;
2672
+ PRECONDITION(!g_pDebugger->HasDebuggerDataLock());
2673
+ }
2674
+ CONTRACTL_END;
2668
2675
2669
2676
DebuggerMethodInfo *dmi = NULL;
2670
2677
DebuggerJitInfo *dji = NULL;
2671
2678
2679
+ if (pMethInfo)
2680
+ {
2681
+ *pMethInfo = NULL;
2682
+ }
2683
+
2672
2684
// If we have a null MethodDesc - we're not going to get a jit-info. Do this check once at the top
2673
2685
// rather than littered throughout the rest of this function.
2674
2686
if (fd == NULL)
2675
2687
{
2676
- LOG((LF_CORDB, LL_EVERYTHING, "Debugger::GetJitInfo, addr=0x%p - null fd - returning null\n", pbAddr));
2688
+ LOG((LF_CORDB, LL_EVERYTHING, "D::GJIW: addr=0x%p - null fd - returning null\n", pbAddr));
2677
2689
return NULL;
2678
2690
}
2679
- else
2680
- {
2681
- CONSISTENCY_CHECK_MSGF(!fd->IsWrapperStub(), ("Can't get Jit-info for wrapper MDesc,'%s'", fd->m_pszDebugMethodName));
2682
- }
2683
2691
2684
- // The debugger doesn't track Lightweight-codegen methods b/c they have no metadata.
2692
+ CONSISTENCY_CHECK_MSGF(!fd->IsWrapperStub(), ("Can't get Jit-info for wrapper MDesc,'%s'", fd->m_pszDebugMethodName));
2693
+
2694
+ // The debugger doesn't track dynamic methods b/c they have no metadata.
2685
2695
if (fd->IsDynamicMethod())
2686
2696
{
2687
2697
return NULL;
2688
2698
}
2689
2699
2690
-
2691
- // initialize our out param
2692
- if (pMethInfo)
2693
- {
2694
- *pMethInfo = NULL;
2695
- }
2696
-
2697
- LOG((LF_CORDB, LL_EVERYTHING, "Debugger::GetJitInfo called\n"));
2698
- // CHECK_DJI_TABLE_DEBUGGER;
2699
-
2700
2700
// Find the DJI via the DMI
2701
2701
//
2702
2702
// One way to improve the perf, both in terms of memory usage, number of allocations
2703
2703
// and lookup speeds would be to have the first JitInfo inline in the MethodInfo
2704
2704
// struct. After all, we never want to have a MethodInfo in the table without an
2705
2705
// associated JitInfo, and this should bring us back very close to the old situation
2706
2706
// in terms of perf. But correctness comes first, and perf later...
2707
- // CHECK_DMI_TABLE;
2708
2707
dmi = GetOrCreateMethodInfo(fd->GetModule(), fd->GetMemberDef());
2709
-
2710
2708
if (dmi == NULL)
2711
2709
{
2712
2710
// If we can't create the DMI, we won't be able to create the DJI.
2713
2711
return NULL;
2714
2712
}
2715
2713
2716
- // TODO: Currently, this method does not handle code versioning properly (at least in some profiler scenarios), it may need
2717
- // to take pbAddr into account and lazily create a DJI for that particular version of the method.
2718
-
2719
- // This may take the lock and lazily create an entry, so we do it up front.
2720
- dji = dmi->GetLatestJitInfo(fd);
2721
-
2722
-
2723
- DebuggerDataLockHolder debuggerDataLockHolder(this);
2724
-
2725
- // Note the call to GetLatestJitInfo() will lazily create the first DJI if we don't already have one.
2726
- for (; dji != NULL; dji = dji->m_prevJitInfo)
2714
+ if (pbAddr == NULL)
2727
2715
{
2728
- if (PTR_TO_TADDR(dji->m_nativeCodeVersion.GetMethodDesc()) == PTR_HOST_TO_TADDR(fd))
2729
- {
2730
- break;
2731
- }
2716
+ dji = dmi->GetLatestJitInfo(fd);
2732
2717
}
2733
-
2734
- LOG((LF_CORDB, LL_INFO1000, "D::GJI: for md:0x%p (%s::%s), got dmi:0x%p, dji:0x%p, latest dji:0x%p, latest fd:0x%p, prev dji:0x%p\n",
2735
- fd, fd->m_pszDebugClassName, fd->m_pszDebugMethodName,
2736
- dmi, dji, (dmi ? dmi->GetLatestJitInfo_NoCreate() : 0),
2737
- ((dmi && dmi->GetLatestJitInfo_NoCreate()) ? dmi->GetLatestJitInfo_NoCreate()->m_nativeCodeVersion.GetMethodDesc():0),
2738
- (dji?dji->m_prevJitInfo:0)));
2739
-
2740
- if ((dji != NULL) && (pbAddr != NULL))
2741
- {
2742
- dji = dji->GetJitInfoByAddress(pbAddr);
2743
-
2744
- // XXX Microsoft - dac doesn't support stub tracing
2745
- // so this just results in not-impl exceptions.
2746
2718
#ifndef DACCESS_COMPILE
2747
- if (dji == NULL) //may have been given address of a thunk
2719
+ else
2720
+ {
2721
+ PCODE startAddr = g_pEEInterface->GetNativeCodeStartAddress((PCODE)pbAddr);
2722
+ if (startAddr == NULL)
2748
2723
{
2749
- LOG((LF_CORDB,LL_INFO1000,"Couldn't find a DJI by address 0x%p, "
2724
+ LOG((LF_CORDB,LL_INFO1000,"D::GJIW: Couldn't find a DJI by address 0x%p, "
2750
2725
"so it might be a stub or thunk\n", pbAddr));
2751
- TraceDestination trace;
2752
2726
2753
- g_pEEInterface->TraceStub((const BYTE *)pbAddr, &trace);
2754
-
2755
- if ((trace.GetTraceType() == TRACE_MANAGED) && (pbAddr != (const BYTE *)trace.GetAddress()))
2727
+ // if the address wasn't in jitted code we'll also check to see if it is a stub that leads to jitted code
2728
+ TraceDestination trace;
2729
+ (void)g_pEEInterface->TraceStub(pbAddr, &trace);
2730
+ if(trace.GetTraceType() == TRACE_MANAGED && (PCODE)pbAddr != trace.GetAddress())
2756
2731
{
2757
- LOG((LF_CORDB,LL_INFO1000,"Address thru thunk"
2758
- ": 0x%p\n", trace.GetAddress()));
2759
- dji = GetJitInfo(fd, dac_cast<PTR_CBYTE>(trace.GetAddress()));
2732
+ startAddr = trace.GetAddress();
2733
+ LOG((LF_CORDB,LL_INFO1000,"D::GJIW: Address thru thunk: 0x%p\n", startAddr));
2760
2734
}
2761
2735
#ifdef LOGGING
2762
2736
else
2763
2737
{
2764
- _ASSERTE(trace.GetTraceType() != TRACE_UNJITTED_METHOD ||
2765
- (fd == trace.GetMethodDesc()));
2766
- LOG((LF_CORDB,LL_INFO1000,"Address not thunked - "
2738
+ _ASSERTE(trace.GetTraceType() != TRACE_UNJITTED_METHOD || (fd == trace.GetMethodDesc()));
2739
+ LOG((LF_CORDB,LL_INFO1000,"D::GJIW: Address not thunked - "
2767
2740
"must be to unJITted method, or normal managed "
2768
2741
"method lacking a DJI!\n"));
2769
2742
}
2770
- #endif //LOGGING
2743
+ #endif // LOGGING
2744
+ }
2745
+
2746
+ if (startAddr != NULL)
2747
+ {
2748
+ dji = dmi->FindOrCreateInitAndAddJitInfo(fd, startAddr);
2771
2749
}
2772
- #endif // #ifndef DACCESS_COMPILE
2773
2750
}
2751
+ #endif // !DACCESS_COMPILE
2774
2752
2775
2753
if (pMethInfo)
2776
2754
{
2777
2755
*pMethInfo = dmi;
2778
2756
}
2779
2757
2780
- // DebuggerDataLockHolder out of scope - release implied
2781
-
2782
2758
return dji;
2783
2759
}
2784
2760
@@ -2813,7 +2789,7 @@ DebuggerMethodInfo *Debugger::GetOrCreateMethodInfo(Module *pModule, mdMethodDef
2813
2789
{
2814
2790
info = CreateMethodInfo(pModule, token);
2815
2791
2816
- LOG((LF_CORDB, LL_INFO1000, "D::GOCMI: created DMI for mdToken:0x%x, dmi:0x%x \n",
2792
+ LOG((LF_CORDB, LL_INFO1000, "D::GOCMI: created DMI for mdToken:0x%x, dmi:0x%p \n",
2817
2793
token, info));
2818
2794
}
2819
2795
#endif // #ifndef DACCESS_COMPILE
@@ -3093,12 +3069,12 @@ CodeRegionInfo CodeRegionInfo::GetCodeRegionInfo(DebuggerJitInfo *dji, MethodDes
3093
3069
3094
3070
if (dji && dji->m_addrOfCode)
3095
3071
{
3096
- LOG((LF_CORDB, LL_EVERYTHING , "CRI::GCRI: simple case\n"));
3072
+ LOG((LF_CORDB, LL_INFO10000 , "CRI::GCRI: simple case: CodeRegionInfo* 0x%p \n", &dji->m_codeRegionInfo ));
3097
3073
return dji->m_codeRegionInfo;
3098
3074
}
3099
3075
else
3100
3076
{
3101
- LOG((LF_CORDB, LL_EVERYTHING , "CRI::GCRI: more complex case\n"));
3077
+ LOG((LF_CORDB, LL_INFO10000 , "CRI::GCRI: more complex case\n"));
3102
3078
CodeRegionInfo codeRegionInfo;
3103
3079
3104
3080
// Use method desc from dji if present
@@ -3119,6 +3095,7 @@ CodeRegionInfo CodeRegionInfo::GetCodeRegionInfo(DebuggerJitInfo *dji, MethodDes
3119
3095
(addr == dac_cast<PTR_CORDB_ADDRESS_TYPE>(g_pEEInterface->GetFunctionAddress(md))));
3120
3096
}
3121
3097
3098
+ LOG((LF_CORDB, LL_INFO10000, "CRI::GCRI: Initializing CodeRegionInfo from 0x%p, md=0x%p\n", addr, md));
3122
3099
if (addr)
3123
3100
{
3124
3101
PCODE pCode = PINSTRToPCODE(dac_cast<TADDR>(addr));
@@ -13961,7 +13938,7 @@ Debugger::InsertToMethodInfoList( DebuggerMethodInfo *dmi )
13961
13938
}
13962
13939
CONTRACTL_END;
13963
13940
13964
- LOG((LF_CORDB,LL_INFO10000,"D:IAHOL DMI: dmi:0x%08x \n", dmi));
13941
+ LOG((LF_CORDB,LL_INFO10000,"D:IAHOL DMI: dmi:0x%p \n", dmi));
13965
13942
13966
13943
HRESULT hr = S_OK;
13967
13944
@@ -13981,7 +13958,7 @@ Debugger::InsertToMethodInfoList( DebuggerMethodInfo *dmi )
13981
13958
13982
13959
_ASSERTE((dmiPrev == NULL) || ((dmi->m_token == dmiPrev->m_token) && (dmi->m_module == dmiPrev->m_module)));
13983
13960
13984
- LOG((LF_CORDB,LL_INFO10000,"D:IAHOL: current head of dmi list:0x%08x \n",dmiPrev));
13961
+ LOG((LF_CORDB,LL_INFO10000,"D:IAHOL: current head of dmi list:0x%p \n",dmiPrev));
13985
13962
13986
13963
if (dmiPrev != NULL)
13987
13964
{
@@ -14006,7 +13983,7 @@ Debugger::InsertToMethodInfoList( DebuggerMethodInfo *dmi )
14006
13983
}
14007
13984
#ifdef _DEBUG
14008
13985
dmiPrev = m_pMethodInfos->GetMethodInfo(dmi->m_module, dmi->m_token);
14009
- LOG((LF_CORDB,LL_INFO10000,"D:IAHOL: new head of dmi list:0x%08x \n",
13986
+ LOG((LF_CORDB,LL_INFO10000,"D:IAHOL: new head of dmi list:0x%p \n",
14010
13987
dmiPrev));
14011
13988
#endif //_DEBUG
14012
13989
0 commit comments