diff --git a/src/coreclr/debug/createdump/crashinfo.cpp b/src/coreclr/debug/createdump/crashinfo.cpp index 23601cfde1b5d9..529ed2f7f35777 100644 --- a/src/coreclr/debug/createdump/crashinfo.cpp +++ b/src/coreclr/debug/createdump/crashinfo.cpp @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #include "createdump.h" +#include // This is for the PAL_VirtualUnwindOutOfProc read memory adapter. CrashInfo* g_crashInfo; @@ -328,24 +329,34 @@ CrashInfo::EnumerateMemoryRegionsWithDAC(MINIDUMP_TYPE minidumpType) { TRACE("EnumerateMemoryRegionsWithDAC: Memory enumeration STARTED (%d %d)\n", m_enumMemoryPagesAdded, m_dataTargetPagesAdded); - // Since on both Linux and MacOS all the RW regions will be added for heap - // dumps by createdump, the only thing differentiating a MiniDumpNormal and - // a MiniDumpWithPrivateReadWriteMemory is that the later uses the EnumMemory - // APIs. This is kind of expensive on larger applications (4 minutes, or even - // more), and this should already be in RW pages. Change the dump type to the - // faster normal one. This one already ensures necessary DAC globals, etc. - // without the costly assembly, module, class, type runtime data structures - // enumeration. + // Since on MacOS all the RW regions will be added for heap dumps by createdump, the + // only thing differentiating a MiniDumpNormal and a MiniDumpWithPrivateReadWriteMemory + // is that the later uses the EnumMemoryRegions APIs. This is kind of expensive on larger + // applications (4 minutes, or even more), and this should already be in RW pages. Change + // the dump type to the faster normal one. This one already ensures necessary DAC globals, + // etc. without the costly assembly, module, class, type runtime data structures enumeration. + CLRDataEnumMemoryFlags flags = CLRDATA_ENUM_MEM_DEFAULT; if (minidumpType & MiniDumpWithPrivateReadWriteMemory) { - char* fastHeapDumps = getenv("COMPlus_DbgEnableFastHeapDumps"); - if (fastHeapDumps != nullptr && strcmp(fastHeapDumps, "1") == 0) + // This is the old fast heap env var for backwards compatibility for VS4Mac. + CLRConfigNoCache fastHeapDumps = CLRConfigNoCache::Get("DbgEnableFastHeapDumps", /*noprefix*/ false, &getenv); + DWORD val = 0; + if (fastHeapDumps.IsSet() && fastHeapDumps.TryAsInteger(10, val) && val == 1) { minidumpType = MiniDumpNormal; } + // This the new variable that also skips the expensive (in both time and memory usage) + // enumeration of the low level data structures and adds all the loader allocator heaps + // instead. The above original env var didn't generate a complete enough heap dump on + // Linux and this new one does. + fastHeapDumps = CLRConfigNoCache::Get("EnableFastHeapDumps", /*noprefix*/ false, &getenv); + if (fastHeapDumps.IsSet() && fastHeapDumps.TryAsInteger(10, val) && val == 1) + { + flags = CLRDATA_ENUM_MEM_HEAP2; + } } // Calls CrashInfo::EnumMemoryRegion for each memory region found by the DAC - HRESULT hr = m_pClrDataEnumRegions->EnumMemoryRegions(this, minidumpType, CLRDATA_ENUM_MEM_DEFAULT); + HRESULT hr = m_pClrDataEnumRegions->EnumMemoryRegions(this, minidumpType, flags); if (FAILED(hr)) { printf_error("EnumMemoryRegions FAILED %s (%08x)\n", GetHResultString(hr), hr); diff --git a/src/coreclr/debug/createdump/crashinfomac.cpp b/src/coreclr/debug/createdump/crashinfomac.cpp index 02534a7a9e7eb0..f1f91ff4a55ca2 100644 --- a/src/coreclr/debug/createdump/crashinfomac.cpp +++ b/src/coreclr/debug/createdump/crashinfomac.cpp @@ -487,7 +487,7 @@ ModuleInfo::LoadModule() } else { - TRACE("LoadModule: dlopen(%s) FAILED %d %s\n", m_moduleName.c_str(), errno, strerror(errno)); + TRACE("LoadModule: dlopen(%s) FAILED %s\n", m_moduleName.c_str(), dlerror()); } } } diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index 71bfcd7f898f47..bb476fa8145aaf 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -6246,24 +6246,15 @@ bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*= { if (!IsFullyReadable(addr, size)) { - if (!fExpectSuccess) + if (fExpectSuccess) { - // We know the read might fail (eg. we're trying to find mapped pages in - // a module image), so just skip this block silently. - // Note that the EnumMemoryRegion callback won't necessarily do anything if any part of - // the region is unreadable, and so there is no point in calling it. For cases where we expect - // the read might fail, but we want to report any partial blocks, we have to break up the region - // into pages and try reporting each page anyway - return true; + // We're reporting bogus memory, so the target must be corrupt (or there is a issue). We should abort + // reporting and continue with the next data structure (where the exception is caught), + // just like we would for a DAC read error (otherwise we might do something stupid + // like get into an infinite loop, or otherwise waste time with corrupt data). + TARGET_CONSISTENCY_CHECK(false, "Found unreadable memory while reporting memory regions for dump gathering"); + return false; } - - // We're reporting bogus memory, so the target must be corrupt (or there is a issue). We should abort - // reporting and continue with the next data structure (where the exception is caught), - // just like we would for a DAC read error (otherwise we might do something stupid - // like get into an infinite loop, or otherwise waste time with corrupt data). - - TARGET_CONSISTENCY_CHECK(false, "Found unreadable memory while reporting memory regions for dump gathering"); - return false; } } @@ -6275,9 +6266,7 @@ bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*= // data structure at all. Hopefully experience will help guide this going forward. // @dbgtodo : Extend dump-gathering API to allow a dump-log to be included. const TSIZE_T kMaxMiniDumpRegion = 4*1024*1024 - 3; // 4MB-3 - if( size > kMaxMiniDumpRegion - && (m_enumMemFlags == CLRDATA_ENUM_MEM_MINI - || m_enumMemFlags == CLRDATA_ENUM_MEM_TRIAGE)) + if (size > kMaxMiniDumpRegion && (m_enumMemFlags == CLRDATA_ENUM_MEM_MINI || m_enumMemFlags == CLRDATA_ENUM_MEM_TRIAGE)) { TARGET_CONSISTENCY_CHECK( false, "Dump target consistency failure - truncating minidump data structure"); size = kMaxMiniDumpRegion; diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index 91a6e4ecc7e261..acf458a39d2bea 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -3618,7 +3618,7 @@ void DacDbiInterfaceImpl::EnumerateMemRangesForLoaderAllocator(PTR_LoaderAllocat // GetVirtualCallStubManager returns VirtualCallStubManager*, but it's really an address to target as // pLoaderAllocator is DACized. Cast it so we don't try to to a Host to Target translation. - VirtualCallStubManager *pVcsMgr = PTR_VirtualCallStubManager(TO_TADDR(pLoaderAllocator->GetVirtualCallStubManager())); + VirtualCallStubManager *pVcsMgr = pLoaderAllocator->GetVirtualCallStubManager(); LOG((LF_CORDB, LL_INFO10000, "DDBII::EMRFLA: VirtualCallStubManager 0x%x\n", PTR_HOST_TO_TADDR(pVcsMgr))); if (pVcsMgr) { diff --git a/src/coreclr/debug/daccess/dacimpl.h b/src/coreclr/debug/daccess/dacimpl.h index c6a01bd2d48ff9..33a2149e9a56e3 100644 --- a/src/coreclr/debug/daccess/dacimpl.h +++ b/src/coreclr/debug/daccess/dacimpl.h @@ -1328,6 +1328,7 @@ class ClrDataAccess HRESULT EnumMemCollectImages(); HRESULT EnumMemCLRStatic(CLRDataEnumMemoryFlags flags); + HRESULT EnumMemDumpJitManagerInfo(IN CLRDataEnumMemoryFlags flags); HRESULT EnumMemCLRHeapCrticalStatic(CLRDataEnumMemoryFlags flags); HRESULT EnumMemDumpModuleList(CLRDataEnumMemoryFlags flags); HRESULT EnumMemDumpAppDomainInfo(CLRDataEnumMemoryFlags flags); diff --git a/src/coreclr/debug/daccess/enummem.cpp b/src/coreclr/debug/daccess/enummem.cpp index 7db97915d132d1..ee30bf593bb5f3 100644 --- a/src/coreclr/debug/daccess/enummem.cpp +++ b/src/coreclr/debug/daccess/enummem.cpp @@ -283,6 +283,21 @@ HRESULT ClrDataAccess::EnumMemCLRStatic(IN CLRDataEnumMemoryFlags flags) return S_OK; } +HRESULT ClrDataAccess::EnumMemDumpJitManagerInfo(IN CLRDataEnumMemoryFlags flags) +{ + SUPPORTS_DAC; + + HRESULT status = S_OK; + + if (flags == CLRDATA_ENUM_MEM_HEAP2) + { + EEJitManager* managerPtr = ExecutionManager::GetEEJitManager(); + managerPtr->EnumMemoryRegions(flags); + } + + return status; +} + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // This function reports memory that a heap dump need to debug CLR @@ -325,6 +340,9 @@ HRESULT ClrDataAccess::EnumMemoryRegionsWorkerHeap(IN CLRDataEnumMemoryFlags fla // Dump AppDomain-specific info CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( status = EnumMemDumpAppDomainInfo(flags); ) + // Dump jit manager info + CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( status = EnumMemDumpJitManagerInfo(flags); ) + // Dump the Debugger object data needed CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( g_pDebugger->EnumMemoryRegions(flags); ) @@ -680,6 +698,11 @@ HRESULT ClrDataAccess::EnumMemDumpAppDomainInfo(CLRDataEnumMemoryFlags flags) { SUPPORTS_DAC; + if (flags == CLRDATA_ENUM_MEM_HEAP2) + { + SystemDomain::System()->GetLoaderAllocator()->EnumMemoryRegions(flags); + } + AppDomainIterator adIter(FALSE); EX_TRY { @@ -1853,7 +1876,7 @@ HRESULT ClrDataAccess::EnumMemoryRegionsWrapper(IN CLRDataEnumMemoryFlags flags) // triage micro-dump status = EnumMemoryRegionsWorkerMicroTriage(flags); } - else if (flags == CLRDATA_ENUM_MEM_HEAP) + else if (flags == CLRDATA_ENUM_MEM_HEAP || flags == CLRDATA_ENUM_MEM_HEAP2) { status = EnumMemoryRegionsWorkerHeap(flags); } @@ -1946,7 +1969,15 @@ ClrDataAccess::EnumMemoryRegions(IN ICLRDataEnumMemoryRegionsCallback* callback, if (miniDumpFlags & MiniDumpWithPrivateReadWriteMemory) { // heap dump - status = EnumMemoryRegionsWrapper(CLRDATA_ENUM_MEM_HEAP); + if (flags == CLRDATA_ENUM_MEM_HEAP2) + { + DacLogMessage("EnumMemoryRegions(CLRDATA_ENUM_MEM_HEAP2)\n"); + } + else + { + flags = CLRDATA_ENUM_MEM_HEAP; + } + status = EnumMemoryRegionsWrapper(flags); } else if (miniDumpFlags & MiniDumpWithFullAuxiliaryState) { diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index 7e2906cfcae443..5d755b2bf556e6 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -3497,7 +3497,7 @@ ClrDataAccess::TraverseVirtCallStubHeap(CLRDATA_ADDRESS pAppDomain, VCSHeapType SOSDacEnter(); BaseDomain* pBaseDomain = PTR_BaseDomain(TO_TADDR(pAppDomain)); - VirtualCallStubManager *pVcsMgr = PTR_VirtualCallStubManager((TADDR)pBaseDomain->GetLoaderAllocator()->GetVirtualCallStubManager()); + VirtualCallStubManager *pVcsMgr = pBaseDomain->GetLoaderAllocator()->GetVirtualCallStubManager(); if (!pVcsMgr) { hr = E_POINTER; diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index df05ee034a0d96..bbae9cf6d28e1c 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -16596,22 +16596,23 @@ Debugger::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { DAC_ENUM_VTHIS(); SUPPORTS_DAC; - _ASSERTE(m_rgHijackFunction != NULL); - if ( flags != CLRDATA_ENUM_MEM_TRIAGE) + if (flags != CLRDATA_ENUM_MEM_TRIAGE) { if (m_pMethodInfos.IsValid()) { m_pMethodInfos->EnumMemoryRegions(flags); } - DacEnumMemoryRegion(dac_cast(m_pLazyData), - sizeof(DebuggerLazyInit)); + DacEnumMemoryRegion(dac_cast(m_pLazyData), sizeof(DebuggerLazyInit)); } // Needed for stack walking from an initial native context. If the debugger can find the // on-disk image of clr.dll, then this is not necessary. - DacEnumMemoryRegion(dac_cast(m_rgHijackFunction), sizeof(MemoryRange)*kMaxHijackFunctions); + if (m_rgHijackFunction.IsValid()) + { + DacEnumMemoryRegion(dac_cast(m_rgHijackFunction), sizeof(MemoryRange)*kMaxHijackFunctions); + } } diff --git a/src/coreclr/debug/ee/functioninfo.cpp b/src/coreclr/debug/ee/functioninfo.cpp index 4cef128986074b..54c31f50f17127 100644 --- a/src/coreclr/debug/ee/functioninfo.cpp +++ b/src/coreclr/debug/ee/functioninfo.cpp @@ -2456,9 +2456,7 @@ DebuggerMethodInfoEntry::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) // For a MiniDumpNormal, what is needed for modules is already enumerated elsewhere. // Don't waste time doing it here an extra time. Also, this will add many MB extra into the dump. - if ((key.pModule.IsValid()) && - CLRDATA_ENUM_MEM_MINI != flags - && CLRDATA_ENUM_MEM_TRIAGE != flags) + if ((key.pModule.IsValid()) && CLRDATA_ENUM_MEM_MINI != flags && CLRDATA_ENUM_MEM_TRIAGE != flags && CLRDATA_ENUM_MEM_HEAP2 != flags) { key.pModule->EnumMemoryRegions(flags, true); } @@ -2476,7 +2474,7 @@ DebuggerMethodInfo::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) DAC_ENUM_DTHIS(); SUPPORTS_DAC; - if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) + if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE && flags != CLRDATA_ENUM_MEM_HEAP2) { // Modules are enumerated already for minidumps, save the empty calls. if (m_module.IsValid()) @@ -2505,7 +2503,7 @@ DebuggerJitInfo::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) m_methodInfo->EnumMemoryRegions(flags); } - if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) + if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE && flags != CLRDATA_ENUM_MEM_HEAP2) { if (m_nativeCodeVersion.GetMethodDesc().IsValid()) { diff --git a/src/coreclr/inc/clrdata.idl b/src/coreclr/inc/clrdata.idl index 2663a7b057fd7d..81b0e0bc7fc653 100644 --- a/src/coreclr/inc/clrdata.idl +++ b/src/coreclr/inc/clrdata.idl @@ -308,10 +308,12 @@ interface ICLRDataLoggingCallback : IUnknown typedef enum CLRDataEnumMemoryFlags { CLRDATA_ENUM_MEM_DEFAULT = 0x0, - CLRDATA_ENUM_MEM_MINI = CLRDATA_ENUM_MEM_DEFAULT, // generating skinny mini-dump - CLRDATA_ENUM_MEM_HEAP = 0x1, // generating heap dump - CLRDATA_ENUM_MEM_TRIAGE = 0x2, // generating triage mini-dump - + CLRDATA_ENUM_MEM_MINI = CLRDATA_ENUM_MEM_DEFAULT, // generating skinny mini-dump + CLRDATA_ENUM_MEM_HEAP = 0x1, // generating heap dump + CLRDATA_ENUM_MEM_TRIAGE = 0x2, // generating triage mini-dump + /* Generate heap dumps faster with less memory usage than CLRDATA_ENUM_MEM_HEAP by adding + the loader heaps instead of traversing all the individual runtime data structures. */ + CLRDATA_ENUM_MEM_HEAP2 = 0x3, /* More bits to be added here later */ } CLRDataEnumMemoryFlags; diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index c2053d748b0c73..a8056a5451561a 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -2466,7 +2466,7 @@ typedef DPTR(PTR_PCODE) PTR_PTR_PCODE; // Helper macro for tracking EnumMemoryRegions progress. #if 0 -#define EMEM_OUT(args) DacWarning args +#define EMEM_OUT(args) DacLogMessage args #else #define EMEM_OUT(args) #endif diff --git a/src/coreclr/pal/prebuilt/inc/clrdata.h b/src/coreclr/pal/prebuilt/inc/clrdata.h index 09b24af8ccf094..802c34a87bf0cb 100644 --- a/src/coreclr/pal/prebuilt/inc/clrdata.h +++ b/src/coreclr/pal/prebuilt/inc/clrdata.h @@ -1299,7 +1299,8 @@ enum CLRDataEnumMemoryFlags CLRDATA_ENUM_MEM_DEFAULT = 0, CLRDATA_ENUM_MEM_MINI = CLRDATA_ENUM_MEM_DEFAULT, CLRDATA_ENUM_MEM_HEAP = 0x1, - CLRDATA_ENUM_MEM_TRIAGE = 0x2 + CLRDATA_ENUM_MEM_TRIAGE = 0x2, + CLRDATA_ENUM_MEM_HEAP2 = 0x3 } CLRDataEnumMemoryFlags; diff --git a/src/coreclr/utilcode/loaderheap.cpp b/src/coreclr/utilcode/loaderheap.cpp index 5c55e6283c16b4..db6489026b2921 100644 --- a/src/coreclr/utilcode/loaderheap.cpp +++ b/src/coreclr/utilcode/loaderheap.cpp @@ -341,6 +341,7 @@ RangeList::RangeListBlock::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) // code:LoaderHeap::UnlockedReservePages adds a range for the entire reserved region, instead // of updating the RangeList when pages are committed. But in that case, the committed region of // memory will be enumerated by the LoaderHeap anyway, so it's OK if this fails + EMEM_OUT(("MEM: RangeListBlock %p - %p\n", range->start, range->end)); DacEnumMemoryRegion(range->start, size, false); } } @@ -1933,8 +1934,6 @@ void UnlockedLoaderHeap::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { WRAPPER_NO_CONTRACT; - DAC_ENUM_DTHIS(); - PTR_LoaderHeapBlock block = m_pFirstBlock; while (block.IsValid()) { @@ -1946,6 +1945,7 @@ void UnlockedLoaderHeap::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) // but it seems wasteful (eg. makes each AppDomain objects 32 bytes larger on x64). TADDR addr = dac_cast(block->pVirtualAddress); TSIZE_T size = block->dwVirtualSize; + EMEM_OUT(("MEM: UnlockedLoaderHeap %p - %p\n", addr, addr + size)); DacEnumMemoryRegion(addr, size, false); block = block->pNext; diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index 39a02a3ffdd639..1ca1fe8cad79c6 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -5086,26 +5086,7 @@ DomainLocalModule::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) } void -BaseDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, - bool enumThis) -{ - SUPPORTS_DAC; - if (enumThis) - { - // This is wrong. Don't do it. - // BaseDomain cannot be instantiated. - // The only thing this code can hope to accomplish is to potentially break - // memory enumeration walking through the derived class if we - // explicitly call the base class enum first. -// DAC_ENUM_VTHIS(); - } - - EMEM_OUT(("MEM: %p BaseDomain\n", dac_cast(this))); -} - -void -AppDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, - bool enumThis) +AppDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, bool enumThis) { SUPPORTS_DAC; @@ -5113,8 +5094,8 @@ AppDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, { //sizeof(AppDomain) == 0xeb0 DAC_ENUM_VTHIS(); + EMEM_OUT(("MEM: %p AppDomain\n", dac_cast(this))); } - BaseDomain::EnumMemoryRegions(flags, false); // We don't need AppDomain name in triage dumps. if (flags != CLRDATA_ENUM_MEM_TRIAGE) @@ -5122,6 +5103,11 @@ AppDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, m_friendlyName.EnumMemoryRegions(flags); } + if (flags == CLRDATA_ENUM_MEM_HEAP2) + { + GetLoaderAllocator()->EnumMemoryRegions(flags); + } + m_Assemblies.EnumMemoryRegions(flags); AssemblyIterator assem = IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded | kIncludeExecution)); CollectibleAssemblyHolder pDomainAssembly; @@ -5133,16 +5119,19 @@ AppDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, } void -SystemDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, - bool enumThis) +SystemDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, bool enumThis) { SUPPORTS_DAC; if (enumThis) { DAC_ENUM_VTHIS(); + EMEM_OUT(("MEM: %p SystemAppomain\n", dac_cast(this))); } - BaseDomain::EnumMemoryRegions(flags, false); + if (flags == CLRDATA_ENUM_MEM_HEAP2) + { + GetLoaderAllocator()->EnumMemoryRegions(flags); + } if (m_pSystemPEAssembly.IsValid()) { m_pSystemPEAssembly->EnumMemoryRegions(flags); diff --git a/src/coreclr/vm/appdomain.hpp b/src/coreclr/vm/appdomain.hpp index 5798301810d2d0..e25b2d56cd6573 100644 --- a/src/coreclr/vm/appdomain.hpp +++ b/src/coreclr/vm/appdomain.hpp @@ -1260,8 +1260,7 @@ class BaseDomain #ifdef DACCESS_COMPILE public: - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags, - bool enumThis); + virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags, bool enumThis) = 0; #endif }; // class BaseDomain diff --git a/src/coreclr/vm/assembly.cpp b/src/coreclr/vm/assembly.cpp index 97f1d26d1c281e..9bb246a62f49e8 100644 --- a/src/coreclr/vm/assembly.cpp +++ b/src/coreclr/vm/assembly.cpp @@ -2132,21 +2132,28 @@ Assembly::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) DAC_ENUM_DTHIS(); EMEM_OUT(("MEM: %p Assembly\n", dac_cast(this))); - if (m_pDomain.IsValid()) + if (flags == CLRDATA_ENUM_MEM_HEAP2) { - m_pDomain->EnumMemoryRegions(flags, true); + GetLoaderAllocator()->EnumMemoryRegions(flags); } - if (m_pClassLoader.IsValid()) - { - m_pClassLoader->EnumMemoryRegions(flags); - } - if (m_pModule.IsValid()) - { - m_pModule->EnumMemoryRegions(flags, true); - } - if (m_pPEAssembly.IsValid()) + else { - m_pPEAssembly->EnumMemoryRegions(flags); + if (m_pDomain.IsValid()) + { + m_pDomain->EnumMemoryRegions(flags, true); + } + if (m_pClassLoader.IsValid()) + { + m_pClassLoader->EnumMemoryRegions(flags); + } + if (m_pModule.IsValid()) + { + m_pModule->EnumMemoryRegions(flags, true); + } + if (m_pPEAssembly.IsValid()) + { + m_pPEAssembly->EnumMemoryRegions(flags); + } } } diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 04e65cbfbdbe1c..e6a1f86114c4e8 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -5123,7 +5123,6 @@ void Module::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, { m_ModuleID->EnumMemoryRegions(flags); } - if (m_pPEAssembly.IsValid()) { m_pPEAssembly->EnumMemoryRegions(flags); @@ -5136,7 +5135,11 @@ void Module::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, m_TypeRefToMethodTableMap.ListEnumMemoryRegions(flags); m_TypeDefToMethodTableMap.ListEnumMemoryRegions(flags); - if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) + if (flags == CLRDATA_ENUM_MEM_HEAP2) + { + GetLoaderAllocator()->EnumMemoryRegions(flags); + } + else if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) { if (m_pAvailableClasses.IsValid()) { @@ -5224,7 +5227,7 @@ void Module::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, } } - } // !CLRDATA_ENUM_MEM_MINI && !CLRDATA_ENUM_MEM_TRIAGE + } // !CLRDATA_ENUM_MEM_MINI && !CLRDATA_ENUM_MEM_TRIAGE && !CLRDATA_ENUM_MEM_HEAP2 LookupMap::Iterator fileRefIter(&m_FileReferencesMap); @@ -5589,4 +5592,4 @@ void DECLSPEC_NORETURN Module::ThrowTypeLoadExceptionImpl(IMDInternalImport *pIn WRAPPER_NO_CONTRACT; GetAssembly()->ThrowTypeLoadException(pInternalImport, token, NULL, resIDWhy); } -#endif \ No newline at end of file +#endif diff --git a/src/coreclr/vm/class.cpp b/src/coreclr/vm/class.cpp index 4492c025d71a51..fd6053c64bfb50 100644 --- a/src/coreclr/vm/class.cpp +++ b/src/coreclr/vm/class.cpp @@ -2994,7 +2994,7 @@ EEClass::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, MethodTable * pMT) if (HasOptionalFields()) DacEnumMemoryRegion(dac_cast(GetOptionalFields()), sizeof(EEClassOptionalFields)); - if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) + if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE && flags != CLRDATA_ENUM_MEM_HEAP2) { PTR_Module pModule = pMT->GetModule(); if (pModule.IsValid()) diff --git a/src/coreclr/vm/domainassembly.cpp b/src/coreclr/vm/domainassembly.cpp index 3e5706e48c817f..2ae508ca073c5b 100644 --- a/src/coreclr/vm/domainassembly.cpp +++ b/src/coreclr/vm/domainassembly.cpp @@ -1067,14 +1067,17 @@ void DomainAssembly::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) m_pPEAssembly->EnumMemoryRegions(flags); } - if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE - && m_pDomain.IsValid()) + if (flags == CLRDATA_ENUM_MEM_HEAP2) { - m_pDomain->EnumMemoryRegions(flags, true); + GetLoaderAllocator()->EnumMemoryRegions(flags); } - - if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) + else if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) { + if (m_pDomain.IsValid()) + { + m_pDomain->EnumMemoryRegions(flags, true); + } + if (m_pAssembly.IsValid()) { m_pAssembly->EnumMemoryRegions(flags); diff --git a/src/coreclr/vm/loaderallocator.cpp b/src/coreclr/vm/loaderallocator.cpp index b7eebd07afecb5..86a72ff57fac5a 100644 --- a/src/coreclr/vm/loaderallocator.cpp +++ b/src/coreclr/vm/loaderallocator.cpp @@ -1445,6 +1445,7 @@ void LoaderAllocator::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { SUPPORTS_DAC; DAC_ENUM_DTHIS(); + EMEM_OUT(("MEM: %p LoaderAllocator\n", dac_cast(this))); if (m_pLowFrequencyHeap.IsValid()) { m_pLowFrequencyHeap->EnumMemoryRegions(flags); @@ -1461,9 +1462,27 @@ void LoaderAllocator::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { m_pPrecodeHeap->EnumMemoryRegions(flags); } - if (m_pPrecodeHeap.IsValid()) + if (m_pExecutableHeap.IsValid()) { - m_pPrecodeHeap->EnumMemoryRegions(flags); + m_pExecutableHeap->EnumMemoryRegions(flags); + } +#ifdef FEATURE_READYTORUN + if (m_pDynamicHelpersHeap.IsValid()) + { + m_pDynamicHelpersHeap->EnumMemoryRegions(flags); + } +#endif + if (m_pFixupPrecodeHeap.IsValid()) + { + m_pFixupPrecodeHeap->EnumMemoryRegions(flags); + } + if (m_pNewStubPrecodeHeap.IsValid()) + { + m_pNewStubPrecodeHeap->EnumMemoryRegions(flags); + } + if (m_pVirtualCallStubManager.IsValid()) + { + m_pVirtualCallStubManager->EnumMemoryRegions(flags); } } #endif //DACCESS_COMPILE diff --git a/src/coreclr/vm/loaderallocator.hpp b/src/coreclr/vm/loaderallocator.hpp index 90311d3a01ca18..cbe6ce460f3fe8 100644 --- a/src/coreclr/vm/loaderallocator.hpp +++ b/src/coreclr/vm/loaderallocator.hpp @@ -240,7 +240,7 @@ class LoaderAllocator FatTokenSet *m_pFatTokenSet; #endif - VirtualCallStubManager *m_pVirtualCallStubManager; + PTR_VirtualCallStubManager m_pVirtualCallStubManager; private: LoaderAllocatorSet m_LoaderAllocatorReferences; @@ -599,7 +599,7 @@ class LoaderAllocator void InitVirtualCallStubManager(BaseDomain *pDomain); void UninitVirtualCallStubManager(); - inline VirtualCallStubManager *GetVirtualCallStubManager() + inline PTR_VirtualCallStubManager GetVirtualCallStubManager() { LIMITED_METHOD_CONTRACT; return m_pVirtualCallStubManager; diff --git a/src/coreclr/vm/methodtable.cpp b/src/coreclr/vm/methodtable.cpp index c4d8156fc939b8..e61162ac553c89 100644 --- a/src/coreclr/vm/methodtable.cpp +++ b/src/coreclr/vm/methodtable.cpp @@ -7904,7 +7904,7 @@ MethodTable::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) pWriteableData.EnumMem(); } - if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) + if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE && flags != CLRDATA_ENUM_MEM_HEAP2) { DispatchMap * pMap = GetDispatchMap(); if (pMap != NULL) diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 91b2f55d9ea33a..c86a6886515042 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -8383,7 +8383,7 @@ Thread::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) WRAPPER_NO_CONTRACT; DAC_ENUM_DTHIS(); - if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) + if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE && flags != CLRDATA_ENUM_MEM_HEAP2) { if (m_pDomain.IsValid()) { @@ -8467,7 +8467,7 @@ Thread::EnumMemoryRegionsWorker(CLRDataEnumMemoryFlags flags) DacGetThreadContext(this, &context); } - if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE) + if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE && flags != CLRDATA_ENUM_MEM_HEAP2) { AppDomain::GetCurrentDomain()->EnumMemoryRegions(flags, true); }