@@ -4357,156 +4357,6 @@ void CordbProcess::GetAssembliesInLoadOrder(
43574357 // pAssemblies array has now been updated.
43584358}
43594359
4360- // Callback data for code:CordbProcess::GetModulesInLoadOrder
4361- class ShimModuleCallbackData
4362- {
4363- public:
4364- // Ctor to initialize callback data
4365- //
4366- // Arguments:
4367- // pAssembly - assembly that the Modules are in.
4368- // pModules - preallocated array of smart pointers to hold Modules
4369- // countModules - size of pModules in elements.
4370- ShimModuleCallbackData(
4371- CordbAssembly * pAssembly,
4372- RSExtSmartPtr<ICorDebugModule>* pModules,
4373- ULONG countModules)
4374- {
4375- _ASSERTE(pAssembly != NULL);
4376- _ASSERTE(pModules != NULL);
4377-
4378- m_pProcess = pAssembly->GetAppDomain()->GetProcess();
4379- m_pAssembly = pAssembly;
4380- m_pModules = pModules;
4381- m_countElements = countModules;
4382- m_index = 0;
4383-
4384- // Just to be safe, clear them all out
4385- for(ULONG i = 0; i < countModules; i++)
4386- {
4387- pModules[i].Clear();
4388- }
4389- }
4390-
4391- // Dtor
4392- //
4393- // Notes:
4394- // This can assert end-of-enumeration invariants.
4395- ~ShimModuleCallbackData()
4396- {
4397- // Ensure that we went through all Modules.
4398- _ASSERTE(m_index == m_countElements);
4399- }
4400-
4401- // Callback invoked from DAC enumeration.
4402- //
4403- // arguments:
4404- // vmAssembly - VMPTR for Assembly
4405- // pData - a 'this' pointer
4406- //
4407- static void Callback(VMPTR_Assembly vmAssembly, void * pData)
4408- {
4409- ShimModuleCallbackData * pThis = static_cast<ShimModuleCallbackData *> (pData);
4410- INTERNAL_DAC_CALLBACK(pThis->m_pProcess);
4411-
4412- CordbModule * pModule = pThis->m_pAssembly->GetAppDomain()->LookupOrCreateModule(vmAssembly);
4413-
4414- pThis->SetAndMoveNext(pModule);
4415- }
4416-
4417- // Set the current index in the table and increment the cursor.
4418- //
4419- // Arguments:
4420- // pModule - Module from DAC enumerator
4421- void SetAndMoveNext(CordbModule * pModule)
4422- {
4423- _ASSERTE(pModule != NULL);
4424-
4425- if (m_index >= m_countElements)
4426- {
4427- // Enumerating the Modules in the target should be fixed since
4428- // the target is not running.
4429- // We should never get here unless the target is unstable.
4430- // The caller (the shim) pre-allocated the table of Modules.
4431- m_pProcess->TargetConsistencyCheck(!"Target changed Module count");
4432- return;
4433- }
4434-
4435- m_pModules[m_index].Assign(pModule);
4436- m_index++;
4437- }
4438-
4439- protected:
4440- CordbProcess * m_pProcess;
4441- CordbAssembly * m_pAssembly;
4442- RSExtSmartPtr<ICorDebugModule>* m_pModules;
4443- ULONG m_countElements;
4444- ULONG m_index;
4445- };
4446-
4447- //---------------------------------------------------------------------------------------
4448- // Shim Helper to enumerate the Modules in the load-order
4449- //
4450- // Arguments:
4451- // pAppdomain - non-null appdomain to enumerate Modules.
4452- // pModules - caller pre-allocated array to hold Modules
4453- // countModules - size of the array.
4454- //
4455- // Notes:
4456- // Caller preallocated array (likely from ICorDebugModuleEnum::GetCount),
4457- // and now this function fills in the Modules in the order they were
4458- // loaded.
4459- //
4460- // The target should be stable, such that the number of Modules in the
4461- // target is stable, and therefore countModules as determined by the
4462- // shim via ICorDebugModuleEnum::GetCount should match the number of
4463- // Modules enumerated here.
4464- //
4465- // Called by code:ShimProcess::QueueFakeAssemblyAndModuleEvent.
4466- // This provides the Modules in load-order. In contrast,
4467- // ICorDebugAssembly::EnumerateModules is a random order. The shim needs
4468- // load-order to match Whidbey semantics for dispatching fake load-Module
4469- // callbacks on attach. The most important thing is that the manifest module
4470- // gets a LodModule callback before any secondary modules. For dynamic
4471- // modules, this is necessary for operations on the secondary module
4472- // that rely on manifest metadata (eg. GetSimpleName).
4473- //
4474- // @dbgtodo : This is almost identical to GetAssembliesInLoadOrder, and
4475- // (together wih the CallbackData classes) seems a HUGE amount of code and
4476- // complexity for such a simple thing. We also have extra code to order
4477- // AppDomains and Threads. We should try and rip all of this extra complexity
4478- // out, and replace it with better data structures for storing these items.
4479- // Eg., if we used std::map, we could have efficient lookups and ordered
4480- // enumerations. However, we do need to be careful about exposing new invariants
4481- // through ICorDebug that customers may depend on, which could place a long-term
4482- // compatibility burden on us. We could have a simple generic data structure
4483- // (eg. built on std::hash_map and std::list) which provided efficient look-up
4484- // and both in-order and random enumeration.
4485- //
4486- void CordbProcess::GetModulesInLoadOrder(
4487- ICorDebugAssembly * pAssembly,
4488- RSExtSmartPtr<ICorDebugModule>* pModules,
4489- ULONG countModules)
4490- {
4491- PUBLIC_API_ENTRY_FOR_SHIM(this);
4492- RSLockHolder lockHolder(GetProcessLock());
4493-
4494- _ASSERTE(GetShim() != NULL);
4495-
4496- CordbAssembly * pAssemblyInternal = static_cast<CordbAssembly *> (pAssembly);
4497-
4498- ShimModuleCallbackData data(pAssemblyInternal, pModules, countModules);
4499-
4500- // Enumerate through and fill out pModules table.
4501- IfFailThrow(GetDAC()->EnumerateModulesInAssembly(
4502- pAssemblyInternal->GetAssemblyPtr(),
4503- ShimModuleCallbackData::Callback,
4504- &data)); // user data
4505-
4506- // pModules array has now been updated.
4507- }
4508-
4509-
45104360//---------------------------------------------------------------------------------------
45114361// Callback to count the number of enumerations in a process.
45124362//
@@ -14748,7 +14598,7 @@ CordbClass * CordbProcess::LookupClass(ICorDebugAppDomain * pAppDomain, VMPTR_As
1474814598 if (pAppDomain != NULL)
1474914599 {
1475014600 VMPTR_Module vmModule = VMPTR_Module::NullPtr();
14751- IfFailThrow(GetProcess()->GetDAC()->GetModuleForAssembly(vmAssembly, &vmModule));
14601+ IfFailThrow(GetProcess()->GetDAC()->GetModuleForAssembly(vmAssembly, &vmModule, NULL ));
1475214602 _ASSERTE(!vmModule.IsNull());
1475314603 CordbModule * pModule = ((CordbAppDomain *)pAppDomain)->m_modules.GetBase(VmPtrToCookie(vmModule));
1475414604 if (pModule != NULL)
0 commit comments