diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs index 6ce99198c9c156..0bf6a82d1bc369 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs @@ -49,6 +49,7 @@ private static class Messages { public const EventOpcode IOEnqueue = (EventOpcode)13; public const EventOpcode IODequeue = (EventOpcode)14; + public const EventOpcode IOPack = (EventOpcode)15; public const EventOpcode Wait = (EventOpcode)90; public const EventOpcode Sample = (EventOpcode)100; public const EventOpcode Adjustment = (EventOpcode)101; @@ -204,5 +205,17 @@ public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID } LogThreadPoolWorkingThreadCount(Count, ClrInstanceID); } + + [Event(65, Level = EventLevel.Verbose, Message = Messages.IO, Task = Tasks.ThreadPool, Opcode = Opcodes.IOPack, Version = 0, Keywords = Keywords.ThreadingKeyword)] + private unsafe void ThreadPoolIOPack( + IntPtr NativeOverlapped, + IntPtr Overlapped, + ushort ClrInstanceID = DefaultClrInstanceId) + { + // In .NET 6, this event is exclusively fired in CoreCLR from a QCALL. + // This function only needs to exist for the EventSource to generate metadata + // for in-process EventListeners. It will not be called. + throw new NotImplementedException(); + } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs index 785000089bdaaf..0c731b73643216 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs @@ -51,6 +51,7 @@ private static class Messages { public const EventOpcode IOEnqueue = (EventOpcode)13; public const EventOpcode IODequeue = (EventOpcode)14; + public const EventOpcode IOPack = (EventOpcode)15; public const EventOpcode Wait = (EventOpcode)90; public const EventOpcode Sample = (EventOpcode)100; public const EventOpcode Adjustment = (EventOpcode)101; diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 96124153d89d79..949a5d26976f12 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -960,6 +960,10 @@ + + https://github.com/dotnet/runtime/issues/68032 + + https://github.com/dotnet/runtime/issues/56887 diff --git a/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs b/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs index 43306a803ffbfc..c05747fca34382 100644 --- a/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs +++ b/src/tests/tracing/runtimeeventsource/NativeRuntimeEventSourceTest.cs @@ -5,8 +5,11 @@ using System.IO; using System.Diagnostics.Tracing; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Threading; +using System.Threading.Tasks; using Tracing.Tests.Common; +using System.Collections.Generic; namespace Tracing.Tests { @@ -22,7 +25,11 @@ static int Main(string[] args) using (SimpleEventListener listener = new SimpleEventListener("Simple")) { // Trigger the allocator task. - System.Threading.Tasks.Task.Run(new Action(Allocator)); + Task.Run(new Action(Allocator)); + + // If on Windows, attempt some Overlapped IO (triggers ThreadPool events) + if (OperatingSystem.IsWindows()) + DoOverlappedIO(); // Wait for events. Thread.Sleep(1000); @@ -34,7 +41,11 @@ static int Main(string[] args) Thread.Sleep(1000); // Ensure that we've seen some events. + foreach (string s in listener.SeenProvidersAndEvents) + Console.WriteLine(s); Assert.True("listener.EventCount > 0", listener.EventCount > 0); + if (OperatingSystem.IsWindows()) + Assert.True("Saw the ThreadPoolIOPack event", listener.SeenProvidersAndEvents.Contains("Microsoft-Windows-DotNETRuntime/EVENTID(65)")); } // Generate some more GC events. @@ -57,10 +68,19 @@ private static void Allocator() Thread.Sleep(10); } } + + private static unsafe void DoOverlappedIO() + { + Console.WriteLine("DOOVERLAPPEDIO"); + Overlapped overlapped = new(); + NativeOverlapped* pOverlap = overlapped.Pack(null, null); + Overlapped.Free(pOverlap); + } } internal sealed class SimpleEventListener : EventListener { + public HashSet SeenProvidersAndEvents { get; private set; } = new(); private string m_name; // Keep track of the set of keywords to be enabled. @@ -108,6 +128,9 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData) } Console.WriteLine("\n"); + SeenProvidersAndEvents.Add($"{eventData.EventSource.Name}"); + SeenProvidersAndEvents.Add($"{eventData.EventSource.Name}/EVENTID({eventData.EventId})"); + EventCount++; } } diff --git a/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj b/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj index 70336054f35e5c..2d90928194e63a 100644 --- a/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj +++ b/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj @@ -7,15 +7,9 @@ true true - - true - +