From b72d9fd8d93761607dc876b46c6dc910138771d3 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Fri, 10 Aug 2018 15:16:48 -0700 Subject: [PATCH] Adding comments for thread execution mode in DebuggerRCThread::SendIPCEvent Commit migrated from https://github.com/dotnet/coreclr/commit/1992834d8b4d80ab4227d0e6a7c0f9b6939d890b --- src/coreclr/src/debug/ee/rcthread.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/coreclr/src/debug/ee/rcthread.cpp b/src/coreclr/src/debug/ee/rcthread.cpp index 95d00f7..987c290 100644 --- a/src/coreclr/src/debug/ee/rcthread.cpp +++ b/src/coreclr/src/debug/ee/rcthread.cpp @@ -1777,7 +1777,23 @@ HRESULT DebuggerRCThread::SendIPCEvent() NOTHROW; GC_NOTRIGGER; // duh, we're in preemptive.. - if (!m_debugger->m_isBlockedOnGarbageCollectionEvent) + if (m_debugger->m_isBlockedOnGarbageCollectionEvent) + { + // + // If m_debugger->m_isBlockedOnGarbageCollectionEvent is true, then it must be reporting + // either the BeforeGarbageCollection event or the AfterGarbageCollection event + // The thread is in preemptive mode during BeforeGarbageCollection + // The thread is in cooperative mode during AfterGarbageCollection + // In either case, the thread mode doesn't really matter because GC has already taken control + // of execution. + // + // Despite the fact that we are actually in preemptive mode during BeforeGarbageCollection, + // because IsGCThread() is true, the EEContract::DoCheck() will happily accept the fact we are + // testing for MODE_COOPERATIVE. + // + MODE_COOPERATIVE; + } + else { if (ThisIsHelperThreadWorker()) { @@ -1794,8 +1810,6 @@ HRESULT DebuggerRCThread::SendIPCEvent() MODE_PREEMPTIVE; } } - - PRECONDITION(ThisMaybeHelperThread()); } CONTRACTL_END; -- 2.7.4