From 41770967a2e61c07293f1611fe1f64c732d6c0a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 10 May 2026 22:30:46 +0000 Subject: [PATCH 1/3] Switch CreateHeapReferenceValue to CORDB_ADDRESS and remove GetObjectContents DACDBI API Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com> --- src/coreclr/debug/daccess/dacdbiimpl.cpp | 49 +++++++------------ src/coreclr/debug/daccess/dacdbiimpl.h | 11 ++--- src/coreclr/debug/di/divalue.cpp | 37 +++----------- src/coreclr/debug/di/rspriv.h | 6 +-- src/coreclr/debug/inc/dacdbiinterface.h | 28 +++-------- src/coreclr/inc/dacdbi.idl | 9 ++-- .../Dbi/DacDbiImpl.cs | 3 -- .../Dbi/IDacDbiInterface.cs | 3 -- 8 files changed, 42 insertions(+), 104 deletions(-) diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index 478b6ae9155f10..b484da4167cb1f 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -3354,17 +3354,19 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::IsDelegate(VMPTR_Object vmObject, // DacDbi API: GetDelegateType // Given a delegate pointer, compute the type of delegate according to the data held in it. //----------------------------------------------------------------------------- -HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateType(VMPTR_Object delegateObject, DelegateType *delegateType) +HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateType(CORDB_ADDRESS delegateObject, DelegateType *delegateType) { DD_ENTER_MAY_THROW; - _ASSERTE(!delegateObject.IsNull()); + _ASSERTE(delegateObject != (CORDB_ADDRESS)NULL); _ASSERTE(delegateType != NULL); #ifdef _DEBUG // ensure we have a Delegate object BOOL fIsDelegate = FALSE; - IsDelegate(delegateObject, &fIsDelegate); + VMPTR_Object vmDelegate = VMPTR_Object::NullPtr(); + vmDelegate.SetDacTargetPtr(CORDB_ADDRESS_TO_TADDR(delegateObject)); + IsDelegate(vmDelegate, &fIsDelegate); _ASSERTE(fIsDelegate); #endif @@ -3378,7 +3380,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateType(VMPTR_Object dele // - DELEGATE KINDS TABLE in comdelegate.cpp *delegateType = DelegateType::kUnknownDelegateType; - PTR_DelegateObject pDelObj = dac_cast(delegateObject.GetDacPtr()); + PTR_DelegateObject pDelObj = dac_cast(CORDB_ADDRESS_TO_TADDR(delegateObject)); INT_PTR invocationCount = pDelObj->GetInvocationCount(); if (invocationCount == -1) @@ -3439,7 +3441,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateType(VMPTR_Object dele HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateFunctionData( DelegateType delegateType, - VMPTR_Object delegateObject, + CORDB_ADDRESS delegateObject, OUT VMPTR_Assembly *ppFunctionAssembly, OUT mdMethodDef *pMethodDef) { @@ -3448,12 +3450,14 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateFunctionData( #ifdef _DEBUG // ensure we have a Delegate object BOOL fIsDelegate = FALSE; - IsDelegate(delegateObject, &fIsDelegate); + VMPTR_Object vmDelegate = VMPTR_Object::NullPtr(); + vmDelegate.SetDacTargetPtr(CORDB_ADDRESS_TO_TADDR(delegateObject)); + IsDelegate(vmDelegate, &fIsDelegate); _ASSERTE(fIsDelegate); #endif HRESULT hr = S_OK; - PTR_DelegateObject pDelObj = dac_cast(delegateObject.GetDacPtr()); + PTR_DelegateObject pDelObj = dac_cast(CORDB_ADDRESS_TO_TADDR(delegateObject)); TADDR targetMethodPtr = (TADDR)NULL; VMPTR_MethodDesc pMD; @@ -3481,8 +3485,8 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateFunctionData( HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateTargetObject( DelegateType delegateType, - VMPTR_Object delegateObject, - OUT VMPTR_Object *ppTargetObj, + CORDB_ADDRESS delegateObject, + OUT CORDB_ADDRESS *ppTargetObj, OUT VMPTR_AppDomain *ppTargetAppDomain) { DD_ENTER_MAY_THROW; @@ -3490,24 +3494,26 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateTargetObject( #ifdef _DEBUG // ensure we have a Delegate object BOOL fIsDelegate = FALSE; - IsDelegate(delegateObject, &fIsDelegate); + VMPTR_Object vmDelegate = VMPTR_Object::NullPtr(); + vmDelegate.SetDacTargetPtr(CORDB_ADDRESS_TO_TADDR(delegateObject)); + IsDelegate(vmDelegate, &fIsDelegate); _ASSERTE(fIsDelegate); #endif HRESULT hr = S_OK; - PTR_DelegateObject pDelObj = dac_cast(delegateObject.GetDacPtr()); + PTR_DelegateObject pDelObj = dac_cast(CORDB_ADDRESS_TO_TADDR(delegateObject)); switch (delegateType) { case kClosedDelegate: { PTR_Object pRemoteTargetObj = OBJECTREFToObject(pDelObj->GetTarget()); - ppTargetObj->SetDacTargetPtr(pRemoteTargetObj.GetAddr()); + *ppTargetObj = (CORDB_ADDRESS)pRemoteTargetObj.GetAddr(); break; } default: - ppTargetObj->SetDacTargetPtr((TADDR)NULL); + *ppTargetObj = (CORDB_ADDRESS)NULL; break; } @@ -5979,23 +5985,6 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetHandleAddressFromVmHandle(VMPT return hr; } -// Create a TargetBuffer which describes the location of the object -HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetObjectContents(VMPTR_Object obj, OUT TargetBuffer * pRetVal) -{ - DD_ENTER_MAY_THROW; - - HRESULT hr = S_OK; - EX_TRY - { - PTR_Object objPtr = obj.GetDacPtr(); - - _ASSERTE(objPtr->GetSize() <= 0xffffffff); - *pRetVal = TargetBuffer(PTR_TO_TADDR(objPtr), (ULONG)objPtr->GetSize()); - } - EX_CATCH_HRESULT(hr); - return hr; -} - // ============================================================================ // functions to get information about objects referenced via an instance of CordbReferenceValue or // CordbHandleValue diff --git a/src/coreclr/debug/daccess/dacdbiimpl.h b/src/coreclr/debug/daccess/dacdbiimpl.h index 36a077548987cd..2f74328f0ea3f1 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.h +++ b/src/coreclr/debug/daccess/dacdbiimpl.h @@ -297,18 +297,18 @@ class DacDbiInterfaceImpl : HRESULT STDMETHODCALLTYPE IsDelegate(VMPTR_Object vmObject, OUT BOOL * pResult); - HRESULT STDMETHODCALLTYPE GetDelegateType(VMPTR_Object delegateObject, DelegateType *delegateType); + HRESULT STDMETHODCALLTYPE GetDelegateType(CORDB_ADDRESS delegateObject, DelegateType *delegateType); HRESULT STDMETHODCALLTYPE GetDelegateFunctionData( DelegateType delegateType, - VMPTR_Object delegateObject, + CORDB_ADDRESS delegateObject, OUT VMPTR_Assembly *ppFunctionAssembly, OUT mdMethodDef *pMethodDef); HRESULT STDMETHODCALLTYPE GetDelegateTargetObject( DelegateType delegateType, - VMPTR_Object delegateObject, - OUT VMPTR_Object *ppTargetObj, + CORDB_ADDRESS delegateObject, + OUT CORDB_ADDRESS *ppTargetObj, OUT VMPTR_AppDomain *ppTargetAppDomain); HRESULT STDMETHODCALLTYPE GetLoaderHeapMemoryRanges(OUT DacDbiArrayList * pRanges); @@ -838,9 +838,6 @@ class DacDbiInterfaceImpl : // Get the target address from a VMPTR_OBJECTHANDLE, i.e., the handle address HRESULT STDMETHODCALLTYPE GetHandleAddressFromVmHandle(VMPTR_OBJECTHANDLE vmHandle, OUT CORDB_ADDRESS * pRetVal); - // Gets the target address of an VMPTR of an Object - HRESULT STDMETHODCALLTYPE GetObjectContents(VMPTR_Object obj, OUT TargetBuffer * pRetVal); - // Create a VMPTR_OBJECTHANDLE from a CORDB_ADDRESS pointing to an object handle HRESULT STDMETHODCALLTYPE GetVmObjectHandle(CORDB_ADDRESS handleAddress, OUT VMPTR_OBJECTHANDLE * pRetVal); diff --git a/src/coreclr/debug/di/divalue.cpp b/src/coreclr/debug/di/divalue.cpp index 709b33281d8736..271e47c67d55ab 100644 --- a/src/coreclr/debug/di/divalue.cpp +++ b/src/coreclr/debug/di/divalue.cpp @@ -263,26 +263,9 @@ void CordbValue::CreateVCObjOrRefValue(CordbAppDomain * pAppdomain } } // CordbValue::CreateValueByType -// Create the proper ICDValue instance based on the given remote heap object -// Arguments: -// pAppDomain - the app domain the remote object is in -// vmObj - the remote object to get an ICDValue for -ICorDebugValue* CordbValue::CreateHeapValue(CordbAppDomain* pAppDomain, VMPTR_Object vmObj) -{ - // Create a temporary reference and dereference it to construct the heap value we want. - RSSmartPtr pRefValue(CordbValue::CreateHeapReferenceValue(pAppDomain, vmObj)); - ICorDebugValue* pExtValue; - IfFailThrow(pRefValue->Dereference(&pExtValue)); - return pExtValue; -} - -CordbReferenceValue* CordbValue::CreateHeapReferenceValue(CordbAppDomain* pAppDomain, VMPTR_Object vmObj) +CordbReferenceValue* CordbValue::CreateHeapReferenceValue(CordbAppDomain* pAppDomain, CORDB_ADDRESS objAddr) { - IDacDbiInterface* pDac = pAppDomain->GetProcess()->GetDAC(); - - TargetBuffer objBuffer; - IfFailThrow(pDac->GetObjectContents(vmObj, &objBuffer)); - VOID* pRemoteAddr = CORDB_ADDRESS_TO_PTR(objBuffer.pAddress); + VOID* pRemoteAddr = CORDB_ADDRESS_TO_PTR(objAddr); // This creates a local reference that has a remote address in it. Ie &pRemoteAddr is an address // in the host address space and pRemoteAddr is an address in the target. MemoryRange localReferenceDescription(&pRemoteAddr, sizeof(pRemoteAddr)); @@ -2650,16 +2633,14 @@ HRESULT IsSupportedDelegateHelper(IDacDbiInterface::DelegateType delType) HRESULT CordbObjectValue::GetTargetHelper(ICorDebugReferenceValue **ppTarget) { IDacDbiInterface::DelegateType delType; - VMPTR_Object pDelegateObj; - VMPTR_Object pDelegateTargetObj; + CORDB_ADDRESS pDelegateTargetObj; VMPTR_AppDomain pAppDomainOfTarget; CORDB_ADDRESS delegateAddr = m_valueHome.GetAddress(); IDacDbiInterface *pDAC = GetProcess()->GetDAC(); - IfFailThrow(pDAC->GetObject(delegateAddr, &pDelegateObj)); - HRESULT hr = pDAC->GetDelegateType(pDelegateObj, &delType); + HRESULT hr = pDAC->GetDelegateType(delegateAddr, &delType); if (hr != S_OK) return hr; @@ -2667,8 +2648,8 @@ HRESULT CordbObjectValue::GetTargetHelper(ICorDebugReferenceValue **ppTarget) if (hr != S_OK) return hr; - hr = pDAC->GetDelegateTargetObject(delType, pDelegateObj, &pDelegateTargetObj, &pAppDomainOfTarget); - if (hr != S_OK || pDelegateTargetObj.IsNull()) + hr = pDAC->GetDelegateTargetObject(delType, delegateAddr, &pDelegateTargetObj, &pAppDomainOfTarget); + if (hr != S_OK || pDelegateTargetObj == (CORDB_ADDRESS)NULL) { *ppTarget = NULL; return hr; @@ -2686,15 +2667,13 @@ HRESULT CordbObjectValue::GetTargetHelper(ICorDebugReferenceValue **ppTarget) HRESULT CordbObjectValue::GetFunctionHelper(ICorDebugFunction **ppFunction) { IDacDbiInterface::DelegateType delType; - VMPTR_Object pDelegateObj; *ppFunction = NULL; CORDB_ADDRESS delegateAddr = m_valueHome.GetAddress(); IDacDbiInterface *pDAC = GetProcess()->GetDAC(); - IfFailThrow(pDAC->GetObject(delegateAddr, &pDelegateObj)); - HRESULT hr = pDAC->GetDelegateType(pDelegateObj, &delType); + HRESULT hr = pDAC->GetDelegateType(delegateAddr, &delType); if (hr != S_OK) return hr; @@ -2708,7 +2687,7 @@ HRESULT CordbObjectValue::GetFunctionHelper(ICorDebugFunction **ppFunction) VMPTR_Assembly functionAssembly; mdMethodDef functionMethodDef = 0; - hr = pDAC->GetDelegateFunctionData(delType, pDelegateObj, &functionAssembly, &functionMethodDef); + hr = pDAC->GetDelegateFunctionData(delType, delegateAddr, &functionAssembly, &functionMethodDef); if (hr != S_OK) return hr; diff --git a/src/coreclr/debug/di/rspriv.h b/src/coreclr/debug/di/rspriv.h index d376dea2ba6ebc..9bacb01c8f74ab 100644 --- a/src/coreclr/debug/di/rspriv.h +++ b/src/coreclr/debug/di/rspriv.h @@ -8621,13 +8621,9 @@ class CordbValue : public CordbBase EnregisteredValueHomeHolder * ppRemoteRegAddr, ICorDebugValue** ppValue); - // Create the proper ICDValue instance based on the given remote heap object - static ICorDebugValue* CreateHeapValue(CordbAppDomain* pAppDomain, - VMPTR_Object vmObj); - // Creates a proper CordbReferenceValue instance based on the given remote heap object static CordbReferenceValue* CreateHeapReferenceValue(CordbAppDomain* pAppDomain, - VMPTR_Object vmObj); + CORDB_ADDRESS objAddr); // Returns a pointer to the ValueHome field of this instance of CordbValue if one exists or NULL // otherwise. Therefore, this also tells us indirectly whether this instance of CordbValue is also an diff --git a/src/coreclr/debug/inc/dacdbiinterface.h b/src/coreclr/debug/inc/dacdbiinterface.h index c024524724e633..e5d3267d2a39ba 100644 --- a/src/coreclr/debug/inc/dacdbiinterface.h +++ b/src/coreclr/debug/inc/dacdbiinterface.h @@ -1783,7 +1783,7 @@ IDacDbiInterface : public IUnknown // S_OK on success; otherwise, an appropriate failure HRESULT. // // Notes: - // The VMPTR this produces can be deconstructed by GetObjectContents. + // The VMPTR this produces wraps the target address that was passed in. // This function will return a failure HRESULT if given a NULL or otherwise invalid pointer, // but if given a valid address to an invalid pointer, it will produce // a VMPTR_Object which points to invalid memory. @@ -1800,7 +1800,7 @@ IDacDbiInterface : public IUnknown // S_OK on success; otherwise, an appropriate failure HRESULT. // // Notes: - // The VMPTR this produces can be deconstructed by GetObjectContents. + // The VMPTR this produces wraps the target address that was passed in. // This will produce a VMPTR_Object regardless of whether the pointer is // valid or not. virtual HRESULT STDMETHODCALLTYPE GetObject(CORDB_ADDRESS ptr, OUT VMPTR_Object * pRetVal) = 0; @@ -1893,22 +1893,6 @@ IDacDbiInterface : public IUnknown // virtual HRESULT STDMETHODCALLTYPE GetHandleAddressFromVmHandle(VMPTR_OBJECTHANDLE vmHandle, OUT CORDB_ADDRESS * pRetVal) = 0; - // Given a VMPTR to an Object, get the target address. - // - // Arguments: - // obj - the Object VMPTR to get the address from - // pRetVal - [out] The target address which obj is using. - // - // Return Value: - // S_OK on success; otherwise, an appropriate failure HRESULT. - // - // Notes: - // The VMPTR this consumes can be reconstructed using GetObject and - // providing the address stored in the returned TargetBuffer. This has - // undefined behavior for invalid VMPTR_Objects. - - virtual HRESULT STDMETHODCALLTYPE GetObjectContents(VMPTR_Object obj, OUT TargetBuffer * pRetVal) = 0; - // // Get the thread which owns the monitor lock on an object and the acquisition // count @@ -2259,18 +2243,18 @@ IDacDbiInterface : public IUnknown virtual HRESULT STDMETHODCALLTYPE IsDelegate(VMPTR_Object vmObject, OUT BOOL * pResult) = 0; // Get the delegate type - virtual HRESULT STDMETHODCALLTYPE GetDelegateType(VMPTR_Object delegateObject, DelegateType *delegateType) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDelegateType(CORDB_ADDRESS delegateObject, DelegateType *delegateType) = 0; virtual HRESULT STDMETHODCALLTYPE GetDelegateFunctionData( DelegateType delegateType, - VMPTR_Object delegateObject, + CORDB_ADDRESS delegateObject, OUT VMPTR_Assembly *ppFunctionAssembly, OUT mdMethodDef *pMethodDef) = 0; virtual HRESULT STDMETHODCALLTYPE GetDelegateTargetObject( DelegateType delegateType, - VMPTR_Object delegateObject, - OUT VMPTR_Object *ppTargetObj, + CORDB_ADDRESS delegateObject, + OUT CORDB_ADDRESS *ppTargetObj, OUT VMPTR_AppDomain *ppTargetAppDomain) = 0; virtual HRESULT STDMETHODCALLTYPE GetLoaderHeapMemoryRanges(OUT DacDbiArrayList *pRanges) = 0; diff --git a/src/coreclr/inc/dacdbi.idl b/src/coreclr/inc/dacdbi.idl index edbeec2e00e1b4..8026c676d6eea6 100644 --- a/src/coreclr/inc/dacdbi.idl +++ b/src/coreclr/inc/dacdbi.idl @@ -358,7 +358,6 @@ interface IDacDbiInterface : IUnknown HRESULT GetHandleAddressFromVmHandle([in] VMPTR_OBJECTHANDLE vmHandle, [out] CORDB_ADDRESS * pRetVal); // Object Contents and Monitor - HRESULT GetObjectContents([in] VMPTR_Object obj, [out] struct TargetBuffer * pRetVal); HRESULT GetThreadOwningMonitorLock([in] VMPTR_Object vmObject, [out] struct MonitorLockInfo * pRetVal); HRESULT EnumerateMonitorEventWaitList([in] VMPTR_Object vmObject, [in] FP_THREAD_ENUMERATION_CALLBACK fpCallback, [in] CALLBACK_DATA pUserData); @@ -417,16 +416,16 @@ interface IDacDbiInterface : IUnknown // Delegate HRESULT IsDelegate([in] VMPTR_Object vmObject, [out] BOOL * pResult); - HRESULT GetDelegateType([in] VMPTR_Object delegateObject, [out] DelegateType * delegateType); + HRESULT GetDelegateType([in] CORDB_ADDRESS delegateObject, [out] DelegateType * delegateType); HRESULT GetDelegateFunctionData( [in] DelegateType delegateType, - [in] VMPTR_Object delegateObject, + [in] CORDB_ADDRESS delegateObject, [out] VMPTR_Assembly * ppFunctionAssembly, [out] mdMethodDef * pMethodDef); HRESULT GetDelegateTargetObject( [in] DelegateType delegateType, - [in] VMPTR_Object delegateObject, - [out] VMPTR_Object * ppTargetObj, + [in] CORDB_ADDRESS delegateObject, + [out] CORDB_ADDRESS * ppTargetObj, [out] VMPTR_AppDomain * ppTargetAppDomain); // Loader Heap diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs index 508aaeb440d322..cec2f346f85cee 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs @@ -1574,9 +1574,6 @@ public int GetHandleAddressFromVmHandle(ulong vmHandle, ulong* pRetVal) return hr; } - public int GetObjectContents(ulong obj, DacDbiTargetBuffer* pRetVal) - => LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.GetObjectContents(obj, pRetVal) : HResults.E_NOTIMPL; - public int GetThreadOwningMonitorLock(ulong vmObject, DacDbiMonitorLockInfo* pRetVal) => LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.GetThreadOwningMonitorLock(vmObject, pRetVal) : HResults.E_NOTIMPL; diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs index e3a2e87bd70421..37d70e8d6d8b7a 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs @@ -464,9 +464,6 @@ public unsafe partial interface IDacDbiInterface [PreserveSig] int GetHandleAddressFromVmHandle(ulong vmHandle, ulong* pRetVal); - [PreserveSig] - int GetObjectContents(ulong obj, DacDbiTargetBuffer* pRetVal); - [PreserveSig] int GetThreadOwningMonitorLock(ulong vmObject, DacDbiMonitorLockInfo* pRetVal); From 15be4fe39f679ab3ab5e928c454e1ec1768b5379 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 10 May 2026 22:52:40 +0000 Subject: [PATCH 2/3] Change IsDelegate DACDBI input to CORDB_ADDRESS Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com> --- src/coreclr/debug/daccess/dacdbiimpl.cpp | 18 ++++++------------ src/coreclr/debug/daccess/dacdbiimpl.h | 2 +- src/coreclr/debug/di/divalue.cpp | 4 +--- src/coreclr/debug/inc/dacdbiinterface.h | 4 ++-- src/coreclr/inc/dacdbi.idl | 2 +- .../Dbi/DacDbiImpl.cs | 4 ++-- .../Dbi/IDacDbiInterface.cs | 2 +- 7 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index b484da4167cb1f..b4d937aed24b94 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -3327,7 +3327,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetMethodDescPtrFromIpEx(TADDR fu return S_OK; } -HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::IsDelegate(VMPTR_Object vmObject, OUT BOOL * pResult) +HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::IsDelegate(CORDB_ADDRESS objectAddress, OUT BOOL * pResult) { DD_ENTER_MAY_THROW; @@ -3335,13 +3335,13 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::IsDelegate(VMPTR_Object vmObject, EX_TRY { - if (vmObject.IsNull()) + if (objectAddress == (CORDB_ADDRESS)NULL) { *pResult = FALSE; } else { - Object *pObj = vmObject.GetDacPtr(); + PTR_Object pObj = dac_cast(CORDB_ADDRESS_TO_TADDR(objectAddress)); *pResult = pObj->GetGCSafeMethodTable()->IsDelegate(); } } @@ -3364,9 +3364,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateType(CORDB_ADDRESS del #ifdef _DEBUG // ensure we have a Delegate object BOOL fIsDelegate = FALSE; - VMPTR_Object vmDelegate = VMPTR_Object::NullPtr(); - vmDelegate.SetDacTargetPtr(CORDB_ADDRESS_TO_TADDR(delegateObject)); - IsDelegate(vmDelegate, &fIsDelegate); + IsDelegate(delegateObject, &fIsDelegate); _ASSERTE(fIsDelegate); #endif @@ -3450,9 +3448,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateFunctionData( #ifdef _DEBUG // ensure we have a Delegate object BOOL fIsDelegate = FALSE; - VMPTR_Object vmDelegate = VMPTR_Object::NullPtr(); - vmDelegate.SetDacTargetPtr(CORDB_ADDRESS_TO_TADDR(delegateObject)); - IsDelegate(vmDelegate, &fIsDelegate); + IsDelegate(delegateObject, &fIsDelegate); _ASSERTE(fIsDelegate); #endif @@ -3494,9 +3490,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetDelegateTargetObject( #ifdef _DEBUG // ensure we have a Delegate object BOOL fIsDelegate = FALSE; - VMPTR_Object vmDelegate = VMPTR_Object::NullPtr(); - vmDelegate.SetDacTargetPtr(CORDB_ADDRESS_TO_TADDR(delegateObject)); - IsDelegate(vmDelegate, &fIsDelegate); + IsDelegate(delegateObject, &fIsDelegate); _ASSERTE(fIsDelegate); #endif diff --git a/src/coreclr/debug/daccess/dacdbiimpl.h b/src/coreclr/debug/daccess/dacdbiimpl.h index 2f74328f0ea3f1..8ad5ab428260e4 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.h +++ b/src/coreclr/debug/daccess/dacdbiimpl.h @@ -295,7 +295,7 @@ class DacDbiInterfaceImpl : // Returns true if the argument is a runtime callable wrapper HRESULT STDMETHODCALLTYPE IsRcw(VMPTR_Object vmObject, OUT BOOL * pResult); - HRESULT STDMETHODCALLTYPE IsDelegate(VMPTR_Object vmObject, OUT BOOL * pResult); + HRESULT STDMETHODCALLTYPE IsDelegate(CORDB_ADDRESS objectAddress, OUT BOOL * pResult); HRESULT STDMETHODCALLTYPE GetDelegateType(CORDB_ADDRESS delegateObject, DelegateType *delegateType); diff --git a/src/coreclr/debug/di/divalue.cpp b/src/coreclr/debug/di/divalue.cpp index 271e47c67d55ab..6ac7de7407fea5 100644 --- a/src/coreclr/debug/di/divalue.cpp +++ b/src/coreclr/debug/di/divalue.cpp @@ -2605,10 +2605,8 @@ HRESULT CordbObjectValue::IsDelegate() { IDacDbiInterface *pDAC = GetProcess()->GetDAC(); - VMPTR_Object vmObj; - IfFailThrow(pDAC->GetObject(objAddr, &vmObj)); BOOL fIsDelegate; - IfFailThrow(pDAC->IsDelegate(vmObj, &fIsDelegate)); + IfFailThrow(pDAC->IsDelegate(objAddr, &fIsDelegate)); if (!fIsDelegate) hr = S_FALSE; diff --git a/src/coreclr/debug/inc/dacdbiinterface.h b/src/coreclr/debug/inc/dacdbiinterface.h index e5d3267d2a39ba..d8e213f65528c8 100644 --- a/src/coreclr/debug/inc/dacdbiinterface.h +++ b/src/coreclr/debug/inc/dacdbiinterface.h @@ -2237,10 +2237,10 @@ IDacDbiInterface : public IUnknown // Returns true if the object is a type deriving from System.MulticastDelegate // // Arguments: - // vmObject - pointer to runtime object to query for. + // objectAddress - address of runtime object to query for. // pResult - [out] // - virtual HRESULT STDMETHODCALLTYPE IsDelegate(VMPTR_Object vmObject, OUT BOOL * pResult) = 0; + virtual HRESULT STDMETHODCALLTYPE IsDelegate(CORDB_ADDRESS objectAddress, OUT BOOL * pResult) = 0; // Get the delegate type virtual HRESULT STDMETHODCALLTYPE GetDelegateType(CORDB_ADDRESS delegateObject, DelegateType *delegateType) = 0; diff --git a/src/coreclr/inc/dacdbi.idl b/src/coreclr/inc/dacdbi.idl index 8026c676d6eea6..338bb6d04704cf 100644 --- a/src/coreclr/inc/dacdbi.idl +++ b/src/coreclr/inc/dacdbi.idl @@ -415,7 +415,7 @@ interface IDacDbiInterface : IUnknown HRESULT EnableGCNotificationEvents([in] BOOL fEnable); // Delegate - HRESULT IsDelegate([in] VMPTR_Object vmObject, [out] BOOL * pResult); + HRESULT IsDelegate([in] CORDB_ADDRESS objectAddress, [out] BOOL * pResult); HRESULT GetDelegateType([in] CORDB_ADDRESS delegateObject, [out] DelegateType * delegateType); HRESULT GetDelegateFunctionData( [in] DelegateType delegateType, diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs index cec2f346f85cee..9de497a219f4c5 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs @@ -2109,8 +2109,8 @@ public int EnableGCNotificationEvents(Interop.BOOL fEnable) return hr; } - public int IsDelegate(ulong vmObject, Interop.BOOL* pResult) - => LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.IsDelegate(vmObject, pResult) : HResults.E_NOTIMPL; + public int IsDelegate(ulong objectAddress, Interop.BOOL* pResult) + => LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.IsDelegate(objectAddress, pResult) : HResults.E_NOTIMPL; public int GetDelegateType(ulong delegateObject, int* delegateType) => LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.GetDelegateType(delegateObject, delegateType) : HResults.E_NOTIMPL; diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs index 37d70e8d6d8b7a..04db57a2b88ad1 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs @@ -552,7 +552,7 @@ public unsafe partial interface IDacDbiInterface int EnableGCNotificationEvents(Interop.BOOL fEnable); [PreserveSig] - int IsDelegate(ulong vmObject, Interop.BOOL* pResult); + int IsDelegate(ulong objectAddress, Interop.BOOL* pResult); [PreserveSig] int GetDelegateType(ulong delegateObject, int* delegateType); From 7e806053efd2605e2dd3b55da9af8d833506fc1e Mon Sep 17 00:00:00 2001 From: Rachel Jarvi Date: Sun, 10 May 2026 17:05:23 -0700 Subject: [PATCH 3/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/coreclr/inc/dacdbi.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/inc/dacdbi.idl b/src/coreclr/inc/dacdbi.idl index 338bb6d04704cf..f2d98625277932 100644 --- a/src/coreclr/inc/dacdbi.idl +++ b/src/coreclr/inc/dacdbi.idl @@ -357,7 +357,7 @@ interface IDacDbiInterface : IUnknown HRESULT IsWinRTModule([in] VMPTR_Module vmModule, [out] BOOL * pIsWinRT); HRESULT GetHandleAddressFromVmHandle([in] VMPTR_OBJECTHANDLE vmHandle, [out] CORDB_ADDRESS * pRetVal); - // Object Contents and Monitor + // Monitor HRESULT GetThreadOwningMonitorLock([in] VMPTR_Object vmObject, [out] struct MonitorLockInfo * pRetVal); HRESULT EnumerateMonitorEventWaitList([in] VMPTR_Object vmObject, [in] FP_THREAD_ENUMERATION_CALLBACK fpCallback, [in] CALLBACK_DATA pUserData);