Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/inc/profilepriv.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,7 @@ inline BOOL CORProfilerTrackPinnedAllocations()

return
(CORProfilerPresent() &&
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_MONITOR_PINNEDOBJECT_ALLOCATED));
(&g_profControlBlock)->globalEventMask.IsEventMaskHighSet(COR_PRF_HIGH_MONITOR_PINNEDOBJECT_ALLOCATED));
}

inline BOOL CORProfilerEnableRejit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ HRESULT GCAllocateProfiler::Initialize(IUnknown* pICorProfilerInfoUnk)
Profiler::Initialize(pICorProfilerInfoUnk);

HRESULT hr = S_OK;
if (FAILED(hr = pCorProfilerInfo->SetEventMask2(COR_PRF_ENABLE_OBJECT_ALLOCATED, COR_PRF_HIGH_MONITOR_LARGEOBJECT_ALLOCATED | COR_PRF_HIGH_MONITOR_PINNEDOBJECT_ALLOCATED)))
if (FAILED(hr = pCorProfilerInfo->SetEventMask2(COR_PRF_ENABLE_OBJECT_ALLOCATED, COR_PRF_HIGH_BASIC_GC | COR_PRF_HIGH_MONITOR_LARGEOBJECT_ALLOCATED | COR_PRF_HIGH_MONITOR_PINNEDOBJECT_ALLOCATED)))
{
printf("FAIL: ICorProfilerInfo::SetEventMask2() failed hr=0x%x", hr);
return hr;
Expand All @@ -31,14 +31,20 @@ HRESULT STDMETHODCALLTYPE GCAllocateProfiler::ObjectAllocated(ObjectID objectId,
if (FAILED(hr))
{
printf("GetObjectGeneration failed hr=0x%x\n", hr);
_failures++;
}
else if (gen.generation == COR_PRF_GC_LARGE_OBJECT_HEAP)
{
_gcLOHAllocations++;
}
else if (gen.generation == COR_PRF_GC_PINNED_OBJECT_HEAP)
{
_gcPOHAllocations++;
}
else if (gen.generation == COR_PRF_GC_LARGE_OBJECT_HEAP)
else
{
_gcLOHAllocations++;
printf("Unexpected object allocation captured, gen.generation=0x%x\n", gen.generation);
_failures++;
}

return S_OK;
Expand All @@ -47,9 +53,20 @@ HRESULT STDMETHODCALLTYPE GCAllocateProfiler::ObjectAllocated(ObjectID objectId,
HRESULT GCAllocateProfiler::Shutdown()
{
Profiler::Shutdown();
assert(_gcPOHAllocations > 0);
assert(_gcLOHAllocations > 0);
printf("PROFILER TEST PASSES. PinnedObjectAllocations=%d, LargeObjectAllocations=%d.\n", (int)_gcPOHAllocations, (int)_gcLOHAllocations);
if (_gcPOHAllocations == 0)
{
printf("There is no POH allocations\n");
}
else if (_gcLOHAllocations == 0)
{
printf("There is no LOH allocations\n");
}
else if (_failures == 0)
{
printf("%d LOH objects allocated\n", (int)_gcLOHAllocations);
printf("%d POH objects allocated\n", (int)_gcPOHAllocations);
printf("PROFILER TEST PASSES\n");
}
fflush(stdout);

return S_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class GCAllocateProfiler : public Profiler
public:
GCAllocateProfiler() : Profiler(),
_gcLOHAllocations(0),
_gcPOHAllocations(0)
_gcPOHAllocations(0),
_failures(0)
{}

virtual GUID GetClsid();
Expand All @@ -21,4 +22,5 @@ class GCAllocateProfiler : public Profiler
private:
std::atomic<int> _gcLOHAllocations;
std::atomic<int> _gcPOHAllocations;
std::atomic<int> _failures;
};
4 changes: 2 additions & 2 deletions src/tests/profiler/native/gcbasicprofiler/gcbasicprofiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ HRESULT GCBasicProfiler::Initialize(IUnknown* pICorProfilerInfoUnk)
Profiler::Initialize(pICorProfilerInfoUnk);

HRESULT hr = S_OK;
if (FAILED(hr = pCorProfilerInfo->SetEventMask2(0, 0x10)))
if (FAILED(hr = pCorProfilerInfo->SetEventMask2(0, COR_PRF_HIGH_BASIC_GC)))
{
_failures++;
printf("FAIL: ICorProfilerInfo::SetEventMask2() failed hr=0x%x", hr);
Expand All @@ -31,7 +31,7 @@ HRESULT GCBasicProfiler::Shutdown()

if (_gcStarts == 0)
{
printf("GCBasicProfiler::Shutdown: FAIL: Expected GarbaseCollectionStarted to be called\n");
printf("GCBasicProfiler::Shutdown: FAIL: Expected GarbageCollectionStarted to be called\n");
}
else if (_gcFinishes == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/profiler/native/gcprofiler/gcprofiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ HRESULT GCProfiler::Shutdown()

if (_gcStarts == 0)
{
printf("GCProfiler::Shutdown: FAIL: Expected GarbaseCollectionStarted to be called\n");
printf("GCProfiler::Shutdown: FAIL: Expected GarbageCollectionStarted to be called\n");
}
else if (_gcFinishes == 0)
{
Expand Down