Skip to content

Commit 5ca3f79

Browse files
authored
Remove DebuggerModule::Get/SetPrimaryModule - always itself (#107767)
1 parent 170b42c commit 5ca3f79

File tree

4 files changed

+8
-147
lines changed

4 files changed

+8
-147
lines changed

src/coreclr/debug/ee/debugger.h

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -469,57 +469,27 @@ class DebuggerModule
469469

470470
Module * GetRuntimeModule();
471471

472-
473-
// <TODO> (8/12/2002)
474-
// Currently we create a new DebuggerModules for each appdomain a shared
475-
// module lives in. We then pretend there aren't any shared modules.
476-
// This is bad. We need to move away from this.
477-
// Once we stop lying, then every module will be it's own PrimaryModule. :)
478-
//
479-
// Currently, Module* is 1:n w/ DebuggerModule.
480-
// We add a notion of PrimaryModule so that:
481-
// Module* is 1:1 w/ DebuggerModule::GetPrimaryModule();
482-
// This should help transition towards exposing shared modules.
483-
// If the Runtime module is shared, then this gives a common DM.
484-
// If the runtime module is not shared, then this is an identity function.
485-
//
486-
// The runtime has the notion of "DomainAssembly", which is 1:1 with DebuggerModule
487-
// and thus 1:1 with CordbModule. The CordbModule hash table on the RS now uses
488-
// the DomainAssembly as the key instead of DebuggerModule. This is a temporary
489-
// workaround to facilitate the removal of DebuggerModule.
490-
// </TODO>
491-
DebuggerModule * GetPrimaryModule();
492472
DomainAssembly * GetDomainAssembly()
493473
{
494474
LIMITED_METHOD_DAC_CONTRACT;
495475
return m_pRuntimeDomainAssembly;
496476
}
497477

498-
// Called by DebuggerModuleTable to set our primary module
499-
void SetPrimaryModule(DebuggerModule * pPrimary);
500-
501478
void SetCanChangeJitFlags(bool fCanChangeJitFlags);
502479

503480
private:
504481
BOOL m_enableClassLoadCallbacks;
505482

506-
// First step in moving away from hiding shared modules.
507-
DebuggerModule* m_pPrimaryModule;
508-
509483
PTR_Module m_pRuntimeModule;
510484
PTR_DomainAssembly m_pRuntimeDomainAssembly;
511485

512486
AppDomain* m_pAppDomain;
513487

514488
bool m_fHasOptimizedCode;
515489

516-
void PickPrimaryModule();
517-
518490
// Can we change jit flags on the module?
519491
// This is true during the Module creation
520492
bool m_fCanChangeJitFlags;
521-
522-
523493
};
524494

525495
/* ------------------------------------------------------------------------ *
@@ -1109,12 +1079,13 @@ class DebuggerMethodInfo
11091079
// correct IL offset if this code happens to be instrumented
11101080
ULONG32 TranslateToInstIL(const InstrumentedILOffsetMapping * pMapping, ULONG32 offOrig, bool fOrigToInst);
11111081

1112-
1082+
private:
11131083
// We don't always have a debugger module. (Ex: we're tracking debug info,
11141084
// but no debugger's attached). So this may return NULL alot.
11151085
// If we can, we should use the RuntimeModule when ever possible.
1116-
DebuggerModule* GetPrimaryModule();
1086+
DebuggerModule* GetModule();
11171087

1088+
public:
11181089
// We always have a runtime module.
11191090
Module * GetRuntimeModule();
11201091

src/coreclr/debug/ee/debugger.inl

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,13 @@ inline DebuggerModule::DebuggerModule(Module * pRuntimeModule,
5555
DomainAssembly * pDomainAssembly,
5656
AppDomain * pAppDomain) :
5757
m_enableClassLoadCallbacks(FALSE),
58-
m_pPrimaryModule(NULL),
5958
m_pRuntimeModule(pRuntimeModule),
6059
m_pRuntimeDomainAssembly(pDomainAssembly),
6160
m_pAppDomain(pAppDomain)
6261
{
6362
LOG((LF_CORDB,LL_INFO10000, "DM::DM this:0x%x Module:0x%x DF:0x%x AD:0x%x\n",
6463
this, pRuntimeModule, pDomainAssembly, pAppDomain));
6564

66-
// Pick a primary module.
67-
// Arguably, this could be in DebuggerModuleTable::AddModule
68-
PickPrimaryModule();
69-
70-
7165
// Do we have any optimized code?
7266
DWORD dwDebugBits = pRuntimeModule->GetDebuggerInfoBits();
7367
m_fHasOptimizedCode = CORDebuggerAllowJITOpts(dwDebugBits);
@@ -90,7 +84,7 @@ inline DebuggerModule::DebuggerModule(Module * pRuntimeModule,
9084
inline bool DebuggerModule::HasAnyOptimizedCode()
9185
{
9286
LIMITED_METHOD_CONTRACT;
93-
Module * pModule = this->GetPrimaryModule()->GetRuntimeModule();
87+
Module * pModule = GetRuntimeModule();
9488
DWORD dwDebugBits = pModule->GetDebuggerInfoBits();
9589
return CORDebuggerAllowJITOpts(dwDebugBits);
9690
}
@@ -142,40 +136,6 @@ inline Module * DebuggerModule::GetRuntimeModule()
142136
return m_pRuntimeModule;
143137
}
144138

145-
//-----------------------------------------------------------------------------
146-
// <TODO> (8/12/2002)
147-
// Currently we create a new DebuggerModules for each appdomain a shared
148-
// module lives in. We then pretend there aren't any shared modules.
149-
// This is bad. We need to move away from this.
150-
// Once we stop lying, then every module will be it's own PrimaryModule. :)
151-
//
152-
// Currently, Module* is 1:n w/ DebuggerModule.
153-
// We add a notion of PrimaryModule so that:
154-
// Module* is 1:1 w/ DebuggerModule::GetPrimaryModule();
155-
// This should help transition towards exposing shared modules.
156-
// If the Runtime module is shared, then this gives a common DM.
157-
// If the runtime module is not shared, then this is an identity function.
158-
// </TODO>
159-
//-----------------------------------------------------------------------------
160-
inline DebuggerModule * DebuggerModule::GetPrimaryModule()
161-
{
162-
_ASSERTE(m_pPrimaryModule != NULL);
163-
return m_pPrimaryModule;
164-
}
165-
166-
//-----------------------------------------------------------------------------
167-
// This is called by DebuggerModuleTable to set our primary module.
168-
//-----------------------------------------------------------------------------
169-
inline void DebuggerModule::SetPrimaryModule(DebuggerModule * pPrimary)
170-
{
171-
_ASSERTE(pPrimary != NULL);
172-
// Our primary module must by definition refer to the same runtime module as us
173-
_ASSERTE(pPrimary->GetRuntimeModule() == this->GetRuntimeModule());
174-
175-
LOG((LF_CORDB, LL_EVERYTHING, "DM::SetPrimaryModule - this=%p, pPrimary=%p\n", this, pPrimary));
176-
m_pPrimaryModule = pPrimary;
177-
}
178-
179139
inline DebuggerEval * FuncEvalFrame::GetDebuggerEval()
180140
{
181141
LIMITED_METHOD_DAC_CONTRACT;

src/coreclr/debug/ee/debuggermodule.cpp

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -22,69 +22,6 @@
2222
* Debugger Module routines
2323
* ------------------------------------------------------------------------ */
2424

25-
// <TODO> (8/12/2002)
26-
// We need to stop lying to the debugger about not sharing Modules.
27-
// Primary Modules allow a transition to that. Once we stop lying,
28-
// then all modules will be their own Primary.
29-
// </TODO>
30-
// Select the primary module.
31-
// Primary Modules are selected DebuggerModules that map 1:1 w/ Module*.
32-
// If the runtime module is not shared, then we're our own Primary Module.
33-
// If the Runtime module is shared, the primary module is some specific instance.
34-
// Note that a domain-neutral module can be loaded into multiple domains without
35-
// being loaded into the default domain, and so there is no "primary module" as far
36-
// as the CLR is concerned - we just pick any one and call it primary.
37-
void DebuggerModule::PickPrimaryModule()
38-
{
39-
CONTRACTL
40-
{
41-
NOTHROW;
42-
GC_NOTRIGGER;
43-
}
44-
CONTRACTL_END;
45-
46-
Debugger::DebuggerDataLockHolder ch(g_pDebugger);
47-
48-
LOG((LF_CORDB, LL_INFO100000, "DM::PickPrimaryModule, this=0x%p\n", this));
49-
50-
// We're our own primary module, unless something else proves otherwise.
51-
// Note that we should be able to skip all of this if this module is not domain neutral
52-
m_pPrimaryModule = this;
53-
54-
// This should be thread safe because our creation for the DebuggerModules
55-
// are serialized.
56-
57-
// Lookup our Runtime Module. If it's already in there,
58-
// then
59-
DebuggerModuleTable * pTable = g_pDebugger->GetModuleTable();
60-
61-
// If the table doesn't exist yet, then we must be a primary module.
62-
if (pTable == NULL)
63-
{
64-
LOG((LF_CORDB, LL_INFO100000, "DM::PickPrimaryModule, this=0x%p, table not created yet\n", this));
65-
return;
66-
}
67-
68-
// Look through existing module list to find a common primary DebuggerModule
69-
// for the given EE Module. We don't know what order we'll traverse in.
70-
71-
HASHFIND f;
72-
for (DebuggerModule * m = pTable->GetFirstModule(&f);
73-
m != NULL;
74-
m = pTable->GetNextModule(&f))
75-
{
76-
77-
if (m->GetRuntimeModule() == this->GetRuntimeModule())
78-
{
79-
// Make sure we're picking another primary module.
80-
_ASSERTE(m->GetPrimaryModule() != m);
81-
}
82-
} // end for
83-
84-
// If we got here, then this instance is a Primary Module.
85-
LOG((LF_CORDB, LL_INFO100000, "DM::PickPrimaryModule, this=%p is first, primary.\n", this));
86-
}
87-
8825
void DebuggerModule::SetCanChangeJitFlags(bool fCanChangeJitFlags)
8926
{
9027
m_fCanChangeJitFlags = fCanChangeJitFlags;
@@ -218,9 +155,6 @@ void DebuggerModuleTable::AddModule(DebuggerModule *pModule)
218155
}
219156

220157
pEntry->module = pModule;
221-
222-
// Don't need to update the primary module since it was set when we created the module.
223-
_ASSERTE(pModule->GetPrimaryModule() != NULL);
224158
}
225159

226160
//-----------------------------------------------------------------------------

src/coreclr/debug/ee/functioninfo.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ DebuggerMethodInfo::DebuggerMethodInfo(Module *module, mdMethodDef token) :
14321432

14331433
_ASSERTE(g_pDebugger->HasDebuggerDataLock());
14341434

1435-
DebuggerModule * pModule = GetPrimaryModule();
1435+
DebuggerModule * pModule = GetModule();
14361436

14371437
m_fJMCStatus = false;
14381438

@@ -1448,9 +1448,9 @@ DebuggerMethodInfo::DebuggerMethodInfo(Module *module, mdMethodDef token) :
14481448

14491449

14501450
/******************************************************************************
1451-
* Get the primary debugger module for this DMI. This is 1:1 w/ an EE Module.
1451+
* Get the debugger module for this DMI. This is 1:1 w/ an EE Module.
14521452
******************************************************************************/
1453-
DebuggerModule* DebuggerMethodInfo::GetPrimaryModule()
1453+
DebuggerModule* DebuggerMethodInfo::GetModule()
14541454
{
14551455
CONTRACTL
14561456
{
@@ -1478,11 +1478,7 @@ DebuggerModule* DebuggerMethodInfo::GetPrimaryModule()
14781478
return NULL;
14791479
}
14801480

1481-
// Only give back primary modules...
1482-
DebuggerModule * p2 = pModule->GetPrimaryModule();
1483-
_ASSERTE(p2 != NULL);
1484-
1485-
return p2;
1481+
return pModule;
14861482
}
14871483

14881484
/******************************************************************************

0 commit comments

Comments
 (0)