From a04deb44c6bfea74c34b8d4c74463eb3c82cf07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire?= Date: Thu, 7 Dec 2023 18:39:33 -0500 Subject: [PATCH] Add EventSource event for WaitHandle waits (#94737) Add start/stop events for WaitHandle waits Context: #94264 --- src/coreclr/gc/env/etmdummy.h | 2 + src/coreclr/inc/eventtracebase.h | 13 +++ src/coreclr/vm/ClrEtwAll.man | 56 +++++++++++- src/coreclr/vm/ClrEtwAllMeta.lst | 7 ++ src/coreclr/vm/syncblk.cpp | 1 + src/coreclr/vm/threads.cpp | 66 ++++++++++++-- src/coreclr/vm/threads.h | 3 +- .../Diagnostics/Tracing/TestEventListener.cs | 9 +- .../System.Threading/tests/EtwTests.cs | 87 +++++++++++++++++++ 9 files changed, 235 insertions(+), 9 deletions(-) diff --git a/src/coreclr/gc/env/etmdummy.h b/src/coreclr/gc/env/etmdummy.h index 556372127577a..2853049545c7f 100644 --- a/src/coreclr/gc/env/etmdummy.h +++ b/src/coreclr/gc/env/etmdummy.h @@ -414,3 +414,5 @@ #define FireEtwAppDomainAssemblyResolveHandlerInvoked(ClrInstanceId, assemblyName, handlerName, resultAssemblyName, resultAssemblyPath) 0 #define FireEtwAssemblyLoadFromResolveHandlerInvoked(ClrInstanceId, assemblyName, isTrackedAssembly, requestingAssemblyPath, requestedAssemblyPath) 0 #define FireEtwEventSource(eventID, eventName, eventSourceName, payload) 0 +#define FireEtwWaitHandleWaitStart(WaitSource, AssociatedObjectID, ClrInstanceID) 0 +#define FireEtwWaitHandleWaitStop(ClrInstanceID) 0 diff --git a/src/coreclr/inc/eventtracebase.h b/src/coreclr/inc/eventtracebase.h index 74d2b799e9433..212f1dfda5d53 100644 --- a/src/coreclr/inc/eventtracebase.h +++ b/src/coreclr/inc/eventtracebase.h @@ -1145,6 +1145,19 @@ namespace ETW } ContentionFlags; } ContentionStructs; }; + + class WaitHandleLog + { + public: + typedef union _WaitHandleStructs + { + typedef enum _WaitSource { + Unknown=0, + MonitorWait=1 + } WaitSource; + } WaitHandleStructs; + }; + // Class to wrap all Interop logic for ETW class InteropLog { diff --git a/src/coreclr/vm/ClrEtwAll.man b/src/coreclr/vm/ClrEtwAll.man index 3457bca2b0177..e506e2ca10676 100644 --- a/src/coreclr/vm/ClrEtwAll.man +++ b/src/coreclr/vm/ClrEtwAll.man @@ -89,6 +89,8 @@ message="$(string.RuntimePublisher.JitInstrumentationDataKeywordMessage)" symbol="CLR_JITINSTRUMENTEDDATA_KEYWORD" /> + @@ -446,7 +448,13 @@ - + + + + + @@ -497,6 +505,10 @@ + + + + @@ -1730,6 +1742,30 @@ + + + +