Skip to content

Commit

Permalink
Fix Thread::SetProfilerFilterContext usage (dotnet#52575)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikem8361 authored May 11, 2021
1 parent b43bea8 commit 7d0065f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/coreclr/debug/daccess/dacimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2001,12 +2001,15 @@ class DacStackReferenceWalker : public DefaultCOMImpl<ISOSStackRefEnum, IID_ISOS
_ASSERTE(mCurr == NULL);
_ASSERTE(mHead.next == NULL);

bool clearProfilerFilterContext = false;
T_CONTEXT ctx;

// Get the current thread's context and set that as the filter context
if (mThread->GetFilterContext() == NULL && mThread->GetProfilerFilterContext() == NULL)
{
T_CONTEXT ctx;
mDac->m_pTarget->GetThreadContext(mThread->GetOSThreadId(), CONTEXT_FULL, sizeof(ctx), (BYTE*)&ctx);
mThread->SetProfilerFilterContext(&ctx);
clearProfilerFilterContext = true;
}

// Setup GCCONTEXT structs for the stackwalk.
Expand All @@ -2033,6 +2036,11 @@ class DacStackReferenceWalker : public DefaultCOMImpl<ISOSStackRefEnum, IID_ISOS
mEnumerated = true;
mThread->StackWalkFrames(DacStackReferenceWalker::Callback, &gcctx, flagsStackWalk);

if (clearProfilerFilterContext)
{
mThread->SetProfilerFilterContext(NULL);
}

// We have filled the user's array as much as we could. If there's more data than
// could fit, mHead.Next will contain a linked list of refs to enumerate.
mCurr = mHead.next;
Expand Down

0 comments on commit 7d0065f

Please sign in to comment.