Skip to content

Commit 39314d4

Browse files
am11jkotas
andauthored
Make UCO MethodDesc globals DAC-accessible (#126927)
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent 20461f5 commit 39314d4

File tree

11 files changed

+36
-11
lines changed

11 files changed

+36
-11
lines changed

src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,20 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::UnwindStackWalkFrame(StackWalkHan
297297
}
298298
else if (pIter->GetFrameState() == StackFrameIterator::SFITER_FRAMELESS_METHOD)
299299
{
300-
// Skip the new exception handling managed code, the debugger clients are not supposed to see them
301300
MethodDesc *pMD = pIter->m_crawl.GetFunction();
301+
MethodTable *pMT = pMD->GetMethodTable();
302302

303+
// Skip the exception handling managed code, the debugger clients are not supposed to see them
303304
// EH.DispatchEx, EH.RhThrowEx, EH.RhThrowHwEx, ExceptionServices.InternalCalls.SfiInit, ExceptionServices.InternalCalls.SfiNext
304305
// and System.Runtime.StackFrameIterator.*
305-
if (pMD->GetMethodTable() == g_pEHClass || pMD->GetMethodTable() == g_pExceptionServicesInternalCallsClass || pMD->GetMethodTable() == g_pStackFrameIteratorClass)
306+
if (pMT == g_pEHClass || pMT == g_pExceptionServicesInternalCallsClass || pMT == g_pStackFrameIteratorClass)
307+
{
308+
continue;
309+
}
310+
311+
// Skip the runtime helper that invokes the main program entrypoint, the debuggers do not want to see it.
312+
// Environment.CallEntryPoint
313+
if (pMD == g_pEnvironmentCallEntryPointMethodDesc)
306314
{
307315
continue;
308316
}
@@ -421,6 +429,11 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetStackWalkCurrentFrameInfo(Stac
421429
{
422430
ftResult = kManagedExceptionHandlingCodeFrame;
423431
}
432+
// Environment.CallEntryPoint
433+
else if (pMD == g_pEnvironmentCallEntryPointMethodDesc)
434+
{
435+
ftResult = kRuntimeEntryPointFrame;
436+
}
424437
else
425438
{
426439
ftResult = kManagedStackFrame;

src/coreclr/debug/di/rsstackwalk.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,11 @@ HRESULT CordbStackWalk::GetFrameWorker(ICorDebugFrame ** ppFrame)
602602
STRESS_LOG1(LF_CORDB, LL_INFO1000, "CSW::GFW - managed exception handling code frame (%p)", this);
603603
return S_FALSE;
604604
}
605+
else if (ft == IDacDbiInterface::kRuntimeEntryPointFrame)
606+
{
607+
STRESS_LOG1(LF_CORDB, LL_INFO1000, "CSW::GFW - runtime entry point frame (%p)", this);
608+
return S_FALSE;
609+
}
605610
else if (ft == IDacDbiInterface::kExplicitFrame)
606611
{
607612
STRESS_LOG1(LF_CORDB, LL_INFO1000, "CSW::GFW - explicit frame (%p)", this);

src/coreclr/debug/ee/controller.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6767,14 +6767,21 @@ bool DebuggerStepper::IsInterestingFrame(FrameInfo * pFrame)
67676767
{
67686768
LIMITED_METHOD_CONTRACT;
67696769

6770-
// Ignore managed exception handling frames
67716770
if (pFrame->md != NULL)
67726771
{
67736772
MethodTable *pMT = pFrame->md->GetMethodTable();
6773+
6774+
// Ignore managed exception handling frames
67746775
if ((pMT == g_pEHClass) || (pMT == g_pExceptionServicesInternalCallsClass))
67756776
{
67766777
return false;
67776778
}
6779+
6780+
// Ignore the runtime helper that invokes the main program entrypoint
6781+
if (pFrame->md == g_pEnvironmentCallEntryPointMethodDesc)
6782+
{
6783+
return false;
6784+
}
67786785
}
67796786

67806787
return true;

src/coreclr/debug/inc/dacdbiinterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,7 @@ IDacDbiInterface : public IUnknown
12311231
kNativeStackFrame,
12321232
kNativeRuntimeUnwindableStackFrame,
12331233
kManagedExceptionHandlingCodeFrame,
1234+
kRuntimeEntryPointFrame,
12341235
kAtEndOfStack,
12351236
} FrameType;
12361237

src/coreclr/inc/dacvars.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pEHClass, ::g_pEHClass)
125125
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pExceptionServicesInternalCallsClass, ::g_pExceptionServicesInternalCallsClass)
126126
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pStackFrameIteratorClass, ::g_pStackFrameIteratorClass)
127127

128+
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pEnvironmentCallEntryPointMethodDesc, ::g_pEnvironmentCallEntryPointMethodDesc)
129+
128130
DEFINE_DACVAR(PTR_SString, SString__s_Empty, SString::s_Empty)
129131

130132
DEFINE_DACVAR(INT32, ArrayBase__s_arrayBoundsZero, ArrayBase::s_arrayBoundsZero)

src/coreclr/vm/assembly.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,6 @@ struct Param
11651165
bool captureException;
11661166
} param;
11671167

1168-
MethodDesc* g_pEnvironmentCallEntryPointMethodDesc = nullptr;
1169-
11701168
#if defined(TARGET_BROWSER)
11711169
extern "C" void SystemJS_ResolveMainPromise(int exitCode);
11721170
#endif // TARGET_BROWSER

src/coreclr/vm/debugdebugger.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232

3333
#ifndef DACCESS_COMPILE
3434

35-
extern MethodDesc* g_pEnvironmentCallEntryPointMethodDesc;
36-
3735
//
3836
// Notes:
3937
// If a managed debugger is attached, this should send the managed UserBreak event.

src/coreclr/vm/eepolicy.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#include "eventtrace.h"
2424
#undef ExitProcess
2525

26-
extern MethodDesc* g_pEnvironmentCallEntryPointMethodDesc;
27-
2826
void SafeExitProcess(UINT exitCode, ShutdownCompleteAction sca = SCA_ExitProcessWhenShutdownComplete)
2927
{
3028
STRESS_LOG2(LF_SYNC, LL_INFO10, "SafeExitProcess: exitCode = %d sca = %d\n", exitCode, sca);
@@ -180,7 +178,7 @@ class CallStackLogger
180178

181179
MethodDesc* pMD = pCF->GetFunction();
182180

183-
// Skip Environment.CallEntryPoint so it doesn't appear in vanilla
181+
// Skip Environment.CallEntryPoint so it doesn't appear in
184182
// unhandled exception experiences.
185183
if (pMD != nullptr && pMD == g_pEnvironmentCallEntryPointMethodDesc)
186184
{

src/coreclr/vm/exceptionhandling.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "exinfo.h"
1919
#include "configuration.h"
2020

21-
extern MethodDesc* g_pEnvironmentCallEntryPointMethodDesc;
2221
extern MethodDesc* g_pThreadStartCallbackMethodDesc;
2322
extern MethodDesc* g_pGCRunFinalizersMethodDesc;
2423

src/coreclr/vm/vars.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ GPTR_IMPL(MethodTable, g_pEHClass);
112112
GPTR_IMPL(MethodTable, g_pExceptionServicesInternalCallsClass);
113113
GPTR_IMPL(MethodTable, g_pStackFrameIteratorClass);
114114

115+
GPTR_IMPL(MethodDesc, g_pEnvironmentCallEntryPointMethodDesc);
116+
115117
GVAL_IMPL_INIT(PTR_WSTR, g_EntryAssemblyPath, NULL);
116118

117119
#ifndef DACCESS_COMPILE

0 commit comments

Comments
 (0)