Skip to content

Commit 6b4936e

Browse files
authored
Use module as ID for debugger module cache instead of domain assembly (#118414)
* Index CordbModule using module instead of domain assembly * Ensure domain assembly is non-null in CordbModule
1 parent 4da283c commit 6b4936e

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

src/coreclr/debug/daccess/dacdbiimpl.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7324,6 +7324,23 @@ HRESULT DacDbiInterfaceImpl::EnableGCNotificationEvents(BOOL fEnable)
73247324
return hr;
73257325
}
73267326

7327+
HRESULT DacDbiInterfaceImpl::GetDomainAssemblyFromModule(VMPTR_Module vmModule, OUT VMPTR_DomainAssembly *pVmDomainAssembly)
7328+
{
7329+
DD_ENTER_MAY_THROW;
7330+
7331+
if (vmModule.IsNull() || pVmDomainAssembly == NULL)
7332+
return E_INVALIDARG;
7333+
7334+
Module *pModule = vmModule.GetDacPtr();
7335+
if (pModule == NULL)
7336+
return E_INVALIDARG;
7337+
7338+
*pVmDomainAssembly = VMPTR_DomainAssembly::NullPtr();
7339+
pVmDomainAssembly->SetHostPtr(pModule->GetDomainAssembly());
7340+
7341+
return S_OK;
7342+
}
7343+
73277344
DacRefWalker::DacRefWalker(ClrDataAccess *dac, BOOL walkStacks, BOOL walkFQ, UINT32 handleMask, BOOL resolvePointers)
73287345
: mDac(dac), mWalkStacks(walkStacks), mWalkFQ(walkFQ), mHandleMask(handleMask), mStackWalker(NULL),
73297346
mResolvePointers(resolvePointers), mHandleWalker(NULL), mFQStart(PTR_NULL), mFQEnd(PTR_NULL), mFQCurr(PTR_NULL)

src/coreclr/debug/daccess/dacdbiimpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class DacDbiInterfaceImpl :
162162
HRESULT GetDefinesBitField(ULONG32 *pDefines);
163163
HRESULT GetMDStructuresVersion(ULONG32* pMDStructuresVersion);
164164
HRESULT EnableGCNotificationEvents(BOOL fEnable);
165+
HRESULT GetDomainAssemblyFromModule(VMPTR_Module vmModule, OUT VMPTR_DomainAssembly *pVmDomainAssembly);
165166

166167
private:
167168
void TypeHandleToExpandedTypeInfoImpl(AreValueTypesBoxed boxed,

src/coreclr/debug/di/module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CordbModule::CordbModule(
2727
CordbProcess * pProcess,
2828
VMPTR_Module vmModule,
2929
VMPTR_DomainAssembly vmDomainAssembly)
30-
: CordbBase(pProcess, vmDomainAssembly.IsNull() ? VmPtrToCookie(vmModule) : VmPtrToCookie(vmDomainAssembly), enumCordbModule),
30+
: CordbBase(pProcess, VmPtrToCookie(vmModule), enumCordbModule),
3131
m_pAssembly(0),
3232
m_pAppDomain(0),
3333
m_classes(11),

src/coreclr/debug/di/process.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15240,7 +15240,10 @@ CordbClass * CordbProcess::LookupClass(ICorDebugAppDomain * pAppDomain, VMPTR_Do
1524015240

1524115241
if (pAppDomain != NULL)
1524215242
{
15243-
CordbModule * pModule = ((CordbAppDomain *)pAppDomain)->m_modules.GetBase(VmPtrToCookie(vmDomainAssembly));
15243+
VMPTR_Module vmModule = VMPTR_Module::NullPtr();
15244+
GetProcess()->GetDAC()->GetModuleForDomainAssembly(vmDomainAssembly, &vmModule);
15245+
_ASSERTE(!vmModule.IsNull());
15246+
CordbModule * pModule = ((CordbAppDomain *)pAppDomain)->m_modules.GetBase(VmPtrToCookie(vmModule));
1524415247
if (pModule != NULL)
1524515248
{
1524615249
return pModule->LookupClass(classToken);

src/coreclr/debug/di/rsappdomain.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,15 +834,25 @@ CordbModule* CordbAppDomain::LookupOrCreateModule(VMPTR_Module vmModule, VMPTR_D
834834

835835
_ASSERTE(!vmDomainAssembly.IsNull() || !vmModule.IsNull());
836836

837+
if (vmModule.IsNull())
838+
GetProcess()->GetDAC()->GetModuleForDomainAssembly(vmDomainAssembly, &vmModule);
839+
840+
_ASSERTE(!vmModule.IsNull());
841+
837842
// check to see if the module is present in this app domain
838-
pModule = m_modules.GetBase(vmDomainAssembly.IsNull() ? VmPtrToCookie(vmModule) : VmPtrToCookie(vmDomainAssembly));
843+
pModule = m_modules.GetBase(VmPtrToCookie(vmModule));
839844
if (pModule != NULL)
840845
{
841846
return pModule;
842847
}
843848

844-
if (vmModule.IsNull())
845-
GetProcess()->GetDAC()->GetModuleForDomainAssembly(vmDomainAssembly, &vmModule);
849+
if (vmDomainAssembly.IsNull())
850+
{
851+
// If we don't have a domain assembly, we can look it up from the module.
852+
GetProcess()->GetDAC()->GetDomainAssemblyFromModule(vmModule, &vmDomainAssembly);
853+
}
854+
855+
_ASSERTE(!vmDomainAssembly.IsNull());
846856

847857
RSInitHolder<CordbModule> pModuleInit(new CordbModule(GetProcess(), vmModule, vmDomainAssembly));
848858
pModule = pModuleInit.TransferOwnershipToHash(&m_modules);

src/coreclr/debug/inc/dacdbiinterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,6 +2729,9 @@ class IDacDbiInterface
27292729
virtual
27302730
bool MetadataUpdatesApplied() = 0;
27312731

2732+
virtual
2733+
HRESULT GetDomainAssemblyFromModule(VMPTR_Module vmModule, OUT VMPTR_DomainAssembly *pVmDomainAssembly) = 0;
2734+
27322735
// The following tag tells the DD-marshalling tool to stop scanning.
27332736
// END_MARSHAL
27342737

0 commit comments

Comments
 (0)