@@ -916,6 +916,7 @@ Debugger::Debugger()
916916 m_ignoreThreadDetach(FALSE),
917917 m_pMethodInfos(NULL),
918918 m_pForceCatchHandlerFoundEventsTable(NULL),
919+ m_pCustomNotificationTable(NULL),
919920 m_mutex(CrstDebuggerMutex, (CrstFlags)(CRST_UNSAFE_ANYMODE | CRST_REENTRANCY | CRST_DEBUGGER_THREAD)),
920921#ifdef _DEBUG
921922 m_mutexOwner(0),
@@ -958,8 +959,7 @@ Debugger::Debugger()
958959 m_processId = GetCurrentProcessId();
959960
960961 m_pForceCatchHandlerFoundEventsTable = new ForceCatchHandlerFoundTable();
961-
962-
962+ m_pCustomNotificationTable = new CustomNotificationTable();
963963
964964 //------------------------------------------------------------------------------
965965 // Metadata data structure version numbers
@@ -8045,6 +8045,20 @@ BOOL Debugger::ShouldSendCatchHandlerFound(Thread* pThread)
80458045 }
80468046}
80478047
8048+ BOOL Debugger::ShouldSendCustomNotification(DomainAssembly *pAssembly, mdTypeDef typeDef)
8049+ {
8050+ CONTRACTL
8051+ {
8052+ THROWS;
8053+ GC_NOTRIGGER;
8054+ MODE_ANY;
8055+ }
8056+ CONTRACTL_END;
8057+
8058+ Module *pModule = pAssembly->GetModule();
8059+ TypeInModule tim(pModule, typeDef);
8060+ return !(m_pCustomNotificationTable->Lookup(tim).IsNull());
8061+ }
80488062
80498063// Actually send the catch handler found event.
80508064// This can be used to send CHF for both regular managed catchers as well
@@ -10485,6 +10499,26 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
1048510499 }
1048610500 break;
1048710501
10502+ case DB_IPCE_SET_ENABLE_CUSTOM_NOTIFICATION:
10503+ {
10504+ Module * pModule = pEvent->CustomNotificationData.vmModule.GetRawPtr();
10505+ mdTypeDef classToken = pEvent->CustomNotificationData.classMetadataToken;
10506+ BOOL enabled = pEvent->CustomNotificationData.Enabled;
10507+
10508+ HRESULT hr = UpdateCustomNotificationTable(pModule, classToken, enabled);
10509+
10510+ DebuggerIPCEvent * pIPCResult = m_pRCThread->GetIPCEventReceiveBuffer();
10511+ InitIPCEvent(pIPCResult,
10512+ DB_IPCE_SET_ENABLE_CUSTOM_NOTIFICATION_RESULT,
10513+ g_pEEInterface->GetThread(),
10514+ pEvent->vmAppDomain);
10515+
10516+ pIPCResult->hr = hr;
10517+
10518+ m_pRCThread->SendIPCReply();
10519+ }
10520+ break;
10521+
1048810522 case DB_IPCE_BREAKPOINT_ADD:
1048910523 {
1049010524
@@ -12408,6 +12442,35 @@ HRESULT Debugger::IsMethodDeoptimized(Module *pModule, mdMethodDef methodDef, BO
1240812442 return S_OK;
1240912443}
1241012444
12445+ HRESULT Debugger::UpdateCustomNotificationTable(Module *pModule, mdTypeDef classToken, BOOL enabled)
12446+ {
12447+ CONTRACTL
12448+ {
12449+ THROWS;
12450+ CAN_TAKE_LOCK;
12451+ GC_NOTRIGGER;
12452+ }
12453+ CONTRACTL_END;
12454+
12455+ TypeInModule tim(pModule, classToken);
12456+ if (enabled)
12457+ {
12458+ if (m_pCustomNotificationTable->Lookup(tim).IsNull())
12459+ {
12460+ m_pCustomNotificationTable->Add(tim);
12461+ }
12462+ }
12463+ else
12464+ {
12465+ if (!(m_pCustomNotificationTable->Lookup(tim).IsNull()))
12466+ {
12467+ m_pCustomNotificationTable->Remove(tim);
12468+ }
12469+ }
12470+
12471+ return S_OK;
12472+ }
12473+
1241112474HRESULT Debugger::UpdateForceCatchHandlerFoundTable(BOOL enableEvents, OBJECTREF exObj, AppDomain *pAppDomain)
1241212475{
1241312476 CONTRACTL
@@ -14583,7 +14646,7 @@ void Debugger::SendCustomDebuggerNotification(Thread * pThread,
1458314646 Thread *curThread = g_pEEInterface->GetThread();
1458414647 SENDIPCEVENT_BEGIN(this, curThread);
1458514648
14586- if (CORDebuggerAttached())
14649+ if (CORDebuggerAttached() && ShouldSendCustomNotification(pDomain, classToken) )
1458714650 {
1458814651 DebuggerIPCEvent* ipce = m_pRCThread->GetIPCEventSendBuffer();
1458914652 InitIPCEvent(ipce,
0 commit comments