Skip to content

Commit 01bfb3b

Browse files
authored
Merge pull request #1 from cshung/changed
Misc changes for the tests
2 parents 6dc0a38 + b3a07f1 commit 01bfb3b

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

src/coreclr/inc/profilepriv.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ inline BOOL CORProfilerTrackPinnedAllocations()
18721872

18731873
return
18741874
(CORProfilerPresent() &&
1875-
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_MONITOR_PINNEDOBJECT_ALLOCATED));
1875+
(&g_profControlBlock)->globalEventMask.IsEventMaskHighSet(COR_PRF_HIGH_MONITOR_PINNEDOBJECT_ALLOCATED));
18761876
}
18771877

18781878
inline BOOL CORProfilerEnableRejit()

src/tests/profiler/native/gcallocateprofiler/gcallocateprofiler.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ HRESULT GCAllocateProfiler::Initialize(IUnknown* pICorProfilerInfoUnk)
1515
Profiler::Initialize(pICorProfilerInfoUnk);
1616

1717
HRESULT hr = S_OK;
18-
if (FAILED(hr = pCorProfilerInfo->SetEventMask2(COR_PRF_ENABLE_OBJECT_ALLOCATED, COR_PRF_HIGH_MONITOR_LARGEOBJECT_ALLOCATED | COR_PRF_HIGH_MONITOR_PINNEDOBJECT_ALLOCATED)))
18+
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)))
1919
{
2020
printf("FAIL: ICorProfilerInfo::SetEventMask2() failed hr=0x%x", hr);
2121
return hr;
@@ -31,14 +31,20 @@ HRESULT STDMETHODCALLTYPE GCAllocateProfiler::ObjectAllocated(ObjectID objectId,
3131
if (FAILED(hr))
3232
{
3333
printf("GetObjectGeneration failed hr=0x%x\n", hr);
34+
_failures++;
35+
}
36+
else if (gen.generation == COR_PRF_GC_LARGE_OBJECT_HEAP)
37+
{
38+
_gcLOHAllocations++;
3439
}
3540
else if (gen.generation == COR_PRF_GC_PINNED_OBJECT_HEAP)
3641
{
3742
_gcPOHAllocations++;
3843
}
39-
else if (gen.generation == COR_PRF_GC_LARGE_OBJECT_HEAP)
44+
else
4045
{
41-
_gcLOHAllocations++;
46+
printf("Unexpected object allocation captured, gen.generation=0x%x\n", gen.generation);
47+
_failures++;
4248
}
4349

4450
return S_OK;
@@ -47,9 +53,20 @@ HRESULT STDMETHODCALLTYPE GCAllocateProfiler::ObjectAllocated(ObjectID objectId,
4753
HRESULT GCAllocateProfiler::Shutdown()
4854
{
4955
Profiler::Shutdown();
50-
assert(_gcPOHAllocations > 0);
51-
assert(_gcLOHAllocations > 0);
52-
printf("PROFILER TEST PASSES. PinnedObjectAllocations=%d, LargeObjectAllocations=%d.\n", (int)_gcPOHAllocations, (int)_gcLOHAllocations);
56+
if (_gcPOHAllocations == 0)
57+
{
58+
printf("There is no POH allocations\n");
59+
}
60+
else if (_gcLOHAllocations == 0)
61+
{
62+
printf("There is no LOH allocations\n");
63+
}
64+
else if (_failures == 0)
65+
{
66+
printf("%d LOH objects allocated\n", (int)_gcLOHAllocations);
67+
printf("%d POH objects allocated\n", (int)_gcPOHAllocations);
68+
printf("PROFILER TEST PASSES\n");
69+
}
5370
fflush(stdout);
5471

5572
return S_OK;

src/tests/profiler/native/gcallocateprofiler/gcallocateprofiler.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class GCAllocateProfiler : public Profiler
1010
public:
1111
GCAllocateProfiler() : Profiler(),
1212
_gcLOHAllocations(0),
13-
_gcPOHAllocations(0)
13+
_gcPOHAllocations(0),
14+
_failures(0)
1415
{}
1516

1617
virtual GUID GetClsid();
@@ -21,4 +22,5 @@ class GCAllocateProfiler : public Profiler
2122
private:
2223
std::atomic<int> _gcLOHAllocations;
2324
std::atomic<int> _gcPOHAllocations;
25+
std::atomic<int> _failures;
2426
};

src/tests/profiler/native/gcbasicprofiler/gcbasicprofiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ HRESULT GCBasicProfiler::Initialize(IUnknown* pICorProfilerInfoUnk)
1515
Profiler::Initialize(pICorProfilerInfoUnk);
1616

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

3232
if (_gcStarts == 0)
3333
{
34-
printf("GCBasicProfiler::Shutdown: FAIL: Expected GarbaseCollectionStarted to be called\n");
34+
printf("GCBasicProfiler::Shutdown: FAIL: Expected GarbageCollectionStarted to be called\n");
3535
}
3636
else if (_gcFinishes == 0)
3737
{

src/tests/profiler/native/gcprofiler/gcprofiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ HRESULT GCProfiler::Shutdown()
3131

3232
if (_gcStarts == 0)
3333
{
34-
printf("GCProfiler::Shutdown: FAIL: Expected GarbaseCollectionStarted to be called\n");
34+
printf("GCProfiler::Shutdown: FAIL: Expected GarbageCollectionStarted to be called\n");
3535
}
3636
else if (_gcFinishes == 0)
3737
{

0 commit comments

Comments
 (0)