diff options
author | Andrew Au <andrewau@microsoft.com> | 2018-10-24 19:22:44 -0700 |
---|---|---|
committer | Andrew Au <cshung@gmail.com> | 2018-11-06 18:34:47 -0800 |
commit | 7cf7f086e17b7052eb1c34ce3b0000f900ac2ff0 (patch) | |
tree | 9a81f11b03cb6ba99a544cf772f4942ba571188b | |
parent | d742a2f03ab849a2d6a101320d3f1107a8f82c13 (diff) | |
download | coreclr-7cf7f086e17b7052eb1c34ce3b0000f900ac2ff0.tar.gz coreclr-7cf7f086e17b7052eb1c34ce3b0000f900ac2ff0.tar.bz2 coreclr-7cf7f086e17b7052eb1c34ce3b0000f900ac2ff0.zip |
Change GetContainingObject API
-rw-r--r-- | src/debug/di/divalue.cpp | 49 | ||||
-rw-r--r-- | src/debug/di/process.cpp | 26 | ||||
-rw-r--r-- | src/debug/di/rspriv.h | 8 | ||||
-rw-r--r-- | src/inc/cordebug.idl | 8 | ||||
-rw-r--r-- | src/pal/prebuilt/inc/cordebug.h | 8 |
5 files changed, 84 insertions, 15 deletions
diff --git a/src/debug/di/divalue.cpp b/src/debug/di/divalue.cpp index 59cd382085..fe87fa3b9c 100644 --- a/src/debug/di/divalue.cpp +++ b/src/debug/di/divalue.cpp @@ -485,6 +485,55 @@ HRESULT CordbValue::InternalCreateHandle(CorDebugHandleType handleType, return S_OK; } // CordbValue::InternalCreateHandle +CordbValue* CordbValue::GetCordbValue(ICorDebugValue* pValue) +{ + HRESULT hr = S_OK; + RSExtSmartPtr<ICorDebugArrayValue> pCorDebugArrayValue; + RSExtSmartPtr<ICorDebugBoxValue> pCorDebugBoxValue; + RSExtSmartPtr<ICorDebugHandleValue> pCorDebugHandleValue; + RSExtSmartPtr<ICorDebugReferenceValue> pCorDebugReferenceValue; + RSExtSmartPtr<ICorDebugHeapValue2> pCorDebugHeapValue2; + RSExtSmartPtr<ICorDebugObjectValue> pCorDebugObjectValue; + RSExtSmartPtr<ICorDebugGenericValue> pCorDebugGenericValue; + hr = pValue->QueryInterface(__uuidof(ICorDebugArrayValue), (void**)&pCorDebugArrayValue); + if (SUCCEEDED(hr)) + { + return static_cast<CordbValue*>(static_cast<CordbArrayValue*>(pCorDebugArrayValue.GetValue())); + } + hr = pValue->QueryInterface(__uuidof(ICorDebugBoxValue), (void**)&pCorDebugBoxValue); + if (SUCCEEDED(hr)) + { + return static_cast<CordbValue*>(static_cast<CordbBoxValue*>(pCorDebugBoxValue.GetValue())); + } + hr = pValue->QueryInterface(__uuidof(ICorDebugHandleValue), (void**)&pCorDebugHandleValue); + if (SUCCEEDED(hr)) + { + return static_cast<CordbValue*>(static_cast<CordbHandleValue*>(pCorDebugHandleValue.GetValue())); + } + hr = pValue->QueryInterface(__uuidof(ICorDebugReferenceValue), (void**)&pCorDebugReferenceValue); + if (SUCCEEDED(hr)) + { + return static_cast<CordbValue*>(static_cast<CordbReferenceValue*>(pCorDebugReferenceValue.GetValue())); + } + hr = pValue->QueryInterface(__uuidof(ICorDebugHeapValue2), (void**)&pCorDebugHeapValue2); + if (SUCCEEDED(hr)) + { + return static_cast<CordbValue*>(static_cast<CordbObjectValue*>(pCorDebugHeapValue2.GetValue())); + } + hr = pValue->QueryInterface(__uuidof(ICorDebugObjectValue), (void**)&pCorDebugObjectValue); + if (SUCCEEDED(hr)) + { + return static_cast<CordbValue*>(static_cast<CordbVCObjectValue*>(pCorDebugObjectValue.GetValue())); + } + hr = pValue->QueryInterface(__uuidof(ICorDebugGenericValue), (void**)&pCorDebugGenericValue); + if (SUCCEEDED(hr)) + { + return static_cast<CordbValue*>(static_cast<CordbGenericValue*>(pCorDebugGenericValue.GetValue())); + } + _ASSERTE(false); // who are you? + return nullptr; +} + /* ------------------------------------------------------------------------- * * Generic Value class * ------------------------------------------------------------------------- */ diff --git a/src/debug/di/process.cpp b/src/debug/di/process.cpp index fffc6d943b..89e1de814a 100644 --- a/src/debug/di/process.cpp +++ b/src/debug/di/process.cpp @@ -2307,7 +2307,12 @@ HRESULT CordbProcess::EnumerateHeapRegions(ICorDebugHeapSegmentEnum **ppRegions) return hr; } -HRESULT CordbProcess::GetObject(CORDB_ADDRESS addr, ICorDebugObjectValue **pObject) +HRESULT CordbProcess::GetObject(CORDB_ADDRESS addr, ICorDebugObjectValue **ppObject) +{ + return this->GetObjectInternal(addr, nullptr, ppObject); +} + +HRESULT CordbProcess::GetObjectInternal(CORDB_ADDRESS addr, CordbAppDomain* pAppDomainOverride, ICorDebugObjectValue **pObject) { HRESULT hr = S_OK; @@ -2331,7 +2336,7 @@ HRESULT CordbProcess::GetObject(CORDB_ADDRESS addr, ICorDebugObjectValue **pObje CordbAppDomain *cdbAppDomain = NULL; CordbType *pType = NULL; - hr = GetTypeForObject(addr, &pType, &cdbAppDomain); + hr = GetTypeForObject(addr, pAppDomainOverride, &pType, &cdbAppDomain); if (SUCCEEDED(hr)) { @@ -2527,7 +2532,7 @@ COM_METHOD CordbProcess::EnableExceptionCallbacksOutsideOfMyCode(BOOL enableExce return hr; } -COM_METHOD CordbProcess::GetContainingObject(CORDB_ADDRESS interiorPointer, ICorDebugObjectValue** ppContainingObject) +COM_METHOD CordbProcess::GetContainingObject(ICorDebugValue* pValue, ICorDebugObjectValue** ppContainingObject) { if (!ppContainingObject) return E_POINTER; @@ -2538,6 +2543,9 @@ COM_METHOD CordbProcess::GetContainingObject(CORDB_ADDRESS interiorPointer, ICor FAIL_IF_NEUTERED(this); ATT_REQUIRE_STOPPED_MAY_FAIL(this); + CORDB_ADDRESS interiorPointer; + IfFailRet(pValue->GetAddress(&interiorPointer)); + *ppContainingObject = nullptr; DebuggerIPCEvent event; @@ -2561,7 +2569,11 @@ COM_METHOD CordbProcess::GetContainingObject(CORDB_ADDRESS interiorPointer, ICor } else { - hr = this->GetObject(containerAddress, ppContainingObject); + if (SUCCEEDED(hr)) + { + CordbAppDomain* pAppDomain = (CordbValue::GetCordbValue(pValue))->GetAppDomain(); + hr = this->GetObjectInternal(containerAddress, pAppDomain, ppContainingObject); + } } } @@ -2593,7 +2605,7 @@ COM_METHOD CordbProcess::InvokeResumeCallback() #endif -HRESULT CordbProcess::GetTypeForObject(CORDB_ADDRESS addr, CordbType **ppType, CordbAppDomain **pAppDomain) +HRESULT CordbProcess::GetTypeForObject(CORDB_ADDRESS addr, CordbAppDomain* pAppDomainOverride, CordbType **ppType, CordbAppDomain **pAppDomain) { VMPTR_AppDomain appDomain; VMPTR_Module mod; @@ -2602,6 +2614,10 @@ HRESULT CordbProcess::GetTypeForObject(CORDB_ADDRESS addr, CordbType **ppType, C HRESULT hr = E_FAIL; if (GetDAC()->GetAppDomainForObject(addr, &appDomain, &mod, &domainFile)) { + if (pAppDomainOverride) + { + appDomain = pAppDomainOverride->GetADToken(); + } CordbAppDomain *cdbAppDomain = appDomain.IsNull() ? GetSharedAppDomain() : LookupOrCreateAppDomain(appDomain); _ASSERTE(cdbAppDomain); diff --git a/src/debug/di/rspriv.h b/src/debug/di/rspriv.h index 4cccb4ccf0..6d804e755e 100644 --- a/src/debug/di/rspriv.h +++ b/src/debug/di/rspriv.h @@ -3138,7 +3138,7 @@ public: //----------------------------------------------------------- // ICorDebugProcess10 //----------------------------------------------------------- - COM_METHOD GetContainingObject(CORDB_ADDRESS interiorPointer, ICorDebugObjectValue** ppContainingObject); + COM_METHOD GetContainingObject(ICorDebugValue* pValue, ICorDebugObjectValue** ppContainingObject); COM_METHOD EnableGCNotificationEvents(BOOL fEnable); #ifdef FEATURE_LEGACYNETCF_DBG_HOST_CONTROL @@ -3653,7 +3653,7 @@ public: // the jit attach. HRESULT GetAttachStateFlags(CLR_DEBUGGING_PROCESS_FLAGS *pFlags); - HRESULT GetTypeForObject(CORDB_ADDRESS obj, CordbType **ppType, CordbAppDomain **pAppDomain = NULL); + HRESULT GetTypeForObject(CORDB_ADDRESS obj, CordbAppDomain* pAppDomainOverride, CordbType **ppType, CordbAppDomain **pAppDomain = NULL); WriteableMetadataUpdateMode GetWriteableMetadataUpdateMode() { return m_writableMetadataUpdateMode; } private: @@ -4114,6 +4114,8 @@ private: // controls how metadata updated in the target is handled WriteableMetadataUpdateMode m_writableMetadataUpdateMode; + + COM_METHOD GetObjectInternal(CORDB_ADDRESS addr, CordbAppDomain* pAppDomainOverride, ICorDebugObjectValue **pObject); }; // Some IMDArocess APIs are supported as interop-only. @@ -8771,6 +8773,8 @@ public: CorDebugHandleType handleType, ICorDebugHandleValue ** ppHandle); + static CordbValue* GetCordbValue(ICorDebugValue* pValue); + //----------------------------------------------------------- // Data members //----------------------------------------------------------- diff --git a/src/inc/cordebug.idl b/src/inc/cordebug.idl index c23f305b5a..a9157d09ec 100644 --- a/src/inc/cordebug.idl +++ b/src/inc/cordebug.idl @@ -3298,19 +3298,19 @@ interface ICorDebugProcess8 : IUnknown interface ICorDebugProcess10 : IUnknown { // - // Given a pointer that is pointing to the interior of an object (for example, a field on an object), + // Given a value inside an object (for example, a field on an object), // returns the containing object. // // Parameters - // interiorPointer - the pointer pointing to the interior of an object. + // pValue - the value in the interior of an object. // ppContainingObject - [out] An ICorDebugObjectValue that represents the containing object. // // Returns // S_OK - on success - // S_FALSE - if the given interior pointer is not inside an object + // S_FALSE - if the given value is not inside an object // E_POINTER - ppContainingObject is NULL // - HRESULT GetContainingObject([in] CORDB_ADDRESS interiorPointer, [out] ICorDebugObjectValue** ppContainingObject); + HRESULT GetContainingObject([in] ICorDebugValue* pValue, [out] ICorDebugObjectValue** ppContainingObject); // // Enable or disable the GC notification events. The GC notification events are turned off by default diff --git a/src/pal/prebuilt/inc/cordebug.h b/src/pal/prebuilt/inc/cordebug.h index f633fda7b1..169dfa5613 100644 --- a/src/pal/prebuilt/inc/cordebug.h +++ b/src/pal/prebuilt/inc/cordebug.h @@ -7839,7 +7839,7 @@ EXTERN_C const IID IID_ICorDebugProcess10; { public: virtual HRESULT STDMETHODCALLTYPE GetContainingObject( - /* [in] */ CORDB_ADDRESS interiorPointer, + /* [in] */ ICorDebugValue *pValue, /* [out] */ ICorDebugObjectValue **ppContainingObject) = 0; virtual HRESULT STDMETHODCALLTYPE EnableGCNotificationEvents( @@ -7868,7 +7868,7 @@ EXTERN_C const IID IID_ICorDebugProcess10; HRESULT ( STDMETHODCALLTYPE *GetContainingObject )( ICorDebugProcess10 * This, - /* [in] */ CORDB_ADDRESS interiorPointer, + /* [in] */ ICorDebugValue *pValue, /* [out] */ ICorDebugObjectValue **ppContainingObject); HRESULT ( STDMETHODCALLTYPE *EnableGCNotificationEvents )( @@ -7898,8 +7898,8 @@ EXTERN_C const IID IID_ICorDebugProcess10; ( (This)->lpVtbl -> Release(This) ) -#define ICorDebugProcess10_GetContainingObject(This,interiorPointer,ppContainingObject) \ - ( (This)->lpVtbl -> GetContainingObject(This,interiorPointer,ppContainingObject) ) +#define ICorDebugProcess10_GetContainingObject(This,pValue,ppContainingObject) \ + ( (This)->lpVtbl -> GetContainingObject(This,pValue,ppContainingObject) ) #define ICorDebugProcess10_EnableGCNotificationEvents(This,fEnable) \ ( (This)->lpVtbl -> EnableGCNotificationEvents(This,fEnable) ) |