diff options
author | Sean Gillespie <sean.william.g@gmail.com> | 2016-09-08 13:06:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-08 13:06:21 -0700 |
commit | 1c43df95410e57f0d40e6ee55012ef65bdac2487 (patch) | |
tree | b57fda7959af77de7c77353e5a5dd70a77f7d0dd /src/debug | |
parent | 65c2ff78e0e88f5052751747f6686084caab3d4c (diff) | |
parent | 6519911fbccbec049f9592484f69c213b4b78264 (diff) | |
download | coreclr-1c43df95410e57f0d40e6ee55012ef65bdac2487.tar.gz coreclr-1c43df95410e57f0d40e6ee55012ef65bdac2487.tar.bz2 coreclr-1c43df95410e57f0d40e6ee55012ef65bdac2487.zip |
Merge pull request #6764 from swgillespie/gc-interface-3
Move the GC behind an interface and use that interface in the VM
Diffstat (limited to 'src/debug')
-rw-r--r-- | src/debug/daccess/daccess.cpp | 6 | ||||
-rw-r--r-- | src/debug/daccess/dacdbiimpl.cpp | 8 | ||||
-rw-r--r-- | src/debug/daccess/enummem.cpp | 6 | ||||
-rw-r--r-- | src/debug/daccess/request.cpp | 76 | ||||
-rw-r--r-- | src/debug/daccess/request_svr.cpp | 4 |
5 files changed, 54 insertions, 46 deletions
diff --git a/src/debug/daccess/daccess.cpp b/src/debug/daccess/daccess.cpp index ba3995b1f7..aebfa43a91 100644 --- a/src/debug/daccess/daccess.cpp +++ b/src/debug/daccess/daccess.cpp @@ -7974,7 +7974,7 @@ HRESULT DacHandleWalker::Init(ClrDataAccess *dac, UINT types[], UINT typeCount, { SUPPORTS_DAC; - if (gen < 0 || gen > (int)GCHeap::GetMaxGeneration()) + if (gen < 0 || gen > (int)GCHeapUtilities::GetMaxGeneration()) return E_INVALIDARG; mGenerationFilter = gen; @@ -8033,7 +8033,7 @@ bool DacHandleWalker::FetchMoreHandles(HANDLESCANPROC callback) int max_slots = 1; #ifdef FEATURE_SVR_GC - if (GCHeap::IsServerHeap()) + if (GCHeapUtilities::IsServerHeap()) max_slots = GCHeapCount(); #endif // FEATURE_SVR_GC @@ -8089,7 +8089,7 @@ bool DacHandleWalker::FetchMoreHandles(HANDLESCANPROC callback) HndScanHandlesForGC(hTable, callback, (LPARAM)¶m, 0, &handleType, 1, - mGenerationFilter, GCHeap::GetMaxGeneration(), 0); + mGenerationFilter, GCHeapUtilities::GetMaxGeneration(), 0); else HndEnumHandles(hTable, &handleType, 1, callback, (LPARAM)¶m, 0, FALSE); } diff --git a/src/debug/daccess/dacdbiimpl.cpp b/src/debug/daccess/dacdbiimpl.cpp index 9b17f4cd46..cb9c0310cc 100644 --- a/src/debug/daccess/dacdbiimpl.cpp +++ b/src/debug/daccess/dacdbiimpl.cpp @@ -6517,7 +6517,7 @@ HRESULT DacHeapWalker::Init(CORDB_ADDRESS start, CORDB_ADDRESS end) if (thread == NULL) continue; - alloc_context *ctx = thread->GetAllocContext(); + gc_alloc_context *ctx = thread->GetAllocContext(); if (ctx == NULL) continue; @@ -6533,7 +6533,7 @@ HRESULT DacHeapWalker::Init(CORDB_ADDRESS start, CORDB_ADDRESS end) } #ifdef FEATURE_SVR_GC - HRESULT hr = GCHeap::IsServerHeap() ? InitHeapDataSvr(mHeaps, mHeapCount) : InitHeapDataWks(mHeaps, mHeapCount); + HRESULT hr = GCHeapUtilities::IsServerHeap() ? InitHeapDataSvr(mHeaps, mHeapCount) : InitHeapDataWks(mHeaps, mHeapCount); #else HRESULT hr = InitHeapDataWks(mHeaps, mHeapCount); #endif @@ -6777,7 +6777,7 @@ HRESULT DacDbiInterfaceImpl::GetHeapSegments(OUT DacDbiArrayList<COR_SEGMENT> *p HeapData *heaps = 0; #ifdef FEATURE_SVR_GC - HRESULT hr = GCHeap::IsServerHeap() ? DacHeapWalker::InitHeapDataSvr(heaps, heapCount) : DacHeapWalker::InitHeapDataWks(heaps, heapCount); + HRESULT hr = GCHeapUtilities::IsServerHeap() ? DacHeapWalker::InitHeapDataSvr(heaps, heapCount) : DacHeapWalker::InitHeapDataWks(heaps, heapCount); #else HRESULT hr = DacHeapWalker::InitHeapDataWks(heaps, heapCount); #endif @@ -7171,7 +7171,7 @@ void DacDbiInterfaceImpl::GetGCHeapInformation(COR_HEAPINFO * pHeapInfo) pHeapInfo->areGCStructuresValid = GCScan::GetGcRuntimeStructuresValid(); #ifdef FEATURE_SVR_GC - if (GCHeap::IsServerHeap()) + if (GCHeapUtilities::IsServerHeap()) { pHeapInfo->gcType = CorDebugServerGC; pHeapInfo->numHeaps = DacGetNumHeaps(); diff --git a/src/debug/daccess/enummem.cpp b/src/debug/daccess/enummem.cpp index 068c2f2b13..cc3ae4f606 100644 --- a/src/debug/daccess/enummem.cpp +++ b/src/debug/daccess/enummem.cpp @@ -250,9 +250,9 @@ HRESULT ClrDataAccess::EnumMemCLRStatic(IN CLRDataEnumMemoryFlags flags) ReportMem(m_globalBase + g_dacGlobals.SharedDomain__m_pSharedDomain, sizeof(SharedDomain)); - // We need GCHeap pointer to make EEVersion work + // We need IGCHeap pointer to make EEVersion work ReportMem(m_globalBase + g_dacGlobals.dac__g_pGCHeap, - sizeof(GCHeap *)); + sizeof(IGCHeap *)); // see synblk.cpp, the pointer is pointed to a static byte[] SyncBlockCache::s_pSyncBlockCache.EnumMem(); @@ -316,7 +316,7 @@ HRESULT ClrDataAccess::EnumMemCLRStatic(IN CLRDataEnumMemoryFlags flags) #ifdef FEATURE_SVR_GC CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED ( - GCHeap::gcHeapType.EnumMem(); + IGCHeap::gcHeapType.EnumMem(); ); #endif // FEATURE_SVR_GC diff --git a/src/debug/daccess/request.cpp b/src/debug/daccess/request.cpp index a30ec37eac..9de09e7f85 100644 --- a/src/debug/daccess/request.cpp +++ b/src/debug/daccess/request.cpp @@ -725,7 +725,7 @@ ClrDataAccess::GetHeapAllocData(unsigned int count, struct DacpGenerationAllocDa SOSDacEnter(); #if defined(FEATURE_SVR_GC) - if (GCHeap::IsServerHeap()) + if (GCHeapUtilities::IsServerHeap()) { hr = GetServerAllocData(count, data, pNeeded); } @@ -2809,7 +2809,7 @@ ClrDataAccess::GetGCHeapDetails(CLRDATA_ADDRESS heap, struct DacpGcHeapDetails * SOSDacEnter(); // doesn't make sense to call this on WKS mode - if (!GCHeap::IsServerHeap()) + if (!GCHeapUtilities::IsServerHeap()) hr = E_INVALIDARG; else #ifdef FEATURE_SVR_GC @@ -2884,7 +2884,7 @@ ClrDataAccess::GetHeapSegmentData(CLRDATA_ADDRESS seg, struct DacpHeapSegmentDat SOSDacEnter(); - if (GCHeap::IsServerHeap()) + if (GCHeapUtilities::IsServerHeap()) { #if !defined(FEATURE_SVR_GC) _ASSERTE(0); @@ -2924,7 +2924,7 @@ ClrDataAccess::GetGCHeapList(unsigned int count, CLRDATA_ADDRESS heaps[], unsign SOSDacEnter(); // make sure we called this in appropriate circumstances (i.e., we have multiple heaps) - if (GCHeap::IsServerHeap()) + if (GCHeapUtilities::IsServerHeap()) { #if !defined(FEATURE_SVR_GC) _ASSERTE(0); @@ -2960,45 +2960,53 @@ ClrDataAccess::GetGCHeapData(struct DacpGcHeapData *gcheapData) SOSDacEnter(); - // Now get the heap type. The first data member of the GCHeap class is the GC_HEAP_TYPE, which has - // three possible values: - // GC_HEAP_INVALID = 0, - // GC_HEAP_WKS = 1, - // GC_HEAP_SVR = 2 - - TADDR gcHeapLocation = g_pGCHeap.GetAddrRaw (); // get the starting address of the global GCHeap instance - size_t gcHeapValue = 0; // this will hold the heap type + size_t gcHeapValue = 0; ULONG32 returned = 0; + TADDR gcHeapTypeLocation = m_globalBase + g_dacGlobals.IGCHeap__gcHeapType; // @todo Microsoft: we should probably be capturing the HRESULT from ReadVirtual. We could // provide a more informative error message. E_FAIL is a wretchedly vague thing to return. - hr = m_pTarget->ReadVirtual(gcHeapLocation, (PBYTE)&gcHeapValue, sizeof(gcHeapValue), &returned); + hr = m_pTarget->ReadVirtual(gcHeapTypeLocation, (PBYTE)&gcHeapValue, sizeof(gcHeapValue), &returned); + if (!SUCCEEDED(hr)) + { + goto cleanup; + } + + // GC_HEAP_TYPE has three possible values: + // GC_HEAP_INVALID = 0, + // GC_HEAP_WKS = 1, + // GC_HEAP_SVR = 2 + // If we get something other than that, we probably read the wrong location. + _ASSERTE(gcHeapValue >= 0 && gcHeapValue <= 2); //@todo Microsoft: We have an enumerated type, we probably should use the symbolic name // we have GC_HEAP_INVALID if gcHeapValue == 0, so we're done if (SUCCEEDED(hr) && ((returned != sizeof(gcHeapValue)) || (gcHeapValue == 0))) + { hr = E_FAIL; + goto cleanup; + } - if (SUCCEEDED(hr)) + // Now we can get other important information about the heap + gcheapData->g_max_generation = GCHeapUtilities::GetMaxGeneration(); + gcheapData->bServerMode = GCHeapUtilities::IsServerHeap(); + gcheapData->bGcStructuresValid = GCScan::GetGcRuntimeStructuresValid(); + if (GCHeapUtilities::IsServerHeap()) { - // Now we can get other important information about the heap - gcheapData->g_max_generation = GCHeap::GetMaxGeneration(); - gcheapData->bServerMode = GCHeap::IsServerHeap(); - gcheapData->bGcStructuresValid = GCScan::GetGcRuntimeStructuresValid(); - if (GCHeap::IsServerHeap()) - { #if !defined (FEATURE_SVR_GC) - _ASSERTE(0); - gcheapData->HeapCount = 1; + _ASSERTE(0); + gcheapData->HeapCount = 1; #else // !defined (FEATURE_SVR_GC) - gcheapData->HeapCount = GCHeapCount(); + gcheapData->HeapCount = GCHeapCount(); #endif // !defined (FEATURE_SVR_GC) - } - else - { - gcheapData->HeapCount = 1; - } } + else + { + gcheapData->HeapCount = 1; + } + +cleanup: + ; SOSDacLeave(); return hr; @@ -3014,7 +3022,7 @@ ClrDataAccess::GetOOMStaticData(struct DacpOomData *oomData) memset(oomData, 0, sizeof(DacpOomData)); - if (!GCHeap::IsServerHeap()) + if (!GCHeapUtilities::IsServerHeap()) { oom_history* pOOMInfo = &(WKS::gc_heap::oom_info); oomData->reason = pOOMInfo->reason; @@ -3043,7 +3051,7 @@ ClrDataAccess::GetOOMData(CLRDATA_ADDRESS oomAddr, struct DacpOomData *data) SOSDacEnter(); memset(data, 0, sizeof(DacpOomData)); - if (!GCHeap::IsServerHeap()) + if (!GCHeapUtilities::IsServerHeap()) hr = E_FAIL; // doesn't make sense to call this on WKS mode #ifdef FEATURE_SVR_GC @@ -3090,7 +3098,7 @@ ClrDataAccess::GetGCInterestingInfoStaticData(struct DacpGCInterestingInfoData * SOSDacEnter(); memset(data, 0, sizeof(DacpGCInterestingInfoData)); - if (!GCHeap::IsServerHeap()) + if (!GCHeapUtilities::IsServerHeap()) { for (int i = 0; i < NUM_GC_DATA_POINTS; i++) data->interestingDataPoints[i] = WKS::interesting_data_per_heap[i]; @@ -3123,7 +3131,7 @@ ClrDataAccess::GetGCInterestingInfoData(CLRDATA_ADDRESS interestingInfoAddr, str SOSDacEnter(); memset(data, 0, sizeof(DacpGCInterestingInfoData)); - if (!GCHeap::IsServerHeap()) + if (!GCHeapUtilities::IsServerHeap()) hr = E_FAIL; // doesn't make sense to call this on WKS mode #ifdef FEATURE_SVR_GC @@ -3149,7 +3157,7 @@ ClrDataAccess::GetHeapAnalyzeData(CLRDATA_ADDRESS addr, struct DacpGcHeapAnalyz SOSDacEnter(); - if (!GCHeap::IsServerHeap()) + if (!GCHeapUtilities::IsServerHeap()) hr = E_FAIL; // doesn't make sense to call this on WKS mode #ifdef FEATURE_SVR_GC @@ -3856,7 +3864,7 @@ ClrDataAccess::EnumWksGlobalMemoryRegions(CLRDataEnumMemoryFlags flags) // enumerating the generations from max (which is normally gen2) to max+1 gives you // the segment list for all the normal segements plus the large heap segment (max+1) // this is the convention in the GC so it is repeated here - for (ULONG i = GCHeap::GetMaxGeneration(); i <= GCHeap::GetMaxGeneration()+1; i++) + for (ULONG i = GCHeapUtilities::GetMaxGeneration(); i <= GCHeapUtilities::GetMaxGeneration()+1; i++) { __DPtr<WKS::heap_segment> seg = dac_cast<TADDR>(WKS::generation_table[i].start_segment); while (seg) diff --git a/src/debug/daccess/request_svr.cpp b/src/debug/daccess/request_svr.cpp index 429f30020f..1fe20e2b60 100644 --- a/src/debug/daccess/request_svr.cpp +++ b/src/debug/daccess/request_svr.cpp @@ -256,7 +256,7 @@ ClrDataAccess::EnumSvrGlobalMemoryRegions(CLRDataEnumMemoryFlags flags) // enumerating the generations from max (which is normally gen2) to max+1 gives you // the segment list for all the normal segements plus the large heap segment (max+1) // this is the convention in the GC so it is repeated here - for (ULONG i = GCHeap::GetMaxGeneration(); i <= GCHeap::GetMaxGeneration()+1; i++) + for (ULONG i = GCHeapUtilities::GetMaxGeneration(); i <= GCHeapUtilities::GetMaxGeneration()+1; i++) { __DPtr<SVR::heap_segment> seg = dac_cast<TADDR>(pHeap->generation_table[i].start_segment); while (seg) @@ -271,7 +271,7 @@ ClrDataAccess::EnumSvrGlobalMemoryRegions(CLRDataEnumMemoryFlags flags) DWORD DacGetNumHeaps() { - if (GCHeap::IsServerHeap()) + if (GCHeapUtilities::IsServerHeap()) return (DWORD)SVR::gc_heap::n_heaps; // workstation gc |