Skip to content

Commit 983639b

Browse files
Copilotrcj1
andauthored
Delete DacDbi APIs AreGCStructuresValid and IsWinRTModule (#128014)
<!-- --> Removes the DacDbi interface methods `AreGCStructuresValid` and `IsWinRTModule` everywhere. Both native implementations were trivial constants (`TRUE` and `FALSE` respectively), the managed cDAC mirrors did the same, and only one in-tree caller existed. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
1 parent 553a1fe commit 983639b

10 files changed

Lines changed: 4 additions & 147 deletions

File tree

src/coreclr/debug/daccess/dacdbiimpl.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5948,20 +5948,6 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::IsVmObjectHandleValid(VMPTR_OBJEC
59485948
return hr;
59495949
}
59505950

5951-
// determines if the specified module is a WinRT module
5952-
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::IsWinRTModule(VMPTR_Module vmModule, BOOL * pIsWinRT)
5953-
{
5954-
if (pIsWinRT == NULL)
5955-
return E_POINTER;
5956-
5957-
DD_ENTER_MAY_THROW;
5958-
5959-
HRESULT hr = S_OK;
5960-
*pIsWinRT = FALSE;
5961-
5962-
return hr;
5963-
}
5964-
59655951
// Get the target address from a VMPTR_OBJECTHANDLE, i.e., the handle address
59665952
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetHandleAddressFromVmHandle(VMPTR_OBJECTHANDLE vmHandle, OUT CORDB_ADDRESS * pRetVal)
59675953
{
@@ -6420,17 +6406,6 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::EnumerateMonitorEventWaitList(VMP
64206406
}
64216407

64226408

6423-
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::AreGCStructuresValid(OUT BOOL * pResult)
6424-
{
6425-
HRESULT hr = S_OK;
6426-
EX_TRY
6427-
{
6428-
*pResult = TRUE;
6429-
}
6430-
EX_CATCH_HRESULT(hr);
6431-
return hr;
6432-
}
6433-
64346409
HeapData::HeapData()
64356410
: YoungestGenPtr(0), YoungestGenLimit(0), Gen0Start(0), Gen0End(0), SegmentCount(0), Segments(0)
64366411
{

src/coreclr/debug/daccess/dacdbiimpl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ class DacDbiInterfaceImpl :
110110
HRESULT STDMETHODCALLTYPE IsThreadSuspendedOrHijacked(VMPTR_Thread vmThread, OUT BOOL * pResult);
111111

112112

113-
HRESULT STDMETHODCALLTYPE AreGCStructuresValid(OUT BOOL * pResult);
114113
HRESULT STDMETHODCALLTYPE CreateHeapWalk(HeapWalkHandle *pHandle);
115114
HRESULT STDMETHODCALLTYPE DeleteHeapWalk(HeapWalkHandle handle);
116115

@@ -847,9 +846,6 @@ class DacDbiInterfaceImpl :
847846
// Validate that the VMPTR_OBJECTHANDLE refers to a legitimate managed object
848847
HRESULT STDMETHODCALLTYPE IsVmObjectHandleValid(VMPTR_OBJECTHANDLE vmHandle, OUT BOOL * pResult);
849848

850-
// if the specified module is a WinRT module then isWinRT will equal TRUE
851-
HRESULT STDMETHODCALLTYPE IsWinRTModule(VMPTR_Module vmModule, BOOL * pIsWinRT);
852-
853849
private:
854850
// Check whether the specified thread is at a GC-safe place, i.e. in an interruptible region.
855851
BOOL IsThreadAtGCSafePlace(VMPTR_Thread vmThread);

src/coreclr/debug/daccess/dacimpl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,9 +1721,6 @@ DWORD DacGetNumHeaps();
17211721
* the event that we find heap corruption on a segment, or if the background
17221722
* GC is modifying a segment, the remainder of that segment will be skipped
17231723
* by design.
1724-
* - The GC heap must be in a walkable state before you attempt to use this
1725-
* class on it. The IDacDbiInterface::AreGCStructuresValid function will
1726-
* tell you whether it is safe to walk the heap or not.
17271724
*/
17281725
class DacHeapWalker
17291726
{

src/coreclr/debug/di/process.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,18 +2165,9 @@ HRESULT CordbProcess::EnumerateHeap(ICorDebugHeapEnum **ppObjects)
21652165

21662166
EX_TRY
21672167
{
2168-
BOOL gcValid;
2169-
IfFailThrow(m_pDacPrimitives->AreGCStructuresValid(&gcValid));
2170-
if (gcValid)
2171-
{
2172-
CordbHeapEnum *pHeapEnum = new CordbHeapEnum(this);
2173-
GetContinueNeuterList()->Add(this, pHeapEnum);
2174-
hr = pHeapEnum->QueryInterface(__uuidof(ICorDebugHeapEnum), (void**)ppObjects);
2175-
}
2176-
else
2177-
{
2178-
hr = CORDBG_E_GC_STRUCTURES_INVALID;
2179-
}
2168+
CordbHeapEnum *pHeapEnum = new CordbHeapEnum(this);
2169+
GetContinueNeuterList()->Add(this, pHeapEnum);
2170+
hr = pHeapEnum->QueryInterface(__uuidof(ICorDebugHeapEnum), (void**)ppObjects);
21802171
}
21812172
EX_CATCH_HRESULT(hr);
21822173

src/coreclr/debug/inc/dacdbiinterface.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,17 +1871,6 @@ IDacDbiInterface : public IUnknown
18711871
//
18721872
virtual HRESULT STDMETHODCALLTYPE IsVmObjectHandleValid(VMPTR_OBJECTHANDLE vmHandle, OUT BOOL * pResult) = 0;
18731873

1874-
// indicates if the specified module is a WinRT module
1875-
//
1876-
// Arguments:
1877-
// vmModule: the module to check
1878-
// pIsWinRT: [out] indicating state of module
1879-
//
1880-
// Return value:
1881-
// S_OK on success; otherwise, an appropriate failure HRESULT.
1882-
//
1883-
virtual HRESULT STDMETHODCALLTYPE IsWinRTModule(VMPTR_Module vmModule, BOOL * pIsWinRT) = 0;
1884-
18851874
// Determines the app domain id for the object referred to by a given VMPTR_OBJECTHANDLE
18861875
//
18871876
// Get the target address from a VMPTR_OBJECTHANDLE, i.e., the handle address
@@ -1954,11 +1943,6 @@ IDacDbiInterface : public IUnknown
19541943

19551944
typedef void* * HeapWalkHandle;
19561945

1957-
// Returns true if it is safe to walk the heap. If this function returns false,
1958-
// you could still create a heap walk and attempt to walk it, but there's no
1959-
// telling how much of the heap will be available.
1960-
virtual HRESULT STDMETHODCALLTYPE AreGCStructuresValid(OUT BOOL * pResult) = 0;
1961-
19621946
// Creates a HeapWalkHandle which can be used to walk the managed heap with the
19631947
// WalkHeap function. Note if this function completes successfully you will need
19641948
// to delete the handle by passing it into DeleteHeapWalk.
@@ -1976,9 +1960,7 @@ IDacDbiInterface : public IUnknown
19761960
virtual HRESULT STDMETHODCALLTYPE DeleteHeapWalk(HeapWalkHandle handle) = 0;
19771961

19781962
// Walks the heap using the given heap walk handle, enumerating objects
1979-
// on the managed heap. Note that walking the heap requires that the GC
1980-
// data structures be in a valid state, which you can find by calling
1981-
// AreGCStructuresValid.
1963+
// on the managed heap.
19821964
//
19831965
// Arguments:
19841966
// handle - a HeapWalkHandle obtained from CreateHeapWalk

src/coreclr/inc/dacdbi.idl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ interface IDacDbiInterface : IUnknown
354354
// VM Object Handle
355355
HRESULT GetVmObjectHandle([in] CORDB_ADDRESS handleAddress, [out] VMPTR_OBJECTHANDLE * pRetVal);
356356
HRESULT IsVmObjectHandleValid([in] VMPTR_OBJECTHANDLE vmHandle, [out] BOOL * pResult);
357-
HRESULT IsWinRTModule([in] VMPTR_Module vmModule, [out] BOOL * pIsWinRT);
358357
HRESULT GetHandleAddressFromVmHandle([in] VMPTR_OBJECTHANDLE vmHandle, [out] CORDB_ADDRESS * pRetVal);
359358

360359
// Object Contents and Monitor
@@ -377,7 +376,6 @@ interface IDacDbiInterface : IUnknown
377376
HRESULT IsThreadSuspendedOrHijacked([in] VMPTR_Thread vmThread, [out] BOOL * pResult);
378377

379378
// GC
380-
HRESULT AreGCStructuresValid([out] BOOL * pResult);
381379
HRESULT CreateHeapWalk([out] HeapWalkHandle * pHandle);
382380
HRESULT DeleteHeapWalk([in] HeapWalkHandle handle);
383381
HRESULT WalkHeap([in] HeapWalkHandle handle, [in] ULONG count, [out] COR_HEAPOBJECT * objects, [out] ULONG * pFetched);

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,23 +1540,6 @@ public int IsVmObjectHandleValid(ulong vmHandle, Interop.BOOL* pResult)
15401540
return hr;
15411541
}
15421542

1543-
public int IsWinRTModule(ulong vmModule, Interop.BOOL* isWinRT)
1544-
{
1545-
*isWinRT = Interop.BOOL.FALSE;
1546-
int hr = HResults.S_OK;
1547-
#if DEBUG
1548-
if (_legacy is not null)
1549-
{
1550-
Interop.BOOL isWinRTLocal;
1551-
int hrLocal = _legacy.IsWinRTModule(vmModule, &isWinRTLocal);
1552-
Debug.ValidateHResult(hr, hrLocal);
1553-
if (hr == HResults.S_OK)
1554-
Debug.Assert(*isWinRT == isWinRTLocal, $"cDAC: {*isWinRT}, DAC: {isWinRTLocal}");
1555-
}
1556-
#endif
1557-
return hr;
1558-
}
1559-
15601543
public int GetHandleAddressFromVmHandle(ulong vmHandle, ulong* pRetVal)
15611544
{
15621545
*pRetVal = vmHandle;
@@ -1616,25 +1599,6 @@ public int GetMetaDataFileInfoFromPEFile(ulong vmPEAssembly, uint* dwTimeStamp,
16161599
public int IsThreadSuspendedOrHijacked(ulong vmThread, Interop.BOOL* pResult)
16171600
=> LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.IsThreadSuspendedOrHijacked(vmThread, pResult) : HResults.E_NOTIMPL;
16181601

1619-
public int AreGCStructuresValid(Interop.BOOL* pResult)
1620-
{
1621-
// Native DacDbiInterfaceImpl::AreGCStructuresValid always returns TRUE.
1622-
// DacDbi callers assume the runtime is suspended, so GC structures are always valid.
1623-
*pResult = Interop.BOOL.TRUE;
1624-
int hr = HResults.S_OK;
1625-
#if DEBUG
1626-
if (_legacy is not null)
1627-
{
1628-
Interop.BOOL resultLocal;
1629-
int hrLocal = _legacy.AreGCStructuresValid(&resultLocal);
1630-
Debug.ValidateHResult(hr, hrLocal);
1631-
if (hr == HResults.S_OK)
1632-
Debug.Assert(*pResult == resultLocal, $"cDAC: {*pResult}, DAC: {resultLocal}");
1633-
}
1634-
#endif
1635-
return hr;
1636-
}
1637-
16381602
public int CreateHeapWalk(nuint* pHandle)
16391603
=> LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.CreateHeapWalk(pHandle) : HResults.E_NOTIMPL;
16401604

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,6 @@ public unsafe partial interface IDacDbiInterface
458458
[PreserveSig]
459459
int IsVmObjectHandleValid(ulong vmHandle, Interop.BOOL* pResult);
460460

461-
[PreserveSig]
462-
int IsWinRTModule(ulong vmModule, Interop.BOOL* isWinRT);
463-
464461
[PreserveSig]
465462
int GetHandleAddressFromVmHandle(ulong vmHandle, ulong* pRetVal);
466463

@@ -482,9 +479,6 @@ public unsafe partial interface IDacDbiInterface
482479
[PreserveSig]
483480
int IsThreadSuspendedOrHijacked(ulong vmThread, Interop.BOOL* pResult);
484481

485-
[PreserveSig]
486-
int AreGCStructuresValid(Interop.BOOL* pResult);
487-
488482
[PreserveSig]
489483
int CreateHeapWalk(nuint* pHandle);
490484

src/native/managed/cdac/tests/DumpTests/DacDbi/DacDbiAppDomainDumpTests.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Collections.Generic;
54
using Microsoft.Diagnostics.DataContractReader.Contracts;
65
using Microsoft.Diagnostics.DataContractReader.Legacy;
76
using Xunit;
@@ -92,28 +91,4 @@ public unsafe void GetTaskID_ReturnsZero(TestConfiguration config)
9291
Assert.Equal(System.HResults.S_OK, hr);
9392
Assert.Equal(0UL, taskId);
9493
}
95-
96-
[ConditionalTheory]
97-
[MemberData(nameof(TestConfigurations))]
98-
public unsafe void IsWinRTModule_ReturnsFalse(TestConfiguration config)
99-
{
100-
InitializeDumpTest(config);
101-
DacDbiImpl dbi = CreateDacDbi();
102-
103-
ILoader loader = Target.Contracts.Loader;
104-
TargetPointer appDomainPtr = Target.ReadGlobalPointer(Constants.Globals.AppDomain);
105-
ulong appDomain = Target.ReadPointer(appDomainPtr);
106-
IEnumerable<ModuleHandle> modules = loader.GetModuleHandles(new TargetPointer(appDomain),
107-
AssemblyIterationFlags.IncludeLoaded | AssemblyIterationFlags.IncludeExecution);
108-
109-
foreach (ModuleHandle module in modules)
110-
{
111-
TargetPointer moduleAddr = loader.GetModule(module);
112-
Interop.BOOL isWinRT;
113-
int hr = dbi.IsWinRTModule(moduleAddr, &isWinRT);
114-
Assert.Equal(System.HResults.S_OK, hr);
115-
Assert.Equal(Interop.BOOL.FALSE, isWinRT);
116-
break;
117-
}
118-
}
11994
}

src/native/managed/cdac/tests/DumpTests/DacDbi/DacDbiGCDumpTests.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,6 @@ public class DacDbiGCDumpTests : DumpTestBase
1818

1919
private DacDbiImpl CreateDacDbi() => new DacDbiImpl(Target, legacyObj: null);
2020

21-
[ConditionalTheory]
22-
[MemberData(nameof(TestConfigurations))]
23-
public unsafe void AreGCStructuresValid_CrossValidateWithContract(TestConfiguration config)
24-
{
25-
InitializeDumpTest(config);
26-
DacDbiImpl dbi = CreateDacDbi();
27-
28-
Interop.BOOL result;
29-
int hr = dbi.AreGCStructuresValid(&result);
30-
Assert.Equal(System.HResults.S_OK, hr);
31-
32-
bool contractResult = Target.Contracts.GC.GetGCStructuresValid();
33-
Assert.Equal(contractResult, result == Interop.BOOL.TRUE);
34-
}
35-
3621
[ConditionalTheory]
3722
[MemberData(nameof(TestConfigurations))]
3823
public unsafe void GetGCHeapInformation_Succeeds(TestConfiguration config)

0 commit comments

Comments
 (0)