Skip to content

Commit 7088332

Browse files
Some more cleanups in Assembly/Binder/Loader area (#59590)
* moved default binder allocation to AppDomain::Create * allowNativeSkip parameter is unused. * Removed PEFile::IsResource and PEFile::IsIStream - these do not exist in CoreClr * make GCC happy * folded impl * Folded PEFile into PEAssembly * renamed pefile files * reorder PEAssembly members * removed meaningless LAYOUT_CREATEIFNEEDED - we always require that * r2r bundled image should Open via cache - no reasons not to. * Some cleanup in PEImage * PEAssembly needs only one reference to PEImage * a few tweaks * some more * We never update published hosted assemblies, no need to support the scenario. * Done with PEAssembly for now * couple fixes, mostly in comments afected by renames * more cleanups for PEImage * PR review suggestion Co-authored-by: Elinor Fung <elfung@microsoft.com> * PR review feedback * this line should be deleted, not commented. * Apply suggestions from code review Co-authored-by: Elinor Fung <elfung@microsoft.com> * More PR feedback Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent bda8727 commit 7088332

82 files changed

Lines changed: 1384 additions & 2784 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ internal RuntimeType[] GetDefinedTypes()
3030
{
3131
returnGetTypes(this);
3232
}
33-
34-
[MethodImpl(MethodImplOptions.InternalCall)]
35-
privatestaticexternboolIsResource(RuntimeModulemodule);
3633
#endregion
3734

3835
#region Module overrides
@@ -472,7 +469,8 @@ public override Guid ModuleVersionId
472469

473470
public override bool IsResource()
474471
{
475-
return IsResource(this);
472+
// CoreClr does not support resource-only modules.
473+
return false;
476474
}
477475

478476
[RequiresUnreferencedCode("Fields might be removed")]

‎src/coreclr/binder/bindertracing.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ namespace
147147
DomainAssembly *parentAssembly = spec->GetParentAssembly();
148148
if (parentAssembly != nullptr)
149149
{
150-
PEAssembly *peAssembly = parentAssembly->GetFile();
151-
_ASSERTE(peAssembly != nullptr);
152-
peAssembly->GetDisplayName(request.RequestingAssembly);
150+
PEAssembly *pPEAssembly = parentAssembly->GetPEAssembly();
151+
_ASSERTE(pPEAssembly != nullptr);
152+
pPEAssembly->GetDisplayName(request.RequestingAssembly);
153153

154154
AppDomain *domain = parentAssembly->GetAppDomain();
155-
AssemblyBinder *binder = peAssembly->GetAssemblyBinder();
155+
AssemblyBinder *binder = pPEAssembly->GetAssemblyBinder();
156156

157157
GetAssemblyLoadContextNameFromBinder(binder, domain, request.RequestingAssemblyLoadContext);
158158
}

‎src/coreclr/debug/createdump/crashinfo.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ CrashInfo::EnumerateManagedModules(IXCLRDataProcess* pClrDataProcess)
320320
if (SUCCEEDED(hr = moduleData.Request(pClrDataModule.GetPtr())))
321321
{
322322
TRACE("MODULE: %"PRIA PRIx64 " dyn %d inmem %d file %d pe %"PRIA PRIx64 " pdb %"PRIA PRIx64, (uint64_t)moduleData.LoadedPEAddress, moduleData.IsDynamic,
323-
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEFile, (uint64_t)moduleData.InMemoryPdbAddress);
323+
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEAssembly, (uint64_t)moduleData.InMemoryPdbAddress);
324324

325325
if (!moduleData.IsDynamic && moduleData.LoadedPEAddress != 0)
326326
{

‎src/coreclr/debug/daccess/daccess.cpp‎

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,6 @@ MetaEnum::New(Module* mod,
679679
*handle = TO_CDENUM(NULL);
680680
}
681681

682-
if (!mod->GetFile()->HasMetadata())
683-
{
684-
returnS_FALSE;
685-
}
686-
687682
metaEnum = new (nothrow) MetaEnum;
688683
if (!metaEnum)
689684
{
@@ -4079,9 +4074,9 @@ ClrDataAccess::GetModuleByAddress(
40794074
{
40804075
TADDR base;
40814076
ULONG32 length;
4082-
PEFile* file = modDef->GetFile();
4077+
PEAssembly* pPEAssembly = modDef->GetPEAssembly();
40834078

4084-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4079+
if ((base = PTR_TO_TADDR(pPEAssembly->GetLoadedImageContents(&length))))
40854080
{
40864081
if (TO_CDADDR(base) <= address &&
40874082
TO_CDADDR(base + length) > address)
@@ -4133,9 +4128,9 @@ ClrDataAccess::StartEnumMethodDefinitionsByAddress(
41334128
{
41344129
TADDR base;
41354130
ULONG32 length;
4136-
PEFile* file = modDef->GetFile();
4131+
PEAssembly* assembly = modDef->GetPEAssembly();
41374132

4138-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4133+
if ((base = PTR_TO_TADDR(assembly->GetLoadedImageContents(&length))))
41394134
{
41404135
if (TO_CDADDR(base) <= address &&
41414136
TO_CDADDR(base + length) > address)
@@ -6459,7 +6454,7 @@ ClrDataAccess::GetHostGcNotificationTable()
64596454
}
64606455

64616456
/* static */bool
6462-
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
6457+
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
64636458
DWORD &dwTimeStamp,
64646459
DWORD &dwSize,
64656460
DWORD &dwDataSize,
@@ -6477,7 +6472,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
64776472
isNGEN = false;
64786473
if (pDir == NULL || pDir->Size == 0)
64796474
{
6480-
mdImage = pPEFile->GetILimage();
6475+
mdImage = pPEAssembly->GetPEImage();
64816476
if (mdImage != NULL)
64826477
{
64836478
layout = mdImage->GetLoadedLayout();
@@ -6526,7 +6521,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
65266521
}
65276522

65286523
/* static */
6529-
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
6524+
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEAssembly *pPEAssembly,
65306525
DWORD &dwTimeStamp,
65316526
DWORD &dwSize,
65326527
__out_ecount(cchFilePath) LPWSTR wszFilePath,
@@ -6536,10 +6531,10 @@ bool ClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
65366531
DWORD dwWritten = 0;
65376532

65386533
// use the IL File name
6539-
if (!peFile->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
6534+
if (!pPEAssembly->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
65406535
{
65416536
// Use DAC hint to retrieve the IL name.
6542-
peFile->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
6537+
pPEAssembly->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
65436538
}
65446539
dwTimeStamp = 0;
65456540
dwSize = 0;
@@ -6603,7 +6598,7 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
66036598
#endif// FEATURE_CORESYSTEM
66046599

66056600
void *
6606-
ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
6601+
ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
66076602
bool* isAlternate)
66086603
{
66096604
DWORD imageTimestamp, imageSize, dataSize;
@@ -6634,7 +6629,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66346629
// so the field remains for now.
66356630

66366631
if (!ClrDataAccess::GetMetaDataFileInfoFromPEFile(
6637-
peFile,
6632+
pPEAssembly,
66386633
imageTimestamp,
66396634
imageSize,
66406635
dataSize,
@@ -6647,7 +6642,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66476642
}
66486643

66496644
// try direct match for the image that is loaded into the managed process
6650-
peFile->GetLoadedMetadata((COUNT_T *)(&dataSize));
6645+
pPEAssembly->GetLoadedMetadata((COUNT_T *)(&dataSize));
66516646

66526647
DWORD allocSize = 0;
66536648
if (!ClrSafeInt<DWORD>::addition(dataSize, sizeof(DAC_INSTANCE), allocSize))
@@ -6665,7 +6660,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66656660
buffer = (void*)(inst + 1);
66666661

66676662
// APIs implemented by hosting debugger. It can use the path/filename, timestamp, and
6668-
//file size to find an exact match for the image. If that fails for an ngen'ed image,
6663+
//pPEAssembly size to find an exact match for the image. If that fails for an ngen'ed image,
66696664
// we can request the IL image which it came from.
66706665
if (m_legacyMetaDataLocator)
66716666
{
@@ -6701,7 +6696,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67016696
//
67026697
isAlt = true;
67036698
if (!ClrDataAccess::GetILImageInfoFromNgenPEFile(
6704-
peFile,
6699+
pPEAssembly,
67056700
imageTimestamp,
67066701
imageSize,
67076702
uniPath,
@@ -6781,13 +6776,13 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67816776

67826777
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67836778
//
6784-
// Given a PEFile or a ReflectionModule try to find the corresponding metadata
6779+
// Given a PEAssembly or a ReflectionModule try to find the corresponding metadata
67856780
// We will first ask debugger to locate it. If fail, we will try
67866781
// to get it from the target process
67876782
//
67886783
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67896784
IMDInternalImport*
6790-
ClrDataAccess::GetMDImport(constPEFile* peFile, const ReflectionModule* reflectionModule, bool throwEx)
6785+
ClrDataAccess::GetMDImport(constPEAssembly* pPEAssembly, const ReflectionModule* reflectionModule, bool throwEx)
67916786
{
67926787
HRESULT status;
67936788
PTR_CVOID mdBaseTarget = NULL;
@@ -6796,22 +6791,22 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
67966791
PVOID mdBaseHost = NULL;
67976792
bool isAlternate = false;
67986793

6799-
_ASSERTE((peFile == NULL && reflectionModule != NULL) || (peFile != NULL && reflectionModule == NULL));
6800-
TADDR peFileAddr = (peFile != NULL) ? dac_cast<TADDR>(peFile) : dac_cast<TADDR>(reflectionModule);
6794+
_ASSERTE((pPEAssembly == NULL && reflectionModule != NULL) || (pPEAssembly != NULL && reflectionModule == NULL));
6795+
TADDRpeAssemblyAddr = (pPEAssembly != NULL) ? dac_cast<TADDR>(pPEAssembly) : dac_cast<TADDR>(reflectionModule);
68016796

68026797
//
68036798
// Look for one we've already created.
68046799
//
6805-
mdImport = m_mdImports.Get(peFileAddr);
6800+
mdImport = m_mdImports.Get(peAssemblyAddr);
68066801
if (mdImport != NULL)
68076802
{
68086803
return mdImport;
68096804
}
68106805

6811-
if (peFile != NULL)
6806+
if (pPEAssembly != NULL)
68126807
{
68136808
// Get the metadata size
6814-
mdBaseTarget = ((PEFile*)peFile)->GetLoadedMetadata(&mdSize);
6809+
mdBaseTarget = const_cast<PEAssembly*>(pPEAssembly)->GetLoadedMetadata(&mdSize);
68156810
}
68166811
elseif (reflectionModule != NULL)
68176812
{
@@ -6862,12 +6857,12 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
68626857
}
68636858

68646859
// Try to see if debugger can locate it
6865-
if (peFile != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
6860+
if (pPEAssembly != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
68666861
{
68676862
// We couldn't read the metadata from memory. Ask
68686863
// the target for metadata as it may be able to
68696864
// provide it from some alternate means.
6870-
mdBaseHost = GetMetaDataFromHost(const_cast<PEFile *>(peFile), &isAlternate);
6865+
mdBaseHost = GetMetaDataFromHost(const_cast<PEAssembly *>(pPEAssembly), &isAlternate);
68716866
}
68726867

68736868
if (mdBaseHost == NULL)
@@ -6902,7 +6897,7 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
69026897
// The m_mdImports list does get cleaned up by calls to ClrDataAccess::Flush,
69036898
// i.e. every time the process changes state.
69046899

6905-
if (m_mdImports.Add(peFileAddr, mdImport, isAlternate) == NULL)
6900+
if (m_mdImports.Add(peAssemblyAddr, mdImport, isAlternate) == NULL)
69066901
{
69076902
mdImport->Release();
69086903
DacError(E_OUTOFMEMORY);
@@ -6970,9 +6965,9 @@ HRESULT ClrDataAccess::VerifyDlls()
69706965
}
69716966

69726967
// Read the debug directory timestamp from the target mscorwks image using DAC
6973-
// Note that we don't use the PE timestamp because the PE file might be changed in ways
6968+
// Note that we don't use the PE timestamp because the PE pPEAssembly might be changed in ways
69746969
// that don't effect the PDB (and therefore don't effect DAC). Specifically, we rebase
6975-
// our DLLs at the end of a build, that changes the PE file, but not the PDB.
6970+
// our DLLs at the end of a build, that changes the PE pPEAssembly, but not the PDB.
69766971
// Note that if we wanted to be extra careful, we could read the CV contents (which includes
69776972
// the GUID signature) and verify it matches. Using the timestamp is useful for helpful error
69786973
// messages, and should be sufficient in any real scenario.

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Some more cleanups in Assembly/Binder/Loader area (#59590) · dotnet/runtime@7088332 · GitHub
Skip to content

Commit 7088332

Browse files
Some more cleanups in Assembly/Binder/Loader area (#59590)
* moved default binder allocation to AppDomain::Create * allowNativeSkip parameter is unused. * Removed PEFile::IsResource and PEFile::IsIStream - these do not exist in CoreClr * make GCC happy * folded impl * Folded PEFile into PEAssembly * renamed pefile files * reorder PEAssembly members * removed meaningless LAYOUT_CREATEIFNEEDED - we always require that * r2r bundled image should Open via cache - no reasons not to. * Some cleanup in PEImage * PEAssembly needs only one reference to PEImage * a few tweaks * some more * We never update published hosted assemblies, no need to support the scenario. * Done with PEAssembly for now * couple fixes, mostly in comments afected by renames * more cleanups for PEImage * PR review suggestion Co-authored-by: Elinor Fung <elfung@microsoft.com> * PR review feedback * this line should be deleted, not commented. * Apply suggestions from code review Co-authored-by: Elinor Fung <elfung@microsoft.com> * More PR feedback Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent bda8727 commit 7088332

82 files changed

Lines changed: 1384 additions & 2784 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ internal RuntimeType[] GetDefinedTypes()
3030
{
3131
returnGetTypes(this);
3232
}
33-
34-
[MethodImpl(MethodImplOptions.InternalCall)]
35-
privatestaticexternboolIsResource(RuntimeModulemodule);
3633
#endregion
3734

3835
#region Module overrides
@@ -472,7 +469,8 @@ public override Guid ModuleVersionId
472469

473470
public override bool IsResource()
474471
{
475-
return IsResource(this);
472+
// CoreClr does not support resource-only modules.
473+
return false;
476474
}
477475

478476
[RequiresUnreferencedCode("Fields might be removed")]

‎src/coreclr/binder/bindertracing.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ namespace
147147
DomainAssembly *parentAssembly = spec->GetParentAssembly();
148148
if (parentAssembly != nullptr)
149149
{
150-
PEAssembly *peAssembly = parentAssembly->GetFile();
151-
_ASSERTE(peAssembly != nullptr);
152-
peAssembly->GetDisplayName(request.RequestingAssembly);
150+
PEAssembly *pPEAssembly = parentAssembly->GetPEAssembly();
151+
_ASSERTE(pPEAssembly != nullptr);
152+
pPEAssembly->GetDisplayName(request.RequestingAssembly);
153153

154154
AppDomain *domain = parentAssembly->GetAppDomain();
155-
AssemblyBinder *binder = peAssembly->GetAssemblyBinder();
155+
AssemblyBinder *binder = pPEAssembly->GetAssemblyBinder();
156156

157157
GetAssemblyLoadContextNameFromBinder(binder, domain, request.RequestingAssemblyLoadContext);
158158
}

‎src/coreclr/debug/createdump/crashinfo.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ CrashInfo::EnumerateManagedModules(IXCLRDataProcess* pClrDataProcess)
320320
if (SUCCEEDED(hr = moduleData.Request(pClrDataModule.GetPtr())))
321321
{
322322
TRACE("MODULE: %"PRIA PRIx64 " dyn %d inmem %d file %d pe %"PRIA PRIx64 " pdb %"PRIA PRIx64, (uint64_t)moduleData.LoadedPEAddress, moduleData.IsDynamic,
323-
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEFile, (uint64_t)moduleData.InMemoryPdbAddress);
323+
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEAssembly, (uint64_t)moduleData.InMemoryPdbAddress);
324324

325325
if (!moduleData.IsDynamic && moduleData.LoadedPEAddress != 0)
326326
{

‎src/coreclr/debug/daccess/daccess.cpp‎

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,6 @@ MetaEnum::New(Module* mod,
679679
*handle = TO_CDENUM(NULL);
680680
}
681681

682-
if (!mod->GetFile()->HasMetadata())
683-
{
684-
returnS_FALSE;
685-
}
686-
687682
metaEnum = new (nothrow) MetaEnum;
688683
if (!metaEnum)
689684
{
@@ -4079,9 +4074,9 @@ ClrDataAccess::GetModuleByAddress(
40794074
{
40804075
TADDR base;
40814076
ULONG32 length;
4082-
PEFile* file = modDef->GetFile();
4077+
PEAssembly* pPEAssembly = modDef->GetPEAssembly();
40834078

4084-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4079+
if ((base = PTR_TO_TADDR(pPEAssembly->GetLoadedImageContents(&length))))
40854080
{
40864081
if (TO_CDADDR(base) <= address &&
40874082
TO_CDADDR(base + length) > address)
@@ -4133,9 +4128,9 @@ ClrDataAccess::StartEnumMethodDefinitionsByAddress(
41334128
{
41344129
TADDR base;
41354130
ULONG32 length;
4136-
PEFile* file = modDef->GetFile();
4131+
PEAssembly* assembly = modDef->GetPEAssembly();
41374132

4138-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4133+
if ((base = PTR_TO_TADDR(assembly->GetLoadedImageContents(&length))))
41394134
{
41404135
if (TO_CDADDR(base) <= address &&
41414136
TO_CDADDR(base + length) > address)
@@ -6459,7 +6454,7 @@ ClrDataAccess::GetHostGcNotificationTable()
64596454
}
64606455

64616456
/* static */bool
6462-
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
6457+
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
64636458
DWORD &dwTimeStamp,
64646459
DWORD &dwSize,
64656460
DWORD &dwDataSize,
@@ -6477,7 +6472,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
64776472
isNGEN = false;
64786473
if (pDir == NULL || pDir->Size == 0)
64796474
{
6480-
mdImage = pPEFile->GetILimage();
6475+
mdImage = pPEAssembly->GetPEImage();
64816476
if (mdImage != NULL)
64826477
{
64836478
layout = mdImage->GetLoadedLayout();
@@ -6526,7 +6521,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
65266521
}
65276522

65286523
/* static */
6529-
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
6524+
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEAssembly *pPEAssembly,
65306525
DWORD &dwTimeStamp,
65316526
DWORD &dwSize,
65326527
__out_ecount(cchFilePath) LPWSTR wszFilePath,
@@ -6536,10 +6531,10 @@ bool ClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
65366531
DWORD dwWritten = 0;
65376532

65386533
// use the IL File name
6539-
if (!peFile->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
6534+
if (!pPEAssembly->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
65406535
{
65416536
// Use DAC hint to retrieve the IL name.
6542-
peFile->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
6537+
pPEAssembly->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
65436538
}
65446539
dwTimeStamp = 0;
65456540
dwSize = 0;
@@ -6603,7 +6598,7 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
66036598
#endif// FEATURE_CORESYSTEM
66046599

66056600
void *
6606-
ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
6601+
ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
66076602
bool* isAlternate)
66086603
{
66096604
DWORD imageTimestamp, imageSize, dataSize;
@@ -6634,7 +6629,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66346629
// so the field remains for now.
66356630

66366631
if (!ClrDataAccess::GetMetaDataFileInfoFromPEFile(
6637-
peFile,
6632+
pPEAssembly,
66386633
imageTimestamp,
66396634
imageSize,
66406635
dataSize,
@@ -6647,7 +6642,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66476642
}
66486643

66496644
// try direct match for the image that is loaded into the managed process
6650-
peFile->GetLoadedMetadata((COUNT_T *)(&dataSize));
6645+
pPEAssembly->GetLoadedMetadata((COUNT_T *)(&dataSize));
66516646

66526647
DWORD allocSize = 0;
66536648
if (!ClrSafeInt<DWORD>::addition(dataSize, sizeof(DAC_INSTANCE), allocSize))
@@ -6665,7 +6660,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66656660
buffer = (void*)(inst + 1);
66666661

66676662
// APIs implemented by hosting debugger. It can use the path/filename, timestamp, and
6668-
//file size to find an exact match for the image. If that fails for an ngen'ed image,
6663+
//pPEAssembly size to find an exact match for the image. If that fails for an ngen'ed image,
66696664
// we can request the IL image which it came from.
66706665
if (m_legacyMetaDataLocator)
66716666
{
@@ -6701,7 +6696,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67016696
//
67026697
isAlt = true;
67036698
if (!ClrDataAccess::GetILImageInfoFromNgenPEFile(
6704-
peFile,
6699+
pPEAssembly,
67056700
imageTimestamp,
67066701
imageSize,
67076702
uniPath,
@@ -6781,13 +6776,13 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67816776

67826777
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67836778
//
6784-
// Given a PEFile or a ReflectionModule try to find the corresponding metadata
6779+
// Given a PEAssembly or a ReflectionModule try to find the corresponding metadata
67856780
// We will first ask debugger to locate it. If fail, we will try
67866781
// to get it from the target process
67876782
//
67886783
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67896784
IMDInternalImport*
6790-
ClrDataAccess::GetMDImport(constPEFile* peFile, const ReflectionModule* reflectionModule, bool throwEx)
6785+
ClrDataAccess::GetMDImport(constPEAssembly* pPEAssembly, const ReflectionModule* reflectionModule, bool throwEx)
67916786
{
67926787
HRESULT status;
67936788
PTR_CVOID mdBaseTarget = NULL;
@@ -6796,22 +6791,22 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
67966791
PVOID mdBaseHost = NULL;
67976792
bool isAlternate = false;
67986793

6799-
_ASSERTE((peFile == NULL && reflectionModule != NULL) || (peFile != NULL && reflectionModule == NULL));
6800-
TADDR peFileAddr = (peFile != NULL) ? dac_cast<TADDR>(peFile) : dac_cast<TADDR>(reflectionModule);
6794+
_ASSERTE((pPEAssembly == NULL && reflectionModule != NULL) || (pPEAssembly != NULL && reflectionModule == NULL));
6795+
TADDRpeAssemblyAddr = (pPEAssembly != NULL) ? dac_cast<TADDR>(pPEAssembly) : dac_cast<TADDR>(reflectionModule);
68016796

68026797
//
68036798
// Look for one we've already created.
68046799
//
6805-
mdImport = m_mdImports.Get(peFileAddr);
6800+
mdImport = m_mdImports.Get(peAssemblyAddr);
68066801
if (mdImport != NULL)
68076802
{
68086803
return mdImport;
68096804
}
68106805

6811-
if (peFile != NULL)
6806+
if (pPEAssembly != NULL)
68126807
{
68136808
// Get the metadata size
6814-
mdBaseTarget = ((PEFile*)peFile)->GetLoadedMetadata(&mdSize);
6809+
mdBaseTarget = const_cast<PEAssembly*>(pPEAssembly)->GetLoadedMetadata(&mdSize);
68156810
}
68166811
elseif (reflectionModule != NULL)
68176812
{
@@ -6862,12 +6857,12 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
68626857
}
68636858

68646859
// Try to see if debugger can locate it
6865-
if (peFile != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
6860+
if (pPEAssembly != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
68666861
{
68676862
// We couldn't read the metadata from memory. Ask
68686863
// the target for metadata as it may be able to
68696864
// provide it from some alternate means.
6870-
mdBaseHost = GetMetaDataFromHost(const_cast<PEFile *>(peFile), &isAlternate);
6865+
mdBaseHost = GetMetaDataFromHost(const_cast<PEAssembly *>(pPEAssembly), &isAlternate);
68716866
}
68726867

68736868
if (mdBaseHost == NULL)
@@ -6902,7 +6897,7 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
69026897
// The m_mdImports list does get cleaned up by calls to ClrDataAccess::Flush,
69036898
// i.e. every time the process changes state.
69046899

6905-
if (m_mdImports.Add(peFileAddr, mdImport, isAlternate) == NULL)
6900+
if (m_mdImports.Add(peAssemblyAddr, mdImport, isAlternate) == NULL)
69066901
{
69076902
mdImport->Release();
69086903
DacError(E_OUTOFMEMORY);
@@ -6970,9 +6965,9 @@ HRESULT ClrDataAccess::VerifyDlls()
69706965
}
69716966

69726967
// Read the debug directory timestamp from the target mscorwks image using DAC
6973-
// Note that we don't use the PE timestamp because the PE file might be changed in ways
6968+
// Note that we don't use the PE timestamp because the PE pPEAssembly might be changed in ways
69746969
// that don't effect the PDB (and therefore don't effect DAC). Specifically, we rebase
6975-
// our DLLs at the end of a build, that changes the PE file, but not the PDB.
6970+
// our DLLs at the end of a build, that changes the PE pPEAssembly, but not the PDB.
69766971
// Note that if we wanted to be extra careful, we could read the CV contents (which includes
69776972
// the GUID signature) and verify it matches. Using the timestamp is useful for helpful error
69786973
// messages, and should be sufficient in any real scenario.

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Some more cleanups in Assembly/Binder/Loader area (#59590) · dotnet/runtime@7088332 · GitHub
Skip to content

Commit 7088332

Browse files
Some more cleanups in Assembly/Binder/Loader area (#59590)
* moved default binder allocation to AppDomain::Create * allowNativeSkip parameter is unused. * Removed PEFile::IsResource and PEFile::IsIStream - these do not exist in CoreClr * make GCC happy * folded impl * Folded PEFile into PEAssembly * renamed pefile files * reorder PEAssembly members * removed meaningless LAYOUT_CREATEIFNEEDED - we always require that * r2r bundled image should Open via cache - no reasons not to. * Some cleanup in PEImage * PEAssembly needs only one reference to PEImage * a few tweaks * some more * We never update published hosted assemblies, no need to support the scenario. * Done with PEAssembly for now * couple fixes, mostly in comments afected by renames * more cleanups for PEImage * PR review suggestion Co-authored-by: Elinor Fung <elfung@microsoft.com> * PR review feedback * this line should be deleted, not commented. * Apply suggestions from code review Co-authored-by: Elinor Fung <elfung@microsoft.com> * More PR feedback Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent bda8727 commit 7088332

82 files changed

Lines changed: 1384 additions & 2784 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ internal RuntimeType[] GetDefinedTypes()
3030
{
3131
returnGetTypes(this);
3232
}
33-
34-
[MethodImpl(MethodImplOptions.InternalCall)]
35-
privatestaticexternboolIsResource(RuntimeModulemodule);
3633
#endregion
3734

3835
#region Module overrides
@@ -472,7 +469,8 @@ public override Guid ModuleVersionId
472469

473470
public override bool IsResource()
474471
{
475-
return IsResource(this);
472+
// CoreClr does not support resource-only modules.
473+
return false;
476474
}
477475

478476
[RequiresUnreferencedCode("Fields might be removed")]

‎src/coreclr/binder/bindertracing.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ namespace
147147
DomainAssembly *parentAssembly = spec->GetParentAssembly();
148148
if (parentAssembly != nullptr)
149149
{
150-
PEAssembly *peAssembly = parentAssembly->GetFile();
151-
_ASSERTE(peAssembly != nullptr);
152-
peAssembly->GetDisplayName(request.RequestingAssembly);
150+
PEAssembly *pPEAssembly = parentAssembly->GetPEAssembly();
151+
_ASSERTE(pPEAssembly != nullptr);
152+
pPEAssembly->GetDisplayName(request.RequestingAssembly);
153153

154154
AppDomain *domain = parentAssembly->GetAppDomain();
155-
AssemblyBinder *binder = peAssembly->GetAssemblyBinder();
155+
AssemblyBinder *binder = pPEAssembly->GetAssemblyBinder();
156156

157157
GetAssemblyLoadContextNameFromBinder(binder, domain, request.RequestingAssemblyLoadContext);
158158
}

‎src/coreclr/debug/createdump/crashinfo.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ CrashInfo::EnumerateManagedModules(IXCLRDataProcess* pClrDataProcess)
320320
if (SUCCEEDED(hr = moduleData.Request(pClrDataModule.GetPtr())))
321321
{
322322
TRACE("MODULE: %"PRIA PRIx64 " dyn %d inmem %d file %d pe %"PRIA PRIx64 " pdb %"PRIA PRIx64, (uint64_t)moduleData.LoadedPEAddress, moduleData.IsDynamic,
323-
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEFile, (uint64_t)moduleData.InMemoryPdbAddress);
323+
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEAssembly, (uint64_t)moduleData.InMemoryPdbAddress);
324324

325325
if (!moduleData.IsDynamic && moduleData.LoadedPEAddress != 0)
326326
{

‎src/coreclr/debug/daccess/daccess.cpp‎

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,6 @@ MetaEnum::New(Module* mod,
679679
*handle = TO_CDENUM(NULL);
680680
}
681681

682-
if (!mod->GetFile()->HasMetadata())
683-
{
684-
returnS_FALSE;
685-
}
686-
687682
metaEnum = new (nothrow) MetaEnum;
688683
if (!metaEnum)
689684
{
@@ -4079,9 +4074,9 @@ ClrDataAccess::GetModuleByAddress(
40794074
{
40804075
TADDR base;
40814076
ULONG32 length;
4082-
PEFile* file = modDef->GetFile();
4077+
PEAssembly* pPEAssembly = modDef->GetPEAssembly();
40834078

4084-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4079+
if ((base = PTR_TO_TADDR(pPEAssembly->GetLoadedImageContents(&length))))
40854080
{
40864081
if (TO_CDADDR(base) <= address &&
40874082
TO_CDADDR(base + length) > address)
@@ -4133,9 +4128,9 @@ ClrDataAccess::StartEnumMethodDefinitionsByAddress(
41334128
{
41344129
TADDR base;
41354130
ULONG32 length;
4136-
PEFile* file = modDef->GetFile();
4131+
PEAssembly* assembly = modDef->GetPEAssembly();
41374132

4138-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4133+
if ((base = PTR_TO_TADDR(assembly->GetLoadedImageContents(&length))))
41394134
{
41404135
if (TO_CDADDR(base) <= address &&
41414136
TO_CDADDR(base + length) > address)
@@ -6459,7 +6454,7 @@ ClrDataAccess::GetHostGcNotificationTable()
64596454
}
64606455

64616456
/* static */bool
6462-
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
6457+
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
64636458
DWORD &dwTimeStamp,
64646459
DWORD &dwSize,
64656460
DWORD &dwDataSize,
@@ -6477,7 +6472,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
64776472
isNGEN = false;
64786473
if (pDir == NULL || pDir->Size == 0)
64796474
{
6480-
mdImage = pPEFile->GetILimage();
6475+
mdImage = pPEAssembly->GetPEImage();
64816476
if (mdImage != NULL)
64826477
{
64836478
layout = mdImage->GetLoadedLayout();
@@ -6526,7 +6521,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
65266521
}
65276522

65286523
/* static */
6529-
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
6524+
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEAssembly *pPEAssembly,
65306525
DWORD &dwTimeStamp,
65316526
DWORD &dwSize,
65326527
__out_ecount(cchFilePath) LPWSTR wszFilePath,
@@ -6536,10 +6531,10 @@ bool ClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
65366531
DWORD dwWritten = 0;
65376532

65386533
// use the IL File name
6539-
if (!peFile->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
6534+
if (!pPEAssembly->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
65406535
{
65416536
// Use DAC hint to retrieve the IL name.
6542-
peFile->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
6537+
pPEAssembly->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
65436538
}
65446539
dwTimeStamp = 0;
65456540
dwSize = 0;
@@ -6603,7 +6598,7 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
66036598
#endif// FEATURE_CORESYSTEM
66046599

66056600
void *
6606-
ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
6601+
ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
66076602
bool* isAlternate)
66086603
{
66096604
DWORD imageTimestamp, imageSize, dataSize;
@@ -6634,7 +6629,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66346629
// so the field remains for now.
66356630

66366631
if (!ClrDataAccess::GetMetaDataFileInfoFromPEFile(
6637-
peFile,
6632+
pPEAssembly,
66386633
imageTimestamp,
66396634
imageSize,
66406635
dataSize,
@@ -6647,7 +6642,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66476642
}
66486643

66496644
// try direct match for the image that is loaded into the managed process
6650-
peFile->GetLoadedMetadata((COUNT_T *)(&dataSize));
6645+
pPEAssembly->GetLoadedMetadata((COUNT_T *)(&dataSize));
66516646

66526647
DWORD allocSize = 0;
66536648
if (!ClrSafeInt<DWORD>::addition(dataSize, sizeof(DAC_INSTANCE), allocSize))
@@ -6665,7 +6660,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66656660
buffer = (void*)(inst + 1);
66666661

66676662
// APIs implemented by hosting debugger. It can use the path/filename, timestamp, and
6668-
//file size to find an exact match for the image. If that fails for an ngen'ed image,
6663+
//pPEAssembly size to find an exact match for the image. If that fails for an ngen'ed image,
66696664
// we can request the IL image which it came from.
66706665
if (m_legacyMetaDataLocator)
66716666
{
@@ -6701,7 +6696,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67016696
//
67026697
isAlt = true;
67036698
if (!ClrDataAccess::GetILImageInfoFromNgenPEFile(
6704-
peFile,
6699+
pPEAssembly,
67056700
imageTimestamp,
67066701
imageSize,
67076702
uniPath,
@@ -6781,13 +6776,13 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67816776

67826777
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67836778
//
6784-
// Given a PEFile or a ReflectionModule try to find the corresponding metadata
6779+
// Given a PEAssembly or a ReflectionModule try to find the corresponding metadata
67856780
// We will first ask debugger to locate it. If fail, we will try
67866781
// to get it from the target process
67876782
//
67886783
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67896784
IMDInternalImport*
6790-
ClrDataAccess::GetMDImport(constPEFile* peFile, const ReflectionModule* reflectionModule, bool throwEx)
6785+
ClrDataAccess::GetMDImport(constPEAssembly* pPEAssembly, const ReflectionModule* reflectionModule, bool throwEx)
67916786
{
67926787
HRESULT status;
67936788
PTR_CVOID mdBaseTarget = NULL;
@@ -6796,22 +6791,22 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
67966791
PVOID mdBaseHost = NULL;
67976792
bool isAlternate = false;
67986793

6799-
_ASSERTE((peFile == NULL && reflectionModule != NULL) || (peFile != NULL && reflectionModule == NULL));
6800-
TADDR peFileAddr = (peFile != NULL) ? dac_cast<TADDR>(peFile) : dac_cast<TADDR>(reflectionModule);
6794+
_ASSERTE((pPEAssembly == NULL && reflectionModule != NULL) || (pPEAssembly != NULL && reflectionModule == NULL));
6795+
TADDRpeAssemblyAddr = (pPEAssembly != NULL) ? dac_cast<TADDR>(pPEAssembly) : dac_cast<TADDR>(reflectionModule);
68016796

68026797
//
68036798
// Look for one we've already created.
68046799
//
6805-
mdImport = m_mdImports.Get(peFileAddr);
6800+
mdImport = m_mdImports.Get(peAssemblyAddr);
68066801
if (mdImport != NULL)
68076802
{
68086803
return mdImport;
68096804
}
68106805

6811-
if (peFile != NULL)
6806+
if (pPEAssembly != NULL)
68126807
{
68136808
// Get the metadata size
6814-
mdBaseTarget = ((PEFile*)peFile)->GetLoadedMetadata(&mdSize);
6809+
mdBaseTarget = const_cast<PEAssembly*>(pPEAssembly)->GetLoadedMetadata(&mdSize);
68156810
}
68166811
elseif (reflectionModule != NULL)
68176812
{
@@ -6862,12 +6857,12 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
68626857
}
68636858

68646859
// Try to see if debugger can locate it
6865-
if (peFile != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
6860+
if (pPEAssembly != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
68666861
{
68676862
// We couldn't read the metadata from memory. Ask
68686863
// the target for metadata as it may be able to
68696864
// provide it from some alternate means.
6870-
mdBaseHost = GetMetaDataFromHost(const_cast<PEFile *>(peFile), &isAlternate);
6865+
mdBaseHost = GetMetaDataFromHost(const_cast<PEAssembly *>(pPEAssembly), &isAlternate);
68716866
}
68726867

68736868
if (mdBaseHost == NULL)
@@ -6902,7 +6897,7 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
69026897
// The m_mdImports list does get cleaned up by calls to ClrDataAccess::Flush,
69036898
// i.e. every time the process changes state.
69046899

6905-
if (m_mdImports.Add(peFileAddr, mdImport, isAlternate) == NULL)
6900+
if (m_mdImports.Add(peAssemblyAddr, mdImport, isAlternate) == NULL)
69066901
{
69076902
mdImport->Release();
69086903
DacError(E_OUTOFMEMORY);
@@ -6970,9 +6965,9 @@ HRESULT ClrDataAccess::VerifyDlls()
69706965
}
69716966

69726967
// Read the debug directory timestamp from the target mscorwks image using DAC
6973-
// Note that we don't use the PE timestamp because the PE file might be changed in ways
6968+
// Note that we don't use the PE timestamp because the PE pPEAssembly might be changed in ways
69746969
// that don't effect the PDB (and therefore don't effect DAC). Specifically, we rebase
6975-
// our DLLs at the end of a build, that changes the PE file, but not the PDB.
6970+
// our DLLs at the end of a build, that changes the PE pPEAssembly, but not the PDB.
69766971
// Note that if we wanted to be extra careful, we could read the CV contents (which includes
69776972
// the GUID signature) and verify it matches. Using the timestamp is useful for helpful error
69786973
// messages, and should be sufficient in any real scenario.

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Some more cleanups in Assembly/Binder/Loader area (#59590) · dotnet/runtime@7088332 · GitHub
Skip to content

Commit 7088332

Browse files
Some more cleanups in Assembly/Binder/Loader area (#59590)
* moved default binder allocation to AppDomain::Create * allowNativeSkip parameter is unused. * Removed PEFile::IsResource and PEFile::IsIStream - these do not exist in CoreClr * make GCC happy * folded impl * Folded PEFile into PEAssembly * renamed pefile files * reorder PEAssembly members * removed meaningless LAYOUT_CREATEIFNEEDED - we always require that * r2r bundled image should Open via cache - no reasons not to. * Some cleanup in PEImage * PEAssembly needs only one reference to PEImage * a few tweaks * some more * We never update published hosted assemblies, no need to support the scenario. * Done with PEAssembly for now * couple fixes, mostly in comments afected by renames * more cleanups for PEImage * PR review suggestion Co-authored-by: Elinor Fung <elfung@microsoft.com> * PR review feedback * this line should be deleted, not commented. * Apply suggestions from code review Co-authored-by: Elinor Fung <elfung@microsoft.com> * More PR feedback Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent bda8727 commit 7088332

82 files changed

Lines changed: 1384 additions & 2784 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ internal RuntimeType[] GetDefinedTypes()
3030
{
3131
returnGetTypes(this);
3232
}
33-
34-
[MethodImpl(MethodImplOptions.InternalCall)]
35-
privatestaticexternboolIsResource(RuntimeModulemodule);
3633
#endregion
3734

3835
#region Module overrides
@@ -472,7 +469,8 @@ public override Guid ModuleVersionId
472469

473470
public override bool IsResource()
474471
{
475-
return IsResource(this);
472+
// CoreClr does not support resource-only modules.
473+
return false;
476474
}
477475

478476
[RequiresUnreferencedCode("Fields might be removed")]

‎src/coreclr/binder/bindertracing.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ namespace
147147
DomainAssembly *parentAssembly = spec->GetParentAssembly();
148148
if (parentAssembly != nullptr)
149149
{
150-
PEAssembly *peAssembly = parentAssembly->GetFile();
151-
_ASSERTE(peAssembly != nullptr);
152-
peAssembly->GetDisplayName(request.RequestingAssembly);
150+
PEAssembly *pPEAssembly = parentAssembly->GetPEAssembly();
151+
_ASSERTE(pPEAssembly != nullptr);
152+
pPEAssembly->GetDisplayName(request.RequestingAssembly);
153153

154154
AppDomain *domain = parentAssembly->GetAppDomain();
155-
AssemblyBinder *binder = peAssembly->GetAssemblyBinder();
155+
AssemblyBinder *binder = pPEAssembly->GetAssemblyBinder();
156156

157157
GetAssemblyLoadContextNameFromBinder(binder, domain, request.RequestingAssemblyLoadContext);
158158
}

‎src/coreclr/debug/createdump/crashinfo.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ CrashInfo::EnumerateManagedModules(IXCLRDataProcess* pClrDataProcess)
320320
if (SUCCEEDED(hr = moduleData.Request(pClrDataModule.GetPtr())))
321321
{
322322
TRACE("MODULE: %"PRIA PRIx64 " dyn %d inmem %d file %d pe %"PRIA PRIx64 " pdb %"PRIA PRIx64, (uint64_t)moduleData.LoadedPEAddress, moduleData.IsDynamic,
323-
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEFile, (uint64_t)moduleData.InMemoryPdbAddress);
323+
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEAssembly, (uint64_t)moduleData.InMemoryPdbAddress);
324324

325325
if (!moduleData.IsDynamic && moduleData.LoadedPEAddress != 0)
326326
{

‎src/coreclr/debug/daccess/daccess.cpp‎

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,6 @@ MetaEnum::New(Module* mod,
679679
*handle = TO_CDENUM(NULL);
680680
}
681681

682-
if (!mod->GetFile()->HasMetadata())
683-
{
684-
returnS_FALSE;
685-
}
686-
687682
metaEnum = new (nothrow) MetaEnum;
688683
if (!metaEnum)
689684
{
@@ -4079,9 +4074,9 @@ ClrDataAccess::GetModuleByAddress(
40794074
{
40804075
TADDR base;
40814076
ULONG32 length;
4082-
PEFile* file = modDef->GetFile();
4077+
PEAssembly* pPEAssembly = modDef->GetPEAssembly();
40834078

4084-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4079+
if ((base = PTR_TO_TADDR(pPEAssembly->GetLoadedImageContents(&length))))
40854080
{
40864081
if (TO_CDADDR(base) <= address &&
40874082
TO_CDADDR(base + length) > address)
@@ -4133,9 +4128,9 @@ ClrDataAccess::StartEnumMethodDefinitionsByAddress(
41334128
{
41344129
TADDR base;
41354130
ULONG32 length;
4136-
PEFile* file = modDef->GetFile();
4131+
PEAssembly* assembly = modDef->GetPEAssembly();
41374132

4138-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4133+
if ((base = PTR_TO_TADDR(assembly->GetLoadedImageContents(&length))))
41394134
{
41404135
if (TO_CDADDR(base) <= address &&
41414136
TO_CDADDR(base + length) > address)
@@ -6459,7 +6454,7 @@ ClrDataAccess::GetHostGcNotificationTable()
64596454
}
64606455

64616456
/* static */bool
6462-
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
6457+
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
64636458
DWORD &dwTimeStamp,
64646459
DWORD &dwSize,
64656460
DWORD &dwDataSize,
@@ -6477,7 +6472,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
64776472
isNGEN = false;
64786473
if (pDir == NULL || pDir->Size == 0)
64796474
{
6480-
mdImage = pPEFile->GetILimage();
6475+
mdImage = pPEAssembly->GetPEImage();
64816476
if (mdImage != NULL)
64826477
{
64836478
layout = mdImage->GetLoadedLayout();
@@ -6526,7 +6521,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
65266521
}
65276522

65286523
/* static */
6529-
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
6524+
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEAssembly *pPEAssembly,
65306525
DWORD &dwTimeStamp,
65316526
DWORD &dwSize,
65326527
__out_ecount(cchFilePath) LPWSTR wszFilePath,
@@ -6536,10 +6531,10 @@ bool ClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
65366531
DWORD dwWritten = 0;
65376532

65386533
// use the IL File name
6539-
if (!peFile->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
6534+
if (!pPEAssembly->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
65406535
{
65416536
// Use DAC hint to retrieve the IL name.
6542-
peFile->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
6537+
pPEAssembly->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
65436538
}
65446539
dwTimeStamp = 0;
65456540
dwSize = 0;
@@ -6603,7 +6598,7 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
66036598
#endif// FEATURE_CORESYSTEM
66046599

66056600
void *
6606-
ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
6601+
ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
66076602
bool* isAlternate)
66086603
{
66096604
DWORD imageTimestamp, imageSize, dataSize;
@@ -6634,7 +6629,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66346629
// so the field remains for now.
66356630

66366631
if (!ClrDataAccess::GetMetaDataFileInfoFromPEFile(
6637-
peFile,
6632+
pPEAssembly,
66386633
imageTimestamp,
66396634
imageSize,
66406635
dataSize,
@@ -6647,7 +6642,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66476642
}
66486643

66496644
// try direct match for the image that is loaded into the managed process
6650-
peFile->GetLoadedMetadata((COUNT_T *)(&dataSize));
6645+
pPEAssembly->GetLoadedMetadata((COUNT_T *)(&dataSize));
66516646

66526647
DWORD allocSize = 0;
66536648
if (!ClrSafeInt<DWORD>::addition(dataSize, sizeof(DAC_INSTANCE), allocSize))
@@ -6665,7 +6660,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66656660
buffer = (void*)(inst + 1);
66666661

66676662
// APIs implemented by hosting debugger. It can use the path/filename, timestamp, and
6668-
//file size to find an exact match for the image. If that fails for an ngen'ed image,
6663+
//pPEAssembly size to find an exact match for the image. If that fails for an ngen'ed image,
66696664
// we can request the IL image which it came from.
66706665
if (m_legacyMetaDataLocator)
66716666
{
@@ -6701,7 +6696,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67016696
//
67026697
isAlt = true;
67036698
if (!ClrDataAccess::GetILImageInfoFromNgenPEFile(
6704-
peFile,
6699+
pPEAssembly,
67056700
imageTimestamp,
67066701
imageSize,
67076702
uniPath,
@@ -6781,13 +6776,13 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67816776

67826777
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67836778
//
6784-
// Given a PEFile or a ReflectionModule try to find the corresponding metadata
6779+
// Given a PEAssembly or a ReflectionModule try to find the corresponding metadata
67856780
// We will first ask debugger to locate it. If fail, we will try
67866781
// to get it from the target process
67876782
//
67886783
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67896784
IMDInternalImport*
6790-
ClrDataAccess::GetMDImport(constPEFile* peFile, const ReflectionModule* reflectionModule, bool throwEx)
6785+
ClrDataAccess::GetMDImport(constPEAssembly* pPEAssembly, const ReflectionModule* reflectionModule, bool throwEx)
67916786
{
67926787
HRESULT status;
67936788
PTR_CVOID mdBaseTarget = NULL;
@@ -6796,22 +6791,22 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
67966791
PVOID mdBaseHost = NULL;
67976792
bool isAlternate = false;
67986793

6799-
_ASSERTE((peFile == NULL && reflectionModule != NULL) || (peFile != NULL && reflectionModule == NULL));
6800-
TADDR peFileAddr = (peFile != NULL) ? dac_cast<TADDR>(peFile) : dac_cast<TADDR>(reflectionModule);
6794+
_ASSERTE((pPEAssembly == NULL && reflectionModule != NULL) || (pPEAssembly != NULL && reflectionModule == NULL));
6795+
TADDRpeAssemblyAddr = (pPEAssembly != NULL) ? dac_cast<TADDR>(pPEAssembly) : dac_cast<TADDR>(reflectionModule);
68016796

68026797
//
68036798
// Look for one we've already created.
68046799
//
6805-
mdImport = m_mdImports.Get(peFileAddr);
6800+
mdImport = m_mdImports.Get(peAssemblyAddr);
68066801
if (mdImport != NULL)
68076802
{
68086803
return mdImport;
68096804
}
68106805

6811-
if (peFile != NULL)
6806+
if (pPEAssembly != NULL)
68126807
{
68136808
// Get the metadata size
6814-
mdBaseTarget = ((PEFile*)peFile)->GetLoadedMetadata(&mdSize);
6809+
mdBaseTarget = const_cast<PEAssembly*>(pPEAssembly)->GetLoadedMetadata(&mdSize);
68156810
}
68166811
elseif (reflectionModule != NULL)
68176812
{
@@ -6862,12 +6857,12 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
68626857
}
68636858

68646859
// Try to see if debugger can locate it
6865-
if (peFile != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
6860+
if (pPEAssembly != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
68666861
{
68676862
// We couldn't read the metadata from memory. Ask
68686863
// the target for metadata as it may be able to
68696864
// provide it from some alternate means.
6870-
mdBaseHost = GetMetaDataFromHost(const_cast<PEFile *>(peFile), &isAlternate);
6865+
mdBaseHost = GetMetaDataFromHost(const_cast<PEAssembly *>(pPEAssembly), &isAlternate);
68716866
}
68726867

68736868
if (mdBaseHost == NULL)
@@ -6902,7 +6897,7 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
69026897
// The m_mdImports list does get cleaned up by calls to ClrDataAccess::Flush,
69036898
// i.e. every time the process changes state.
69046899

6905-
if (m_mdImports.Add(peFileAddr, mdImport, isAlternate) == NULL)
6900+
if (m_mdImports.Add(peAssemblyAddr, mdImport, isAlternate) == NULL)
69066901
{
69076902
mdImport->Release();
69086903
DacError(E_OUTOFMEMORY);
@@ -6970,9 +6965,9 @@ HRESULT ClrDataAccess::VerifyDlls()
69706965
}
69716966

69726967
// Read the debug directory timestamp from the target mscorwks image using DAC
6973-
// Note that we don't use the PE timestamp because the PE file might be changed in ways
6968+
// Note that we don't use the PE timestamp because the PE pPEAssembly might be changed in ways
69746969
// that don't effect the PDB (and therefore don't effect DAC). Specifically, we rebase
6975-
// our DLLs at the end of a build, that changes the PE file, but not the PDB.
6970+
// our DLLs at the end of a build, that changes the PE pPEAssembly, but not the PDB.
69766971
// Note that if we wanted to be extra careful, we could read the CV contents (which includes
69776972
// the GUID signature) and verify it matches. Using the timestamp is useful for helpful error
69786973
// messages, and should be sufficient in any real scenario.

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Some more cleanups in Assembly/Binder/Loader area (#59590) · dotnet/runtime@7088332 · GitHub
Skip to content

Commit 7088332

Browse files
Some more cleanups in Assembly/Binder/Loader area (#59590)
* moved default binder allocation to AppDomain::Create * allowNativeSkip parameter is unused. * Removed PEFile::IsResource and PEFile::IsIStream - these do not exist in CoreClr * make GCC happy * folded impl * Folded PEFile into PEAssembly * renamed pefile files * reorder PEAssembly members * removed meaningless LAYOUT_CREATEIFNEEDED - we always require that * r2r bundled image should Open via cache - no reasons not to. * Some cleanup in PEImage * PEAssembly needs only one reference to PEImage * a few tweaks * some more * We never update published hosted assemblies, no need to support the scenario. * Done with PEAssembly for now * couple fixes, mostly in comments afected by renames * more cleanups for PEImage * PR review suggestion Co-authored-by: Elinor Fung <elfung@microsoft.com> * PR review feedback * this line should be deleted, not commented. * Apply suggestions from code review Co-authored-by: Elinor Fung <elfung@microsoft.com> * More PR feedback Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent bda8727 commit 7088332

82 files changed

Lines changed: 1384 additions & 2784 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ internal RuntimeType[] GetDefinedTypes()
3030
{
3131
returnGetTypes(this);
3232
}
33-
34-
[MethodImpl(MethodImplOptions.InternalCall)]
35-
privatestaticexternboolIsResource(RuntimeModulemodule);
3633
#endregion
3734

3835
#region Module overrides
@@ -472,7 +469,8 @@ public override Guid ModuleVersionId
472469

473470
public override bool IsResource()
474471
{
475-
return IsResource(this);
472+
// CoreClr does not support resource-only modules.
473+
return false;
476474
}
477475

478476
[RequiresUnreferencedCode("Fields might be removed")]

‎src/coreclr/binder/bindertracing.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ namespace
147147
DomainAssembly *parentAssembly = spec->GetParentAssembly();
148148
if (parentAssembly != nullptr)
149149
{
150-
PEAssembly *peAssembly = parentAssembly->GetFile();
151-
_ASSERTE(peAssembly != nullptr);
152-
peAssembly->GetDisplayName(request.RequestingAssembly);
150+
PEAssembly *pPEAssembly = parentAssembly->GetPEAssembly();
151+
_ASSERTE(pPEAssembly != nullptr);
152+
pPEAssembly->GetDisplayName(request.RequestingAssembly);
153153

154154
AppDomain *domain = parentAssembly->GetAppDomain();
155-
AssemblyBinder *binder = peAssembly->GetAssemblyBinder();
155+
AssemblyBinder *binder = pPEAssembly->GetAssemblyBinder();
156156

157157
GetAssemblyLoadContextNameFromBinder(binder, domain, request.RequestingAssemblyLoadContext);
158158
}

‎src/coreclr/debug/createdump/crashinfo.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ CrashInfo::EnumerateManagedModules(IXCLRDataProcess* pClrDataProcess)
320320
if (SUCCEEDED(hr = moduleData.Request(pClrDataModule.GetPtr())))
321321
{
322322
TRACE("MODULE: %"PRIA PRIx64 " dyn %d inmem %d file %d pe %"PRIA PRIx64 " pdb %"PRIA PRIx64, (uint64_t)moduleData.LoadedPEAddress, moduleData.IsDynamic,
323-
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEFile, (uint64_t)moduleData.InMemoryPdbAddress);
323+
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEAssembly, (uint64_t)moduleData.InMemoryPdbAddress);
324324

325325
if (!moduleData.IsDynamic && moduleData.LoadedPEAddress != 0)
326326
{

‎src/coreclr/debug/daccess/daccess.cpp‎

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,6 @@ MetaEnum::New(Module* mod,
679679
*handle = TO_CDENUM(NULL);
680680
}
681681

682-
if (!mod->GetFile()->HasMetadata())
683-
{
684-
returnS_FALSE;
685-
}
686-
687682
metaEnum = new (nothrow) MetaEnum;
688683
if (!metaEnum)
689684
{
@@ -4079,9 +4074,9 @@ ClrDataAccess::GetModuleByAddress(
40794074
{
40804075
TADDR base;
40814076
ULONG32 length;
4082-
PEFile* file = modDef->GetFile();
4077+
PEAssembly* pPEAssembly = modDef->GetPEAssembly();
40834078

4084-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4079+
if ((base = PTR_TO_TADDR(pPEAssembly->GetLoadedImageContents(&length))))
40854080
{
40864081
if (TO_CDADDR(base) <= address &&
40874082
TO_CDADDR(base + length) > address)
@@ -4133,9 +4128,9 @@ ClrDataAccess::StartEnumMethodDefinitionsByAddress(
41334128
{
41344129
TADDR base;
41354130
ULONG32 length;
4136-
PEFile* file = modDef->GetFile();
4131+
PEAssembly* assembly = modDef->GetPEAssembly();
41374132

4138-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4133+
if ((base = PTR_TO_TADDR(assembly->GetLoadedImageContents(&length))))
41394134
{
41404135
if (TO_CDADDR(base) <= address &&
41414136
TO_CDADDR(base + length) > address)
@@ -6459,7 +6454,7 @@ ClrDataAccess::GetHostGcNotificationTable()
64596454
}
64606455

64616456
/* static */bool
6462-
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
6457+
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
64636458
DWORD &dwTimeStamp,
64646459
DWORD &dwSize,
64656460
DWORD &dwDataSize,
@@ -6477,7 +6472,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
64776472
isNGEN = false;
64786473
if (pDir == NULL || pDir->Size == 0)
64796474
{
6480-
mdImage = pPEFile->GetILimage();
6475+
mdImage = pPEAssembly->GetPEImage();
64816476
if (mdImage != NULL)
64826477
{
64836478
layout = mdImage->GetLoadedLayout();
@@ -6526,7 +6521,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
65266521
}
65276522

65286523
/* static */
6529-
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
6524+
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEAssembly *pPEAssembly,
65306525
DWORD &dwTimeStamp,
65316526
DWORD &dwSize,
65326527
__out_ecount(cchFilePath) LPWSTR wszFilePath,
@@ -6536,10 +6531,10 @@ bool ClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
65366531
DWORD dwWritten = 0;
65376532

65386533
// use the IL File name
6539-
if (!peFile->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
6534+
if (!pPEAssembly->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
65406535
{
65416536
// Use DAC hint to retrieve the IL name.
6542-
peFile->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
6537+
pPEAssembly->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
65436538
}
65446539
dwTimeStamp = 0;
65456540
dwSize = 0;
@@ -6603,7 +6598,7 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
66036598
#endif// FEATURE_CORESYSTEM
66046599

66056600
void *
6606-
ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
6601+
ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
66076602
bool* isAlternate)
66086603
{
66096604
DWORD imageTimestamp, imageSize, dataSize;
@@ -6634,7 +6629,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66346629
// so the field remains for now.
66356630

66366631
if (!ClrDataAccess::GetMetaDataFileInfoFromPEFile(
6637-
peFile,
6632+
pPEAssembly,
66386633
imageTimestamp,
66396634
imageSize,
66406635
dataSize,
@@ -6647,7 +6642,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66476642
}
66486643

66496644
// try direct match for the image that is loaded into the managed process
6650-
peFile->GetLoadedMetadata((COUNT_T *)(&dataSize));
6645+
pPEAssembly->GetLoadedMetadata((COUNT_T *)(&dataSize));
66516646

66526647
DWORD allocSize = 0;
66536648
if (!ClrSafeInt<DWORD>::addition(dataSize, sizeof(DAC_INSTANCE), allocSize))
@@ -6665,7 +6660,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66656660
buffer = (void*)(inst + 1);
66666661

66676662
// APIs implemented by hosting debugger. It can use the path/filename, timestamp, and
6668-
//file size to find an exact match for the image. If that fails for an ngen'ed image,
6663+
//pPEAssembly size to find an exact match for the image. If that fails for an ngen'ed image,
66696664
// we can request the IL image which it came from.
66706665
if (m_legacyMetaDataLocator)
66716666
{
@@ -6701,7 +6696,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67016696
//
67026697
isAlt = true;
67036698
if (!ClrDataAccess::GetILImageInfoFromNgenPEFile(
6704-
peFile,
6699+
pPEAssembly,
67056700
imageTimestamp,
67066701
imageSize,
67076702
uniPath,
@@ -6781,13 +6776,13 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67816776

67826777
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67836778
//
6784-
// Given a PEFile or a ReflectionModule try to find the corresponding metadata
6779+
// Given a PEAssembly or a ReflectionModule try to find the corresponding metadata
67856780
// We will first ask debugger to locate it. If fail, we will try
67866781
// to get it from the target process
67876782
//
67886783
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67896784
IMDInternalImport*
6790-
ClrDataAccess::GetMDImport(constPEFile* peFile, const ReflectionModule* reflectionModule, bool throwEx)
6785+
ClrDataAccess::GetMDImport(constPEAssembly* pPEAssembly, const ReflectionModule* reflectionModule, bool throwEx)
67916786
{
67926787
HRESULT status;
67936788
PTR_CVOID mdBaseTarget = NULL;
@@ -6796,22 +6791,22 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
67966791
PVOID mdBaseHost = NULL;
67976792
bool isAlternate = false;
67986793

6799-
_ASSERTE((peFile == NULL && reflectionModule != NULL) || (peFile != NULL && reflectionModule == NULL));
6800-
TADDR peFileAddr = (peFile != NULL) ? dac_cast<TADDR>(peFile) : dac_cast<TADDR>(reflectionModule);
6794+
_ASSERTE((pPEAssembly == NULL && reflectionModule != NULL) || (pPEAssembly != NULL && reflectionModule == NULL));
6795+
TADDRpeAssemblyAddr = (pPEAssembly != NULL) ? dac_cast<TADDR>(pPEAssembly) : dac_cast<TADDR>(reflectionModule);
68016796

68026797
//
68036798
// Look for one we've already created.
68046799
//
6805-
mdImport = m_mdImports.Get(peFileAddr);
6800+
mdImport = m_mdImports.Get(peAssemblyAddr);
68066801
if (mdImport != NULL)
68076802
{
68086803
return mdImport;
68096804
}
68106805

6811-
if (peFile != NULL)
6806+
if (pPEAssembly != NULL)
68126807
{
68136808
// Get the metadata size
6814-
mdBaseTarget = ((PEFile*)peFile)->GetLoadedMetadata(&mdSize);
6809+
mdBaseTarget = const_cast<PEAssembly*>(pPEAssembly)->GetLoadedMetadata(&mdSize);
68156810
}
68166811
elseif (reflectionModule != NULL)
68176812
{
@@ -6862,12 +6857,12 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
68626857
}
68636858

68646859
// Try to see if debugger can locate it
6865-
if (peFile != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
6860+
if (pPEAssembly != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
68666861
{
68676862
// We couldn't read the metadata from memory. Ask
68686863
// the target for metadata as it may be able to
68696864
// provide it from some alternate means.
6870-
mdBaseHost = GetMetaDataFromHost(const_cast<PEFile *>(peFile), &isAlternate);
6865+
mdBaseHost = GetMetaDataFromHost(const_cast<PEAssembly *>(pPEAssembly), &isAlternate);
68716866
}
68726867

68736868
if (mdBaseHost == NULL)
@@ -6902,7 +6897,7 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
69026897
// The m_mdImports list does get cleaned up by calls to ClrDataAccess::Flush,
69036898
// i.e. every time the process changes state.
69046899

6905-
if (m_mdImports.Add(peFileAddr, mdImport, isAlternate) == NULL)
6900+
if (m_mdImports.Add(peAssemblyAddr, mdImport, isAlternate) == NULL)
69066901
{
69076902
mdImport->Release();
69086903
DacError(E_OUTOFMEMORY);
@@ -6970,9 +6965,9 @@ HRESULT ClrDataAccess::VerifyDlls()
69706965
}
69716966

69726967
// Read the debug directory timestamp from the target mscorwks image using DAC
6973-
// Note that we don't use the PE timestamp because the PE file might be changed in ways
6968+
// Note that we don't use the PE timestamp because the PE pPEAssembly might be changed in ways
69746969
// that don't effect the PDB (and therefore don't effect DAC). Specifically, we rebase
6975-
// our DLLs at the end of a build, that changes the PE file, but not the PDB.
6970+
// our DLLs at the end of a build, that changes the PE pPEAssembly, but not the PDB.
69766971
// Note that if we wanted to be extra careful, we could read the CV contents (which includes
69776972
// the GUID signature) and verify it matches. Using the timestamp is useful for helpful error
69786973
// messages, and should be sufficient in any real scenario.

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Some more cleanups in Assembly/Binder/Loader area (#59590) · dotnet/runtime@7088332 · GitHub
Skip to content

Commit 7088332

Browse files
Some more cleanups in Assembly/Binder/Loader area (#59590)
* moved default binder allocation to AppDomain::Create * allowNativeSkip parameter is unused. * Removed PEFile::IsResource and PEFile::IsIStream - these do not exist in CoreClr * make GCC happy * folded impl * Folded PEFile into PEAssembly * renamed pefile files * reorder PEAssembly members * removed meaningless LAYOUT_CREATEIFNEEDED - we always require that * r2r bundled image should Open via cache - no reasons not to. * Some cleanup in PEImage * PEAssembly needs only one reference to PEImage * a few tweaks * some more * We never update published hosted assemblies, no need to support the scenario. * Done with PEAssembly for now * couple fixes, mostly in comments afected by renames * more cleanups for PEImage * PR review suggestion Co-authored-by: Elinor Fung <elfung@microsoft.com> * PR review feedback * this line should be deleted, not commented. * Apply suggestions from code review Co-authored-by: Elinor Fung <elfung@microsoft.com> * More PR feedback Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent bda8727 commit 7088332

82 files changed

Lines changed: 1384 additions & 2784 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ internal RuntimeType[] GetDefinedTypes()
3030
{
3131
returnGetTypes(this);
3232
}
33-
34-
[MethodImpl(MethodImplOptions.InternalCall)]
35-
privatestaticexternboolIsResource(RuntimeModulemodule);
3633
#endregion
3734

3835
#region Module overrides
@@ -472,7 +469,8 @@ public override Guid ModuleVersionId
472469

473470
public override bool IsResource()
474471
{
475-
return IsResource(this);
472+
// CoreClr does not support resource-only modules.
473+
return false;
476474
}
477475

478476
[RequiresUnreferencedCode("Fields might be removed")]

‎src/coreclr/binder/bindertracing.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ namespace
147147
DomainAssembly *parentAssembly = spec->GetParentAssembly();
148148
if (parentAssembly != nullptr)
149149
{
150-
PEAssembly *peAssembly = parentAssembly->GetFile();
151-
_ASSERTE(peAssembly != nullptr);
152-
peAssembly->GetDisplayName(request.RequestingAssembly);
150+
PEAssembly *pPEAssembly = parentAssembly->GetPEAssembly();
151+
_ASSERTE(pPEAssembly != nullptr);
152+
pPEAssembly->GetDisplayName(request.RequestingAssembly);
153153

154154
AppDomain *domain = parentAssembly->GetAppDomain();
155-
AssemblyBinder *binder = peAssembly->GetAssemblyBinder();
155+
AssemblyBinder *binder = pPEAssembly->GetAssemblyBinder();
156156

157157
GetAssemblyLoadContextNameFromBinder(binder, domain, request.RequestingAssemblyLoadContext);
158158
}

‎src/coreclr/debug/createdump/crashinfo.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ CrashInfo::EnumerateManagedModules(IXCLRDataProcess* pClrDataProcess)
320320
if (SUCCEEDED(hr = moduleData.Request(pClrDataModule.GetPtr())))
321321
{
322322
TRACE("MODULE: %"PRIA PRIx64 " dyn %d inmem %d file %d pe %"PRIA PRIx64 " pdb %"PRIA PRIx64, (uint64_t)moduleData.LoadedPEAddress, moduleData.IsDynamic,
323-
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEFile, (uint64_t)moduleData.InMemoryPdbAddress);
323+
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEAssembly, (uint64_t)moduleData.InMemoryPdbAddress);
324324

325325
if (!moduleData.IsDynamic && moduleData.LoadedPEAddress != 0)
326326
{

‎src/coreclr/debug/daccess/daccess.cpp‎

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,6 @@ MetaEnum::New(Module* mod,
679679
*handle = TO_CDENUM(NULL);
680680
}
681681

682-
if (!mod->GetFile()->HasMetadata())
683-
{
684-
returnS_FALSE;
685-
}
686-
687682
metaEnum = new (nothrow) MetaEnum;
688683
if (!metaEnum)
689684
{
@@ -4079,9 +4074,9 @@ ClrDataAccess::GetModuleByAddress(
40794074
{
40804075
TADDR base;
40814076
ULONG32 length;
4082-
PEFile* file = modDef->GetFile();
4077+
PEAssembly* pPEAssembly = modDef->GetPEAssembly();
40834078

4084-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4079+
if ((base = PTR_TO_TADDR(pPEAssembly->GetLoadedImageContents(&length))))
40854080
{
40864081
if (TO_CDADDR(base) <= address &&
40874082
TO_CDADDR(base + length) > address)
@@ -4133,9 +4128,9 @@ ClrDataAccess::StartEnumMethodDefinitionsByAddress(
41334128
{
41344129
TADDR base;
41354130
ULONG32 length;
4136-
PEFile* file = modDef->GetFile();
4131+
PEAssembly* assembly = modDef->GetPEAssembly();
41374132

4138-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4133+
if ((base = PTR_TO_TADDR(assembly->GetLoadedImageContents(&length))))
41394134
{
41404135
if (TO_CDADDR(base) <= address &&
41414136
TO_CDADDR(base + length) > address)
@@ -6459,7 +6454,7 @@ ClrDataAccess::GetHostGcNotificationTable()
64596454
}
64606455

64616456
/* static */bool
6462-
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
6457+
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
64636458
DWORD &dwTimeStamp,
64646459
DWORD &dwSize,
64656460
DWORD &dwDataSize,
@@ -6477,7 +6472,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
64776472
isNGEN = false;
64786473
if (pDir == NULL || pDir->Size == 0)
64796474
{
6480-
mdImage = pPEFile->GetILimage();
6475+
mdImage = pPEAssembly->GetPEImage();
64816476
if (mdImage != NULL)
64826477
{
64836478
layout = mdImage->GetLoadedLayout();
@@ -6526,7 +6521,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
65266521
}
65276522

65286523
/* static */
6529-
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
6524+
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEAssembly *pPEAssembly,
65306525
DWORD &dwTimeStamp,
65316526
DWORD &dwSize,
65326527
__out_ecount(cchFilePath) LPWSTR wszFilePath,
@@ -6536,10 +6531,10 @@ bool ClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
65366531
DWORD dwWritten = 0;
65376532

65386533
// use the IL File name
6539-
if (!peFile->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
6534+
if (!pPEAssembly->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
65406535
{
65416536
// Use DAC hint to retrieve the IL name.
6542-
peFile->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
6537+
pPEAssembly->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
65436538
}
65446539
dwTimeStamp = 0;
65456540
dwSize = 0;
@@ -6603,7 +6598,7 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
66036598
#endif// FEATURE_CORESYSTEM
66046599

66056600
void *
6606-
ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
6601+
ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
66076602
bool* isAlternate)
66086603
{
66096604
DWORD imageTimestamp, imageSize, dataSize;
@@ -6634,7 +6629,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66346629
// so the field remains for now.
66356630

66366631
if (!ClrDataAccess::GetMetaDataFileInfoFromPEFile(
6637-
peFile,
6632+
pPEAssembly,
66386633
imageTimestamp,
66396634
imageSize,
66406635
dataSize,
@@ -6647,7 +6642,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66476642
}
66486643

66496644
// try direct match for the image that is loaded into the managed process
6650-
peFile->GetLoadedMetadata((COUNT_T *)(&dataSize));
6645+
pPEAssembly->GetLoadedMetadata((COUNT_T *)(&dataSize));
66516646

66526647
DWORD allocSize = 0;
66536648
if (!ClrSafeInt<DWORD>::addition(dataSize, sizeof(DAC_INSTANCE), allocSize))
@@ -6665,7 +6660,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66656660
buffer = (void*)(inst + 1);
66666661

66676662
// APIs implemented by hosting debugger. It can use the path/filename, timestamp, and
6668-
//file size to find an exact match for the image. If that fails for an ngen'ed image,
6663+
//pPEAssembly size to find an exact match for the image. If that fails for an ngen'ed image,
66696664
// we can request the IL image which it came from.
66706665
if (m_legacyMetaDataLocator)
66716666
{
@@ -6701,7 +6696,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67016696
//
67026697
isAlt = true;
67036698
if (!ClrDataAccess::GetILImageInfoFromNgenPEFile(
6704-
peFile,
6699+
pPEAssembly,
67056700
imageTimestamp,
67066701
imageSize,
67076702
uniPath,
@@ -6781,13 +6776,13 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67816776

67826777
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67836778
//
6784-
// Given a PEFile or a ReflectionModule try to find the corresponding metadata
6779+
// Given a PEAssembly or a ReflectionModule try to find the corresponding metadata
67856780
// We will first ask debugger to locate it. If fail, we will try
67866781
// to get it from the target process
67876782
//
67886783
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67896784
IMDInternalImport*
6790-
ClrDataAccess::GetMDImport(constPEFile* peFile, const ReflectionModule* reflectionModule, bool throwEx)
6785+
ClrDataAccess::GetMDImport(constPEAssembly* pPEAssembly, const ReflectionModule* reflectionModule, bool throwEx)
67916786
{
67926787
HRESULT status;
67936788
PTR_CVOID mdBaseTarget = NULL;
@@ -6796,22 +6791,22 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
67966791
PVOID mdBaseHost = NULL;
67976792
bool isAlternate = false;
67986793

6799-
_ASSERTE((peFile == NULL && reflectionModule != NULL) || (peFile != NULL && reflectionModule == NULL));
6800-
TADDR peFileAddr = (peFile != NULL) ? dac_cast<TADDR>(peFile) : dac_cast<TADDR>(reflectionModule);
6794+
_ASSERTE((pPEAssembly == NULL && reflectionModule != NULL) || (pPEAssembly != NULL && reflectionModule == NULL));
6795+
TADDRpeAssemblyAddr = (pPEAssembly != NULL) ? dac_cast<TADDR>(pPEAssembly) : dac_cast<TADDR>(reflectionModule);
68016796

68026797
//
68036798
// Look for one we've already created.
68046799
//
6805-
mdImport = m_mdImports.Get(peFileAddr);
6800+
mdImport = m_mdImports.Get(peAssemblyAddr);
68066801
if (mdImport != NULL)
68076802
{
68086803
return mdImport;
68096804
}
68106805

6811-
if (peFile != NULL)
6806+
if (pPEAssembly != NULL)
68126807
{
68136808
// Get the metadata size
6814-
mdBaseTarget = ((PEFile*)peFile)->GetLoadedMetadata(&mdSize);
6809+
mdBaseTarget = const_cast<PEAssembly*>(pPEAssembly)->GetLoadedMetadata(&mdSize);
68156810
}
68166811
elseif (reflectionModule != NULL)
68176812
{
@@ -6862,12 +6857,12 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
68626857
}
68636858

68646859
// Try to see if debugger can locate it
6865-
if (peFile != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
6860+
if (pPEAssembly != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
68666861
{
68676862
// We couldn't read the metadata from memory. Ask
68686863
// the target for metadata as it may be able to
68696864
// provide it from some alternate means.
6870-
mdBaseHost = GetMetaDataFromHost(const_cast<PEFile *>(peFile), &isAlternate);
6865+
mdBaseHost = GetMetaDataFromHost(const_cast<PEAssembly *>(pPEAssembly), &isAlternate);
68716866
}
68726867

68736868
if (mdBaseHost == NULL)
@@ -6902,7 +6897,7 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
69026897
// The m_mdImports list does get cleaned up by calls to ClrDataAccess::Flush,
69036898
// i.e. every time the process changes state.
69046899

6905-
if (m_mdImports.Add(peFileAddr, mdImport, isAlternate) == NULL)
6900+
if (m_mdImports.Add(peAssemblyAddr, mdImport, isAlternate) == NULL)
69066901
{
69076902
mdImport->Release();
69086903
DacError(E_OUTOFMEMORY);
@@ -6970,9 +6965,9 @@ HRESULT ClrDataAccess::VerifyDlls()
69706965
}
69716966

69726967
// Read the debug directory timestamp from the target mscorwks image using DAC
6973-
// Note that we don't use the PE timestamp because the PE file might be changed in ways
6968+
// Note that we don't use the PE timestamp because the PE pPEAssembly might be changed in ways
69746969
// that don't effect the PDB (and therefore don't effect DAC). Specifically, we rebase
6975-
// our DLLs at the end of a build, that changes the PE file, but not the PDB.
6970+
// our DLLs at the end of a build, that changes the PE pPEAssembly, but not the PDB.
69766971
// Note that if we wanted to be extra careful, we could read the CV contents (which includes
69776972
// the GUID signature) and verify it matches. Using the timestamp is useful for helpful error
69786973
// messages, and should be sufficient in any real scenario.

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Some more cleanups in Assembly/Binder/Loader area (#59590) · dotnet/runtime@7088332 · GitHub
Skip to content

Commit 7088332

Browse files
Some more cleanups in Assembly/Binder/Loader area (#59590)
* moved default binder allocation to AppDomain::Create * allowNativeSkip parameter is unused. * Removed PEFile::IsResource and PEFile::IsIStream - these do not exist in CoreClr * make GCC happy * folded impl * Folded PEFile into PEAssembly * renamed pefile files * reorder PEAssembly members * removed meaningless LAYOUT_CREATEIFNEEDED - we always require that * r2r bundled image should Open via cache - no reasons not to. * Some cleanup in PEImage * PEAssembly needs only one reference to PEImage * a few tweaks * some more * We never update published hosted assemblies, no need to support the scenario. * Done with PEAssembly for now * couple fixes, mostly in comments afected by renames * more cleanups for PEImage * PR review suggestion Co-authored-by: Elinor Fung <elfung@microsoft.com> * PR review feedback * this line should be deleted, not commented. * Apply suggestions from code review Co-authored-by: Elinor Fung <elfung@microsoft.com> * More PR feedback Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent bda8727 commit 7088332

82 files changed

Lines changed: 1384 additions & 2784 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ internal RuntimeType[] GetDefinedTypes()
3030
{
3131
returnGetTypes(this);
3232
}
33-
34-
[MethodImpl(MethodImplOptions.InternalCall)]
35-
privatestaticexternboolIsResource(RuntimeModulemodule);
3633
#endregion
3734

3835
#region Module overrides
@@ -472,7 +469,8 @@ public override Guid ModuleVersionId
472469

473470
public override bool IsResource()
474471
{
475-
return IsResource(this);
472+
// CoreClr does not support resource-only modules.
473+
return false;
476474
}
477475

478476
[RequiresUnreferencedCode("Fields might be removed")]

‎src/coreclr/binder/bindertracing.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ namespace
147147
DomainAssembly *parentAssembly = spec->GetParentAssembly();
148148
if (parentAssembly != nullptr)
149149
{
150-
PEAssembly *peAssembly = parentAssembly->GetFile();
151-
_ASSERTE(peAssembly != nullptr);
152-
peAssembly->GetDisplayName(request.RequestingAssembly);
150+
PEAssembly *pPEAssembly = parentAssembly->GetPEAssembly();
151+
_ASSERTE(pPEAssembly != nullptr);
152+
pPEAssembly->GetDisplayName(request.RequestingAssembly);
153153

154154
AppDomain *domain = parentAssembly->GetAppDomain();
155-
AssemblyBinder *binder = peAssembly->GetAssemblyBinder();
155+
AssemblyBinder *binder = pPEAssembly->GetAssemblyBinder();
156156

157157
GetAssemblyLoadContextNameFromBinder(binder, domain, request.RequestingAssemblyLoadContext);
158158
}

‎src/coreclr/debug/createdump/crashinfo.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ CrashInfo::EnumerateManagedModules(IXCLRDataProcess* pClrDataProcess)
320320
if (SUCCEEDED(hr = moduleData.Request(pClrDataModule.GetPtr())))
321321
{
322322
TRACE("MODULE: %"PRIA PRIx64 " dyn %d inmem %d file %d pe %"PRIA PRIx64 " pdb %"PRIA PRIx64, (uint64_t)moduleData.LoadedPEAddress, moduleData.IsDynamic,
323-
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEFile, (uint64_t)moduleData.InMemoryPdbAddress);
323+
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEAssembly, (uint64_t)moduleData.InMemoryPdbAddress);
324324

325325
if (!moduleData.IsDynamic && moduleData.LoadedPEAddress != 0)
326326
{

‎src/coreclr/debug/daccess/daccess.cpp‎

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,6 @@ MetaEnum::New(Module* mod,
679679
*handle = TO_CDENUM(NULL);
680680
}
681681

682-
if (!mod->GetFile()->HasMetadata())
683-
{
684-
returnS_FALSE;
685-
}
686-
687682
metaEnum = new (nothrow) MetaEnum;
688683
if (!metaEnum)
689684
{
@@ -4079,9 +4074,9 @@ ClrDataAccess::GetModuleByAddress(
40794074
{
40804075
TADDR base;
40814076
ULONG32 length;
4082-
PEFile* file = modDef->GetFile();
4077+
PEAssembly* pPEAssembly = modDef->GetPEAssembly();
40834078

4084-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4079+
if ((base = PTR_TO_TADDR(pPEAssembly->GetLoadedImageContents(&length))))
40854080
{
40864081
if (TO_CDADDR(base) <= address &&
40874082
TO_CDADDR(base + length) > address)
@@ -4133,9 +4128,9 @@ ClrDataAccess::StartEnumMethodDefinitionsByAddress(
41334128
{
41344129
TADDR base;
41354130
ULONG32 length;
4136-
PEFile* file = modDef->GetFile();
4131+
PEAssembly* assembly = modDef->GetPEAssembly();
41374132

4138-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4133+
if ((base = PTR_TO_TADDR(assembly->GetLoadedImageContents(&length))))
41394134
{
41404135
if (TO_CDADDR(base) <= address &&
41414136
TO_CDADDR(base + length) > address)
@@ -6459,7 +6454,7 @@ ClrDataAccess::GetHostGcNotificationTable()
64596454
}
64606455

64616456
/* static */bool
6462-
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
6457+
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
64636458
DWORD &dwTimeStamp,
64646459
DWORD &dwSize,
64656460
DWORD &dwDataSize,
@@ -6477,7 +6472,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
64776472
isNGEN = false;
64786473
if (pDir == NULL || pDir->Size == 0)
64796474
{
6480-
mdImage = pPEFile->GetILimage();
6475+
mdImage = pPEAssembly->GetPEImage();
64816476
if (mdImage != NULL)
64826477
{
64836478
layout = mdImage->GetLoadedLayout();
@@ -6526,7 +6521,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
65266521
}
65276522

65286523
/* static */
6529-
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
6524+
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEAssembly *pPEAssembly,
65306525
DWORD &dwTimeStamp,
65316526
DWORD &dwSize,
65326527
__out_ecount(cchFilePath) LPWSTR wszFilePath,
@@ -6536,10 +6531,10 @@ bool ClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
65366531
DWORD dwWritten = 0;
65376532

65386533
// use the IL File name
6539-
if (!peFile->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
6534+
if (!pPEAssembly->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
65406535
{
65416536
// Use DAC hint to retrieve the IL name.
6542-
peFile->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
6537+
pPEAssembly->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
65436538
}
65446539
dwTimeStamp = 0;
65456540
dwSize = 0;
@@ -6603,7 +6598,7 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
66036598
#endif// FEATURE_CORESYSTEM
66046599

66056600
void *
6606-
ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
6601+
ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
66076602
bool* isAlternate)
66086603
{
66096604
DWORD imageTimestamp, imageSize, dataSize;
@@ -6634,7 +6629,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66346629
// so the field remains for now.
66356630

66366631
if (!ClrDataAccess::GetMetaDataFileInfoFromPEFile(
6637-
peFile,
6632+
pPEAssembly,
66386633
imageTimestamp,
66396634
imageSize,
66406635
dataSize,
@@ -6647,7 +6642,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66476642
}
66486643

66496644
// try direct match for the image that is loaded into the managed process
6650-
peFile->GetLoadedMetadata((COUNT_T *)(&dataSize));
6645+
pPEAssembly->GetLoadedMetadata((COUNT_T *)(&dataSize));
66516646

66526647
DWORD allocSize = 0;
66536648
if (!ClrSafeInt<DWORD>::addition(dataSize, sizeof(DAC_INSTANCE), allocSize))
@@ -6665,7 +6660,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66656660
buffer = (void*)(inst + 1);
66666661

66676662
// APIs implemented by hosting debugger. It can use the path/filename, timestamp, and
6668-
//file size to find an exact match for the image. If that fails for an ngen'ed image,
6663+
//pPEAssembly size to find an exact match for the image. If that fails for an ngen'ed image,
66696664
// we can request the IL image which it came from.
66706665
if (m_legacyMetaDataLocator)
66716666
{
@@ -6701,7 +6696,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67016696
//
67026697
isAlt = true;
67036698
if (!ClrDataAccess::GetILImageInfoFromNgenPEFile(
6704-
peFile,
6699+
pPEAssembly,
67056700
imageTimestamp,
67066701
imageSize,
67076702
uniPath,
@@ -6781,13 +6776,13 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67816776

67826777
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67836778
//
6784-
// Given a PEFile or a ReflectionModule try to find the corresponding metadata
6779+
// Given a PEAssembly or a ReflectionModule try to find the corresponding metadata
67856780
// We will first ask debugger to locate it. If fail, we will try
67866781
// to get it from the target process
67876782
//
67886783
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67896784
IMDInternalImport*
6790-
ClrDataAccess::GetMDImport(constPEFile* peFile, const ReflectionModule* reflectionModule, bool throwEx)
6785+
ClrDataAccess::GetMDImport(constPEAssembly* pPEAssembly, const ReflectionModule* reflectionModule, bool throwEx)
67916786
{
67926787
HRESULT status;
67936788
PTR_CVOID mdBaseTarget = NULL;
@@ -6796,22 +6791,22 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
67966791
PVOID mdBaseHost = NULL;
67976792
bool isAlternate = false;
67986793

6799-
_ASSERTE((peFile == NULL && reflectionModule != NULL) || (peFile != NULL && reflectionModule == NULL));
6800-
TADDR peFileAddr = (peFile != NULL) ? dac_cast<TADDR>(peFile) : dac_cast<TADDR>(reflectionModule);
6794+
_ASSERTE((pPEAssembly == NULL && reflectionModule != NULL) || (pPEAssembly != NULL && reflectionModule == NULL));
6795+
TADDRpeAssemblyAddr = (pPEAssembly != NULL) ? dac_cast<TADDR>(pPEAssembly) : dac_cast<TADDR>(reflectionModule);
68016796

68026797
//
68036798
// Look for one we've already created.
68046799
//
6805-
mdImport = m_mdImports.Get(peFileAddr);
6800+
mdImport = m_mdImports.Get(peAssemblyAddr);
68066801
if (mdImport != NULL)
68076802
{
68086803
return mdImport;
68096804
}
68106805

6811-
if (peFile != NULL)
6806+
if (pPEAssembly != NULL)
68126807
{
68136808
// Get the metadata size
6814-
mdBaseTarget = ((PEFile*)peFile)->GetLoadedMetadata(&mdSize);
6809+
mdBaseTarget = const_cast<PEAssembly*>(pPEAssembly)->GetLoadedMetadata(&mdSize);
68156810
}
68166811
elseif (reflectionModule != NULL)
68176812
{
@@ -6862,12 +6857,12 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
68626857
}
68636858

68646859
// Try to see if debugger can locate it
6865-
if (peFile != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
6860+
if (pPEAssembly != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
68666861
{
68676862
// We couldn't read the metadata from memory. Ask
68686863
// the target for metadata as it may be able to
68696864
// provide it from some alternate means.
6870-
mdBaseHost = GetMetaDataFromHost(const_cast<PEFile *>(peFile), &isAlternate);
6865+
mdBaseHost = GetMetaDataFromHost(const_cast<PEAssembly *>(pPEAssembly), &isAlternate);
68716866
}
68726867

68736868
if (mdBaseHost == NULL)
@@ -6902,7 +6897,7 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
69026897
// The m_mdImports list does get cleaned up by calls to ClrDataAccess::Flush,
69036898
// i.e. every time the process changes state.
69046899

6905-
if (m_mdImports.Add(peFileAddr, mdImport, isAlternate) == NULL)
6900+
if (m_mdImports.Add(peAssemblyAddr, mdImport, isAlternate) == NULL)
69066901
{
69076902
mdImport->Release();
69086903
DacError(E_OUTOFMEMORY);
@@ -6970,9 +6965,9 @@ HRESULT ClrDataAccess::VerifyDlls()
69706965
}
69716966

69726967
// Read the debug directory timestamp from the target mscorwks image using DAC
6973-
// Note that we don't use the PE timestamp because the PE file might be changed in ways
6968+
// Note that we don't use the PE timestamp because the PE pPEAssembly might be changed in ways
69746969
// that don't effect the PDB (and therefore don't effect DAC). Specifically, we rebase
6975-
// our DLLs at the end of a build, that changes the PE file, but not the PDB.
6970+
// our DLLs at the end of a build, that changes the PE pPEAssembly, but not the PDB.
69766971
// Note that if we wanted to be extra careful, we could read the CV contents (which includes
69776972
// the GUID signature) and verify it matches. Using the timestamp is useful for helpful error
69786973
// messages, and should be sufficient in any real scenario.

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Some more cleanups in Assembly/Binder/Loader area (#59590) · dotnet/runtime@7088332 · GitHub
Skip to content

Commit 7088332

Browse files
Some more cleanups in Assembly/Binder/Loader area (#59590)
* moved default binder allocation to AppDomain::Create * allowNativeSkip parameter is unused. * Removed PEFile::IsResource and PEFile::IsIStream - these do not exist in CoreClr * make GCC happy * folded impl * Folded PEFile into PEAssembly * renamed pefile files * reorder PEAssembly members * removed meaningless LAYOUT_CREATEIFNEEDED - we always require that * r2r bundled image should Open via cache - no reasons not to. * Some cleanup in PEImage * PEAssembly needs only one reference to PEImage * a few tweaks * some more * We never update published hosted assemblies, no need to support the scenario. * Done with PEAssembly for now * couple fixes, mostly in comments afected by renames * more cleanups for PEImage * PR review suggestion Co-authored-by: Elinor Fung <elfung@microsoft.com> * PR review feedback * this line should be deleted, not commented. * Apply suggestions from code review Co-authored-by: Elinor Fung <elfung@microsoft.com> * More PR feedback Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent bda8727 commit 7088332

82 files changed

Lines changed: 1384 additions & 2784 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ internal RuntimeType[] GetDefinedTypes()
3030
{
3131
returnGetTypes(this);
3232
}
33-
34-
[MethodImpl(MethodImplOptions.InternalCall)]
35-
privatestaticexternboolIsResource(RuntimeModulemodule);
3633
#endregion
3734

3835
#region Module overrides
@@ -472,7 +469,8 @@ public override Guid ModuleVersionId
472469

473470
public override bool IsResource()
474471
{
475-
return IsResource(this);
472+
// CoreClr does not support resource-only modules.
473+
return false;
476474
}
477475

478476
[RequiresUnreferencedCode("Fields might be removed")]

‎src/coreclr/binder/bindertracing.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ namespace
147147
DomainAssembly *parentAssembly = spec->GetParentAssembly();
148148
if (parentAssembly != nullptr)
149149
{
150-
PEAssembly *peAssembly = parentAssembly->GetFile();
151-
_ASSERTE(peAssembly != nullptr);
152-
peAssembly->GetDisplayName(request.RequestingAssembly);
150+
PEAssembly *pPEAssembly = parentAssembly->GetPEAssembly();
151+
_ASSERTE(pPEAssembly != nullptr);
152+
pPEAssembly->GetDisplayName(request.RequestingAssembly);
153153

154154
AppDomain *domain = parentAssembly->GetAppDomain();
155-
AssemblyBinder *binder = peAssembly->GetAssemblyBinder();
155+
AssemblyBinder *binder = pPEAssembly->GetAssemblyBinder();
156156

157157
GetAssemblyLoadContextNameFromBinder(binder, domain, request.RequestingAssemblyLoadContext);
158158
}

‎src/coreclr/debug/createdump/crashinfo.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ CrashInfo::EnumerateManagedModules(IXCLRDataProcess* pClrDataProcess)
320320
if (SUCCEEDED(hr = moduleData.Request(pClrDataModule.GetPtr())))
321321
{
322322
TRACE("MODULE: %"PRIA PRIx64 " dyn %d inmem %d file %d pe %"PRIA PRIx64 " pdb %"PRIA PRIx64, (uint64_t)moduleData.LoadedPEAddress, moduleData.IsDynamic,
323-
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEFile, (uint64_t)moduleData.InMemoryPdbAddress);
323+
moduleData.IsInMemory, moduleData.IsFileLayout, (uint64_t)moduleData.PEAssembly, (uint64_t)moduleData.InMemoryPdbAddress);
324324

325325
if (!moduleData.IsDynamic && moduleData.LoadedPEAddress != 0)
326326
{

‎src/coreclr/debug/daccess/daccess.cpp‎

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,6 @@ MetaEnum::New(Module* mod,
679679
*handle = TO_CDENUM(NULL);
680680
}
681681

682-
if (!mod->GetFile()->HasMetadata())
683-
{
684-
returnS_FALSE;
685-
}
686-
687682
metaEnum = new (nothrow) MetaEnum;
688683
if (!metaEnum)
689684
{
@@ -4079,9 +4074,9 @@ ClrDataAccess::GetModuleByAddress(
40794074
{
40804075
TADDR base;
40814076
ULONG32 length;
4082-
PEFile* file = modDef->GetFile();
4077+
PEAssembly* pPEAssembly = modDef->GetPEAssembly();
40834078

4084-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4079+
if ((base = PTR_TO_TADDR(pPEAssembly->GetLoadedImageContents(&length))))
40854080
{
40864081
if (TO_CDADDR(base) <= address &&
40874082
TO_CDADDR(base + length) > address)
@@ -4133,9 +4128,9 @@ ClrDataAccess::StartEnumMethodDefinitionsByAddress(
41334128
{
41344129
TADDR base;
41354130
ULONG32 length;
4136-
PEFile* file = modDef->GetFile();
4131+
PEAssembly* assembly = modDef->GetPEAssembly();
41374132

4138-
if ((base = PTR_TO_TADDR(file->GetLoadedImageContents(&length))))
4133+
if ((base = PTR_TO_TADDR(assembly->GetLoadedImageContents(&length))))
41394134
{
41404135
if (TO_CDADDR(base) <= address &&
41414136
TO_CDADDR(base + length) > address)
@@ -6459,7 +6454,7 @@ ClrDataAccess::GetHostGcNotificationTable()
64596454
}
64606455

64616456
/* static */bool
6462-
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
6457+
ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEAssembly *pPEAssembly,
64636458
DWORD &dwTimeStamp,
64646459
DWORD &dwSize,
64656460
DWORD &dwDataSize,
@@ -6477,7 +6472,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
64776472
isNGEN = false;
64786473
if (pDir == NULL || pDir->Size == 0)
64796474
{
6480-
mdImage = pPEFile->GetILimage();
6475+
mdImage = pPEAssembly->GetPEImage();
64816476
if (mdImage != NULL)
64826477
{
64836478
layout = mdImage->GetLoadedLayout();
@@ -6526,7 +6521,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
65266521
}
65276522

65286523
/* static */
6529-
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
6524+
boolClrDataAccess::GetILImageInfoFromNgenPEFile(PEAssembly *pPEAssembly,
65306525
DWORD &dwTimeStamp,
65316526
DWORD &dwSize,
65326527
__out_ecount(cchFilePath) LPWSTR wszFilePath,
@@ -6536,10 +6531,10 @@ bool ClrDataAccess::GetILImageInfoFromNgenPEFile(PEFile *peFile,
65366531
DWORD dwWritten = 0;
65376532

65386533
// use the IL File name
6539-
if (!peFile->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
6534+
if (!pPEAssembly->GetPath().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten)))
65406535
{
65416536
// Use DAC hint to retrieve the IL name.
6542-
peFile->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
6537+
pPEAssembly->GetModuleFileNameHint().DacGetUnicode(cchFilePath, wszFilePath, (COUNT_T *)(&dwWritten));
65436538
}
65446539
dwTimeStamp = 0;
65456540
dwSize = 0;
@@ -6603,7 +6598,7 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
66036598
#endif// FEATURE_CORESYSTEM
66046599

66056600
void *
6606-
ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
6601+
ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
66076602
bool* isAlternate)
66086603
{
66096604
DWORD imageTimestamp, imageSize, dataSize;
@@ -6634,7 +6629,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66346629
// so the field remains for now.
66356630

66366631
if (!ClrDataAccess::GetMetaDataFileInfoFromPEFile(
6637-
peFile,
6632+
pPEAssembly,
66386633
imageTimestamp,
66396634
imageSize,
66406635
dataSize,
@@ -6647,7 +6642,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66476642
}
66486643

66496644
// try direct match for the image that is loaded into the managed process
6650-
peFile->GetLoadedMetadata((COUNT_T *)(&dataSize));
6645+
pPEAssembly->GetLoadedMetadata((COUNT_T *)(&dataSize));
66516646

66526647
DWORD allocSize = 0;
66536648
if (!ClrSafeInt<DWORD>::addition(dataSize, sizeof(DAC_INSTANCE), allocSize))
@@ -6665,7 +6660,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
66656660
buffer = (void*)(inst + 1);
66666661

66676662
// APIs implemented by hosting debugger. It can use the path/filename, timestamp, and
6668-
//file size to find an exact match for the image. If that fails for an ngen'ed image,
6663+
//pPEAssembly size to find an exact match for the image. If that fails for an ngen'ed image,
66696664
// we can request the IL image which it came from.
66706665
if (m_legacyMetaDataLocator)
66716666
{
@@ -6701,7 +6696,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67016696
//
67026697
isAlt = true;
67036698
if (!ClrDataAccess::GetILImageInfoFromNgenPEFile(
6704-
peFile,
6699+
pPEAssembly,
67056700
imageTimestamp,
67066701
imageSize,
67076702
uniPath,
@@ -6781,13 +6776,13 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
67816776

67826777
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67836778
//
6784-
// Given a PEFile or a ReflectionModule try to find the corresponding metadata
6779+
// Given a PEAssembly or a ReflectionModule try to find the corresponding metadata
67856780
// We will first ask debugger to locate it. If fail, we will try
67866781
// to get it from the target process
67876782
//
67886783
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67896784
IMDInternalImport*
6790-
ClrDataAccess::GetMDImport(constPEFile* peFile, const ReflectionModule* reflectionModule, bool throwEx)
6785+
ClrDataAccess::GetMDImport(constPEAssembly* pPEAssembly, const ReflectionModule* reflectionModule, bool throwEx)
67916786
{
67926787
HRESULT status;
67936788
PTR_CVOID mdBaseTarget = NULL;
@@ -6796,22 +6791,22 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
67966791
PVOID mdBaseHost = NULL;
67976792
bool isAlternate = false;
67986793

6799-
_ASSERTE((peFile == NULL && reflectionModule != NULL) || (peFile != NULL && reflectionModule == NULL));
6800-
TADDR peFileAddr = (peFile != NULL) ? dac_cast<TADDR>(peFile) : dac_cast<TADDR>(reflectionModule);
6794+
_ASSERTE((pPEAssembly == NULL && reflectionModule != NULL) || (pPEAssembly != NULL && reflectionModule == NULL));
6795+
TADDRpeAssemblyAddr = (pPEAssembly != NULL) ? dac_cast<TADDR>(pPEAssembly) : dac_cast<TADDR>(reflectionModule);
68016796

68026797
//
68036798
// Look for one we've already created.
68046799
//
6805-
mdImport = m_mdImports.Get(peFileAddr);
6800+
mdImport = m_mdImports.Get(peAssemblyAddr);
68066801
if (mdImport != NULL)
68076802
{
68086803
return mdImport;
68096804
}
68106805

6811-
if (peFile != NULL)
6806+
if (pPEAssembly != NULL)
68126807
{
68136808
// Get the metadata size
6814-
mdBaseTarget = ((PEFile*)peFile)->GetLoadedMetadata(&mdSize);
6809+
mdBaseTarget = const_cast<PEAssembly*>(pPEAssembly)->GetLoadedMetadata(&mdSize);
68156810
}
68166811
elseif (reflectionModule != NULL)
68176812
{
@@ -6862,12 +6857,12 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
68626857
}
68636858

68646859
// Try to see if debugger can locate it
6865-
if (peFile != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
6860+
if (pPEAssembly != NULL && mdBaseHost == NULL && (m_target3 || m_legacyMetaDataLocator))
68666861
{
68676862
// We couldn't read the metadata from memory. Ask
68686863
// the target for metadata as it may be able to
68696864
// provide it from some alternate means.
6870-
mdBaseHost = GetMetaDataFromHost(const_cast<PEFile *>(peFile), &isAlternate);
6865+
mdBaseHost = GetMetaDataFromHost(const_cast<PEAssembly *>(pPEAssembly), &isAlternate);
68716866
}
68726867

68736868
if (mdBaseHost == NULL)
@@ -6902,7 +6897,7 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
69026897
// The m_mdImports list does get cleaned up by calls to ClrDataAccess::Flush,
69036898
// i.e. every time the process changes state.
69046899

6905-
if (m_mdImports.Add(peFileAddr, mdImport, isAlternate) == NULL)
6900+
if (m_mdImports.Add(peAssemblyAddr, mdImport, isAlternate) == NULL)
69066901
{
69076902
mdImport->Release();
69086903
DacError(E_OUTOFMEMORY);
@@ -6970,9 +6965,9 @@ HRESULT ClrDataAccess::VerifyDlls()
69706965
}
69716966

69726967
// Read the debug directory timestamp from the target mscorwks image using DAC
6973-
// Note that we don't use the PE timestamp because the PE file might be changed in ways
6968+
// Note that we don't use the PE timestamp because the PE pPEAssembly might be changed in ways
69746969
// that don't effect the PDB (and therefore don't effect DAC). Specifically, we rebase
6975-
// our DLLs at the end of a build, that changes the PE file, but not the PDB.
6970+
// our DLLs at the end of a build, that changes the PE pPEAssembly, but not the PDB.
69766971
// Note that if we wanted to be extra careful, we could read the CV contents (which includes
69776972
// the GUID signature) and verify it matches. Using the timestamp is useful for helpful error
69786973
// messages, and should be sufficient in any real scenario.

0 commit comments

Comments
 (0)