Skip to content

Commit 70fd4cf

Browse files
rcj1jkotas
andauthored
Adding IsDiagnosticsILStub() method on MethodDesc and using it to skip over async thunks in a variety of diagnostics-related code in which we would like to hide these from stackwalks, profiler notifications, etc. (#120982)
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent 1e09fc1 commit 70fd4cf

File tree

9 files changed

+26
-18
lines changed

9 files changed

+26
-18
lines changed

src/coreclr/debug/daccess/dacdbiimpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5270,7 +5270,7 @@ IDacDbiInterface::DynamicMethodType DacDbiInterfaceImpl::IsILStubOrLCGMethod(VMP
52705270

52715271
MethodDesc * pMD = vmMethodDesc.GetDacPtr();
52725272

5273-
if (pMD->IsILStub())
5273+
if (pMD->IsDiagnosticsHidden())
52745274
{
52755275
return kILStub;
52765276
}

src/coreclr/debug/ee/debugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7820,7 +7820,7 @@ void Debugger::FirstChanceManagedExceptionCatcherFound(Thread *pThread,
78207820

78217821
if (pMD != NULL)
78227822
{
7823-
_ASSERTE(!pMD->IsILStub());
7823+
_ASSERTE(!pMD->IsDiagnosticsHidden());
78247824

78257825
pDebugJitInfo = GetJitInfo(pMD, (const BYTE *) pMethodAddr, &pDebugMethodInfo);
78267826
if (pDebugMethodInfo != NULL)

src/coreclr/vm/excep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,7 @@ void StackTraceInfo::AppendElement(OBJECTHANDLE hThrowable, UINT_PTR currentIP,
30183018

30193019
LOG((LF_EH, LL_INFO10000, "StackTraceInfo::AppendElement IP = %p, SP = %p, %s::%s\n", currentIP, currentSP, pFunc ? pFunc->m_pszDebugClassName : "", pFunc ? pFunc->m_pszDebugMethodName : "" ));
30203020

3021-
if (pFunc != NULL && pFunc->IsILStub())
3021+
if ((pFunc != NULL && pFunc->IsDiagnosticsHidden()))
30223022
return;
30233023

30243024
// Do not save stacktrace to preallocated exception. These are shared.

src/coreclr/vm/exinfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ void ExInfo::MakeCallbacksRelatedToHandler(
463463
}
464464
m_EHClauseInfo.SetInfo(COR_PRF_CLAUSE_NONE, (UINT_PTR)dwHandlerStartPC, sfToStore);
465465

466-
if (pMD->IsILStub())
466+
if (pMD->IsDiagnosticsHidden())
467467
{
468468
return;
469469
}
@@ -498,7 +498,7 @@ void ExInfo::MakeCallbacksRelatedToHandler(
498498
}
499499
else
500500
{
501-
if (pMD->IsILStub())
501+
if (pMD->IsDiagnosticsHidden())
502502
{
503503
return;
504504
}

src/coreclr/vm/i386/excepx86.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,7 @@ StackWalkAction COMPlusThrowCallback( // SWA value
20942094
currentSP = 0; //Don't have an SP to get.
20952095
}
20962096

2097-
if (!pFunc->IsILStub())
2097+
if (!pFunc->IsDiagnosticsHidden())
20982098
{
20992099
if (!pData->bSkipLastElement)
21002100
{
@@ -2153,7 +2153,7 @@ StackWalkAction COMPlusThrowCallback( // SWA value
21532153
}
21542154

21552155
bool fIsILStub = pFunc->IsILStub();
2156-
bool fGiveDebuggerAndProfilerNotification = !fIsILStub;
2156+
bool fGiveDebuggerAndProfilerNotification = !pFunc->IsDiagnosticsHidden();
21572157
BOOL fMethodCanHandleException = TRUE;
21582158

21592159
MethodDesc * pUserMDForILStub = NULL;
@@ -2490,7 +2490,7 @@ StackWalkAction COMPlusUnwindCallback (CrawlFrame *pCf, ThrowCallbackType *pData
24902490
#endif
24912491

24922492
bool fGiveDebuggerAndProfilerNotification;
2493-
fGiveDebuggerAndProfilerNotification = !pFunc->IsILStub();
2493+
fGiveDebuggerAndProfilerNotification = !pFunc->IsDiagnosticsHidden();
24942494

24952495
// Notify the profiler of the function we're dealing with in the unwind phase
24962496
if (fGiveDebuggerAndProfilerNotification)

src/coreclr/vm/jitinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7938,7 +7938,7 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
79387938
// chance to prevent it.
79397939
{
79407940
BEGIN_PROFILER_CALLBACK(CORProfilerTrackJITInfo());
7941-
if (pCaller->IsILStub() || pCallee->IsILStub())
7941+
if (pCaller->IsDiagnosticsHidden() || pCallee->IsDiagnosticsHidden())
79427942
{
79437943
// do nothing
79447944
}

src/coreclr/vm/method.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ class MethodDesc
732732
inline bool IsILStub();
733733
inline bool IsLCGMethod();
734734

735+
inline bool IsDiagnosticsHidden();
736+
735737
inline DWORD IsPInvoke()
736738
{
737739
LIMITED_METHOD_DAC_CONTRACT;

src/coreclr/vm/method.inl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ inline bool MethodDesc::IsILStub()
127127
return ((mcDynamic == GetClassification()) && dac_cast<PTR_DynamicMethodDesc>(this)->IsILStub());
128128
}
129129

130+
inline bool MethodDesc::IsDiagnosticsHidden()
131+
{
132+
WRAPPER_NO_CONTRACT;
133+
return IsILStub() || IsAsyncThunkMethod();
134+
}
135+
130136
inline BOOL MethodDesc::IsQCall()
131137
{
132138
WRAPPER_NO_CONTRACT;

src/coreclr/vm/stackwalk.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,14 +2065,14 @@ StackWalkAction StackFrameIterator::Filter(void)
20652065
// and its parent, eventually making a callback for the parent as well.
20662066
if (m_flags & (FUNCTIONSONLY | SKIPFUNCLETS))
20672067
{
2068-
if (!m_sfParent.IsNull() || m_crawl.pFunc->IsILStub())
2068+
if (!m_sfParent.IsNull() || m_crawl.pFunc->IsDiagnosticsHidden())
20692069
{
20702070
STRESS_LOG4(LF_GCROOTS, LL_INFO100,
20712071
"STACKWALK: %s: not making callback for this frame, SPOfParent = %p, \
2072-
isILStub = %d, m_crawl.pFunc = %pM\n",
2073-
(!m_sfParent.IsNull() ? "SKIPPING_TO_FUNCLET_PARENT" : "IS_IL_STUB"),
2072+
isDiagnosticsHidden = %d, m_crawl.pFunc = %pM\n",
2073+
(!m_sfParent.IsNull() ? "SKIPPING_TO_FUNCLET_PARENT" : "IS_DIAGNOSTICS_HIDDEN"),
20742074
m_sfParent.SP,
2075-
(m_crawl.pFunc->IsILStub() ? 1 : 0),
2075+
(m_crawl.pFunc->IsDiagnosticsHidden() ? 1 : 0),
20762076
m_crawl.pFunc);
20772077

20782078
// don't stop here
@@ -2085,10 +2085,10 @@ StackWalkAction StackFrameIterator::Filter(void)
20852085
{
20862086
STRESS_LOG4(LF_GCROOTS, LL_INFO100,
20872087
"STACKWALK: %s: not making callback for this frame, SPOfParent = %p, \
2088-
isILStub = %d, m_crawl.pFunc = %pM\n",
2089-
(!m_sfParent.IsNull() ? "SKIPPING_TO_FUNCLET_PARENT" : "IS_IL_STUB"),
2088+
isDiagnosticsHidden = %d, m_crawl.pFunc = %pM\n",
2089+
(!m_sfParent.IsNull() ? "SKIPPING_TO_FUNCLET_PARENT" : "IS_DIAGNOSTICS_HIDDEN"),
20902090
m_sfParent.SP,
2091-
(m_crawl.pFunc->IsILStub() ? 1 : 0),
2091+
(m_crawl.pFunc->IsDiagnosticsHidden() ? 1 : 0),
20922092
m_crawl.pFunc);
20932093

20942094
// don't stop here
@@ -2114,10 +2114,10 @@ StackWalkAction StackFrameIterator::Filter(void)
21142114
// Skip IL stubs
21152115
if (m_flags & FUNCTIONSONLY)
21162116
{
2117-
if (m_crawl.pFunc->IsILStub())
2117+
if (m_crawl.pFunc->IsDiagnosticsHidden())
21182118
{
21192119
LOG((LF_GCROOTS, LL_INFO100000,
2120-
"STACKWALK: IS_IL_STUB: not making callback for this frame, m_crawl.pFunc = %s\n",
2120+
"STACKWALK: IS_DIAGNOSTICS_HIDDEN: not making callback for this frame, m_crawl.pFunc = %s\n",
21212121
m_crawl.pFunc->m_pszDebugMethodName));
21222122

21232123
// don't stop here

0 commit comments

Comments
 (0)