ToRelease<ICorDebugFunction> m_pRunClassConstructor;
ToRelease<ICorDebugFunction> m_pGetTypeHandle;
+ ToRelease<ICorDebugFunction> m_pSuppressFinalize;
std::mutex m_evalMutex;
std::unordered_map< DWORD, std::promise< std::unique_ptr<ToRelease<ICorDebugValue>> > > m_evalResults;
HRESULT EvalObjectNoConstructor(
ICorDebugThread *pThread,
ICorDebugType *pType,
- ICorDebugValue **ppEvalResult);
+ ICorDebugValue **ppEvalResult,
+ bool suppressFinalize = true);
std::future< std::unique_ptr<ToRelease<ICorDebugValue>> > RunEval(
ICorDebugThread *pThread,
ICorDebugThread *pThread,
std::vector< ToRelease<ICorDebugType> > &types);
+
+ static HRESULT FindFunction(
+ ICorDebugModule *pModule,
+ const WCHAR *typeName,
+ const WCHAR *methodName,
+ ICorDebugFunction **ppFunction);
+
public:
Evaluator(Modules &modules) : m_modules(modules) {}
try
{
auto evalResult = RunEval(pThread, pEval).get();
+ if (!ppEvalResult)
+ return S_OK;
+
if (!evalResult->GetPtr())
return E_FAIL;
*ppEvalResult = evalResult->Detach();
HRESULT Evaluator::EvalObjectNoConstructor(
ICorDebugThread *pThread,
ICorDebugType *pType,
- ICorDebugValue **ppEvalResult)
+ ICorDebugValue **ppEvalResult,
+ bool suppressFinalize)
{
HRESULT Status = S_OK;
(ICorDebugType **)typeParams.data()
));
- return WaitEvalResult(pThread, pEval, ppEvalResult);
+ IfFailRet(WaitEvalResult(pThread, pEval, ppEvalResult));
+
+ if (suppressFinalize)
+ {
+ if (!m_pSuppressFinalize)
+ {
+ ToRelease<ICorDebugModule> pModule;
+ IfFailRet(m_modules.GetModuleWithName("System.Private.CoreLib.dll", &pModule));
+
+ static const WCHAR gcName[] = W("System.GC");
+ static const WCHAR suppressFinalizeMethodName[] = W("SuppressFinalize");
+ IfFailRet(FindFunction(pModule, gcName, suppressFinalizeMethodName, &m_pSuppressFinalize));
+ }
+
+ if (!m_pSuppressFinalize)
+ return E_FAIL;
+
+ IfFailRet(EvalFunction(pThread, m_pSuppressFinalize, nullptr, *ppEvalResult, nullptr /* void method */));
+ }
+
+ return S_OK;
}
static HRESULT FindMethod(ICorDebugType *pType, WCHAR *methodName, ICorDebugFunction **ppFunc)