}
}
-void FindStateMachineTypes(DWORD_PTR* corelibModule, mdTypeDef* stateMachineBox, mdTypeDef* debugStateMachineBox)
+void FindStateMachineTypes(DWORD_PTR* corelibModule, mdTypeDef* stateMachineBox, mdTypeDef* debugStateMachineBox, mdTypeDef* task)
{
int numModule;
ArrayHolder<DWORD_PTR> moduleList = ModuleFromName(const_cast<LPSTR>("System.Private.CoreLib.dll"), &numModule);
*corelibModule = moduleList[0];
GetInfoFromName(*corelibModule, "System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1", stateMachineBox);
GetInfoFromName(*corelibModule, "System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+DebugFinalizableAsyncStateMachineBox`1", debugStateMachineBox);
+ GetInfoFromName(*corelibModule, "System.Threading.Tasks.Task", task);
}
else
{
// Find the state machine types
DWORD_PTR corelibModule;
- mdTypeDef stateMachineBoxMd, debugStateMachineBoxMd;
- FindStateMachineTypes(&corelibModule, &stateMachineBoxMd, &debugStateMachineBoxMd);
+ mdTypeDef stateMachineBoxMd, debugStateMachineBoxMd, taskMd;
+ FindStateMachineTypes(&corelibModule, &stateMachineBoxMd, &debugStateMachineBoxMd, &taskMd);
// Walk each heap object looking for async state machine objects. As we're targeting .NET Core 2.1+, all such objects
// will be Task or Task-derived types.
{
// If the user has selected to include all tasks and not just async state machine boxes, we simply need to validate
// that this is Task or Task-derived, and if it's not, skip it.
- if (!IsDerivedFrom(itr->GetMT(), W("System.Threading.Tasks.Task")))
+ if (!IsDerivedFrom(itr->GetMT(), corelibModule, taskMd))
{
continue;
}
return FALSE;
}
+BOOL IsDerivedFrom(CLRDATA_ADDRESS mtObj, DWORD_PTR modulePtr, mdTypeDef typeDef)
+{
+ DacpMethodTableData dmtd;
+
+ for (CLRDATA_ADDRESS walkMT = mtObj;
+ walkMT != NULL && dmtd.Request(g_sos, walkMT) == S_OK;
+ walkMT = dmtd.ParentMethodTable)
+ {
+ if (dmtd.Module == modulePtr && dmtd.cl == typeDef)
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
BOOL TryGetMethodDescriptorForDelegate(CLRDATA_ADDRESS delegateAddr, CLRDATA_ADDRESS* pMD)
{
if (!sos::IsObject(delegateAddr, false))
BOOL IsObjectArray (DWORD_PTR objPointer);
BOOL IsObjectArray (DacpObjectData *pData);
BOOL IsDerivedFrom(CLRDATA_ADDRESS mtObj, __in_z LPCWSTR baseString);
+BOOL IsDerivedFrom(CLRDATA_ADDRESS mtObj, DWORD_PTR modulePtr, mdTypeDef typeDef);
BOOL TryGetMethodDescriptorForDelegate(CLRDATA_ADDRESS delegateAddr, CLRDATA_ADDRESS* pMD);
#ifdef FEATURE_PAL