return pModule->GetFunctionFromToken(methodDef, ppFunction);
}
+HRESULT EvalHelpers::FindMethodInModule(const std::string &moduleName, const WCHAR className[], const WCHAR methodName[], ICorDebugFunction **ppFunction)
+{
+ HRESULT Status;
+ ToRelease<ICorDebugModule> pModule;
+ IfFailRet(m_sharedModules->GetModuleWithName(moduleName, &pModule));
+ IfFailRet(FindFunction(pModule, className, methodName, ppFunction));
+ return S_OK;
+}
+
static bool TypeHaveStaticMembers(ICorDebugType *pType)
{
HRESULT Status;
if (!m_pSuppressFinalize)
{
- ToRelease<ICorDebugModule> pModule;
- IfFailRet(m_sharedModules->GetModuleWithName("System.Private.CoreLib.dll", &pModule));
-
+ static const std::string assemblyName = "System.Private.CoreLib.dll";
static const WCHAR gcName[] = W("System.GC");
static const WCHAR suppressFinalizeMethodName[] = W("SuppressFinalize");
- IfFailRet(FindFunction(pModule, gcName, suppressFinalizeMethodName, &m_pSuppressFinalize));
+ IfFailRet(FindMethodInModule(assemblyName, gcName, suppressFinalizeMethodName, &m_pSuppressFinalize));
}
if (!m_pSuppressFinalize)
// Call 'ObjectIdForDebugger' property getter.\r
ToRelease<ICorDebugFunction> pFunc;\r
IfFailRet(pModule->GetFunctionFromToken(mdObjectIdForDebuggerGetter, &pFunc));\r
- IfFailRet(pEvalHelpers->EvalFunction(pThread, pFunc, pType.GetRef(), 1, pValue.GetRef(), 1, ppValueAsyncIdRef, defaultEvalFlags));\r
+ IfFailRet(pEvalHelpers->EvalFunction(pThread, pFunc, nullptr, 0, pValue.GetRef(), 1, ppValueAsyncIdRef, defaultEvalFlags));\r
\r
return S_OK;\r
}\r
rgbValue[0] = 1; // TRUE\r
IfFailRet(pGenericValue->SetValue((LPVOID) &(rgbValue[0])));\r
\r
-\r
// Call this.<>t__builder.SetNotificationForWaitCompletion(TRUE).\r
- ToRelease<ICorDebugValue2> pNewBooleanValue2;\r
- IfFailRet(pNewBoolean->QueryInterface(IID_ICorDebugValue2, (LPVOID *) &pNewBooleanValue2));\r
- ToRelease<ICorDebugType> pNewBooleanType;\r
- IfFailRet(pNewBooleanValue2->GetExactType(&pNewBooleanType));\r
-\r
ToRelease<ICorDebugFunction> pFunc;\r
IfFailRet(pModule->GetFunctionFromToken(setNotifDef, &pFunc));\r
\r
- ICorDebugType *ppArgsType[] = {pType, pNewBooleanType};\r
ICorDebugValue *ppArgsValue[] = {pBuilderValue, pNewBoolean};\r
- IfFailRet(pEvalHelpers->EvalFunction(pThread, pFunc, ppArgsType, 2, ppArgsValue, 2, nullptr, defaultEvalFlags));\r
+ IfFailRet(pEvalHelpers->EvalFunction(pThread, pFunc, nullptr, 0, ppArgsValue, 2, nullptr, defaultEvalFlags));\r
\r
return S_OK;\r
}\r
HRESULT AsyncStepper::SetBreakpointIntoNotifyDebuggerOfWaitCompletion()\r
{\r
HRESULT Status = S_OK;\r
+ static const std::string assemblyName = "System.Private.CoreLib.dll";\r
+ static const WCHAR className[] = W("System.Threading.Tasks.Task");\r
+ static const WCHAR methodName[] = W("NotifyDebuggerOfWaitCompletion");\r
+ ToRelease<ICorDebugFunction> pFunc;\r
+ IfFailRet(m_sharedEvalHelpers->FindMethodInModule(assemblyName, className, methodName, &pFunc));\r
\r
ToRelease<ICorDebugModule> pModule;\r
- IfFailRet(m_sharedModules->GetModuleWithName("System.Private.CoreLib.dll", &pModule));\r
-\r
- ToRelease<IUnknown> pMDUnknown;\r
- IfFailRet(pModule->GetMetaDataInterface(IID_IMetaDataImport, &pMDUnknown));\r
- ToRelease<IMetaDataImport> pMD;\r
- IfFailRet(pMDUnknown->QueryInterface(IID_IMetaDataImport, (LPVOID*) &pMD));\r
-\r
- mdTypeDef typeDef = mdTypeDefNil;\r
- static const WCHAR strTypeDef[] = W("System.Threading.Tasks.Task");\r
- IfFailRet(pMD->FindTypeDefByName(strTypeDef, mdTypeDefNil, &typeDef));\r
-\r
- ULONG numMethods = 0;\r
- HCORENUM hEnum = NULL;\r
- mdMethodDef methodDef;\r
- mdMethodDef notifyDef = mdMethodDefNil;\r
- while(SUCCEEDED(pMD->EnumMethods(&hEnum, typeDef, &methodDef, 1, &numMethods)) && numMethods != 0)\r
- {\r
- mdTypeDef memTypeDef;\r
- ULONG nameLen;\r
- WCHAR szFunctionName[mdNameLen] = {0};\r
- if (FAILED(pMD->GetMethodProps(methodDef, &memTypeDef,\r
- szFunctionName, _countof(szFunctionName), &nameLen,\r
- nullptr, nullptr, nullptr, nullptr, nullptr)))\r
- {\r
- continue;\r
- }\r
-\r
- if (!str_equal(szFunctionName, W("NotifyDebuggerOfWaitCompletion")))\r
- continue;\r
-\r
- notifyDef = methodDef;\r
- break;\r
- }\r
- pMD->CloseEnum(hEnum);\r
-\r
- if (notifyDef == mdMethodDefNil)\r
- return E_FAIL;\r
-\r
+ IfFailRet(pFunc->GetModule(&pModule));\r
CORDB_ADDRESS modAddress;\r
IfFailRet(pModule->GetBaseAddress(&modAddress));\r
- ToRelease<ICorDebugFunction> pFunc;\r
- IfFailRet(pModule->GetFunctionFromToken(notifyDef, &pFunc));\r
+ mdMethodDef methodDef;\r
+ IfFailRet(pFunc->GetToken(&methodDef));\r
\r
ToRelease<ICorDebugCode> pCode;\r
IfFailRet(pFunc->GetILCode(&pCode));\r
m_asyncStepNotifyDebuggerOfWaitCompletion.reset(new asyncBreakpoint_t());\r
m_asyncStepNotifyDebuggerOfWaitCompletion->iCorFuncBreakpoint = iCorFuncBreakpoint.Detach();\r
m_asyncStepNotifyDebuggerOfWaitCompletion->modAddress = modAddress;\r
- m_asyncStepNotifyDebuggerOfWaitCompletion->methodToken = notifyDef;\r
+ m_asyncStepNotifyDebuggerOfWaitCompletion->methodToken = methodDef;\r
\r
return S_OK;\r
}\r