From fe031b5d1252137df5452235fd67fe966d9fb59a Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Tue, 7 Aug 2018 16:55:21 -0700 Subject: [PATCH] Turn GarbageCollection events off by default and allow VS turning them on Commit migrated from https://github.com/dotnet/coreclr/commit/4143a9c607a387d16ffa724e37596501bb7e22f2 --- src/coreclr/src/debug/daccess/dacdbiimpl.cpp | 16 ++++++++++++++++ src/coreclr/src/debug/daccess/dacdbiimpl.h | 1 + src/coreclr/src/debug/di/process.cpp | 5 +++++ src/coreclr/src/debug/di/rspriv.h | 1 + src/coreclr/src/debug/ee/debugger.cpp | 7 ++++--- src/coreclr/src/debug/ee/debugger.h | 1 + src/coreclr/src/debug/inc/dacdbiinterface.h | 4 ++++ src/coreclr/src/inc/cordebug.idl | 1 + src/coreclr/src/pal/prebuilt/inc/cordebug.h | 12 +++++++++++- 9 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/coreclr/src/debug/daccess/dacdbiimpl.cpp b/src/coreclr/src/debug/daccess/dacdbiimpl.cpp index b00917c..988f673 100644 --- a/src/coreclr/src/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/src/debug/daccess/dacdbiimpl.cpp @@ -7259,6 +7259,22 @@ HRESULT DacDbiInterfaceImpl::GetMDStructuresVersion(ULONG32* pMDStructuresVersio return S_OK; } +HRESULT DacDbiInterfaceImpl::EnableGCNotificationEvents(BOOL fEnable) +{ + DD_ENTER_MAY_THROW + + HRESULT hr = S_OK; + EX_TRY + { + if (g_pDebugger != NULL) + { + TADDR addr = PTR_HOST_MEMBER_TADDR(Debugger, g_pDebugger, m_isGarbageCollectionEventsEnabled); + SafeWriteStructOrThrow(addr, &fEnable); + } + } + EX_CATCH_HRESULT(hr); + return hr; +} DacRefWalker::DacRefWalker(ClrDataAccess *dac, BOOL walkStacks, BOOL walkFQ, UINT32 handleMask) : mDac(dac), mWalkStacks(walkStacks), mWalkFQ(walkFQ), mHandleMask(handleMask), mStackWalker(NULL), diff --git a/src/coreclr/src/debug/daccess/dacdbiimpl.h b/src/coreclr/src/debug/daccess/dacdbiimpl.h index 6655800..403fa7f 100644 --- a/src/coreclr/src/debug/daccess/dacdbiimpl.h +++ b/src/coreclr/src/debug/daccess/dacdbiimpl.h @@ -156,6 +156,7 @@ public: HRESULT GetILCodeVersionNodeData(VMPTR_ILCodeVersionNode vmILCodeVersionNode, DacSharedReJitInfo* pData); HRESULT GetDefinesBitField(ULONG32 *pDefines); HRESULT GetMDStructuresVersion(ULONG32* pMDStructuresVersion); + HRESULT EnableGCNotificationEvents(BOOL fEnable); private: void TypeHandleToExpandedTypeInfoImpl(AreValueTypesBoxed boxed, diff --git a/src/coreclr/src/debug/di/process.cpp b/src/coreclr/src/debug/di/process.cpp index 99e5aa4e..1411857 100644 --- a/src/coreclr/src/debug/di/process.cpp +++ b/src/coreclr/src/debug/di/process.cpp @@ -2557,6 +2557,11 @@ COM_METHOD CordbProcess::GetContainingObject(CORDB_ADDRESS interiorPointer, ICor return hr; } +COM_METHOD CordbProcess::EnableGCNotificationEvents(BOOL fEnable) +{ + return this->m_pDacPrimitives->EnableGCNotificationEvents(fEnable); +} + #ifdef FEATURE_LEGACYNETCF_DBG_HOST_CONTROL COM_METHOD CordbProcess::InvokePauseCallback() diff --git a/src/coreclr/src/debug/di/rspriv.h b/src/coreclr/src/debug/di/rspriv.h index d0a10be..4cccb4c 100644 --- a/src/coreclr/src/debug/di/rspriv.h +++ b/src/coreclr/src/debug/di/rspriv.h @@ -3139,6 +3139,7 @@ public: // ICorDebugProcess10 //----------------------------------------------------------- COM_METHOD GetContainingObject(CORDB_ADDRESS interiorPointer, ICorDebugObjectValue** ppContainingObject); + COM_METHOD EnableGCNotificationEvents(BOOL fEnable); #ifdef FEATURE_LEGACYNETCF_DBG_HOST_CONTROL // --------------------------------------------------------------- diff --git a/src/coreclr/src/debug/ee/debugger.cpp b/src/coreclr/src/debug/ee/debugger.cpp index e8134a4..a6ba5ce 100644 --- a/src/coreclr/src/debug/ee/debugger.cpp +++ b/src/coreclr/src/debug/ee/debugger.cpp @@ -952,7 +952,8 @@ Debugger::Debugger() m_forceNonInterceptable(FALSE), m_pLazyData(NULL), m_defines(_defines), - m_isBlockedOnGarbageCollectionEvent(FALSE) + m_isBlockedOnGarbageCollectionEvent(FALSE), + m_isGarbageCollectionEventsEnabled(FALSE) { CONTRACTL { @@ -6008,7 +6009,7 @@ void Debugger::BeforeGarbageCollection() } CONTRACTL_END; - if (!CORDebuggerAttached()) + if (!CORDebuggerAttached() || !this->m_isGarbageCollectionEventsEnabled) { return; } @@ -6046,7 +6047,7 @@ void Debugger::AfterGarbageCollection() } CONTRACTL_END; - if (!CORDebuggerAttached()) + if (!CORDebuggerAttached() || !this->m_isGarbageCollectionEventsEnabled) { return; } diff --git a/src/coreclr/src/debug/ee/debugger.h b/src/coreclr/src/debug/ee/debugger.h index a07531b..381cb57 100644 --- a/src/coreclr/src/debug/ee/debugger.h +++ b/src/coreclr/src/debug/ee/debugger.h @@ -2958,6 +2958,7 @@ public: virtual void AfterGarbageCollection(); #endif BOOL m_isBlockedOnGarbageCollectionEvent; + BOOL m_isGarbageCollectionEventsEnabled; private: HANDLE GetGarbageCollectionBlockerEvent() { return GetLazyData()->m_garbageCollectionBlockerEvent; } diff --git a/src/coreclr/src/debug/inc/dacdbiinterface.h b/src/coreclr/src/debug/inc/dacdbiinterface.h index 7295884..abbe7d9 100644 --- a/src/coreclr/src/debug/inc/dacdbiinterface.h +++ b/src/coreclr/src/debug/inc/dacdbiinterface.h @@ -2696,6 +2696,10 @@ public: virtual HRESULT GetILCodeVersionNodeData(VMPTR_ILCodeVersionNode ilCodeVersionNode, DacSharedReJitInfo* pData) = 0; + // TODO, andrewau, documentation + virtual + HRESULT EnableGCNotificationEvents(BOOL fEnable) = 0; + // The following tag tells the DD-marshalling tool to stop scanning. // END_MARSHAL diff --git a/src/coreclr/src/inc/cordebug.idl b/src/coreclr/src/inc/cordebug.idl index 63adbb7..32ec503 100644 --- a/src/coreclr/src/inc/cordebug.idl +++ b/src/coreclr/src/inc/cordebug.idl @@ -3271,6 +3271,7 @@ interface ICorDebugProcess8 : IUnknown interface ICorDebugProcess10 : IUnknown { HRESULT GetContainingObject([in] CORDB_ADDRESS interiorPointer, [out] ICorDebugObjectValue** ppContainingObject); + HRESULT EnableGCNotificationEvents(BOOL fEnable); } // Event types MODULE_LOADED and MODULE_UNLOADED implement this interface diff --git a/src/coreclr/src/pal/prebuilt/inc/cordebug.h b/src/coreclr/src/pal/prebuilt/inc/cordebug.h index 9eccc51..59375ba 100644 --- a/src/coreclr/src/pal/prebuilt/inc/cordebug.h +++ b/src/coreclr/src/pal/prebuilt/inc/cordebug.h @@ -6,7 +6,7 @@ /* File created by MIDL compiler version 8.01.0622 */ /* at Mon Jan 18 19:14:07 2038 */ -/* Compiler settings for C:/Dev/CoreCLR/src/inc/cordebug.idl: +/* Compiler settings for F:/Dev/coreclr/src/inc/cordebug.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data @@ -7842,6 +7842,9 @@ EXTERN_C const IID IID_ICorDebugProcess10; /* [in] */ CORDB_ADDRESS interiorPointer, /* [out] */ ICorDebugObjectValue **ppContainingObject) = 0; + virtual HRESULT STDMETHODCALLTYPE EnableGCNotificationEvents( + BOOL fEnable) = 0; + }; @@ -7868,6 +7871,10 @@ EXTERN_C const IID IID_ICorDebugProcess10; /* [in] */ CORDB_ADDRESS interiorPointer, /* [out] */ ICorDebugObjectValue **ppContainingObject); + HRESULT ( STDMETHODCALLTYPE *EnableGCNotificationEvents )( + ICorDebugProcess10 * This, + BOOL fEnable); + END_INTERFACE } ICorDebugProcess10Vtbl; @@ -7894,6 +7901,9 @@ EXTERN_C const IID IID_ICorDebugProcess10; #define ICorDebugProcess10_GetContainingObject(This,interiorPointer,ppContainingObject) \ ( (This)->lpVtbl -> GetContainingObject(This,interiorPointer,ppContainingObject) ) +#define ICorDebugProcess10_EnableGCNotificationEvents(This,fEnable) \ + ( (This)->lpVtbl -> EnableGCNotificationEvents(This,fEnable) ) + #endif /* COBJMACROS */ -- 2.7.4