* Returns:
* S_OK on success,
* E_INVALIDARG if not an app domain static,
- * CORPROF_E_DATAINCOMPLETE if not yet initialized.
+ * CORPROF_E_DATAINCOMPLETE if not yet initialized or the module is being unloaded.
*
*/
HRESULT ProfToEEInterfaceImpl::GetAppDomainStaticAddress(ClassID classId,
return CORPROF_E_DATAINCOMPLETE;
}
- if (typeHandle.GetModule()->GetLoaderAllocator() == NULL ||
- typeHandle.GetModule()->GetLoaderAllocator()->GetExposedObject() == NULL)
+ // We might have caught a collectible assembly in the middle of being collected
+ Module *pModule = typeHandle.GetModule();
+ if (pModule->IsCollectible() &&
+ (pModule->GetLoaderAllocator() == NULL || pModule->GetLoaderAllocator()->GetExposedObject() == NULL))
{
return CORPROF_E_DATAINCOMPLETE;
}
refCount(0),
failures(0),
successes(0),
+ collectibleCount(0),
+ nonCollectibleCount(0),
jitEventCount(0),
gcTriggerThread(),
gcWaitEvent(),
this->pCorProfilerInfo = nullptr;
}
- if(failures == 0 && successes > 0)
+ if(failures == 0 && successes > 0 && collectibleCount > 0 && nonCollectibleCount > 0)
{
printf("PROFILER TEST PASSES\n");
}
else
{
- printf("Test failed number of failures=%d successes=%d\n", failures.load(), successes.load());
+ printf("Test failed number of failures=%d successes=%d collectibleCount=%d nonCollectibleCount=%d\n",
+ failures.load(), successes.load(), collectibleCount.load(), nonCollectibleCount.load());
}
fflush(stdout);
// Module is being unloaded...
continue;
}
- if (FAILED(hr))
+ else if (FAILED(hr))
{
printf("GetModuleMetaData returned 0x%x for ModuleID 0x%" PRIxPTR "\n", hr, classModuleId);
++failures;
// Class load not complete. We can not inspect yet.
continue;
}
- if (FAILED(hr))
+ else if (FAILED(hr))
{
printf("GetClassIDInfo2returned 0x%x\n", hr);
++failures;
++failures;
continue;
}
+ else if (hr != CORPROF_E_DATAINCOMPLETE)
+ {
+ String moduleName = GetModuleIDName(classModuleId);
+ if (EndsWith(moduleName, WCHAR("unloadlibrary.dll")))
+ {
+ ++collectibleCount;
+ }
+ else
+ {
+ ++nonCollectibleCount;
+ }
+ }
}
}
}
std::atomic<int> refCount;
std::atomic<ULONG32> failures;
std::atomic<ULONG32> successes;
+ std::atomic<ULONG32> collectibleCount;
+ std::atomic<ULONG32> nonCollectibleCount;
std::atomic<int> jitEventCount;
std::thread gcTriggerThread;
#else // WIN32
-bool EndsWith(const char *lhs, const char *rhs)
-{
- size_t lhsLen = strlen(lhs);
- size_t rhsLen = strlen(rhs);
- if (lhsLen < rhsLen)
- {
- return false;
- }
-
- size_t lhsPos = lhsLen - rhsLen;
- size_t rhsPos = 0;
-
- while (rhsPos < rhsLen)
- {
- if (lhs[lhsPos] != rhs[rhsPos])
- {
- return false;
- }
-
- ++lhsPos;
- ++rhsPos;
- }
-
- return true;
-}
-
#ifdef __APPLE__
string GetCoreCLRPath()
{
return temp;
}
- size_t Size() const
+ size_t Length() const
{
return wcslen(buffer);
}
return os;
}
+
+inline bool EndsWith(const char *lhs, const char *rhs)
+{
+ size_t lhsLen = strlen(lhs);
+ size_t rhsLen = strlen(rhs);
+ if (lhsLen < rhsLen)
+ {
+ return false;
+ }
+
+ size_t lhsPos = lhsLen - rhsLen;
+ size_t rhsPos = 0;
+
+ while (rhsPos < rhsLen)
+ {
+ if (lhs[lhsPos] != rhs[rhsPos])
+ {
+ return false;
+ }
+
+ ++lhsPos;
+ ++rhsPos;
+ }
+
+ return true;
+}
+
+inline bool EndsWith(const String &lhs, const String &rhs)
+{
+ size_t lhsLength = lhs.Length();
+ size_t rhsLength = rhs.Length();
+ if (lhsLength < rhsLength)
+ {
+ return false;
+ }
+
+ size_t lhsPos = lhsLength - rhsLength;
+ size_t rhsPos = 0;
+
+ while (rhsPos < rhsLength)
+ {
+ if (std::tolower(lhs[lhsPos]) != std::tolower(rhs[rhsPos]))
+ {
+ return false;
+ }
+
+ ++lhsPos;
+ ++rhsPos;
+ }
+
+ return true;
+}
typeArgs);
return moduleId;
}
-
-bool ReJITProfiler::EndsWith(const String &lhs, const String &rhs)
-{
- if (lhs.Size() < rhs.Size())
- {
- return false;
- }
-
- size_t lhsPos = lhs.Size() - rhs.Size();
- size_t rhsPos = 0;
-
- while (rhsPos < rhs.Size())
- {
- if (std::tolower(lhs[lhsPos]) != std::tolower(rhs[rhsPos]))
- {
- return false;
- }
-
- ++lhsPos;
- ++rhsPos;
- }
-
- return true;
-}
FunctionID GetFunctionIDFromToken(ModuleID module, mdMethodDef token);
mdMethodDef GetMethodDefForFunction(FunctionID functionId);
ModuleID GetModuleIDForFunction(FunctionID functionId);
- bool EndsWith(const String &lhs, const String &rhs);
ICorProfilerInfo10 *_profInfo10;
std::atomic<int> _failures;