diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index a42a26b5d6092..c39d656d3189b 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -248,7 +248,7 @@ extends: extraStepsTemplate: /eng/pipelines/coreclr/nativeaot-post-build-steps.yml extraStepsParameters: creator: dotnet-bot - testBuildArgs: 'nativeaot tree ";nativeaot;Loader;Interop;tracing/eventpipe/config;tracing/eventpipe/diagnosticport;tracing/eventpipe/reverse;" test tracing/eventcounter/runtimecounters.csproj /p:BuildNativeAotFrameworkObjects=true' + testBuildArgs: 'nativeaot tree ";nativeaot;Loader;Interop;tracing/eventpipe/config;tracing/eventpipe/diagnosticport;tracing/eventpipe/reverse;tracing/eventpipe/simpleruntimeeventvalidation;" test tracing/eventcounter/runtimecounters.csproj /p:BuildNativeAotFrameworkObjects=true' liveLibrariesBuildConfig: Release testRunNamePrefixSuffix: NativeAOT_$(_BuildConfig) extraVariablesTemplates: @@ -290,7 +290,7 @@ extends: extraStepsTemplate: /eng/pipelines/coreclr/nativeaot-post-build-steps.yml extraStepsParameters: creator: dotnet-bot - testBuildArgs: 'nativeaot tree ";nativeaot;tracing/eventpipe/simpleprovidervalidation;"' + testBuildArgs: 'nativeaot tree ";nativeaot;tracing/eventpipe/providervalidation;"' liveLibrariesBuildConfig: Release testRunNamePrefixSuffix: NativeAOT_$(_BuildConfig) extraVariablesTemplates: diff --git a/src/coreclr/nativeaot/Runtime/EventPipeInterface.h b/src/coreclr/nativeaot/Runtime/EventPipeInterface.h index 662259f930270..406b180a23d69 100644 --- a/src/coreclr/nativeaot/Runtime/EventPipeInterface.h +++ b/src/coreclr/nativeaot/Runtime/EventPipeInterface.h @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef __EVENTPIPE_INTERFACE_H__ -#define __EVENTPIPE_INTERFACE_H__ +#ifndef EVENTPIPE_INTERFACE_H +#define EVENTPIPE_INTERFACE_H // Initialize EventPipe void EventPipeAdapter_Initialize(); @@ -18,4 +18,4 @@ void EventPipeAdapter_FinishInitialize(); void EventPipeAdapter_Shutdown(); bool DiagnosticServerAdapter_Shutdown(); -#endif //__EVENTPIPE_INTERFACE_H__ \ No newline at end of file +#endif //EVENTPIPE_INTERFACE_H \ No newline at end of file diff --git a/src/coreclr/nativeaot/Runtime/clretwallmain.h b/src/coreclr/nativeaot/Runtime/clretwallmain.h index 7c608c27464ec..99c60a92c7f01 100644 --- a/src/coreclr/nativeaot/Runtime/clretwallmain.h +++ b/src/coreclr/nativeaot/Runtime/clretwallmain.h @@ -1,10 +1,11 @@ - // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Work In Progress to add native events to EventPipe // shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase // @TODO: Audit native events in NativeAOT Runtime +#ifndef CLR_ETW_ALL_MAIN_H +#define CLR_ETW_ALL_MAIN_H #include "clreventpipewriteevents.h" #include "EtwEvents.h" @@ -45,66 +46,6 @@ inline ULONG FireEtwExceptionThrown_V1( return status; } -inline BOOL EventEnabledGCAllocationTick_V1(void) {return EventPipeEventEnabledGCAllocationTick_V1();} - -inline ULONG FireEtwGCAllocationTick_V1( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -) -{ - ULONG status = EventPipeWriteEventGCAllocationTick_V1(AllocationAmount,AllocationKind,ClrInstanceID,ActivityId,RelatedActivityId); -#ifndef TARGET_UNIX - status &= FireEtXplatGCAllocationTick_V1(AllocationAmount,AllocationKind,ClrInstanceID); -#endif - return status; -} - -inline BOOL EventEnabledGCAllocationTick_V2(void) {return EventPipeEventEnabledGCAllocationTick_V2();} - -inline ULONG FireEtwGCAllocationTick_V2( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const unsigned __int64 AllocationAmount64, - void* TypeID, - const WCHAR* TypeName, - const unsigned int HeapIndex, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -) -{ - ULONG status = EventPipeWriteEventGCAllocationTick_V2(AllocationAmount,AllocationKind,ClrInstanceID,AllocationAmount64,TypeID,TypeName,HeapIndex,ActivityId,RelatedActivityId); -#ifndef TARGET_UNIX - status &= FireEtXplatGCAllocationTick_V2(AllocationAmount,AllocationKind,ClrInstanceID,AllocationAmount64,TypeID,TypeName,HeapIndex); -#endif - return status; -} - -inline BOOL EventEnabledGCAllocationTick_V3(void) {return EventPipeEventEnabledGCAllocationTick_V3();} - -inline ULONG FireEtwGCAllocationTick_V3( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const unsigned __int64 AllocationAmount64, - void* TypeID, - const WCHAR* TypeName, - const unsigned int HeapIndex, - void* Address, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -) -{ - ULONG status = EventPipeWriteEventGCAllocationTick_V3(AllocationAmount,AllocationKind,ClrInstanceID,AllocationAmount64,TypeID,TypeName,HeapIndex,Address,ActivityId,RelatedActivityId); -#ifndef TARGET_UNIX - status &= FireEtXplatGCAllocationTick_V3(AllocationAmount,AllocationKind,ClrInstanceID,AllocationAmount64,TypeID,TypeName,HeapIndex,Address); -#endif - return status; -} - inline BOOL EventEnabledGCBulkEdge(void) {return EventPipeEventEnabledGCBulkEdge();} inline ULONG FireEtwGCBulkEdge( @@ -340,29 +281,6 @@ inline ULONG FireEtwGCGenerationRange( return status; } -inline BOOL EventEnabledGCGlobalHeapHistory_V2(void) {return EventPipeEventEnabledGCGlobalHeapHistory_V2();} - -inline ULONG FireEtwGCGlobalHeapHistory_V2( - const unsigned __int64 FinalYoungestDesired, - const signed int NumHeaps, - const unsigned int CondemnedGeneration, - const unsigned int Gen0ReductionCount, - const unsigned int Reason, - const unsigned int GlobalMechanisms, - const unsigned short ClrInstanceID, - const unsigned int PauseMode, - const unsigned int MemoryPressure, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -) -{ - ULONG status = EventPipeWriteEventGCGlobalHeapHistory_V2(FinalYoungestDesired,NumHeaps,CondemnedGeneration,Gen0ReductionCount,Reason,GlobalMechanisms,ClrInstanceID,PauseMode,MemoryPressure,ActivityId,RelatedActivityId); -#ifndef TARGET_UNIX - status &= FireEtXplatGCGlobalHeapHistory_V2(FinalYoungestDesired,NumHeaps,CondemnedGeneration,Gen0ReductionCount,Reason,GlobalMechanisms,ClrInstanceID,PauseMode,MemoryPressure); -#endif - return status; -} - inline BOOL EventEnabledGCHeapStats_V1(void) {return EventPipeEventEnabledGCHeapStats_V1();} inline ULONG FireEtwGCHeapStats_V1( @@ -601,25 +519,6 @@ inline ULONG FireEtwSetGCHandle( return status; } -inline BOOL EventEnabledGCStart_V1(void) {return EventPipeEventEnabledGCStart_V1();} - -inline ULONG FireEtwGCStart_V1( - const unsigned int Count, - const unsigned int Depth, - const unsigned int Reason, - const unsigned int Type, - const unsigned short ClrInstanceID, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -) -{ - ULONG status = EventPipeWriteEventGCStart_V1(Count,Depth,Reason,Type,ClrInstanceID,ActivityId,RelatedActivityId); -#ifndef TARGET_UNIX - status &= FireEtXplatGCStart_V1(Count,Depth,Reason,Type,ClrInstanceID); -#endif - return status; -} - inline BOOL EventEnabledGCStart_V2(void) {return EventPipeEventEnabledGCStart_V2();} inline ULONG FireEtwGCStart_V2( @@ -702,3 +601,467 @@ inline ULONG FireEtwGCSuspendEEBegin_V1( #endif return status; } + +inline BOOL EventEnabledDecreaseMemoryPressure(void) {return EventPipeEventEnabledDecreaseMemoryPressure();} + +inline ULONG FireEtwDecreaseMemoryPressure( + const unsigned __int64 BytesFreed, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventDecreaseMemoryPressure(BytesFreed,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledFinalizeObject(void) {return EventPipeEventEnabledFinalizeObject();} + +inline ULONG FireEtwFinalizeObject( + const void* TypeID, + const void* ObjectID, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventFinalizeObject(TypeID,ObjectID,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCFinalizersBegin_V1(void) {return EventPipeEventEnabledGCFinalizersBegin_V1();} + +inline ULONG FireEtwGCFinalizersBegin_V1( + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCFinalizersBegin_V1(ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCFinalizersEnd_V1(void) {return EventPipeEventEnabledGCFinalizersEnd_V1();} + +inline ULONG FireEtwGCFinalizersEnd_V1( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCFinalizersEnd_V1(Count,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledContentionStart_V2(void) {return EventPipeEventEnabledContentionStart_V2();} + +inline ULONG FireEtwContentionStart_V2( + const unsigned char ContentionFlags, + const unsigned short ClrInstanceID, + const void* LockID, + const void* AssociatedObjectID, + const unsigned __int64 LockOwnerThreadID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventContentionStart_V2(ContentionFlags,ClrInstanceID,LockID,AssociatedObjectID,LockOwnerThreadID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledContentionStop_V1(void) {return EventPipeEventEnabledContentionStop_V1();} + +inline ULONG FireEtwContentionStop_V1( + const unsigned char ContentionFlags, + const unsigned short ClrInstanceID, + const double DurationNs, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventContentionStop_V1(ContentionFlags,ClrInstanceID,DurationNs,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledContentionLockCreated(void) {return EventPipeEventEnabledContentionLockCreated();} + +inline ULONG FireEtwContentionLockCreated( + const void* LockID, + const void* AssociatedObjectID, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventContentionLockCreated(LockID,AssociatedObjectID,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledThreadPoolWorkerThreadStart(void) {return EventPipeEventEnabledThreadPoolWorkerThreadStart();} + +inline uint32_t FireEtwThreadPoolWorkerThreadStart( + const unsigned int ActiveWorkerThreadCount, + const unsigned int RetiredWorkerThreadCount, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolWorkerThreadStart(ActiveWorkerThreadCount,RetiredWorkerThreadCount,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline uint32_t FireEtwThreadPoolWorkerThreadStop( + const unsigned int ActiveWorkerThreadCount, + const unsigned int RetiredWorkerThreadCount, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolWorkerThreadStop(ActiveWorkerThreadCount,RetiredWorkerThreadCount,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline uint32_t FireEtwThreadPoolWorkerThreadWait( + const unsigned int ActiveWorkerThreadCount, + const unsigned int RetiredWorkerThreadCount, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolWorkerThreadWait(ActiveWorkerThreadCount,RetiredWorkerThreadCount,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledThreadPoolMinMaxThreads(void) {return EventPipeEventEnabledThreadPoolMinMaxThreads();} + +inline uint32_t FireEtwThreadPoolMinMaxThreads( + const unsigned short MinWorkerThreads, + const unsigned short MaxWorkerThreads, + const unsigned short MinIOCompletionThreads, + const unsigned short MaxIOCompletionThreads, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolMinMaxThreads(MinWorkerThreads,MaxWorkerThreads,MinIOCompletionThreads,MaxIOCompletionThreads,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledThreadPoolWorkerThreadAdjustmentSample(void) {return EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentSample();} + +inline uint32_t FireEtwThreadPoolWorkerThreadAdjustmentSample( + const double Throughput, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolWorkerThreadAdjustmentSample(Throughput,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledThreadPoolWorkerThreadAdjustmentAdjustment(void) {return EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentAdjustment();} + +inline uint32_t FireEtwThreadPoolWorkerThreadAdjustmentAdjustment( + const double AverageThroughput, + const unsigned int NewWorkerThreadCount, + const unsigned int Reason, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolWorkerThreadAdjustmentAdjustment(AverageThroughput,NewWorkerThreadCount,Reason,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledThreadPoolWorkerThreadAdjustmentStats(void) {return EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentStats();} + +inline uint32_t FireEtwThreadPoolWorkerThreadAdjustmentStats( + const double Duration, + const double Throughput, + const double ThreadWave, + const double ThroughputWave, + const double ThroughputErrorEstimate, + const double AverageThroughputErrorEstimate, + const double ThroughputRatio, + const double Confidence, + const double NewControlSetting, + const unsigned short NewThreadWaveMagnitude, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolWorkerThreadAdjustmentStats(Duration,Throughput,ThreadWave,ThroughputWave,ThroughputErrorEstimate,AverageThroughputErrorEstimate,ThroughputRatio,Confidence,NewControlSetting,NewThreadWaveMagnitude,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledThreadPoolIOEnqueue(void) {return EventPipeEventEnabledThreadPoolIOEnqueue();} + +inline uint32_t FireEtwThreadPoolIOEnqueue( + const void* NativeOverlapped, + const void* Overlapped, + const BOOL MultiDequeues, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolIOEnqueue(NativeOverlapped,Overlapped,MultiDequeues,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledThreadPoolIODequeue(void) {return EventPipeEventEnabledThreadPoolIODequeue();} + +inline uint32_t FireEtwThreadPoolIODequeue( + const void* NativeOverlapped, + const void* Overlapped, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolIODequeue(NativeOverlapped,Overlapped,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledThreadPoolWorkingThreadCount(void) {return EventPipeEventEnabledThreadPoolWorkingThreadCount();} + +inline uint32_t FireEtwThreadPoolWorkingThreadCount( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolWorkingThreadCount(Count,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledThreadPoolIOPack(void) {return EventPipeEventEnabledThreadPoolIOPack();} + +inline uint32_t FireEtwThreadPoolIOPack( + const void* NativeOverlapped, + const void* Overlapped, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + uint32_t status = EventPipeWriteEventThreadPoolIOPack(NativeOverlapped,Overlapped,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCAllocationTick_V4(void) {return EventPipeEventEnabledGCAllocationTick_V4();} + +inline ULONG FireEtwGCAllocationTick_V4( + const unsigned int AllocationAmount, + const unsigned int AllocationKind, + const unsigned short ClrInstanceID, + const unsigned __int64 AllocationAmount64, + const void* TypeID, + const WCHAR* TypeName, + const unsigned int HeapIndex, + const void* Address, + const unsigned __int64 ObjectSize, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCAllocationTick_V4(AllocationAmount,AllocationKind,ClrInstanceID,AllocationAmount64,TypeID,TypeName,HeapIndex,Address,ObjectSize,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCHeapStats_V2(void) {return EventPipeEventEnabledGCHeapStats_V2();} + +inline ULONG FireEtwGCHeapStats_V2( + const unsigned __int64 GenerationSize0, + const unsigned __int64 TotalPromotedSize0, + const unsigned __int64 GenerationSize1, + const unsigned __int64 TotalPromotedSize1, + const unsigned __int64 GenerationSize2, + const unsigned __int64 TotalPromotedSize2, + const unsigned __int64 GenerationSize3, + const unsigned __int64 TotalPromotedSize3, + const unsigned __int64 FinalizationPromotedSize, + const unsigned __int64 FinalizationPromotedCount, + const unsigned int PinnedObjectCount, + const unsigned int SinkBlockCount, + const unsigned int GCHandleCount, + const unsigned short ClrInstanceID, + const unsigned __int64 GenerationSize4, + const unsigned __int64 TotalPromotedSize4, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCHeapStats_V2(GenerationSize0,TotalPromotedSize0,GenerationSize1,TotalPromotedSize1,GenerationSize2,TotalPromotedSize2,GenerationSize3,TotalPromotedSize3,FinalizationPromotedSize,FinalizationPromotedCount,PinnedObjectCount,SinkBlockCount,GCHandleCount,ClrInstanceID,GenerationSize4,TotalPromotedSize4,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCSampledObjectAllocationHigh(void) {return EventPipeEventEnabledGCSampledObjectAllocationHigh();} + +inline ULONG FireEtwGCSampledObjectAllocationHigh( + const void* Address, + const void* TypeID, + const unsigned int ObjectCountForTypeSample, + const unsigned __int64 TotalSizeForTypeSample, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCSampledObjectAllocationHigh(Address,TypeID,ObjectCountForTypeSample,TotalSizeForTypeSample,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCSampledObjectAllocationLow(void) {return EventPipeEventEnabledGCSampledObjectAllocationLow();} + +inline ULONG FireEtwGCSampledObjectAllocationLow( + const void* Address, + const void* TypeID, + const unsigned int ObjectCountForTypeSample, + const unsigned __int64 TotalSizeForTypeSample, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCSampledObjectAllocationLow(Address,TypeID,ObjectCountForTypeSample,TotalSizeForTypeSample,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledPinObjectAtGCTime(void) {return EventPipeEventEnabledPinObjectAtGCTime();} + +inline ULONG FireEtwPinObjectAtGCTime( + const void* HandleID, + const void* ObjectID, + const unsigned __int64 ObjectSize, + const WCHAR* TypeName, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventPinObjectAtGCTime(HandleID,ObjectID,ObjectSize,TypeName,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCBulkRootStaticVar(void) {return EventPipeEventEnabledGCBulkRootStaticVar();} + +inline ULONG FireEtwGCBulkRootStaticVar( + const unsigned int Count, + const unsigned __int64 AppDomainID, + const unsigned short ClrInstanceID, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCBulkRootStaticVar(Count,AppDomainID,ClrInstanceID,Values_ElementSize, Values,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledIncreaseMemoryPressure(void) {return EventPipeEventEnabledIncreaseMemoryPressure();} + +inline ULONG FireEtwIncreaseMemoryPressure( + const unsigned __int64 BytesAllocated, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventIncreaseMemoryPressure(BytesAllocated,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCGlobalHeapHistory_V4(void) {return EventPipeEventEnabledGCGlobalHeapHistory_V4();} + +inline ULONG FireEtwGCGlobalHeapHistory_V4( + const unsigned __int64 FinalYoungestDesired, + const signed int NumHeaps, + const unsigned int CondemnedGeneration, + const unsigned int Gen0ReductionCount, + const unsigned int Reason, + const unsigned int GlobalMechanisms, + const unsigned short ClrInstanceID, + const unsigned int PauseMode, + const unsigned int MemoryPressure, + const unsigned int CondemnReasons0, + const unsigned int CondemnReasons1, + const unsigned int Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCGlobalHeapHistory_V4(FinalYoungestDesired,NumHeaps,CondemnedGeneration,Gen0ReductionCount,Reason,GlobalMechanisms,ClrInstanceID,PauseMode,MemoryPressure,CondemnReasons0,CondemnReasons1,Count,Values_ElementSize, Values,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGenAwareBegin(void) {return EventPipeEventEnabledGenAwareBegin();} + +inline ULONG FireEtwGenAwareBegin( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGenAwareBegin(Count,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGenAwareEnd(void) {return EventPipeEventEnabledGenAwareEnd();} + +inline ULONG FireEtwGenAwareEnd( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGenAwareEnd(Count,ClrInstanceID,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCLOHCompact(void) {return EventPipeEventEnabledGCLOHCompact();} + +inline ULONG FireEtwGCLOHCompact( + const unsigned short ClrInstanceID, + const unsigned short Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCLOHCompact(ClrInstanceID,Count,Values_ElementSize, Values,ActivityId,RelatedActivityId); + return status; +} + +inline BOOL EventEnabledGCFitBucketInfo(void) {return EventPipeEventEnabledGCFitBucketInfo();} + +inline ULONG FireEtwGCFitBucketInfo( + const unsigned short ClrInstanceID, + const unsigned short BucketKind, + const unsigned __int64 TotalSize, + const unsigned short Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +) +{ + ULONG status = EventPipeWriteEventGCFitBucketInfo(ClrInstanceID,BucketKind,TotalSize,Count,Values_ElementSize, Values,ActivityId,RelatedActivityId); + return status; +} +#endif // __CLR_ETW_ALL_MAIN_H__ \ No newline at end of file diff --git a/src/coreclr/nativeaot/Runtime/clreventpipewriteevents.h b/src/coreclr/nativeaot/Runtime/clreventpipewriteevents.h index f6a16806c6b7e..92da9196ec901 100644 --- a/src/coreclr/nativeaot/Runtime/clreventpipewriteevents.h +++ b/src/coreclr/nativeaot/Runtime/clreventpipewriteevents.h @@ -24,39 +24,6 @@ ULONG EventPipeWriteEventExceptionThrown_V1( const GUID * ActivityId = nullptr, const GUID * RelatedActivityId = nullptr ); -BOOL EventPipeEventEnabledGCAllocationTick_V1(void); -ULONG EventPipeWriteEventGCAllocationTick_V1( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -); -BOOL EventPipeEventEnabledGCAllocationTick_V2(void); -ULONG EventPipeWriteEventGCAllocationTick_V2( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const unsigned __int64 AllocationAmount64, - const void* TypeID, - const WCHAR* TypeName, - const unsigned int HeapIndex, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -); -BOOL EventPipeEventEnabledGCAllocationTick_V3(void); -ULONG EventPipeWriteEventGCAllocationTick_V3( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const unsigned __int64 AllocationAmount64, - const void* TypeID, - const WCHAR* TypeName, - const unsigned int HeapIndex, - const void* Address, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -); BOOL EventPipeEventEnabledGCBulkEdge(void); ULONG EventPipeWriteEventGCBulkEdge( const unsigned int Index, @@ -175,20 +142,6 @@ ULONG EventPipeWriteEventGCGenerationRange( const GUID * ActivityId = nullptr, const GUID * RelatedActivityId = nullptr ); -BOOL EventPipeEventEnabledGCGlobalHeapHistory_V2(void); -ULONG EventPipeWriteEventGCGlobalHeapHistory_V2( - const unsigned __int64 FinalYoungestDesired, - const signed int NumHeaps, - const unsigned int CondemnedGeneration, - const unsigned int Gen0ReductionCount, - const unsigned int Reason, - const unsigned int GlobalMechanisms, - const unsigned short ClrInstanceID, - const unsigned int PauseMode, - const unsigned int MemoryPressure, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -); BOOL EventPipeEventEnabledGCHeapStats_V1(void); ULONG EventPipeWriteEventGCHeapStats_V1( const unsigned __int64 GenerationSize0, @@ -319,16 +272,6 @@ ULONG EventPipeWriteEventSetGCHandle( const GUID * ActivityId = nullptr, const GUID * RelatedActivityId = nullptr ); -BOOL EventPipeEventEnabledGCStart_V1(void); -ULONG EventPipeWriteEventGCStart_V1( - const unsigned int Count, - const unsigned int Depth, - const unsigned int Reason, - const unsigned int Type, - const unsigned short ClrInstanceID, - const GUID * ActivityId = nullptr, - const GUID * RelatedActivityId = nullptr -); BOOL EventPipeEventEnabledGCStart_V2(void); ULONG EventPipeWriteEventGCStart_V2( const unsigned int Count, @@ -366,3 +309,291 @@ ULONG EventPipeWriteEventGCSuspendEEBegin_V1( const GUID * ActivityId = nullptr, const GUID * RelatedActivityId = nullptr ); +BOOL EventPipeEventEnabledDecreaseMemoryPressure(void); +ULONG EventPipeWriteEventDecreaseMemoryPressure( + const unsigned __int64 BytesFreed, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledFinalizeObject(void); +ULONG EventPipeWriteEventFinalizeObject( + const void* TypeID, + const void* ObjectID, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCFinalizersBegin_V1(void); +ULONG EventPipeWriteEventGCFinalizersBegin_V1( + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCFinalizersEnd_V1(void); +ULONG EventPipeWriteEventGCFinalizersEnd_V1( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledContentionStart_V2(void); +ULONG EventPipeWriteEventContentionStart_V2( + const unsigned char ContentionFlags, + const unsigned short ClrInstanceID, + const void* LockID, + const void* AssociatedObjectID, + const unsigned __int64 LockOwnerThreadID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledContentionStop_V1(void); +ULONG EventPipeWriteEventContentionStop_V1( + const unsigned char ContentionFlags, + const unsigned short ClrInstanceID, + const double DurationNs, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledContentionLockCreated(void); +ULONG EventPipeWriteEventContentionLockCreated( + const void* LockID, + const void* AssociatedObjectID, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolWorkerThreadStart(void); +ULONG EventPipeWriteEventThreadPoolWorkerThreadStart( + const unsigned int ActiveWorkerThreadCount, + const unsigned int RetiredWorkerThreadCount, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolWorkerThreadStop(void); +ULONG EventPipeWriteEventThreadPoolWorkerThreadStop( + const unsigned int ActiveWorkerThreadCount, + const unsigned int RetiredWorkerThreadCount, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolWorkerThreadWait(void); +ULONG EventPipeWriteEventThreadPoolWorkerThreadWait( + const unsigned int ActiveWorkerThreadCount, + const unsigned int RetiredWorkerThreadCount, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolMinMaxThreads(void); +ULONG EventPipeWriteEventThreadPoolMinMaxThreads( + const unsigned short MinWorkerThreads, + const unsigned short MaxWorkerThreads, + const unsigned short MinIOCompletionThreads, + const unsigned short MaxIOCompletionThreads, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentSample(void); +ULONG EventPipeWriteEventThreadPoolWorkerThreadAdjustmentSample( + const double Throughput, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentAdjustment(void); +ULONG EventPipeWriteEventThreadPoolWorkerThreadAdjustmentAdjustment( + const double AverageThroughput, + const unsigned int NewWorkerThreadCount, + const unsigned int Reason, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentStats(void); +ULONG EventPipeWriteEventThreadPoolWorkerThreadAdjustmentStats( + const double Duration, + const double Throughput, + const double ThreadWave, + const double ThroughputWave, + const double ThroughputErrorEstimate, + const double AverageThroughputErrorEstimate, + const double ThroughputRatio, + const double Confidence, + const double NewControlSetting, + const unsigned short NewThreadWaveMagnitude, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolIOEnqueue(void); +ULONG EventPipeWriteEventThreadPoolIOEnqueue( + const void* NativeOverlapped, + const void* Overlapped, + const BOOL MultiDequeues, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolIODequeue(void); +ULONG EventPipeWriteEventThreadPoolIODequeue( + const void* NativeOverlapped, + const void* Overlapped, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolWorkingThreadCount(void); +ULONG EventPipeWriteEventThreadPoolWorkingThreadCount( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledThreadPoolIOPack(void); +ULONG EventPipeWriteEventThreadPoolIOPack( + const void* NativeOverlapped, + const void* Overlapped, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCAllocationTick_V4(void); +ULONG EventPipeWriteEventGCAllocationTick_V4( + const unsigned int AllocationAmount, + const unsigned int AllocationKind, + const unsigned short ClrInstanceID, + const unsigned __int64 AllocationAmount64, + const void* TypeID, + const WCHAR* TypeName, + const unsigned int HeapIndex, + const void* Address, + const unsigned __int64 ObjectSize, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCHeapStats_V2(void); +ULONG EventPipeWriteEventGCHeapStats_V2( + const unsigned __int64 GenerationSize0, + const unsigned __int64 TotalPromotedSize0, + const unsigned __int64 GenerationSize1, + const unsigned __int64 TotalPromotedSize1, + const unsigned __int64 GenerationSize2, + const unsigned __int64 TotalPromotedSize2, + const unsigned __int64 GenerationSize3, + const unsigned __int64 TotalPromotedSize3, + const unsigned __int64 FinalizationPromotedSize, + const unsigned __int64 FinalizationPromotedCount, + const unsigned int PinnedObjectCount, + const unsigned int SinkBlockCount, + const unsigned int GCHandleCount, + const unsigned short ClrInstanceID, + const unsigned __int64 GenerationSize4, + const unsigned __int64 TotalPromotedSize4, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCSampledObjectAllocationHigh(void); +ULONG EventPipeWriteEventGCSampledObjectAllocationHigh( + const void* Address, + const void* TypeID, + const unsigned int ObjectCountForTypeSample, + const unsigned __int64 TotalSizeForTypeSample, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCSampledObjectAllocationLow(void); +ULONG EventPipeWriteEventGCSampledObjectAllocationLow( + const void* Address, + const void* TypeID, + const unsigned int ObjectCountForTypeSample, + const unsigned __int64 TotalSizeForTypeSample, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledPinObjectAtGCTime(void); +ULONG EventPipeWriteEventPinObjectAtGCTime( + const void* HandleID, + const void* ObjectID, + const unsigned __int64 ObjectSize, + const WCHAR* TypeName, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCBulkRootStaticVar(void); +ULONG EventPipeWriteEventGCBulkRootStaticVar( + const unsigned int Count, + const unsigned __int64 AppDomainID, + const unsigned short ClrInstanceID, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledIncreaseMemoryPressure(void); +ULONG EventPipeWriteEventIncreaseMemoryPressure( + const unsigned __int64 BytesAllocated, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCGlobalHeapHistory_V4(void); +ULONG EventPipeWriteEventGCGlobalHeapHistory_V4( + const unsigned __int64 FinalYoungestDesired, + const signed int NumHeaps, + const unsigned int CondemnedGeneration, + const unsigned int Gen0ReductionCount, + const unsigned int Reason, + const unsigned int GlobalMechanisms, + const unsigned short ClrInstanceID, + const unsigned int PauseMode, + const unsigned int MemoryPressure, + const unsigned int CondemnReasons0, + const unsigned int CondemnReasons1, + const unsigned int Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGenAwareBegin(void); +ULONG EventPipeWriteEventGenAwareBegin( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGenAwareEnd(void); +ULONG EventPipeWriteEventGenAwareEnd( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCLOHCompact(void); +ULONG EventPipeWriteEventGCLOHCompact( + const unsigned short ClrInstanceID, + const unsigned short Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); +BOOL EventPipeEventEnabledGCFitBucketInfo(void); +ULONG EventPipeWriteEventGCFitBucketInfo( + const unsigned short ClrInstanceID, + const unsigned short BucketKind, + const unsigned __int64 TotalSize, + const unsigned short Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId = nullptr, + const GUID * RelatedActivityId = nullptr +); + diff --git a/src/coreclr/nativeaot/Runtime/diagnosticserveradapter.h b/src/coreclr/nativeaot/Runtime/diagnosticserveradapter.h index 62cd5816d08fd..7a133ce9f9c15 100644 --- a/src/coreclr/nativeaot/Runtime/diagnosticserveradapter.h +++ b/src/coreclr/nativeaot/Runtime/diagnosticserveradapter.h @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef __DIAGNOSTIC_SERVER_ADAPTER_H__ -#define __DIAGNOSTIC_SERVER_ADAPTER_H__ +#ifndef DIAGNOSTIC_SERVER_ADAPTER_H +#define DIAGNOSTIC_SERVER_ADAPTER_H #if defined(FEATURE_PERFTRACING) @@ -39,4 +39,4 @@ class DiagnosticServerAdapter final #endif // FEATURE_PERFTRACING -#endif // __DIAGNOSTIC_SERVER_ADAPTER_H__ +#endif // DIAGNOSTIC_SERVER_ADAPTER_H diff --git a/src/coreclr/nativeaot/Runtime/disabledeventpipeinternal.cpp b/src/coreclr/nativeaot/Runtime/disabledeventpipeinternal.cpp index b1464bdb22570..f2de93efbf035 100644 --- a/src/coreclr/nativeaot/Runtime/disabledeventpipeinternal.cpp +++ b/src/coreclr/nativeaot/Runtime/disabledeventpipeinternal.cpp @@ -23,13 +23,11 @@ EXTERN_C NATIVEAOT_API uint64_t __cdecl RhEventPipeInternal_Enable( /* COR_PRF_EVENTPIPE_PROVIDER_CONFIG */ const void * pProviders, uint32_t numProviders) { - PalDebugBreak(); return 0; } EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_Disable(uint64_t sessionID) { - PalDebugBreak(); } EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_CreateProvider( @@ -54,7 +52,6 @@ EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_DefineEvent( EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_GetProvider(LPCWSTR providerName) { - PalDebugBreak(); return 0; } @@ -64,7 +61,6 @@ EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_DeleteProvider(intptr_t EXTERN_C NATIVEAOT_API int __cdecl RhEventPipeInternal_EventActivityIdControl(uint32_t controlCode, GUID *pActivityId) { - PalDebugBreak(); return 0; } @@ -79,25 +75,21 @@ EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_WriteEventData( EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_GetSessionInfo(uint64_t sessionID, EventPipeSessionInfo *pSessionInfo) { - PalDebugBreak(); return FALSE; } EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_GetNextEvent(uint64_t sessionID, EventPipeEventInstanceData *pInstance) { - PalDebugBreak(); return FALSE; } EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_SignalSession(uint64_t sessionID) { - PalDebugBreak(); return FALSE; } EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_WaitForSessionSignal(uint64_t sessionID, int32_t timeoutMs) { - PalDebugBreak(); return FALSE; } diff --git a/src/coreclr/nativeaot/Runtime/disabledruntimeeventinternal.cpp b/src/coreclr/nativeaot/Runtime/disabledruntimeeventinternal.cpp new file mode 100644 index 0000000000000..57ef8d3604b68 --- /dev/null +++ b/src/coreclr/nativeaot/Runtime/disabledruntimeeventinternal.cpp @@ -0,0 +1,85 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include "eventpipeadapter.h" + +#ifdef FEATURE_PERFTRACING + +// We will do a no-op for events in the disabled EventPipe This is similar to the way eventpipe checks if the provider and an event is enabled before firting the event, and no-op otherwise. + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogContentionLockCreated(intptr_t LockID, intptr_t AssociatedObjectID, uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogContentionStart(uint8_t ContentionFlags, uint16_t ClrInstanceID, intptr_t LockID, intptr_t AssociatedObjectID, uint64_t LockOwnerThreadID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogContentionStop(uint8_t ContentionFlags, uint16_t ClrInstanceID, double DurationNs) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadStart(uint32_t activeWorkerThreadCount, uint32_t retiredWorkerThreadCount, uint16_t clrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop(uint32_t ActiveWorkerThreadCount, uint32_t RetiredWorkerThreadCount, uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait(uint32_t ActiveWorkerThreadCount, uint32_t RetiredWorkerThreadCount, uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolMinMaxThreads(uint16_t MinWorkerThreads, uint16_t MaxWorkerThreads, uint16_t MinIOCompletionThreads, uint16_t MaxIOCompletionThreads, uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample(double Throughput, uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment(double AverageThroughput, uint32_t NewWorkerThreadCount, uint32_t Reason, uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats( + double Duration, + double Throughput, + double ThreadPoolWorkerThreadWait, + double ThroughputWave, + double ThroughputErrorEstimate, + double AverageThroughputErrorEstimate, + double ThroughputRatio, + double Confidence, + double NewControlSetting, + uint16_t NewThreadWaveMagnitude, + uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolIOEnqueue( + void * NativeOverlapped, + void * Overlapped, + bool MultiDequeues, + uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolIODequeue(void * NativeOverlapped, void * Overlapped, uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount(uint32_t Count, uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolIOPack(void * NativeOverlapped, void * Overlapped, uint16_t ClrInstanceID) +{ +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogExceptionThrown(LPCWSTR exceptionTypeName, LPCWSTR exceptionMessage, void* faultingIP, HRESULT hresult) +{ +} + +#endif // FEATURE_PERFTRACING diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index d0b918e3aabc3..b8a8808f9b0f1 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -95,6 +95,7 @@ list(APPEND AOT_EVENTPIPE_MANAGED_TO_NATIVE_SOURCES ${RUNTIME_DIR}/eventpipeadapter.h ${RUNTIME_DIR}/diagnosticserveradapter.h ${RUNTIME_DIR}/EnabledEventPipeInterface.cpp + ${RUNTIME_DIR}/runtimeeventinternal.cpp ) list(APPEND EVENTPIPE_SOURCES @@ -110,6 +111,7 @@ list(APPEND EVENTPIPE_SOURCES list(APPEND AOT_EVENTPIPE_DISABLED_SOURCES ${RUNTIME_DIR}/DisabledEventPipeInterface.cpp ${RUNTIME_DIR}/disabledeventpipeinternal.cpp + ${RUNTIME_DIR}/disabledruntimeeventinternal.cpp ${AOT_EVENTPIPE_SHIM_DIR}/disableddotnetruntime.cpp ) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/disableddotnetruntime.cpp b/src/coreclr/nativeaot/Runtime/eventpipe/disableddotnetruntime.cpp index f39a14e782452..f2ba91f3c4d2d 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/disableddotnetruntime.cpp +++ b/src/coreclr/nativeaot/Runtime/eventpipe/disableddotnetruntime.cpp @@ -39,49 +39,6 @@ ULONG EventPipeWriteEventExceptionThrown_V1( return 0; } -ULONG EventPipeWriteEventGCAllocationTick_V1( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const GUID * ActivityId, - const GUID * RelatedActivityId -) -{ - return 0; -} - - -ULONG EventPipeWriteEventGCAllocationTick_V2( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const unsigned __int64 AllocationAmount64, - const void* TypeID, - const WCHAR* TypeName, - const unsigned int HeapIndex, - const GUID * ActivityId, - const GUID * RelatedActivityId -) -{ - return 0; -} - -ULONG EventPipeWriteEventGCAllocationTick_V3( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const unsigned __int64 AllocationAmount64, - const void* TypeID, - const WCHAR* TypeName, - const unsigned int HeapIndex, - const void* Address, - const GUID * ActivityId, - const GUID * RelatedActivityId -) -{ - return 0; -} - ULONG EventPipeWriteEventGCBulkEdge( const unsigned int Index, const unsigned int Count, @@ -239,23 +196,6 @@ ULONG EventPipeWriteEventGCGenerationRange( return 0; } -ULONG EventPipeWriteEventGCGlobalHeapHistory_V2( - const unsigned __int64 FinalYoungestDesired, - const signed int NumHeaps, - const unsigned int CondemnedGeneration, - const unsigned int Gen0ReductionCount, - const unsigned int Reason, - const unsigned int GlobalMechanisms, - const unsigned short ClrInstanceID, - const unsigned int PauseMode, - const unsigned int MemoryPressure, - const GUID * ActivityId, - const GUID * RelatedActivityId -) -{ - return 0; -} - ULONG EventPipeWriteEventGCHeapStats_V1( const unsigned __int64 GenerationSize0, const unsigned __int64 TotalPromotedSize0, @@ -422,19 +362,6 @@ ULONG EventPipeWriteEventSetGCHandle( return 0; } -ULONG EventPipeWriteEventGCStart_V1( - const unsigned int Count, - const unsigned int Depth, - const unsigned int Reason, - const unsigned int Type, - const unsigned short ClrInstanceID, - const GUID * ActivityId, - const GUID * RelatedActivityId -) -{ - return 0; -} - ULONG EventPipeWriteEventGCStart_V2( const unsigned int Count, const unsigned int Depth, @@ -481,3 +408,227 @@ ULONG EventPipeWriteEventGCRestartEEEnd_V1( { return 0; } + +ULONG EventPipeWriteEventDecreaseMemoryPressure( + const unsigned __int64 BytesFreed, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + +ULONG EventPipeWriteEventFinalizeObject( + const void* TypeID, + const void* ObjectID, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + +ULONG EventPipeWriteEventGCFinalizersBegin_V1( + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGCFinalizersEnd_V1( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGCAllocationTick_V4( + const unsigned int AllocationAmount, + const unsigned int AllocationKind, + const unsigned short ClrInstanceID, + const unsigned __int64 AllocationAmount64, + const void* TypeID, + const WCHAR* TypeName, + const unsigned int HeapIndex, + const void* Address, + const unsigned __int64 ObjectSize, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGCHeapStats_V2( + const unsigned __int64 GenerationSize0, + const unsigned __int64 TotalPromotedSize0, + const unsigned __int64 GenerationSize1, + const unsigned __int64 TotalPromotedSize1, + const unsigned __int64 GenerationSize2, + const unsigned __int64 TotalPromotedSize2, + const unsigned __int64 GenerationSize3, + const unsigned __int64 TotalPromotedSize3, + const unsigned __int64 FinalizationPromotedSize, + const unsigned __int64 FinalizationPromotedCount, + const unsigned int PinnedObjectCount, + const unsigned int SinkBlockCount, + const unsigned int GCHandleCount, + const unsigned short ClrInstanceID, + const unsigned __int64 GenerationSize4, + const unsigned __int64 TotalPromotedSize4, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGCSampledObjectAllocationHigh( + const void* Address, + const void* TypeID, + const unsigned int ObjectCountForTypeSample, + const unsigned __int64 TotalSizeForTypeSample, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGCSampledObjectAllocationLow( + const void* Address, + const void* TypeID, + const unsigned int ObjectCountForTypeSample, + const unsigned __int64 TotalSizeForTypeSample, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventPinObjectAtGCTime( + const void* HandleID, + const void* ObjectID, + const unsigned __int64 ObjectSize, + const WCHAR* TypeName, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGCBulkRootStaticVar( + const unsigned int Count, + const unsigned __int64 AppDomainID, + const unsigned short ClrInstanceID, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventIncreaseMemoryPressure( + const unsigned __int64 BytesAllocated, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGCGlobalHeapHistory_V4( + const unsigned __int64 FinalYoungestDesired, + const signed int NumHeaps, + const unsigned int CondemnedGeneration, + const unsigned int Gen0ReductionCount, + const unsigned int Reason, + const unsigned int GlobalMechanisms, + const unsigned short ClrInstanceID, + const unsigned int PauseMode, + const unsigned int MemoryPressure, + const unsigned int CondemnReasons0, + const unsigned int CondemnReasons1, + const unsigned int Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGenAwareBegin( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGenAwareEnd( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGCLOHCompact( + const unsigned short ClrInstanceID, + const unsigned short Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} + + +ULONG EventPipeWriteEventGCFitBucketInfo( + const unsigned short ClrInstanceID, + const unsigned short BucketKind, + const unsigned __int64 TotalSize, + const unsigned short Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId, + const GUID * RelatedActivityId +) +{ + return 0; +} diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/dotnetruntime.cpp b/src/coreclr/nativeaot/Runtime/eventpipe/dotnetruntime.cpp index de33f2303d7b7..53c4574f9f2b6 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/dotnetruntime.cpp +++ b/src/coreclr/nativeaot/Runtime/eventpipe/dotnetruntime.cpp @@ -64,6 +64,23 @@ bool WriteToBuffer(const BYTE *src, size_t len, BYTE *&buffer, size_t& offset, s return true; } +bool WriteToBuffer(const WCHAR* str, BYTE *&buffer, size_t& offset, size_t& size, bool &fixedBuffer) +{ + if (str == NULL) + return true; + + size_t byteCount = (ep_rt_utf16_string_len(reinterpret_cast(str)) + 1) * sizeof(*str); + if (offset + byteCount > size) + { + if (!ResizeBuffer(buffer, size, offset, size + byteCount, fixedBuffer)) + return false; + } + + memcpy(buffer + offset, str, byteCount); + offset += byteCount; + return true; +} + bool ResizeBuffer(BYTE *&buffer, size_t& size, size_t currLen, size_t newSize, bool &fixedBuffer) { newSize = (size_t)(newSize * 1.5); @@ -95,9 +112,6 @@ const WCHAR* DotNETRuntimeName = W("Microsoft-Windows-DotNETRuntime"); EventPipeProvider *EventPipeProviderDotNETRuntime = nullptr; EventPipeEvent *EventPipeEventDestroyGCHandle = nullptr; EventPipeEvent *EventPipeEventExceptionThrown_V1 = nullptr; -EventPipeEvent *EventPipeEventGCAllocationTick_V1 = nullptr; -EventPipeEvent *EventPipeEventGCAllocationTick_V2 = nullptr; -EventPipeEvent *EventPipeEventGCAllocationTick_V3 = nullptr; EventPipeEvent *EventPipeEventGCBulkEdge = nullptr; EventPipeEvent *EventPipeEventGCBulkMovedObjectRanges = nullptr; EventPipeEvent *EventPipeEventGCBulkNode = nullptr; @@ -111,7 +125,6 @@ EventPipeEvent *EventPipeEventGCCreateSegment_V1 = nullptr; EventPipeEvent *EventPipeEventGCEnd_V1 = nullptr; EventPipeEvent *EventPipeEventGCFreeSegment_V1 = nullptr; EventPipeEvent *EventPipeEventGCGenerationRange = nullptr; -EventPipeEvent *EventPipeEventGCGlobalHeapHistory_V2 = nullptr; EventPipeEvent *EventPipeEventGCHeapStats_V1 = nullptr; EventPipeEvent *EventPipeEventGCJoin_V2 = nullptr; EventPipeEvent *EventPipeEventGCMarkFinalizeQueueRoots = nullptr; @@ -124,16 +137,45 @@ EventPipeEvent *EventPipeEventGCTerminateConcurrentThread_V1 = nullptr; EventPipeEvent *EventPipeEventGCTriggered = nullptr; EventPipeEvent *EventPipeEventModuleLoad_V2 = nullptr; EventPipeEvent *EventPipeEventSetGCHandle = nullptr; -EventPipeEvent *EventPipeEventGCStart_V1 = nullptr; EventPipeEvent *EventPipeEventGCStart_V2 = nullptr; EventPipeEvent *EventPipeEventGCRestartEEEnd_V1 = nullptr; EventPipeEvent *EventPipeEventGCRestartEEBegin_V1 = nullptr; EventPipeEvent *EventPipeEventGCSuspendEEEnd_V1 = nullptr; EventPipeEvent *EventPipeEventGCSuspendEEBegin_V1 = nullptr; +EventPipeEvent *EventPipeEventDecreaseMemoryPressure = nullptr; +EventPipeEvent *EventPipeEventFinalizeObject = nullptr; +EventPipeEvent *EventPipeEventGCFinalizersBegin_V1 = nullptr; +EventPipeEvent *EventPipeEventGCFinalizersEnd_V1 = nullptr; +EventPipeEvent *EventPipeEventContentionStart_V2 = nullptr; +EventPipeEvent *EventPipeEventContentionStop_V1 = nullptr; +EventPipeEvent *EventPipeEventContentionLockCreated = nullptr; +EventPipeEvent *EventPipeEventThreadPoolWorkerThreadStart = nullptr; +EventPipeEvent *EventPipeEventThreadPoolWorkerThreadStop = nullptr; +EventPipeEvent *EventPipeEventThreadPoolWorkerThreadWait = nullptr; +EventPipeEvent *EventPipeEventThreadPoolMinMaxThreads = nullptr; +EventPipeEvent *EventPipeEventThreadPoolWorkerThreadAdjustmentSample = nullptr; +EventPipeEvent *EventPipeEventThreadPoolWorkerThreadAdjustmentAdjustment = nullptr; +EventPipeEvent *EventPipeEventThreadPoolWorkerThreadAdjustmentStats = nullptr; +EventPipeEvent *EventPipeEventThreadPoolIOEnqueue = nullptr; +EventPipeEvent *EventPipeEventThreadPoolIODequeue = nullptr; +EventPipeEvent *EventPipeEventThreadPoolWorkingThreadCount = nullptr; +EventPipeEvent *EventPipeEventThreadPoolIOPack = nullptr; +EventPipeEvent *EventPipeEventGCAllocationTick_V4 = nullptr; +EventPipeEvent *EventPipeEventGCHeapStats_V2 = nullptr; +EventPipeEvent *EventPipeEventGCSampledObjectAllocationHigh = nullptr; +EventPipeEvent *EventPipeEventGCSampledObjectAllocationLow = nullptr; +EventPipeEvent *EventPipeEventPinObjectAtGCTime = nullptr; +EventPipeEvent *EventPipeEventGCBulkRootStaticVar = nullptr; +EventPipeEvent *EventPipeEventIncreaseMemoryPressure = nullptr; +EventPipeEvent *EventPipeEventGCGlobalHeapHistory_V4 = nullptr; +EventPipeEvent *EventPipeEventGenAwareBegin = nullptr; +EventPipeEvent *EventPipeEventGenAwareEnd = nullptr; +EventPipeEvent *EventPipeEventGCLOHCompact = nullptr; +EventPipeEvent *EventPipeEventGCFitBucketInfo = nullptr; BOOL EventPipeEventEnabledDestroyGCHandle(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventDestroyGCHandle); + return ep_event_is_enabled(EventPipeEventDestroyGCHandle); } ULONG EventPipeWriteEventDestroyGCHandle( @@ -173,7 +215,7 @@ ULONG EventPipeWriteEventDestroyGCHandle( BOOL EventPipeEventEnabledExceptionThrown_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventExceptionThrown_V1); + return ep_event_is_enabled(EventPipeEventExceptionThrown_V1); } ULONG EventPipeWriteEventExceptionThrown_V1( @@ -221,155 +263,9 @@ ULONG EventPipeWriteEventExceptionThrown_V1( return ERROR_SUCCESS; } -BOOL EventPipeEventEnabledGCAllocationTick_V1(void) -{ - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCAllocationTick_V1); -} - -ULONG EventPipeWriteEventGCAllocationTick_V1( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const GUID * ActivityId, - const GUID * RelatedActivityId) -{ - if (!EventPipeEventEnabledGCAllocationTick_V1()) - return ERROR_SUCCESS; - - size_t size = 32; - BYTE stackBuffer[32]; - BYTE *buffer = stackBuffer; - size_t offset = 0; - bool fixedBuffer = true; - bool success = true; - - success &= WriteToBuffer(AllocationAmount, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(AllocationKind, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); - - if (!success) - { - if (!fixedBuffer) - delete[] buffer; - return ERROR_WRITE_FAULT; - } - - EventPipeAdapter::WriteEvent(EventPipeEventGCAllocationTick_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); - - if (!fixedBuffer) - delete[] buffer; - - - return ERROR_SUCCESS; -} - -BOOL EventPipeEventEnabledGCAllocationTick_V2(void) -{ - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCAllocationTick_V2); -} - -ULONG EventPipeWriteEventGCAllocationTick_V2( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const unsigned __int64 AllocationAmount64, - const void* TypeID, - const WCHAR* TypeName, - const unsigned int HeapIndex, - const GUID * ActivityId, - const GUID * RelatedActivityId) -{ - if (!EventPipeEventEnabledGCAllocationTick_V2()) - return ERROR_SUCCESS; - - size_t size = 94; - BYTE stackBuffer[94]; - BYTE *buffer = stackBuffer; - size_t offset = 0; - bool fixedBuffer = true; - bool success = true; - - if (!TypeName) { TypeName = W("NULL"); } - success &= WriteToBuffer(AllocationAmount, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(AllocationKind, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(AllocationAmount64, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(TypeID, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(TypeName, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(HeapIndex, buffer, offset, size, fixedBuffer); - - if (!success) - { - if (!fixedBuffer) - delete[] buffer; - return ERROR_WRITE_FAULT; - } - - EventPipeAdapter::WriteEvent(EventPipeEventGCAllocationTick_V2, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); - - if (!fixedBuffer) - delete[] buffer; - - - return ERROR_SUCCESS; -} - -BOOL EventPipeEventEnabledGCAllocationTick_V3(void) -{ - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCAllocationTick_V3); -} - -ULONG EventPipeWriteEventGCAllocationTick_V3( - const unsigned int AllocationAmount, - const unsigned int AllocationKind, - const unsigned short ClrInstanceID, - const unsigned __int64 AllocationAmount64, - const void* TypeID, - const WCHAR* TypeName, - const unsigned int HeapIndex, - const void* Address, - const GUID * ActivityId, - const GUID * RelatedActivityId) -{ - if (!EventPipeEventEnabledGCAllocationTick_V3()) - return ERROR_SUCCESS; - - size_t size = 102; - BYTE stackBuffer[102]; - BYTE *buffer = stackBuffer; - size_t offset = 0; - bool fixedBuffer = true; - bool success = true; - - if (!TypeName) { TypeName = W("NULL"); } - success &= WriteToBuffer(AllocationAmount, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(AllocationKind, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(AllocationAmount64, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(TypeID, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(TypeName, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(HeapIndex, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(Address, buffer, offset, size, fixedBuffer); - - if (!success) - { - if (!fixedBuffer) - delete[] buffer; - return ERROR_WRITE_FAULT; - } - - EventPipeAdapter::WriteEvent(EventPipeEventGCAllocationTick_V3, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); - - if (!fixedBuffer) - delete[] buffer; - - - return ERROR_SUCCESS; -} - BOOL EventPipeEventEnabledGCBulkEdge(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCBulkEdge); + return ep_event_is_enabled(EventPipeEventGCBulkEdge); } ULONG EventPipeWriteEventGCBulkEdge( @@ -414,7 +310,7 @@ ULONG EventPipeWriteEventGCBulkEdge( BOOL EventPipeEventEnabledGCBulkMovedObjectRanges(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCBulkMovedObjectRanges); + return ep_event_is_enabled(EventPipeEventGCBulkMovedObjectRanges); } ULONG EventPipeWriteEventGCBulkMovedObjectRanges( @@ -459,7 +355,7 @@ ULONG EventPipeWriteEventGCBulkMovedObjectRanges( BOOL EventPipeEventEnabledGCBulkNode(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCBulkNode); + return ep_event_is_enabled(EventPipeEventGCBulkNode); } ULONG EventPipeWriteEventGCBulkNode( @@ -504,7 +400,7 @@ ULONG EventPipeWriteEventGCBulkNode( BOOL EventPipeEventEnabledGCBulkRCW(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCBulkRCW); + return ep_event_is_enabled(EventPipeEventGCBulkRCW); } ULONG EventPipeWriteEventGCBulkRCW( @@ -547,7 +443,7 @@ ULONG EventPipeWriteEventGCBulkRCW( BOOL EventPipeEventEnabledGCBulkRootCCW(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCBulkRootCCW); + return ep_event_is_enabled(EventPipeEventGCBulkRootCCW); } ULONG EventPipeWriteEventGCBulkRootCCW( @@ -590,7 +486,7 @@ ULONG EventPipeWriteEventGCBulkRootCCW( BOOL EventPipeEventEnabledGCBulkRootConditionalWeakTableElementEdge(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCBulkRootConditionalWeakTableElementEdge); + return ep_event_is_enabled(EventPipeEventGCBulkRootConditionalWeakTableElementEdge); } ULONG EventPipeWriteEventGCBulkRootConditionalWeakTableElementEdge( @@ -635,7 +531,7 @@ ULONG EventPipeWriteEventGCBulkRootConditionalWeakTableElementEdge( BOOL EventPipeEventEnabledGCBulkRootEdge(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCBulkRootEdge); + return ep_event_is_enabled(EventPipeEventGCBulkRootEdge); } ULONG EventPipeWriteEventGCBulkRootEdge( @@ -680,7 +576,7 @@ ULONG EventPipeWriteEventGCBulkRootEdge( BOOL EventPipeEventEnabledGCBulkSurvivingObjectRanges(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCBulkSurvivingObjectRanges); + return ep_event_is_enabled(EventPipeEventGCBulkSurvivingObjectRanges); } ULONG EventPipeWriteEventGCBulkSurvivingObjectRanges( @@ -725,7 +621,7 @@ ULONG EventPipeWriteEventGCBulkSurvivingObjectRanges( BOOL EventPipeEventEnabledGCCreateConcurrentThread_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCCreateConcurrentThread_V1); + return ep_event_is_enabled(EventPipeEventGCCreateConcurrentThread_V1); } ULONG EventPipeWriteEventGCCreateConcurrentThread_V1( @@ -763,7 +659,7 @@ ULONG EventPipeWriteEventGCCreateConcurrentThread_V1( BOOL EventPipeEventEnabledGCCreateSegment_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCCreateSegment_V1); + return ep_event_is_enabled(EventPipeEventGCCreateSegment_V1); } ULONG EventPipeWriteEventGCCreateSegment_V1( @@ -807,7 +703,7 @@ ULONG EventPipeWriteEventGCCreateSegment_V1( BOOL EventPipeEventEnabledGCEnd_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCEnd_V1); + return ep_event_is_enabled(EventPipeEventGCEnd_V1); } ULONG EventPipeWriteEventGCEnd_V1( @@ -849,7 +745,7 @@ ULONG EventPipeWriteEventGCEnd_V1( BOOL EventPipeEventEnabledGCFreeSegment_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCFreeSegment_V1); + return ep_event_is_enabled(EventPipeEventGCFreeSegment_V1); } ULONG EventPipeWriteEventGCFreeSegment_V1( @@ -889,7 +785,7 @@ ULONG EventPipeWriteEventGCFreeSegment_V1( BOOL EventPipeEventEnabledGCGenerationRange(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCGenerationRange); + return ep_event_is_enabled(EventPipeEventGCGenerationRange); } ULONG EventPipeWriteEventGCGenerationRange( @@ -933,63 +829,9 @@ ULONG EventPipeWriteEventGCGenerationRange( return ERROR_SUCCESS; } -BOOL EventPipeEventEnabledGCGlobalHeapHistory_V2(void) -{ - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCGlobalHeapHistory_V2); -} - -ULONG EventPipeWriteEventGCGlobalHeapHistory_V2( - const unsigned __int64 FinalYoungestDesired, - const signed int NumHeaps, - const unsigned int CondemnedGeneration, - const unsigned int Gen0ReductionCount, - const unsigned int Reason, - const unsigned int GlobalMechanisms, - const unsigned short ClrInstanceID, - const unsigned int PauseMode, - const unsigned int MemoryPressure, - const GUID * ActivityId, - const GUID * RelatedActivityId) -{ - if (!EventPipeEventEnabledGCGlobalHeapHistory_V2()) - return ERROR_SUCCESS; - - size_t size = 38; - BYTE stackBuffer[38]; - BYTE *buffer = stackBuffer; - size_t offset = 0; - bool fixedBuffer = true; - bool success = true; - - success &= WriteToBuffer(FinalYoungestDesired, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(NumHeaps, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(CondemnedGeneration, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(Gen0ReductionCount, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(Reason, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(GlobalMechanisms, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(PauseMode, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(MemoryPressure, buffer, offset, size, fixedBuffer); - - if (!success) - { - if (!fixedBuffer) - delete[] buffer; - return ERROR_WRITE_FAULT; - } - - EventPipeAdapter::WriteEvent(EventPipeEventGCGlobalHeapHistory_V2, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); - - if (!fixedBuffer) - delete[] buffer; - - - return ERROR_SUCCESS; -} - BOOL EventPipeEventEnabledGCHeapStats_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCHeapStats_V1); + return ep_event_is_enabled(EventPipeEventGCHeapStats_V1); } ULONG EventPipeWriteEventGCHeapStats_V1( @@ -1053,7 +895,7 @@ ULONG EventPipeWriteEventGCHeapStats_V1( BOOL EventPipeEventEnabledGCJoin_V2(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCJoin_V2); + return ep_event_is_enabled(EventPipeEventGCJoin_V2); } ULONG EventPipeWriteEventGCJoin_V2( @@ -1099,7 +941,7 @@ ULONG EventPipeWriteEventGCJoin_V2( BOOL EventPipeEventEnabledGCMarkFinalizeQueueRoots(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCMarkFinalizeQueueRoots); + return ep_event_is_enabled(EventPipeEventGCMarkFinalizeQueueRoots); } ULONG EventPipeWriteEventGCMarkFinalizeQueueRoots( @@ -1139,7 +981,7 @@ ULONG EventPipeWriteEventGCMarkFinalizeQueueRoots( BOOL EventPipeEventEnabledGCMarkHandles(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCMarkHandles); + return ep_event_is_enabled(EventPipeEventGCMarkHandles); } ULONG EventPipeWriteEventGCMarkHandles( @@ -1179,7 +1021,7 @@ ULONG EventPipeWriteEventGCMarkHandles( BOOL EventPipeEventEnabledGCMarkOlderGenerationRoots(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCMarkOlderGenerationRoots); + return ep_event_is_enabled(EventPipeEventGCMarkOlderGenerationRoots); } ULONG EventPipeWriteEventGCMarkOlderGenerationRoots( @@ -1219,7 +1061,7 @@ ULONG EventPipeWriteEventGCMarkOlderGenerationRoots( BOOL EventPipeEventEnabledGCMarkStackRoots(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCMarkStackRoots); + return ep_event_is_enabled(EventPipeEventGCMarkStackRoots); } ULONG EventPipeWriteEventGCMarkStackRoots( @@ -1259,7 +1101,7 @@ ULONG EventPipeWriteEventGCMarkStackRoots( BOOL EventPipeEventEnabledGCMarkWithType(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCMarkWithType); + return ep_event_is_enabled(EventPipeEventGCMarkWithType); } ULONG EventPipeWriteEventGCMarkWithType( @@ -1303,7 +1145,7 @@ ULONG EventPipeWriteEventGCMarkWithType( BOOL EventPipeEventEnabledGCPerHeapHistory_V3(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCPerHeapHistory_V3); + return ep_event_is_enabled(EventPipeEventGCPerHeapHistory_V3); } ULONG EventPipeWriteEventGCPerHeapHistory_V3( @@ -1372,7 +1214,7 @@ ULONG EventPipeWriteEventGCPerHeapHistory_V3( BOOL EventPipeEventEnabledGCTerminateConcurrentThread_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCTerminateConcurrentThread_V1); + return ep_event_is_enabled(EventPipeEventGCTerminateConcurrentThread_V1); } ULONG EventPipeWriteEventGCTerminateConcurrentThread_V1( @@ -1410,7 +1252,7 @@ ULONG EventPipeWriteEventGCTerminateConcurrentThread_V1( BOOL EventPipeEventEnabledGCTriggered(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCTriggered); + return ep_event_is_enabled(EventPipeEventGCTriggered); } ULONG EventPipeWriteEventGCTriggered( @@ -1450,7 +1292,7 @@ ULONG EventPipeWriteEventGCTriggered( BOOL EventPipeEventEnabledModuleLoad_V2(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventModuleLoad_V2); + return ep_event_is_enabled(EventPipeEventModuleLoad_V2); } ULONG EventPipeWriteEventModuleLoad_V2( @@ -1516,7 +1358,7 @@ ULONG EventPipeWriteEventModuleLoad_V2( BOOL EventPipeEventEnabledSetGCHandle(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventSetGCHandle); + return ep_event_is_enabled(EventPipeEventSetGCHandle); } ULONG EventPipeWriteEventSetGCHandle( @@ -1562,21 +1404,22 @@ ULONG EventPipeWriteEventSetGCHandle( return ERROR_SUCCESS; } -BOOL EventPipeEventEnabledGCStart_V1(void) +BOOL EventPipeEventEnabledGCStart_V2(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCStart_V1); + return ep_event_is_enabled(EventPipeEventGCStart_V2); } -ULONG EventPipeWriteEventGCStart_V1( +ULONG EventPipeWriteEventGCStart_V2( const unsigned int Count, const unsigned int Depth, const unsigned int Reason, const unsigned int Type, const unsigned short ClrInstanceID, + const unsigned __int64 ClientSequenceNumber, const GUID * ActivityId, const GUID * RelatedActivityId) { - if (!EventPipeEventEnabledGCStart_V1()) + if (!EventPipeEventEnabledGCStart_V2()) return ERROR_SUCCESS; size_t size = 32; @@ -1591,6 +1434,7 @@ ULONG EventPipeWriteEventGCStart_V1( success &= WriteToBuffer(Reason, buffer, offset, size, fixedBuffer); success &= WriteToBuffer(Type, buffer, offset, size, fixedBuffer); success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClientSequenceNumber, buffer, offset, size, fixedBuffer); if (!success) { @@ -1599,7 +1443,7 @@ ULONG EventPipeWriteEventGCStart_V1( return ERROR_WRITE_FAULT; } - EventPipeAdapter::WriteEvent(EventPipeEventGCStart_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + EventPipeAdapter::WriteEvent(EventPipeEventGCStart_V2, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); if (!fixedBuffer) delete[] buffer; @@ -1608,22 +1452,17 @@ ULONG EventPipeWriteEventGCStart_V1( return ERROR_SUCCESS; } -BOOL EventPipeEventEnabledGCStart_V2(void) +BOOL EventPipeEventEnabledGCRestartEEEnd_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCStart_V2); + return ep_event_is_enabled(EventPipeEventGCRestartEEEnd_V1); } -ULONG EventPipeWriteEventGCStart_V2( - const unsigned int Count, - const unsigned int Depth, - const unsigned int Reason, - const unsigned int Type, +ULONG EventPipeWriteEventGCRestartEEEnd_V1( const unsigned short ClrInstanceID, - const unsigned __int64 ClientSequenceNumber, const GUID * ActivityId, const GUID * RelatedActivityId) { - if (!EventPipeEventEnabledGCStart_V2()) + if (!EventPipeEventEnabledGCRestartEEEnd_V1()) return ERROR_SUCCESS; size_t size = 32; @@ -1633,12 +1472,7 @@ ULONG EventPipeWriteEventGCStart_V2( bool fixedBuffer = true; bool success = true; - success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(Depth, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(Reason, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(Type, buffer, offset, size, fixedBuffer); success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(ClientSequenceNumber, buffer, offset, size, fixedBuffer); if (!success) { @@ -1647,7 +1481,7 @@ ULONG EventPipeWriteEventGCStart_V2( return ERROR_WRITE_FAULT; } - EventPipeAdapter::WriteEvent(EventPipeEventGCStart_V2, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + EventPipeAdapter::WriteEvent(EventPipeEventGCRestartEEEnd_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); if (!fixedBuffer) delete[] buffer; @@ -1656,17 +1490,17 @@ ULONG EventPipeWriteEventGCStart_V2( return ERROR_SUCCESS; } -BOOL EventPipeEventEnabledGCRestartEEEnd_V1(void) +BOOL EventPipeEventEnabledGCRestartEEBegin_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCRestartEEEnd_V1); + return ep_event_is_enabled(EventPipeEventGCRestartEEBegin_V1); } -ULONG EventPipeWriteEventGCRestartEEEnd_V1( +ULONG EventPipeWriteEventGCRestartEEBegin_V1( const unsigned short ClrInstanceID, const GUID * ActivityId, const GUID * RelatedActivityId) { - if (!EventPipeEventEnabledGCRestartEEEnd_V1()) + if (!EventPipeEventEnabledGCRestartEEBegin_V1()) return ERROR_SUCCESS; size_t size = 32; @@ -1685,7 +1519,7 @@ ULONG EventPipeWriteEventGCRestartEEEnd_V1( return ERROR_WRITE_FAULT; } - EventPipeAdapter::WriteEvent(EventPipeEventGCRestartEEEnd_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + EventPipeAdapter::WriteEvent(EventPipeEventGCRestartEEBegin_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); if (!fixedBuffer) delete[] buffer; @@ -1694,17 +1528,17 @@ ULONG EventPipeWriteEventGCRestartEEEnd_V1( return ERROR_SUCCESS; } -BOOL EventPipeEventEnabledGCRestartEEBegin_V1(void) +BOOL EventPipeEventEnabledGCSuspendEEEnd_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCRestartEEBegin_V1); + return ep_event_is_enabled(EventPipeEventGCSuspendEEEnd_V1); } -ULONG EventPipeWriteEventGCRestartEEBegin_V1( +ULONG EventPipeWriteEventGCSuspendEEEnd_V1( const unsigned short ClrInstanceID, const GUID * ActivityId, const GUID * RelatedActivityId) { - if (!EventPipeEventEnabledGCRestartEEBegin_V1()) + if (!EventPipeEventEnabledGCSuspendEEEnd_V1()) return ERROR_SUCCESS; size_t size = 32; @@ -1723,7 +1557,7 @@ ULONG EventPipeWriteEventGCRestartEEBegin_V1( return ERROR_WRITE_FAULT; } - EventPipeAdapter::WriteEvent(EventPipeEventGCRestartEEBegin_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + EventPipeAdapter::WriteEvent(EventPipeEventGCSuspendEEEnd_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); if (!fixedBuffer) delete[] buffer; @@ -1732,17 +1566,19 @@ ULONG EventPipeWriteEventGCRestartEEBegin_V1( return ERROR_SUCCESS; } -BOOL EventPipeEventEnabledGCSuspendEEEnd_V1(void) +BOOL EventPipeEventEnabledGCSuspendEEBegin_V1(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCSuspendEEEnd_V1); + return ep_event_is_enabled(EventPipeEventGCSuspendEEBegin_V1); } -ULONG EventPipeWriteEventGCSuspendEEEnd_V1( +ULONG EventPipeWriteEventGCSuspendEEBegin_V1( + const unsigned int Reason, + const unsigned int Count, const unsigned short ClrInstanceID, const GUID * ActivityId, const GUID * RelatedActivityId) { - if (!EventPipeEventEnabledGCSuspendEEEnd_V1()) + if (!EventPipeEventEnabledGCSuspendEEBegin_V1()) return ERROR_SUCCESS; size_t size = 32; @@ -1752,6 +1588,8 @@ ULONG EventPipeWriteEventGCSuspendEEEnd_V1( bool fixedBuffer = true; bool success = true; + success &= WriteToBuffer(Reason, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); if (!success) @@ -1761,7 +1599,7 @@ ULONG EventPipeWriteEventGCSuspendEEEnd_V1( return ERROR_WRITE_FAULT; } - EventPipeAdapter::WriteEvent(EventPipeEventGCSuspendEEEnd_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + EventPipeAdapter::WriteEvent(EventPipeEventGCSuspendEEBegin_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); if (!fixedBuffer) delete[] buffer; @@ -1770,19 +1608,18 @@ ULONG EventPipeWriteEventGCSuspendEEEnd_V1( return ERROR_SUCCESS; } -BOOL EventPipeEventEnabledGCSuspendEEBegin_V1(void) +BOOL EventPipeEventEnabledDecreaseMemoryPressure(void) { - return EventPipeAdapter::EventIsEnabled(EventPipeEventGCSuspendEEBegin_V1); + return ep_event_is_enabled(EventPipeEventDecreaseMemoryPressure); } -ULONG EventPipeWriteEventGCSuspendEEBegin_V1( - const unsigned int Reason, - const unsigned int Count, +ULONG EventPipeWriteEventDecreaseMemoryPressure( + const unsigned __int64 BytesFreed, const unsigned short ClrInstanceID, const GUID * ActivityId, const GUID * RelatedActivityId) { - if (!EventPipeEventEnabledGCSuspendEEBegin_V1()) + if (!EventPipeEventEnabledDecreaseMemoryPressure()) return ERROR_SUCCESS; size_t size = 32; @@ -1792,8 +1629,7 @@ ULONG EventPipeWriteEventGCSuspendEEBegin_V1( bool fixedBuffer = true; bool success = true; - success &= WriteToBuffer(Reason, buffer, offset, size, fixedBuffer); - success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(BytesFreed, buffer, offset, size, fixedBuffer); success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); if (!success) @@ -1803,7 +1639,1305 @@ ULONG EventPipeWriteEventGCSuspendEEBegin_V1( return ERROR_WRITE_FAULT; } - EventPipeAdapter::WriteEvent(EventPipeEventGCSuspendEEBegin_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + EventPipeAdapter::WriteEvent(EventPipeEventDecreaseMemoryPressure, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledFinalizeObject(void) +{ + return ep_event_is_enabled(EventPipeEventFinalizeObject); +} + +ULONG EventPipeWriteEventFinalizeObject( + const void* TypeID, + const void* ObjectID, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledFinalizeObject()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(TypeID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ObjectID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventFinalizeObject, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCFinalizersBegin_V1(void) +{ + return ep_event_is_enabled(EventPipeEventGCFinalizersBegin_V1); +} + +ULONG EventPipeWriteEventGCFinalizersBegin_V1( + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCFinalizersBegin_V1()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCFinalizersBegin_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCFinalizersEnd_V1(void) +{ + return ep_event_is_enabled(EventPipeEventGCFinalizersEnd_V1); +} + +ULONG EventPipeWriteEventGCFinalizersEnd_V1( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCFinalizersEnd_V1()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCFinalizersEnd_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledContentionStart_V2(void) +{ + return ep_event_is_enabled(EventPipeEventContentionStart_V2); +} + +ULONG EventPipeWriteEventContentionStart_V2( + const unsigned char ContentionFlags, + const unsigned short ClrInstanceID, + const void* LockID, + const void* AssociatedObjectID, + const unsigned __int64 LockOwnerThreadID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledContentionStart_V2()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(ContentionFlags, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(LockID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(AssociatedObjectID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(LockOwnerThreadID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventContentionStart_V2, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledContentionStop_V1(void) +{ + return ep_event_is_enabled(EventPipeEventContentionStop_V1); +} + +ULONG EventPipeWriteEventContentionStop_V1( + const unsigned char ContentionFlags, + const unsigned short ClrInstanceID, + const double DurationNs, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledContentionStop_V1()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(ContentionFlags, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(DurationNs, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventContentionStop_V1, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledContentionLockCreated(void) +{ + return ep_event_is_enabled(EventPipeEventContentionLockCreated); +} + +ULONG EventPipeWriteEventContentionLockCreated( + const void* LockID, + const void* AssociatedObjectID, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledContentionLockCreated()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(LockID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(AssociatedObjectID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventContentionLockCreated, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolWorkerThreadStart(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolWorkerThreadStart); +} + +ULONG EventPipeWriteEventThreadPoolWorkerThreadStart( + const unsigned int ActiveWorkerThreadCount, + const unsigned int RetiredWorkerThreadCount, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolWorkerThreadStart()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(ActiveWorkerThreadCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(RetiredWorkerThreadCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolWorkerThreadStart, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolWorkerThreadStop(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolWorkerThreadStop); +} + +ULONG EventPipeWriteEventThreadPoolWorkerThreadStop( + const unsigned int ActiveWorkerThreadCount, + const unsigned int RetiredWorkerThreadCount, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolWorkerThreadStop()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(ActiveWorkerThreadCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(RetiredWorkerThreadCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolWorkerThreadStop, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolWorkerThreadWait(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolWorkerThreadWait); +} + +ULONG EventPipeWriteEventThreadPoolWorkerThreadWait( + const unsigned int ActiveWorkerThreadCount, + const unsigned int RetiredWorkerThreadCount, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolWorkerThreadWait()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(ActiveWorkerThreadCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(RetiredWorkerThreadCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolWorkerThreadWait, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolMinMaxThreads(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolMinMaxThreads); +} + +ULONG EventPipeWriteEventThreadPoolMinMaxThreads( + const unsigned short MinWorkerThreads, + const unsigned short MaxWorkerThreads, + const unsigned short MinIOCompletionThreads, + const unsigned short MaxIOCompletionThreads, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolMinMaxThreads()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(MinWorkerThreads, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(MaxWorkerThreads, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(MinIOCompletionThreads, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(MaxIOCompletionThreads, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolMinMaxThreads, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentSample(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolWorkerThreadAdjustmentSample); +} + +ULONG EventPipeWriteEventThreadPoolWorkerThreadAdjustmentSample( + const double Throughput, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentSample()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(Throughput, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolWorkerThreadAdjustmentSample, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentAdjustment(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolWorkerThreadAdjustmentAdjustment); +} + +ULONG EventPipeWriteEventThreadPoolWorkerThreadAdjustmentAdjustment( + const double AverageThroughput, + const unsigned int NewWorkerThreadCount, + const unsigned int Reason, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentAdjustment()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(AverageThroughput, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(NewWorkerThreadCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Reason, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolWorkerThreadAdjustmentAdjustment, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentStats(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolWorkerThreadAdjustmentStats); +} + +ULONG EventPipeWriteEventThreadPoolWorkerThreadAdjustmentStats( + const double Duration, + const double Throughput, + const double ThreadWave, + const double ThroughputWave, + const double ThroughputErrorEstimate, + const double AverageThroughputErrorEstimate, + const double ThroughputRatio, + const double Confidence, + const double NewControlSetting, + const unsigned short NewThreadWaveMagnitude, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolWorkerThreadAdjustmentStats()) + return ERROR_SUCCESS; + + size_t size = 76; + BYTE stackBuffer[76]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(Duration, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Throughput, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ThreadWave, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ThroughputWave, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ThroughputErrorEstimate, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(AverageThroughputErrorEstimate, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ThroughputRatio, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Confidence, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(NewControlSetting, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(NewThreadWaveMagnitude, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolWorkerThreadAdjustmentStats, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolIOEnqueue(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolIOEnqueue); +} + +ULONG EventPipeWriteEventThreadPoolIOEnqueue( + const void* NativeOverlapped, + const void* Overlapped, + const BOOL MultiDequeues, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolIOEnqueue()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(NativeOverlapped, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Overlapped, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(MultiDequeues, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolIOEnqueue, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolIODequeue(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolIODequeue); +} + +ULONG EventPipeWriteEventThreadPoolIODequeue( + const void* NativeOverlapped, + const void* Overlapped, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolIODequeue()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(NativeOverlapped, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Overlapped, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolIODequeue, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolWorkingThreadCount(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolWorkingThreadCount); +} + +ULONG EventPipeWriteEventThreadPoolWorkingThreadCount( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolWorkingThreadCount()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolWorkingThreadCount, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledThreadPoolIOPack(void) +{ + return ep_event_is_enabled(EventPipeEventThreadPoolIOPack); +} + +ULONG EventPipeWriteEventThreadPoolIOPack( + const void* NativeOverlapped, + const void* Overlapped, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledThreadPoolIOPack()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(NativeOverlapped, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Overlapped, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventThreadPoolIOPack, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCAllocationTick_V4(void) +{ + return ep_event_is_enabled(EventPipeEventGCAllocationTick_V4); +} + +ULONG EventPipeWriteEventGCAllocationTick_V4( + const unsigned int AllocationAmount, + const unsigned int AllocationKind, + const unsigned short ClrInstanceID, + const unsigned __int64 AllocationAmount64, + const void* TypeID, + const WCHAR* TypeName, + const unsigned int HeapIndex, + const void* Address, + const unsigned __int64 ObjectSize, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCAllocationTick_V4()) + return ERROR_SUCCESS; + + size_t size = 110; + BYTE stackBuffer[110]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + if (!TypeName) { TypeName = W("NULL"); } + success &= WriteToBuffer(AllocationAmount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(AllocationKind, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(AllocationAmount64, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TypeID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TypeName, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(HeapIndex, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Address, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ObjectSize, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCAllocationTick_V4, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCHeapStats_V2(void) +{ + return ep_event_is_enabled(EventPipeEventGCHeapStats_V2); +} + +ULONG EventPipeWriteEventGCHeapStats_V2( + const unsigned __int64 GenerationSize0, + const unsigned __int64 TotalPromotedSize0, + const unsigned __int64 GenerationSize1, + const unsigned __int64 TotalPromotedSize1, + const unsigned __int64 GenerationSize2, + const unsigned __int64 TotalPromotedSize2, + const unsigned __int64 GenerationSize3, + const unsigned __int64 TotalPromotedSize3, + const unsigned __int64 FinalizationPromotedSize, + const unsigned __int64 FinalizationPromotedCount, + const unsigned int PinnedObjectCount, + const unsigned int SinkBlockCount, + const unsigned int GCHandleCount, + const unsigned short ClrInstanceID, + const unsigned __int64 GenerationSize4, + const unsigned __int64 TotalPromotedSize4, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCHeapStats_V2()) + return ERROR_SUCCESS; + + size_t size = 110; + BYTE stackBuffer[110]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(GenerationSize0, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TotalPromotedSize0, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(GenerationSize1, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TotalPromotedSize1, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(GenerationSize2, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TotalPromotedSize2, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(GenerationSize3, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TotalPromotedSize3, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(FinalizationPromotedSize, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(FinalizationPromotedCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(PinnedObjectCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(SinkBlockCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(GCHandleCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(GenerationSize4, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TotalPromotedSize4, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCHeapStats_V2, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCSampledObjectAllocationHigh(void) +{ + return ep_event_is_enabled(EventPipeEventGCSampledObjectAllocationHigh); +} + +ULONG EventPipeWriteEventGCSampledObjectAllocationHigh( + const void* Address, + const void* TypeID, + const unsigned int ObjectCountForTypeSample, + const unsigned __int64 TotalSizeForTypeSample, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCSampledObjectAllocationHigh()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(Address, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TypeID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ObjectCountForTypeSample, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TotalSizeForTypeSample, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCSampledObjectAllocationHigh, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCSampledObjectAllocationLow(void) +{ + return ep_event_is_enabled(EventPipeEventGCSampledObjectAllocationLow); +} + +ULONG EventPipeWriteEventGCSampledObjectAllocationLow( + const void* Address, + const void* TypeID, + const unsigned int ObjectCountForTypeSample, + const unsigned __int64 TotalSizeForTypeSample, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCSampledObjectAllocationLow()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(Address, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TypeID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ObjectCountForTypeSample, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TotalSizeForTypeSample, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCSampledObjectAllocationLow, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledPinObjectAtGCTime(void) +{ + return ep_event_is_enabled(EventPipeEventPinObjectAtGCTime); +} + +ULONG EventPipeWriteEventPinObjectAtGCTime( + const void* HandleID, + const void* ObjectID, + const unsigned __int64 ObjectSize, + const WCHAR* TypeName, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledPinObjectAtGCTime()) + return ERROR_SUCCESS; + + size_t size = 90; + BYTE stackBuffer[90]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + if (!TypeName) { TypeName = W("NULL"); } + success &= WriteToBuffer(HandleID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ObjectID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ObjectSize, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TypeName, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventPinObjectAtGCTime, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCBulkRootStaticVar(void) +{ + return ep_event_is_enabled(EventPipeEventGCBulkRootStaticVar); +} + +ULONG EventPipeWriteEventGCBulkRootStaticVar( + const unsigned int Count, + const unsigned __int64 AppDomainID, + const unsigned short ClrInstanceID, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCBulkRootStaticVar()) + return ERROR_SUCCESS; + + size_t size = 46; + BYTE stackBuffer[46]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(AppDomainID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer((const BYTE *)Values, (int)(Values_ElementSize), buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCBulkRootStaticVar, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledIncreaseMemoryPressure(void) +{ + return ep_event_is_enabled(EventPipeEventIncreaseMemoryPressure); +} + +ULONG EventPipeWriteEventIncreaseMemoryPressure( + const unsigned __int64 BytesAllocated, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledIncreaseMemoryPressure()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(BytesAllocated, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventIncreaseMemoryPressure, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCGlobalHeapHistory_V4(void) +{ + return ep_event_is_enabled(EventPipeEventGCGlobalHeapHistory_V4); +} + +ULONG EventPipeWriteEventGCGlobalHeapHistory_V4( + const unsigned __int64 FinalYoungestDesired, + const signed int NumHeaps, + const unsigned int CondemnedGeneration, + const unsigned int Gen0ReductionCount, + const unsigned int Reason, + const unsigned int GlobalMechanisms, + const unsigned short ClrInstanceID, + const unsigned int PauseMode, + const unsigned int MemoryPressure, + const unsigned int CondemnReasons0, + const unsigned int CondemnReasons1, + const unsigned int Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCGlobalHeapHistory_V4()) + return ERROR_SUCCESS; + + size_t size = 82; + BYTE stackBuffer[82]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(FinalYoungestDesired, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(NumHeaps, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(CondemnedGeneration, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Gen0ReductionCount, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Reason, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(GlobalMechanisms, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(PauseMode, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(MemoryPressure, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(CondemnReasons0, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(CondemnReasons1, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer((const BYTE *)Values, (int)Values_ElementSize * (int)Count, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCGlobalHeapHistory_V4, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGenAwareBegin(void) +{ + return ep_event_is_enabled(EventPipeEventGenAwareBegin); +} + +ULONG EventPipeWriteEventGenAwareBegin( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGenAwareBegin()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGenAwareBegin, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGenAwareEnd(void) +{ + return ep_event_is_enabled(EventPipeEventGenAwareEnd); +} + +ULONG EventPipeWriteEventGenAwareEnd( + const unsigned int Count, + const unsigned short ClrInstanceID, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGenAwareEnd()) + return ERROR_SUCCESS; + + size_t size = 32; + BYTE stackBuffer[32]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGenAwareEnd, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCLOHCompact(void) +{ + return ep_event_is_enabled(EventPipeEventGCLOHCompact); +} + +ULONG EventPipeWriteEventGCLOHCompact( + const unsigned short ClrInstanceID, + const unsigned short Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCLOHCompact()) + return ERROR_SUCCESS; + + size_t size = 36; + BYTE stackBuffer[36]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer((const BYTE *)Values, (int)Values_ElementSize * (int)Count, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCLOHCompact, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); + + if (!fixedBuffer) + delete[] buffer; + + + return ERROR_SUCCESS; +} + +BOOL EventPipeEventEnabledGCFitBucketInfo(void) +{ + return ep_event_is_enabled(EventPipeEventGCFitBucketInfo); +} + +ULONG EventPipeWriteEventGCFitBucketInfo( + const unsigned short ClrInstanceID, + const unsigned short BucketKind, + const unsigned __int64 TotalSize, + const unsigned short Count, + int Values_ElementSize, + const void* Values, + const GUID * ActivityId, + const GUID * RelatedActivityId) +{ + if (!EventPipeEventEnabledGCFitBucketInfo()) + return ERROR_SUCCESS; + + size_t size = 46; + BYTE stackBuffer[46]; + BYTE *buffer = stackBuffer; + size_t offset = 0; + bool fixedBuffer = true; + bool success = true; + + success &= WriteToBuffer(ClrInstanceID, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(BucketKind, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(TotalSize, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer(Count, buffer, offset, size, fixedBuffer); + success &= WriteToBuffer((const BYTE *)Values, (int)Values_ElementSize * (int)Count, buffer, offset, size, fixedBuffer); + + if (!success) + { + if (!fixedBuffer) + delete[] buffer; + return ERROR_WRITE_FAULT; + } + + EventPipeAdapter::WriteEvent(EventPipeEventGCFitBucketInfo, (BYTE *)buffer, (unsigned int)offset, ActivityId, RelatedActivityId); if (!fixedBuffer) delete[] buffer; @@ -1950,13 +3084,9 @@ void InitProvidersAndEvents(void) void InitDotNETRuntime(void) { // shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase - // @TODO - Events need to be audited EventPipeProviderDotNETRuntime = EventPipeAdapter::CreateProvider(DotNETRuntimeName, reinterpret_cast(EventPipeEtwCallbackDotNETRuntime)); EventPipeEventDestroyGCHandle = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,31,2,0,EP_EVENT_LEVEL_INFORMATIONAL,true); EventPipeEventExceptionThrown_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,80,8589967360,1,EP_EVENT_LEVEL_ERROR,true); - EventPipeEventGCAllocationTick_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,10,1,1,EP_EVENT_LEVEL_VERBOSE,true); - EventPipeEventGCAllocationTick_V2 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,10,1,2,EP_EVENT_LEVEL_VERBOSE,true); - EventPipeEventGCAllocationTick_V3 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,10,1,3,EP_EVENT_LEVEL_VERBOSE,true); EventPipeEventGCBulkEdge = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,19,1048576,0,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCBulkMovedObjectRanges = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,22,4194304,0,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCBulkNode = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,18,1048576,0,EP_EVENT_LEVEL_INFORMATIONAL,false); @@ -1970,7 +3100,6 @@ void InitDotNETRuntime(void) EventPipeEventGCEnd_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,2,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCFreeSegment_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,6,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCGenerationRange = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,23,4194304,0,EP_EVENT_LEVEL_INFORMATIONAL,false); - EventPipeEventGCGlobalHeapHistory_V2 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,205,1,2,EP_EVENT_LEVEL_INFORMATIONAL,true); EventPipeEventGCHeapStats_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,4,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCJoin_V2 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,203,1,2,EP_EVENT_LEVEL_VERBOSE,true); EventPipeEventGCMarkFinalizeQueueRoots = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,26,1,0,EP_EVENT_LEVEL_INFORMATIONAL,false); @@ -1983,10 +3112,38 @@ void InitDotNETRuntime(void) EventPipeEventGCTriggered = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,35,1,0,EP_EVENT_LEVEL_INFORMATIONAL,true); EventPipeEventModuleLoad_V2 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,152,536870920,2,EP_EVENT_LEVEL_INFORMATIONAL,true); EventPipeEventSetGCHandle = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,30,2,0,EP_EVENT_LEVEL_INFORMATIONAL,true); - EventPipeEventGCStart_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,1,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCStart_V2 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,1,1,2,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCRestartEEEnd_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,3,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCRestartEEBegin_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,7,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCSuspendEEEnd_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,8,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); EventPipeEventGCSuspendEEBegin_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,9,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventDecreaseMemoryPressure = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,201,1,0,EP_EVENT_LEVEL_VERBOSE,true); + EventPipeEventFinalizeObject = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,29,1,0,EP_EVENT_LEVEL_VERBOSE,false); + EventPipeEventGCFinalizersBegin_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,14,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventGCFinalizersEnd_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,13,1,1,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventContentionStart_V2 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,81,16384,2,EP_EVENT_LEVEL_INFORMATIONAL,true); + EventPipeEventContentionStop_V1 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,91,16384,1,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventContentionLockCreated = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,90,16384,0,EP_EVENT_LEVEL_INFORMATIONAL,true); + EventPipeEventThreadPoolWorkerThreadStart = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,50,65536,0,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventThreadPoolWorkerThreadStop = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,51,65536,0,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventThreadPoolWorkerThreadWait = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,57,65536,0,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventThreadPoolMinMaxThreads = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,59,65536,0,EP_EVENT_LEVEL_INFORMATIONAL,true); + EventPipeEventThreadPoolWorkerThreadAdjustmentSample = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,54,65536,0,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventThreadPoolWorkerThreadAdjustmentAdjustment = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,55,65536,0,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventThreadPoolWorkerThreadAdjustmentStats = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,56,65536,0,EP_EVENT_LEVEL_VERBOSE,true); + EventPipeEventThreadPoolIOEnqueue = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,63,2147549184,0,EP_EVENT_LEVEL_VERBOSE,true); + EventPipeEventThreadPoolIODequeue = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,64,2147549184,0,EP_EVENT_LEVEL_VERBOSE,true); + EventPipeEventThreadPoolWorkingThreadCount = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,60,65536,0,EP_EVENT_LEVEL_VERBOSE,true); + EventPipeEventGCAllocationTick_V4 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,10,1,4,EP_EVENT_LEVEL_VERBOSE,true); + EventPipeEventGCHeapStats_V2 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,4,1,2,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventGCSampledObjectAllocationHigh = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,20,2097152,0,EP_EVENT_LEVEL_INFORMATIONAL,true); + EventPipeEventGCSampledObjectAllocationLow = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,32,33554432,0,EP_EVENT_LEVEL_INFORMATIONAL,true); + EventPipeEventPinObjectAtGCTime = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,33,1,0,EP_EVENT_LEVEL_VERBOSE,false); + EventPipeEventGCBulkRootStaticVar = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,38,1048576,0,EP_EVENT_LEVEL_INFORMATIONAL,false); + EventPipeEventIncreaseMemoryPressure = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,200,1,0,EP_EVENT_LEVEL_VERBOSE,true); + EventPipeEventGCGlobalHeapHistory_V4 = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,205,1,4,EP_EVENT_LEVEL_INFORMATIONAL,true); + EventPipeEventGenAwareBegin = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,206,1048576,0,EP_EVENT_LEVEL_INFORMATIONAL,true); + EventPipeEventGenAwareEnd = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,207,1048576,0,EP_EVENT_LEVEL_INFORMATIONAL,true); + EventPipeEventGCLOHCompact = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,208,1,0,EP_EVENT_LEVEL_INFORMATIONAL,true); + EventPipeEventGCFitBucketInfo = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,209,1,0,EP_EVENT_LEVEL_VERBOSE,true); } diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/ds-rt-aot.h b/src/coreclr/nativeaot/Runtime/eventpipe/ds-rt-aot.h index bd982b81da7ee..3afd85aac0d93 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/ds-rt-aot.h +++ b/src/coreclr/nativeaot/Runtime/eventpipe/ds-rt-aot.h @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // Implementation of ds-rt.h targeting NativeAOT runtime. -#ifndef __DIAGNOSTICS_RT_AOT_H__ -#define __DIAGNOSTICS_RT_AOT_H__ +#ifndef DIAGNOSTICS_RT_AOT_H +#define DIAGNOSTICS_RT_AOT_H #include @@ -314,4 +314,4 @@ ds_rt_server_log_pause_message (void) } #endif /* ENABLE_PERFTRACING */ -#endif /* __DIAGNOSTICS_RT_AOT_H__ */ +#endif /* DIAGNOSTICS_RT_AOT_H */ diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/ds-rt-types-aot.h b/src/coreclr/nativeaot/Runtime/eventpipe/ds-rt-types-aot.h index 7656799718534..e386eca5a2301 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/ds-rt-types-aot.h +++ b/src/coreclr/nativeaot/Runtime/eventpipe/ds-rt-types-aot.h @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // Implementation of ds-rt-types.h targeting NativeAOT runtime. -#ifndef __DIAGNOSTICS_RT_TYPES_AOT_H__ -#define __DIAGNOSTICS_RT_TYPES_AOT_H__ +#ifndef DIAGNOSTICS_RT_TYPES_AOT_H +#define DIAGNOSTICS_RT_TYPES_AOT_H #include @@ -11,4 +11,4 @@ #include "ep-rt-types-aot.h" #endif /* ENABLE_PERFTRACING */ -#endif /* __DIAGNOSTICS_RT_TYPES_AOT_H__ */ +#endif /* DIAGNOSTICS_RT_TYPES_AOT_H */ diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h index 2687fc8f35ed5..899c949821683 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h +++ b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // Implementation of ep-rt.h targeting NativeAOT runtime. -#ifndef __EVENTPIPE_RT_AOT_H__ -#define __EVENTPIPE_RT_AOT_H__ +#ifndef EVENTPIPE_RT_AOT_H +#define EVENTPIPE_RT_AOT_H #include // For isspace #ifdef TARGET_UNIX @@ -2009,4 +2009,4 @@ ep_rt_volatile_store_ptr_without_barrier ( } #endif /* ENABLE_PERFTRACING */ -#endif /* __EVENTPIPE_RT_AOT_H__ */ +#endif /* EVENTPIPE_RT_AOT_H */ diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-config-aot.h b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-config-aot.h index 75c35c33c14e7..335b8ce56778d 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-config-aot.h +++ b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-config-aot.h @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef __EVENTPIPE_RT_CONFIG_AOT_H__ -#define __EVENTPIPE_RT_CONFIG_AOT_H__ +#ifndef EVENTPIPE_RT_CONFIG_AOT_H +#define EVENTPIPE_RT_CONFIG_AOT_H -#endif /* __EVENTPIPE_RT_CONFIG_AOT_H__ */ +#endif /* EVENTPIPE_RT_CONFIG_AOT_H */ diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-types-aot.h b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-types-aot.h index 22c777f692812..c6899ba2792f7 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-types-aot.h +++ b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-types-aot.h @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // Implementation of ep-rt-types.h targeting AOT runtime. -#ifndef __EVENTPIPE_RT_TYPES_AOT_H__ -#define __EVENTPIPE_RT_TYPES_AOT_H__ +#ifndef EVENTPIPE_RT_TYPES_AOT_H +#define EVENTPIPE_RT_TYPES_AOT_H #include @@ -102,4 +102,4 @@ typedef struct _rt_aot_thread_params_t { } ep_rt_thread_params_t; #endif /* ENABLE_PERFTRACING */ -#endif /* __EVENTPIPE_RT_TYPES_AOT_H__ */ +#endif /* EVENTPIPE_RT_TYPES_AOT_H */ diff --git a/src/coreclr/nativeaot/Runtime/eventpipeadapter.h b/src/coreclr/nativeaot/Runtime/eventpipeadapter.h index 343c4628c6a92..9f1b67db5a89a 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipeadapter.h +++ b/src/coreclr/nativeaot/Runtime/eventpipeadapter.h @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef __EVENTPIPE_ADAPTER_H__ -#define __EVENTPIPE_ADAPTER_H__ +#ifndef EVENTPIPE_ADAPTER_H +#define EVENTPIPE_ADAPTER_H #if defined(FEATURE_PERFTRACING) @@ -148,13 +148,7 @@ class EventPipeAdapter final reinterpret_cast(activityId), reinterpret_cast(relatedActivityId)); } - - static inline bool EventIsEnabled (const EventPipeEvent *epEvent) - { - STATIC_CONTRACT_NOTHROW; - return ep_event_is_enabled(epEvent); - } }; #endif // FEATURE_PERFTRACING -#endif // __EVENTPIPE_ADAPTER_H__ +#endif // EVENTPIPE_ADAPTER_H diff --git a/src/coreclr/nativeaot/Runtime/eventpipeadaptertypes.h b/src/coreclr/nativeaot/Runtime/eventpipeadaptertypes.h index f473bde10488d..9d9df452ac7b0 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipeadaptertypes.h +++ b/src/coreclr/nativeaot/Runtime/eventpipeadaptertypes.h @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef __EVENTPIPE_ADAPTER_TYPES_H__ -#define __EVENTPIPE_ADAPTER_TYPES_H__ +#ifndef EVENTPIPE_ADAPTER_TYPES_H +#define EVENTPIPE_ADAPTER_TYPES_H #if defined(FEATURE_PERFTRACING) @@ -12,4 +12,4 @@ typedef struct _EventPipeProvider EventPipeProvider; typedef struct _EventPipeSession EventPipeSession; #endif // FEATURE_PERFTRACING -#endif // __EVENTPIPE_ADAPTER_TYPES_H__ +#endif // EVENTPIPE_ADAPTER_TYPES_H diff --git a/src/coreclr/nativeaot/Runtime/eventpipeinternal.cpp b/src/coreclr/nativeaot/Runtime/eventpipeinternal.cpp index 3615daaeeb249..d9e77f9db0e89 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipeinternal.cpp +++ b/src/coreclr/nativeaot/Runtime/eventpipeinternal.cpp @@ -26,9 +26,17 @@ struct EventPipeEventInstanceData struct EventPipeSessionInfo { - FILETIME StartTimeAsUTCFileTime; - LARGE_INTEGER StartTimeStamp; - LARGE_INTEGER TimeStampFrequency; + int64_t StartTimeAsUTCFileTime; + int64_t StartTimeStamp; + uint64_t TimeStampFrequency; +}; + +struct EventPipeProviderConfigurationNative +{ + WCHAR *pProviderName; + uint64_t keywords; + uint32_t loggingLevel; + WCHAR *pFilterData; }; EXTERN_C NATIVEAOT_API uint64_t __cdecl RhEventPipeInternal_Enable( @@ -38,8 +46,58 @@ EXTERN_C NATIVEAOT_API uint64_t __cdecl RhEventPipeInternal_Enable( /* COR_PRF_EVENTPIPE_PROVIDER_CONFIG */ const void * pProviders, uint32_t numProviders) { - PalDebugBreak(); - return 0; + uint64_t sessionID = 0; + // Invalid input! + if (circularBufferSizeInMB == 0 || + format >= EP_SERIALIZATION_FORMAT_COUNT || + numProviders == 0 || + pProviders == nullptr) + { + return 0; + } + + const EventPipeProviderConfigurationNative *nativeProviders = reinterpret_cast(pProviders); + + EventPipeProviderConfiguration * configProviders = reinterpret_cast(malloc ((numProviders) * sizeof (EventPipeProviderConfiguration))); + + if (configProviders) { + for (uint32_t i = 0; i < numProviders; ++i) { + ep_provider_config_init ( + &configProviders[i], + ep_rt_utf16_to_utf8_string (reinterpret_cast(nativeProviders[i].pProviderName), -1), + nativeProviders[i].keywords, + static_cast(nativeProviders[i].loggingLevel), + ep_rt_utf16_to_utf8_string (reinterpret_cast(nativeProviders[i].pFilterData), -1)); + } + } + + ep_char8_t *outputPathUTF8 = NULL; + if (outputFile) + outputPathUTF8 = ep_rt_utf16_to_utf8_string (reinterpret_cast(outputFile), -1); + EventPipeSessionID result = ep_enable ( + outputPathUTF8, + circularBufferSizeInMB, + configProviders, + numProviders, + outputFile != NULL ? EP_SESSION_TYPE_FILE : EP_SESSION_TYPE_LISTENER, + format, + false, + nullptr, + nullptr, + nullptr); + ep_rt_utf8_string_free (outputPathUTF8); + + ep_start_streaming(result); + + if (configProviders) { + for (uint32_t i = 0; i < numProviders; ++i) { + ep_rt_utf8_string_free ((ep_char8_t *)ep_provider_config_get_provider_name (&configProviders[i])); + ep_rt_utf8_string_free ((ep_char8_t *)ep_provider_config_get_filter_data (&configProviders[i])); + } + free(configProviders); + } + + return result; } EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_Disable(uint64_t sessionID) @@ -92,7 +150,6 @@ EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_DeleteProvider(intptr_t EXTERN_C NATIVEAOT_API int __cdecl RhEventPipeInternal_EventActivityIdControl(uint32_t controlCode, GUID *pActivityId) { - PalDebugBreak(); return 0; } @@ -110,26 +167,58 @@ EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_WriteEventData( EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_GetSessionInfo(uint64_t sessionID, EventPipeSessionInfo *pSessionInfo) { - PalDebugBreak(); - return FALSE; + bool retVal = false; + if (pSessionInfo != NULL) + { + EventPipeSession *pSession = ep_get_session(sessionID); + if (pSession != NULL) + { + pSessionInfo->StartTimeAsUTCFileTime = ep_session_get_session_start_time (pSession); + pSessionInfo->StartTimeStamp = ep_session_get_session_start_timestamp(pSession); + pSessionInfo->TimeStampFrequency = PalQueryPerformanceFrequency(); + retVal = true; + } + } + return retVal; } EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_GetNextEvent(uint64_t sessionID, EventPipeEventInstanceData *pInstance) { - PalDebugBreak(); - return FALSE; + EventPipeEventInstance *pNextInstance = NULL; + _ASSERTE(pInstance != NULL); + + pNextInstance = ep_get_next_event(sessionID); + if (pNextInstance) + { + pInstance->ProviderID = ep_event_get_provider(ep_event_instance_get_ep_event(pNextInstance)); + pInstance->EventID = ep_event_get_event_id(ep_event_instance_get_ep_event(pNextInstance)); + pInstance->ThreadID = static_cast(ep_event_get_event_id(ep_event_instance_get_ep_event(pNextInstance))); + pInstance->TimeStamp.QuadPart = ep_event_instance_get_timestamp(pNextInstance); + pInstance->ActivityId = *reinterpret_cast(ep_event_instance_get_activity_id_cref(pNextInstance)); + pInstance->RelatedActivityId = *reinterpret_cast(ep_event_instance_get_related_activity_id_cref(pNextInstance)); + pInstance->Payload = ep_event_instance_get_data(pNextInstance); + pInstance->PayloadLength = ep_event_instance_get_data_len(pNextInstance); + } + + return pNextInstance != NULL; } EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_SignalSession(uint64_t sessionID) { - PalDebugBreak(); - return FALSE; + EventPipeSession *const session = ep_get_session (sessionID); + if (!session) + return false; + + return ep_rt_wait_event_set (ep_session_get_wait_event (session)); } EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_WaitForSessionSignal(uint64_t sessionID, int32_t timeoutMs) { - PalDebugBreak(); - return FALSE; + EventPipeSession *const session = ep_get_session (sessionID); + if (!session) + return false; + + return !ep_rt_wait_event_wait (ep_session_get_wait_event (session), (uint32_t)timeoutMs, false) ? true : false; } #endif // FEATURE_PERFTRACING diff --git a/src/coreclr/nativeaot/Runtime/eventtrace.h b/src/coreclr/nativeaot/Runtime/eventtrace.h index 6254e0d92b377..e4124c5056887 100644 --- a/src/coreclr/nativeaot/Runtime/eventtrace.h +++ b/src/coreclr/nativeaot/Runtime/eventtrace.h @@ -212,6 +212,4 @@ inline void ETW::GCLog::RootReference( DWORD rootFlags) { } #endif -inline BOOL EventEnabledPinObjectAtGCTime() { return FALSE; } - #endif //_VMEVENTTRACE_H_ diff --git a/src/coreclr/nativeaot/Runtime/gctoclreventsink.cpp b/src/coreclr/nativeaot/Runtime/gctoclreventsink.cpp index 8a4385f1bb5f8..2dbf0b6482bd5 100644 --- a/src/coreclr/nativeaot/Runtime/gctoclreventsink.cpp +++ b/src/coreclr/nativeaot/Runtime/gctoclreventsink.cpp @@ -70,11 +70,11 @@ void GCToCLREventSink::FireGCHeapStats_V2( { LIMITED_METHOD_CONTRACT; - // TODO: FireEtwGCHeapStats_V2 - FireEtwGCHeapStats_V1(generationSize0, totalPromotedSize0, generationSize1, totalPromotedSize1, + FireEtwGCHeapStats_V2(generationSize0, totalPromotedSize0, generationSize1, totalPromotedSize1, generationSize2, totalPromotedSize2, generationSize3, totalPromotedSize3, finalizationPromotedSize, finalizationPromotedCount, pinnedObjectCount, - sinkBlockCount, gcHandleCount, GetClrInstanceId()); + sinkBlockCount, gcHandleCount, GetClrInstanceId(), + generationSize4, totalPromotedSize4); } void GCToCLREventSink::FireGCCreateSegment_V1(void* address, size_t size, uint32_t type) @@ -142,16 +142,14 @@ void GCToCLREventSink::FireGCGlobalHeapHistory_V4(uint64_t finalYoungestDesired, { LIMITED_METHOD_CONTRACT; - // TODO: FireEtwGCGlobalHeapHistory_V4 - FireEtwGCGlobalHeapHistory_V2(finalYoungestDesired, numHeaps, condemnedGeneration, gen0reductionCount, reason, - globalMechanisms, GetClrInstanceId(), pauseMode, memoryPressure); + FireEtwGCGlobalHeapHistory_V4(finalYoungestDesired, numHeaps, condemnedGeneration, gen0reductionCount, reason, + globalMechanisms, GetClrInstanceId(), pauseMode, memoryPressure, condemnReasons0, condemnReasons1, + count, valuesLen, values); } -void GCToCLREventSink::FireGCAllocationTick_V1(uint32_t allocationAmount, uint32_t allocationKind) +void GCToCLREventSink::FireGCAllocationTick_V1(uint32_t allocationAmount, + uint32_t allocationKind) { - LIMITED_METHOD_CONTRACT; - - FireEtwGCAllocationTick_V1(allocationAmount, allocationKind, GetClrInstanceId()); } void GCToCLREventSink::FireGCAllocationTick_V4(uint64_t allocationAmount, @@ -167,37 +165,39 @@ void GCToCLREventSink::FireGCAllocationTick_V4(uint64_t allocationAmount, if (typeId != nullptr) { - FireEtwGCAllocationTick_V3(static_cast(allocationAmount), + FireEtwGCAllocationTick_V4(static_cast(allocationAmount), allocationKind, GetClrInstanceId(), allocationAmount, typeId, name, heapIndex, - objectAddress); + objectAddress, + objectSize); } } void GCToCLREventSink::FirePinObjectAtGCTime(void* object, uint8_t** ppObject) { - UNREFERENCED_PARAMETER(object); - UNREFERENCED_PARAMETER(ppObject); + LIMITED_METHOD_CONTRACT; + + Object* obj = (Object*)object; + + FireEtwPinObjectAtGCTime(ppObject, + object, + obj->GetSize(), + NULL, + GetClrInstanceId()); } void GCToCLREventSink::FireGCLOHCompact(uint16_t count, uint32_t valuesLen, void* values) { - UNREFERENCED_PARAMETER(count); - UNREFERENCED_PARAMETER(valuesLen); - UNREFERENCED_PARAMETER(values); + FireEtwGCLOHCompact(GetClrInstanceId(), count, valuesLen, values); } void GCToCLREventSink::FireGCFitBucketInfo(uint16_t bucketKind, size_t size, uint16_t count, uint32_t valuesLen, void* values) { - UNREFERENCED_PARAMETER(bucketKind); - UNREFERENCED_PARAMETER(size); - UNREFERENCED_PARAMETER(count); - UNREFERENCED_PARAMETER(valuesLen); - UNREFERENCED_PARAMETER(values); + FireEtwGCFitBucketInfo(GetClrInstanceId(), bucketKind, size, count, valuesLen, values); } void GCToCLREventSink::FirePinPlugAtGCTime(uint8_t* plugStart, uint8_t* plugEnd, uint8_t* gapBeforeSize) diff --git a/src/coreclr/nativeaot/Runtime/rheventtrace.cpp b/src/coreclr/nativeaot/Runtime/rheventtrace.cpp index c9ab168ccc8a8..32c01f26cae26 100644 --- a/src/coreclr/nativeaot/Runtime/rheventtrace.cpp +++ b/src/coreclr/nativeaot/Runtime/rheventtrace.cpp @@ -355,16 +355,3 @@ void ETW::TypeSystemLog::LogTypeAndParametersIfNecessary(BulkTypeEventLogger * p #endif // defined(FEATURE_EVENT_TRACE) } - -COOP_PINVOKE_HELPER(void, RhpEtwExceptionThrown, (LPCWSTR exceptionTypeName, LPCWSTR exceptionMessage, void* faultingIP, HRESULT hresult)) -{ - FireEtXplatExceptionThrown_V1(exceptionTypeName, - exceptionMessage, - faultingIP, - hresult, - 0, - GetClrInstanceId()); -} - - - diff --git a/src/coreclr/nativeaot/Runtime/runtimeeventinternal.cpp b/src/coreclr/nativeaot/Runtime/runtimeeventinternal.cpp new file mode 100644 index 0000000000000..eebe490f3e0b6 --- /dev/null +++ b/src/coreclr/nativeaot/Runtime/runtimeeventinternal.cpp @@ -0,0 +1,103 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include "eventpipeadapter.h" + +#ifdef FEATURE_PERFTRACING + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogContentionLockCreated(intptr_t LockID, intptr_t AssociatedObjectID, uint16_t ClrInstanceID) +{ + FireEtwContentionLockCreated(reinterpret_cast(LockID), reinterpret_cast(AssociatedObjectID), ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogContentionStart(uint8_t ContentionFlags, uint16_t ClrInstanceID, intptr_t LockID, intptr_t AssociatedObjectID, uint64_t LockOwnerThreadID) +{ + FireEtwContentionStart_V2((const unsigned char)(ContentionFlags), ClrInstanceID, reinterpret_cast(LockID), reinterpret_cast(AssociatedObjectID), LockOwnerThreadID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogContentionStop(uint8_t ContentionFlags, uint16_t ClrInstanceID, double DurationNs) +{ + FireEtwContentionStop_V1((const unsigned char)(ContentionFlags), ClrInstanceID, DurationNs); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadStart(uint32_t activeWorkerThreadCount, uint32_t retiredWorkerThreadCount, uint16_t clrInstanceID) +{ + FireEtwThreadPoolWorkerThreadStart(activeWorkerThreadCount, retiredWorkerThreadCount, clrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop(uint32_t ActiveWorkerThreadCount, uint32_t RetiredWorkerThreadCount, uint16_t ClrInstanceID) +{ + FireEtwThreadPoolWorkerThreadStop(ActiveWorkerThreadCount, RetiredWorkerThreadCount, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait(uint32_t ActiveWorkerThreadCount, uint32_t RetiredWorkerThreadCount, uint16_t ClrInstanceID) +{ + FireEtwThreadPoolWorkerThreadWait(ActiveWorkerThreadCount, RetiredWorkerThreadCount, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolMinMaxThreads(uint16_t MinWorkerThreads, uint16_t MaxWorkerThreads, uint16_t MinIOCompletionThreads, uint16_t MaxIOCompletionThreads, uint16_t ClrInstanceID) +{ + FireEtwThreadPoolMinMaxThreads(MinWorkerThreads, MaxWorkerThreads, MinIOCompletionThreads, MaxIOCompletionThreads, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample(double Throughput, uint16_t ClrInstanceID) +{ + FireEtwThreadPoolWorkerThreadAdjustmentSample(Throughput, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment(double AverageThroughput, uint32_t NewWorkerThreadCount, uint32_t Reason, uint16_t ClrInstanceID) +{ + FireEtwThreadPoolWorkerThreadAdjustmentAdjustment(AverageThroughput, NewWorkerThreadCount, Reason, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats( + double Duration, + double Throughput, + double ThreadPoolWorkerThreadWait, + double ThroughputWave, + double ThroughputErrorEstimate, + double AverageThroughputErrorEstimate, + double ThroughputRatio, + double Confidence, + double NewControlSetting, + uint16_t NewThreadWaveMagnitude, + uint16_t ClrInstanceID) +{ + FireEtwThreadPoolWorkerThreadAdjustmentStats(Duration, Throughput, ThreadPoolWorkerThreadWait, ThroughputWave, ThroughputErrorEstimate, AverageThroughputErrorEstimate, ThroughputRatio, Confidence, NewControlSetting, NewThreadWaveMagnitude, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolIOEnqueue( + void * NativeOverlapped, + void * Overlapped, + BOOL MultiDequeues, + uint16_t ClrInstanceID) +{ + FireEtwThreadPoolIOEnqueue(NativeOverlapped, Overlapped, MultiDequeues, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolIODequeue(void * NativeOverlapped, void * Overlapped, uint16_t ClrInstanceID) +{ + FireEtwThreadPoolIODequeue(NativeOverlapped, Overlapped, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount(uint32_t Count, uint16_t ClrInstanceID) +{ + FireEtwThreadPoolWorkingThreadCount(Count, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolIOPack(void * NativeOverlapped, void * Overlapped, uint16_t ClrInstanceID) +{ + FireEtwThreadPoolIOPack(NativeOverlapped, Overlapped, ClrInstanceID); +} + +EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogExceptionThrown(LPCWSTR exceptionTypeName, LPCWSTR exceptionMessage, void* faultingIP, HRESULT hresult) +{ + FireEtwExceptionThrown_V1(exceptionTypeName, + exceptionMessage, + faultingIP, + hresult, + 0, + GetClrInstanceId()); +} + +#endif // FEATURE_PERFTRACING diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj index 896b92604d1a0..817f92a46e8f4 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -174,6 +174,7 @@ + diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.NativeAot.cs new file mode 100644 index 0000000000000..b7db6c9618df9 --- /dev/null +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.Threading.NativeSinks.NativeAot.cs @@ -0,0 +1,136 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime; +using System.Runtime.InteropServices; +using System.Threading; +using System.Diagnostics.Tracing; +using System.Runtime.CompilerServices; + +using Internal.Runtime; +using Internal.Runtime.CompilerServices; + +namespace System.Diagnostics.Tracing +{ + // This is part of the NativeRuntimeEventsource, which is the managed version of the Microsoft-Windows-DotNETRuntime provider. + // It contains the runtime specific interop to native event sinks. + internal sealed partial class NativeRuntimeEventSource : EventSource + { + // We don't have these keywords defined from the genRuntimeEventSources.py, so we need to manually define them here. + public static partial class Keywords + { + public const EventKeywords ContentionKeyword = (EventKeywords)0x4000; + public const EventKeywords ThreadingKeyword = (EventKeywords)0x10000; + public const EventKeywords ThreadTransferKeyword = (EventKeywords)0x80000000; + } + + [NonEvent] + internal static void LogContentionLockCreated(nint LockID, nint AssociatedObjectID, ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogContentionLockCreated(LockID, AssociatedObjectID, ClrInstanceID); + } + + [NonEvent] + internal static void LogContentionStart(ContentionFlagsMap ContentionFlags, ushort ClrInstanceID, nint LockID, nint AssociatedObjectID, ulong LockOwnerThreadID) + { + RuntimeImports.NativeRuntimeEventSource_LogContentionStart((byte)ContentionFlags, ClrInstanceID, LockID, AssociatedObjectID, LockOwnerThreadID); + } + + [NonEvent] + internal static void LogContentionStop(ContentionFlagsMap ContentionFlags, ushort ClrInstanceID, double DurationNs) + { + RuntimeImports.NativeRuntimeEventSource_LogContentionStop((byte)ContentionFlags, ClrInstanceID, DurationNs); + } + + [NonEvent] + internal static void LogThreadPoolWorkerThreadStart(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolWorkerThreadStart(ActiveWorkerThreadCount, RetiredWorkerThreadCount, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolWorkerThreadStop(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop(ActiveWorkerThreadCount, RetiredWorkerThreadCount, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolWorkerThreadWait(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait(ActiveWorkerThreadCount, RetiredWorkerThreadCount, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolMinMaxThreads(ushort MinWorkerThreads, ushort MaxWorkerThreads, ushort MinIOCompletionThreads, ushort MaxIOCompletionThreads, ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolMinMaxThreads(MinWorkerThreads, MaxWorkerThreads, MinIOCompletionThreads, MaxIOCompletionThreads, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolWorkerThreadAdjustmentSample(double Throughput, ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample(Throughput, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolWorkerThreadAdjustmentAdjustment(double AverageThroughput, uint NewWorkerThreadCount, ThreadAdjustmentReasonMap Reason, ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment(AverageThroughput, NewWorkerThreadCount, (uint)Reason, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolWorkerThreadAdjustmentStats( + double Duration, + double Throughput, + double ThreadPoolWorkerThreadWait, + double ThroughputWave, + double ThroughputErrorEstimate, + double AverageThroughputErrorEstimate, + double ThroughputRatio, + double Confidence, + double NewControlSetting, + ushort NewThreadWaveMagnitude, + ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats(Duration, Throughput, ThreadPoolWorkerThreadWait, ThroughputWave, + ThroughputErrorEstimate, AverageThroughputErrorEstimate, ThroughputRatio, Confidence, NewControlSetting, NewThreadWaveMagnitude, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolIOEnqueue( + IntPtr NativeOverlapped, + IntPtr Overlapped, + [MarshalAs(UnmanagedType.Bool)] bool MultiDequeues, + ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolIOEnqueue(NativeOverlapped, Overlapped, MultiDequeues, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolIODequeue( + IntPtr NativeOverlapped, + IntPtr Overlapped, + ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolIODequeue(NativeOverlapped, Overlapped, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolWorkingThreadCount( + uint Count, + ushort ClrInstanceID + ) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount(Count, ClrInstanceID); + } + + [NonEvent] + internal static void LogThreadPoolIOPack( + IntPtr NativeOverlapped, + IntPtr Overlapped, + ushort ClrInstanceID) + { + RuntimeImports.NativeRuntimeEventSource_LogThreadPoolIOPack(NativeOverlapped, Overlapped, ClrInstanceID); + } + } +} diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Exception.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Exception.NativeAot.cs index bbe9a1b9b2f4b..db496ad22e5f3 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Exception.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Exception.NativeAot.cs @@ -135,8 +135,7 @@ private static void AppendExceptionStackFrame(object exceptionObj, IntPtr IP, in if (!fatalOutOfMemory) ex.AppendStackIP(IP, isFirstRethrowFrame); - // UNIX-TODO: RhpEtwExceptionThrown -#if TARGET_WINDOWS + #if FEATURE_PERFTRACING if (isFirstFrame) { string typeName = !fatalOutOfMemory ? ex.GetType().ToString() : "System.OutOfMemoryException"; @@ -146,7 +145,7 @@ private static void AppendExceptionStackFrame(object exceptionObj, IntPtr IP, in unsafe { fixed (char* exceptionTypeName = typeName, exceptionMessage = message) - RuntimeImports.RhpEtwExceptionThrown(exceptionTypeName, exceptionMessage, IP, ex.HResult); + RuntimeImports.NativeRuntimeEventSource_LogExceptionThrown(exceptionTypeName, exceptionMessage, IP, ex.HResult); } } #endif diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs index c6ac7d60c9990..a7650ab86379b 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.Tracing; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; @@ -656,15 +657,8 @@ public GCFrameRegistration(void* allocation, uint elemCount, bool areByRefs = tr [RuntimeImport(RuntimeLibrary, "RhUnregisterForGCReporting")] internal static extern unsafe void RhUnregisterForGCReporting(GCFrameRegistration* pRegistration); - // - // ETW helpers. - // - [MethodImplAttribute(MethodImplOptions.InternalCall)] - [RuntimeImport(RuntimeLibrary, "RhpEtwExceptionThrown")] - internal static extern unsafe void RhpEtwExceptionThrown(char* exceptionTypeName, char* exceptionMessage, IntPtr faultingIP, long hresult); #if FEATURE_PERFTRACING - // // EventPipeInternal helpers. // @@ -733,6 +727,89 @@ internal static unsafe partial void RhEventPipeInternal_WriteEventData( [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] internal static partial uint RhEventPipeInternal_WaitForSessionSignal(ulong sessionID, int timeoutMs); + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogContentionLockCreated(nint LockID, nint AssociatedObjectID, ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogContentionStart(byte ContentionFlags, ushort ClrInstanceID, nint LockID, nint AssociatedObjectID, ulong LockOwnerThreadID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogContentionStop(byte ContentionFlags, ushort ClrInstanceID, double DurationNs); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadStart(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolMinMaxThreads(ushort MinWorkerThreads, ushort MaxWorkerThreads, ushort MinIOCompletionThreads, ushort MaxIOCompletionThreads, ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample(double Throughput, ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment(double AverageThroughput, uint NewWorkerThreadCount, uint Reason, ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats( + double Duration, + double Throughput, + double ThreadPoolWorkerThreadWait, + double ThroughputWave, + double ThroughputErrorEstimate, + double AverageThroughputErrorEstimate, + double ThroughputRatio, + double Confidence, + double NewControlSetting, + ushort NewThreadWaveMagnitude, + ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolIOEnqueue( + IntPtr NativeOverlapped, + IntPtr Overlapped, + [MarshalAs(UnmanagedType.Bool)] bool MultiDequeues, + ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolIODequeue( + IntPtr NativeOverlapped, + IntPtr Overlapped, + ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount( + uint Count, + ushort ClrInstanceID + ); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static partial void NativeRuntimeEventSource_LogThreadPoolIOPack( + IntPtr NativeOverlapped, + IntPtr Overlapped, + ushort ClrInstanceID); + + [LibraryImport(RuntimeLibrary)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + internal static unsafe partial void NativeRuntimeEventSource_LogExceptionThrown(char* exceptionTypeName, char* exceptionMessage, IntPtr faultingIP, long hresult); #endif // FEATURE_PERFTRACING // diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 5cc1e4823e5e8..697654cfe3f53 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -1449,8 +1449,8 @@ - - + + diff --git a/src/tests/tracing/Directory.Build.props b/src/tests/tracing/Directory.Build.props new file mode 100644 index 0000000000000..4d3d8c7ee19c2 --- /dev/null +++ b/src/tests/tracing/Directory.Build.props @@ -0,0 +1,8 @@ + + + + + + true + + \ No newline at end of file diff --git a/src/tests/tracing/eventcounter/runtimecounters.csproj b/src/tests/tracing/eventcounter/runtimecounters.csproj index 5c364fac879ea..34660af281c07 100644 --- a/src/tests/tracing/eventcounter/runtimecounters.csproj +++ b/src/tests/tracing/eventcounter/runtimecounters.csproj @@ -7,7 +7,6 @@ true true - true diff --git a/src/tests/tracing/eventpipe/config/name_config_with_pid.csproj b/src/tests/tracing/eventpipe/config/name_config_with_pid.csproj index 187b43060edfb..c090cb1e64fbf 100644 --- a/src/tests/tracing/eventpipe/config/name_config_with_pid.csproj +++ b/src/tests/tracing/eventpipe/config/name_config_with_pid.csproj @@ -5,7 +5,6 @@ true true - true diff --git a/src/tests/tracing/eventpipe/diagnosticport/diagnosticport.csproj b/src/tests/tracing/eventpipe/diagnosticport/diagnosticport.csproj index 2dd6c137f3385..e266e498b4219 100644 --- a/src/tests/tracing/eventpipe/diagnosticport/diagnosticport.csproj +++ b/src/tests/tracing/eventpipe/diagnosticport/diagnosticport.csproj @@ -7,7 +7,6 @@ true true - true diff --git a/src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.cs b/src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.cs index 54b99d1f553dc..47512faeb1292 100644 --- a/src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.cs +++ b/src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.cs @@ -20,16 +20,22 @@ public static int Main() new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Warning, 0b1000_0000_0000_0000) }; - return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024); + bool enableRundown = TestLibrary.Utilities.IsNativeAot? false: true; + Dictionary _expectedEventCounts = TestLibrary.Utilities.IsNativeAot? _expectedEventCountsNativeAOT: _expectedEventCountsCoreCLR; + + return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, enableRundownProvider:enableRundown); } - private static Dictionary _expectedEventCounts = new Dictionary() + private static Dictionary _expectedEventCountsCoreCLR = new Dictionary() { { "Microsoft-Windows-DotNETRuntime", new ExpectedEventCount(1000, 0.2f) }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; - + private static Dictionary _expectedEventCountsNativeAOT = new Dictionary() + { + { "Microsoft-Windows-DotNETRuntime", new ExpectedEventCount(1000, 0.2f) } + }; private static Action _eventGeneratingAction = () => { for (int i = 0; i < 1000; i++) diff --git a/src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.csproj b/src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.csproj index 722bf260cd64b..9454202eb4523 100644 --- a/src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.csproj +++ b/src/tests/tracing/eventpipe/eventsvalidation/ExceptionThrown_V1.csproj @@ -13,5 +13,6 @@ + diff --git a/src/tests/tracing/eventpipe/eventsvalidation/GCEvents.cs b/src/tests/tracing/eventpipe/eventsvalidation/GCEvents.cs index 868aab91453b7..2d2f0bb2aff91 100644 --- a/src/tests/tracing/eventpipe/eventsvalidation/GCEvents.cs +++ b/src/tests/tracing/eventpipe/eventsvalidation/GCEvents.cs @@ -21,16 +21,25 @@ public static int Main() new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, 0b1) }; - return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesTraceContainEvents); + bool enableRundown = TestLibrary.Utilities.IsNativeAot? false: true; + Dictionary _expectedEventCounts = TestLibrary.Utilities.IsNativeAot? _expectedEventCountsNativeAOT: _expectedEventCountsCoreCLR; + + return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesTraceContainEvents, enableRundownProvider:enableRundown); } - private static Dictionary _expectedEventCounts = new Dictionary() + private static Dictionary _expectedEventCountsCoreCLR = new Dictionary() { { "Microsoft-Windows-DotNETRuntime", -1 }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; + private static Dictionary _expectedEventCountsNativeAOT = new Dictionary() + { + { "Microsoft-Windows-DotNETRuntime", -1 } + }; + + private static Action _eventGeneratingAction = () => { for (int i = 0; i < 50; i++) diff --git a/src/tests/tracing/eventpipe/eventsvalidation/GCEvents.csproj b/src/tests/tracing/eventpipe/eventsvalidation/GCEvents.csproj index 92eb223634307..ef843105ee839 100644 --- a/src/tests/tracing/eventpipe/eventsvalidation/GCEvents.csproj +++ b/src/tests/tracing/eventpipe/eventsvalidation/GCEvents.csproj @@ -13,5 +13,6 @@ + diff --git a/src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.cs b/src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.cs index 0401c1466272f..a89b9f240c417 100644 --- a/src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.cs +++ b/src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.cs @@ -21,16 +21,24 @@ public static int Main() new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, 0b1) }; - return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesTraceContainEvents); + bool enableRundown = TestLibrary.Utilities.IsNativeAot? false: true; + Dictionary _expectedEventCounts = TestLibrary.Utilities.IsNativeAot? _expectedEventCountsNativeAOT: _expectedEventCountsCoreCLR; + + return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesTraceContainEvents, enableRundownProvider:enableRundown); } - private static Dictionary _expectedEventCounts = new Dictionary() + private static Dictionary _expectedEventCountsCoreCLR = new Dictionary() { { "Microsoft-Windows-DotNETRuntime", -1 }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; + private static Dictionary _expectedEventCountsNativeAOT = new Dictionary() + { + { "Microsoft-Windows-DotNETRuntime", -1 } + }; + private static Action _eventGeneratingAction = () => { for (int i = 0; i < 50; i++) diff --git a/src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.csproj b/src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.csproj index 794a4794d1526..7d5b89cdd57a3 100644 --- a/src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.csproj +++ b/src/tests/tracing/eventpipe/eventsvalidation/GCFinalizers.csproj @@ -13,5 +13,6 @@ + diff --git a/src/tests/tracing/eventpipe/providervalidation/providervalidation.cs b/src/tests/tracing/eventpipe/providervalidation/providervalidation.cs index 2da95c1523960..1f061e8456b24 100644 --- a/src/tests/tracing/eventpipe/providervalidation/providervalidation.cs +++ b/src/tests/tracing/eventpipe/providervalidation/providervalidation.cs @@ -35,20 +35,29 @@ public static int Main() new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose) }; - var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024); + bool enableRundown = TestLibrary.Utilities.IsNativeAot? false: true; + + Dictionary _expectedEventCounts = TestLibrary.Utilities.IsNativeAot? _expectedEventCountsNativeAOT: _expectedEventCountsCoreCLR; + var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, enableRundownProvider: enableRundown); if (ret < 0) return ret; else return 100; } - private static Dictionary _expectedEventCounts = new Dictionary() + private static Dictionary _expectedEventCountsCoreCLR = new Dictionary() { { "MyEventSource", new ExpectedEventCount(100_000, 0.30f) }, { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, { "Microsoft-DotNETCore-SampleProfiler", -1 } }; + private static Dictionary _expectedEventCountsNativeAOT = new Dictionary() + { + { "MyEventSource", 100_000 }, + { "Microsoft-DotNETCore-EventPipe", 1 } + }; + private static Action _eventGeneratingAction = () => { for (int i = 0; i < 100_000; i++) diff --git a/src/tests/tracing/eventpipe/providervalidation/providervalidation.csproj b/src/tests/tracing/eventpipe/providervalidation/providervalidation.csproj index 18068018243a0..683e3dda99097 100644 --- a/src/tests/tracing/eventpipe/providervalidation/providervalidation.csproj +++ b/src/tests/tracing/eventpipe/providervalidation/providervalidation.csproj @@ -12,5 +12,6 @@ + diff --git a/src/tests/tracing/eventpipe/reverse/reverse.csproj b/src/tests/tracing/eventpipe/reverse/reverse.csproj index 4b4bae03bc0b5..a2fca0e2c1cca 100644 --- a/src/tests/tracing/eventpipe/reverse/reverse.csproj +++ b/src/tests/tracing/eventpipe/reverse/reverse.csproj @@ -8,7 +8,6 @@ true true - true diff --git a/src/tests/tracing/eventpipe/simpleprovidervalidation/simpleprovidervalidation.cs b/src/tests/tracing/eventpipe/simpleprovidervalidation/simpleprovidervalidation.cs deleted file mode 100644 index a954e0c322989..0000000000000 --- a/src/tests/tracing/eventpipe/simpleprovidervalidation/simpleprovidervalidation.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics.Tracing; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Collections.Generic; -using Microsoft.Diagnostics.Tracing; -using Tracing.Tests.Common; -using Microsoft.Diagnostics.NETCore.Client; - -namespace Tracing.Tests.SimpleProviderValidation -{ - public sealed class MyEventSource : EventSource - { - private MyEventSource() {} - public static MyEventSource Log = new MyEventSource(); - public void MyEvent() { WriteEvent(1, "MyEvent"); } - } - - public class ProviderValidation - { - public static int Main() - { - // This test is meant to validate NativeAOT EventPipe implementation and is meant to run in regular CI - // Its currently not enabled in NativeAOT runs and the below issue tracks the work - // https://github.com/dotnet/runtime/issues/84701 - - var providers = new List() - { - new EventPipeProvider("MyEventSource", EventLevel.Verbose), - new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose) - }; - - var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, enableRundownProvider:false); - if (ret < 0) - return ret; - else - return 100; - } - - private static Dictionary _expectedEventCounts = new Dictionary() - { - { "MyEventSource", 100_000 }, - { "Microsoft-DotNETCore-EventPipe", 1} - }; - - private static Action _eventGeneratingAction = () => - { - for (int i = 0; i < 100_000; i++) - { - if (i % 10_000 == 0) - Logger.logger.Log($"Fired MyEvent {i:N0}/100,000 times..."); - MyEventSource.Log.MyEvent(); - } - }; - } -} diff --git a/src/tests/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation.cs b/src/tests/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation.cs new file mode 100644 index 0000000000000..6a851e23385af --- /dev/null +++ b/src/tests/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation.cs @@ -0,0 +1,133 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Diagnostics.Tracing; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Microsoft.Diagnostics.Tracing; +using Tracing.Tests.Common; +using Microsoft.Diagnostics.NETCore.Client; + +namespace Tracing.Tests.SimpleRuntimeEventValidation +{ + public class RuntimeEventValidation + { + public static int Main() + { + // This test validates GC and Exception events in the runtime + var ret = IpcTraceTest.RunAndValidateEventCounts( + // Validation is done with _DoesTraceContainEvents + new Dictionary(){{ "Microsoft-Windows-DotNETRuntime", -1 }}, + _eventGeneratingActionForGC, + //GCKeyword (0x1): 0b1 + new List(){new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, 0b1)}, + 1024, _DoesTraceContainGCEvents, enableRundownProvider:false); + + // Run the 2nd test scenario only if the first one passes + if(ret== 100) + { + ret = IpcTraceTest.RunAndValidateEventCounts( + new Dictionary(){{ "Microsoft-DotNETCore-EventPipe", 1 }}, + _eventGeneratingActionForExceptions, + //ExceptionKeyword (0x8000): 0b1000_0000_0000_0000 + new List(){new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Warning, 0b1000_0000_0000_0000)}, + 1024, _DoesTraceContainExceptionEvents, enableRundownProvider:false); + } + + if (ret < 0) + return ret; + else + return 100; + } + + private static Action _eventGeneratingActionForGC = () => + { + for (int i = 0; i < 50; i++) + { + if (i % 10 == 0) + Logger.logger.Log($"Called GC.Collect() {i} times..."); + RuntimeEventValidation eventValidation = new RuntimeEventValidation(); + eventValidation = null; + GC.Collect(); + } + }; + + private static Action _eventGeneratingActionForExceptions = () => + { + for (int i = 0; i < 10; i++) + { + if (i % 5 == 0) + Logger.logger.Log($"Thrown an exception {i} times..."); + try + { + throw new ArgumentNullException("Throw ArgumentNullException"); + } + catch (Exception e) + { + //Do nothing + } + } + }; + + private static Func> _DoesTraceContainGCEvents = (source) => + { + int GCStartEvents = 0; + int GCEndEvents = 0; + source.Clr.GCStart += (eventData) => GCStartEvents += 1; + source.Clr.GCStop += (eventData) => GCEndEvents += 1; + + int GCRestartEEStartEvents = 0; + int GCRestartEEStopEvents = 0; + source.Clr.GCRestartEEStart += (eventData) => GCRestartEEStartEvents += 1; + source.Clr.GCRestartEEStop += (eventData) => GCRestartEEStopEvents += 1; + + int GCSuspendEEEvents = 0; + int GCSuspendEEEndEvents = 0; + source.Clr.GCSuspendEEStart += (eventData) => GCSuspendEEEvents += 1; + source.Clr.GCSuspendEEStop += (eventData) => GCSuspendEEEndEvents += 1; + + return () => { + Logger.logger.Log("Event counts validation"); + + Logger.logger.Log("GCStartEvents: " + GCStartEvents); + Logger.logger.Log("GCEndEvents: " + GCEndEvents); + bool GCStartStopResult = GCStartEvents >= 50 && GCEndEvents >= 50 && Math.Abs(GCStartEvents - GCEndEvents) <=2; + Logger.logger.Log("GCStartStopResult check: " + GCStartStopResult); + + Logger.logger.Log("GCRestartEEStartEvents: " + GCRestartEEStartEvents); + Logger.logger.Log("GCRestartEEStopEvents: " + GCRestartEEStopEvents); + bool GCRestartEEStartStopResult = GCRestartEEStartEvents >= 50 && GCRestartEEStopEvents >= 50; + Logger.logger.Log("GCRestartEEStartStopResult check: " + GCRestartEEStartStopResult); + + Logger.logger.Log("GCSuspendEEEvents: " + GCSuspendEEEvents); + Logger.logger.Log("GCSuspendEEEndEvents: " + GCSuspendEEEndEvents); + bool GCSuspendEEStartStopResult = GCSuspendEEEvents >= 50 && GCSuspendEEEndEvents >= 50; + Logger.logger.Log("GCSuspendEEStartStopResult check: " + GCSuspendEEStartStopResult); + + return GCStartStopResult && GCRestartEEStartStopResult && GCSuspendEEStartStopResult ? 100 : -1; + }; + }; + + private static Func> _DoesTraceContainExceptionEvents = (source) => + { + int ExStartEvents = 0; + source.Clr.ExceptionStart += (eventData) => + { + if(eventData.ToString().IndexOf("System.ArgumentNullException")>=0) + ExStartEvents += 1; + }; + + return () => { + Logger.logger.Log("Exception Event counts validation"); + Logger.logger.Log("ExStartEvents: " + ExStartEvents); + bool ExStartResult = ExStartEvents >= 10; + + return ExStartResult ? 100 : -1; + }; + }; + } +} diff --git a/src/tests/tracing/eventpipe/simpleprovidervalidation/simpleprovidervalidation.csproj b/src/tests/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation.csproj similarity index 88% rename from src/tests/tracing/eventpipe/simpleprovidervalidation/simpleprovidervalidation.csproj rename to src/tests/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation.csproj index b9330517e010f..18068018243a0 100644 --- a/src/tests/tracing/eventpipe/simpleprovidervalidation/simpleprovidervalidation.csproj +++ b/src/tests/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation.csproj @@ -7,7 +7,6 @@ true true - true