diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs
index a06aa7950521a9..f833134f370be8 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs
@@ -68,5 +68,12 @@ internal static partial void LogThreadPoolWorkingThreadCount(
uint Count,
ushort ClrInstanceID
);
+
+ [NonEvent]
+ [LibraryImport(RuntimeHelpers.QCall)]
+ internal static partial void LogThreadPoolIOPack(
+ IntPtr NativeOverlapped,
+ IntPtr Overlapped,
+ ushort ClrInstanceID);
}
}
diff --git a/src/coreclr/vm/nativeeventsource.cpp b/src/coreclr/vm/nativeeventsource.cpp
index 751e8e625aad78..f2a8d7f7c5344d 100644
--- a/src/coreclr/vm/nativeeventsource.cpp
+++ b/src/coreclr/vm/nativeeventsource.cpp
@@ -133,4 +133,14 @@ extern "C" void QCALLTYPE LogThreadPoolWorkingThreadCount(_In_z_ uint count, _In
END_QCALL;
}
+
+extern "C" void QCALLTYPE LogThreadPoolIOPack(_In_z_ void* nativeOverlapped, _In_z_ void* overlapped, _In_z_ short ClrInstanceID)
+{
+ QCALL_CONTRACT;
+ BEGIN_QCALL;
+
+ FireEtwThreadPoolIOPack(nativeOverlapped, overlapped, ClrInstanceID);
+
+ END_QCALL;
+}
#endif // FEATURE_PERFTRACING
diff --git a/src/coreclr/vm/nativeeventsource.h b/src/coreclr/vm/nativeeventsource.h
index 9dbb751261de68..6f89d55c01e48c 100644
--- a/src/coreclr/vm/nativeeventsource.h
+++ b/src/coreclr/vm/nativeeventsource.h
@@ -26,6 +26,7 @@ extern "C" void QCALLTYPE LogThreadPoolWorkerThreadAdjustmentStats(_In_z_ double
extern "C" void QCALLTYPE LogThreadPoolIOEnqueue(_In_z_ void* nativeOverlapped, _In_z_ void* overlapped, _In_z_ bool multiDequeues, _In_z_ short ClrInstanceID);
extern "C" void QCALLTYPE LogThreadPoolIODequeue(_In_z_ void* nativeOverlapped, _In_z_ void* overlapped, _In_z_ short ClrInstanceID);
extern "C" void QCALLTYPE LogThreadPoolWorkingThreadCount(_In_z_ uint count, _In_z_ short ClrInstanceID);
+extern "C" void QCALLTYPE LogThreadPoolIOPack(_In_z_ void* nativeOverlapped, _In_z_ void* overlapped, _In_z_ short ClrInstanceID);
#endif // defined(FEATURE_PERFTRACING)
#endif //_NATIVEEVENTSOURCE_H_
diff --git a/src/coreclr/vm/qcallentrypoints.cpp b/src/coreclr/vm/qcallentrypoints.cpp
index 2d5d1cfc92b37c..d47454bade8390 100644
--- a/src/coreclr/vm/qcallentrypoints.cpp
+++ b/src/coreclr/vm/qcallentrypoints.cpp
@@ -278,6 +278,7 @@ static const Entry s_QCall[] =
DllImportEntry(LogThreadPoolWorkerThreadAdjustmentStats)
DllImportEntry(LogThreadPoolIOEnqueue)
DllImportEntry(LogThreadPoolIODequeue)
+ DllImportEntry(LogThreadPoolIOPack)
DllImportEntry(LogThreadPoolWorkingThreadCount)
DllImportEntry(EventPipeInternal_Enable)
DllImportEntry(EventPipeInternal_Disable)
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 011f3dc45a4dd6..2d4bcbc6a6b5c9 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
@@ -15,6 +15,7 @@ namespace System.Diagnostics.Tracing
// FireEtw* methods auto-generated from ClrEtwAll.man. This ensures that corresponding event sinks are being used
// for the native platform.
// For implementation of these events not supporting native sinks, refer to NativeRuntimeEventSource.PortableThreadPool.cs.
+ [CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "NativeRuntimeEventSource is a special case where event methods don't use WriteEvent/WriteEventCore but still need to be instance methods.")]
internal sealed partial class NativeRuntimeEventSource : EventSource
{
// This value does not seem to be used, leaving it as zero for now. It may be useful for a scenario that may involve
@@ -46,6 +47,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;
@@ -225,5 +227,26 @@ public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID
}
LogThreadPoolWorkingThreadCount(Count, ClrInstanceID);
}
+
+ [NonEvent]
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public unsafe void ThreadPoolIOPack(NativeOverlapped* nativeOverlapped)
+ {
+ if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword))
+ {
+ ThreadPoolIOPack(
+ (IntPtr)nativeOverlapped,
+ (IntPtr)OverlappedData.GetOverlappedFromNative(nativeOverlapped).GetHashCode());
+ }
+ }
+
+ [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)
+ {
+ LogThreadPoolIOPack(NativeOverlapped, Overlapped, ClrInstanceID);
+ }
}
}
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 08bc3de170d4ef..6e4b13e1e03433 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
@@ -50,6 +50,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;
@@ -362,5 +363,40 @@ public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID
data[1].Reserved = 0;
WriteEventCore(60, 2, data);
}
+
+ [NonEvent]
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public unsafe void ThreadPoolIOPack(NativeOverlapped* nativeOverlapped)
+ {
+ if (IsEnabled(EventLevel.Verbose, Keywords.ThreadingKeyword))
+ {
+ ThreadPoolIOPack(
+ (IntPtr)nativeOverlapped,
+ (IntPtr)OverlappedData.GetOverlappedFromNative(nativeOverlapped).GetHashCode());
+ }
+ }
+
+#if !ES_BUILD_STANDALONE
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern",
+ Justification = EventSourceSuppressMessage)]
+#endif
+ [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)
+ {
+ EventData* data = stackalloc EventData[3];
+ data[0].DataPointer = NativeOverlapped;
+ data[0].Size = sizeof(IntPtr);
+ data[0].Reserved = 0;
+ data[1].DataPointer = Overlapped;
+ data[1].Size = sizeof(IntPtr);
+ data[1].Reserved = 0;
+ data[2].DataPointer = (IntPtr)(&ClrInstanceID);
+ data[2].Size = sizeof(ushort);
+ data[2].Reserved = 0;
+ WriteEventCore(65, 3, data);
+ }
}
}
diff --git a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs
index bf9564fc11a7d9..ed34ddf60e0708 100644
--- a/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs
+++ b/src/mono/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.Mono.cs
@@ -68,5 +68,12 @@ internal static extern void LogThreadPoolWorkingThreadCount(
uint Count,
ushort ClrInstanceID
);
+
+ [NonEvent]
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ internal static extern void LogThreadPoolIOPack(
+ IntPtr NativeOverlapped,
+ IntPtr Overlapped,
+ ushort ClrInstanceID);
}
}
diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs
index 6838de54ba5904..f6a5f5c0f74585 100644
--- a/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs
+++ b/src/mono/System.Private.CoreLib/src/System/Threading/Overlapped.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
+using System.Diagnostics.Tracing;
using System.Runtime.InteropServices;
namespace System.Threading
@@ -98,6 +99,10 @@ internal sealed unsafe class OverlappedData
*(GCHandle*)(_pNativeOverlapped + 1) = GCHandle.Alloc(this);
success = true;
+#if FEATURE_PERFTRACING
+ if (NativeRuntimeEventSource.Log.IsEnabled())
+ NativeRuntimeEventSource.Log.ThreadPoolIOPack(pNativeOverlapped);
+#endif
return _pNativeOverlapped;
}
finally
diff --git a/src/mono/mono/component/event_pipe-stub.c b/src/mono/mono/component/event_pipe-stub.c
index 273d04f62da9fd..e925629ae90acf 100644
--- a/src/mono/mono/component/event_pipe-stub.c
+++ b/src/mono/mono/component/event_pipe-stub.c
@@ -171,6 +171,12 @@ event_pipe_stub_write_event_threadpool_working_thread_count (
uint16_t count,
uint16_t clr_instance_id);
+static bool
+event_pipe_stub_write_event_threadpool_io_pack (
+ intptr_t native_overlapped,
+ intptr_t overlapped,
+ uint16_t clr_instance_id);
+
MonoComponentEventPipe *
component_event_pipe_stub_init (void);
@@ -203,7 +209,8 @@ static MonoComponentEventPipe fn_table = {
&event_pipe_stub_write_event_threadpool_worker_thread_adjustment_stats,
&event_pipe_stub_write_event_threadpool_io_enqueue,
&event_pipe_stub_write_event_threadpool_io_dequeue,
- &event_pipe_stub_write_event_threadpool_working_thread_count
+ &event_pipe_stub_write_event_threadpool_working_thread_count,
+ &event_pipe_stub_write_event_threadpool_io_pack
};
static bool
@@ -443,6 +450,15 @@ event_pipe_stub_write_event_threadpool_working_thread_count (
return true;
}
+static bool
+event_pipe_stub_write_event_threadpool_io_pack (
+ intptr_t native_overlapped,
+ intptr_t overlapped,
+ uint16_t clr_instance_id)
+{
+ return true;
+}
+
MonoComponentEventPipe *
component_event_pipe_stub_init (void)
{
diff --git a/src/mono/mono/component/event_pipe.c b/src/mono/mono/component/event_pipe.c
index 0ca3a18a357728..c23a694714de6e 100644
--- a/src/mono/mono/component/event_pipe.c
+++ b/src/mono/mono/component/event_pipe.c
@@ -113,7 +113,8 @@ static MonoComponentEventPipe fn_table = {
&ep_rt_write_event_threadpool_worker_thread_adjustment_stats,
&ep_rt_write_event_threadpool_io_enqueue,
&ep_rt_write_event_threadpool_io_dequeue,
- &ep_rt_write_event_threadpool_working_thread_count
+ &ep_rt_write_event_threadpool_working_thread_count,
+ &ep_rt_write_event_threadpool_io_pack
};
static bool
diff --git a/src/mono/mono/component/event_pipe.h b/src/mono/mono/component/event_pipe.h
index 940522321d7f96..c67e3b82867cfe 100644
--- a/src/mono/mono/component/event_pipe.h
+++ b/src/mono/mono/component/event_pipe.h
@@ -201,6 +201,12 @@ typedef bool
uint16_t count,
uint16_t clr_instance_id);
+typedef bool
+(*event_pipe_component_write_event_threadpool_io_pack_func)(
+ intptr_t native_overlapped,
+ intptr_t overlapped,
+ uint16_t clr_instance_id);
+
/*
* MonoComponentEventPipe function table.
*/
@@ -235,6 +241,7 @@ typedef struct _MonoComponentEventPipe {
event_pipe_component_write_event_threadpool_io_enqueue_func write_event_threadpool_io_enqueue;
event_pipe_component_write_event_threadpool_io_dequeue_func write_event_threadpool_io_dequeue;
event_pipe_component_write_event_threadpool_working_thread_count_func write_event_threadpool_working_thread_count;
+ event_pipe_component_write_event_threadpool_io_pack_func write_event_threadpool_io_pack;
} MonoComponentEventPipe;
MONO_COMPONENT_EXPORT_ENTRYPOINT
diff --git a/src/mono/mono/eventpipe/ep-rt-mono.c b/src/mono/mono/eventpipe/ep-rt-mono.c
index c29345098d8bfc..189a2dcf003ec0 100644
--- a/src/mono/mono/eventpipe/ep-rt-mono.c
+++ b/src/mono/mono/eventpipe/ep-rt-mono.c
@@ -3802,6 +3802,20 @@ ep_rt_write_event_threadpool_working_thread_count (
NULL) == 0 ? true : false;
}
+bool
+ep_rt_write_event_threadpool_io_pack (
+ intptr_t native_overlapped,
+ intptr_t overlapped,
+ uint16_t clr_instance_id)
+{
+ return FireEtwThreadPoolIOPack (
+ (const void *)native_overlapped,
+ (const void *)overlapped,
+ clr_instance_id,
+ NULL,
+ NULL) == 0 ? true : false;
+}
+
static
void
runtime_profiler_jit_begin (
diff --git a/src/mono/mono/eventpipe/ep-rt-mono.h b/src/mono/mono/eventpipe/ep-rt-mono.h
index ac7e41dc8aee14..f1edf6cd8dbc41 100644
--- a/src/mono/mono/eventpipe/ep-rt-mono.h
+++ b/src/mono/mono/eventpipe/ep-rt-mono.h
@@ -2296,6 +2296,12 @@ ep_rt_write_event_threadpool_working_thread_count (
uint16_t count,
uint16_t clr_instance_id);
+bool
+ep_rt_write_event_threadpool_io_pack (
+ intptr_t native_overlapped,
+ intptr_t overlapped,
+ uint16_t clr_instance_id);
+
/*
* EventPipe provider callbacks.
*/
diff --git a/src/mono/mono/eventpipe/gen-eventing-event-inc.lst b/src/mono/mono/eventpipe/gen-eventing-event-inc.lst
index ad52dd9f8c8ebb..42086b3d81e3d0 100644
--- a/src/mono/mono/eventpipe/gen-eventing-event-inc.lst
+++ b/src/mono/mono/eventpipe/gen-eventing-event-inc.lst
@@ -42,6 +42,7 @@ ThreadPoolWorkerThreadStart
ThreadPoolWorkerThreadStop
ThreadPoolWorkerThreadWait
ThreadPoolWorkingThreadCount
+ThreadPoolIOPack
ThreadTerminated
TypeLoadStart
TypeLoadStop
diff --git a/src/mono/mono/metadata/icall-decl.h b/src/mono/mono/metadata/icall-decl.h
index 0c7334de6d4451..23647ef78a7aff 100644
--- a/src/mono/mono/metadata/icall-decl.h
+++ b/src/mono/mono/metadata/icall-decl.h
@@ -166,6 +166,7 @@ ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_
ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop (uint32_t active_thread_count, uint32_t retired_worker_thread_count, uint16_t clr_instance_id);
ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait (uint32_t active_thread_count, uint32_t retired_worker_thread_count, uint16_t clr_instance_id);
ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount (uint16_t count, uint16_t clr_instance_id);
+ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack (intptr_t native_overlapped, intptr_t overlapped, uint16_t clr_instance_id);
ICALL_EXPORT void ves_icall_Mono_RuntimeGPtrArrayHandle_GPtrArrayFree (GPtrArray *ptr_array);
ICALL_EXPORT void ves_icall_Mono_RuntimeMarshal_FreeAssemblyName (MonoAssemblyName *aname, MonoBoolean free_struct);
diff --git a/src/mono/mono/metadata/icall-def.h b/src/mono/mono/metadata/icall-def.h
index 6845a35a7482f2..d9ce17336ab907 100644
--- a/src/mono/mono/metadata/icall-def.h
+++ b/src/mono/mono/metadata/icall-def.h
@@ -172,6 +172,7 @@ NOHANDLES(ICALL(EVENTPIPE_12, "WriteEventData", ves_icall_System_Diagnostics_Tra
ICALL_TYPE(NATIVE_RUNTIME_EVENT_SOURCE, "System.Diagnostics.Tracing.NativeRuntimeEventSource", NATIVE_RUNTIME_EVENT_SOURCE_1)
NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_1, "LogThreadPoolIODequeue", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIODequeue))
NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_2, "LogThreadPoolIOEnqueue", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOEnqueue))
+NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_10, "LogThreadPoolIOPack", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack))
NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_3, "LogThreadPoolWorkerThreadAdjustmentAdjustment", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment))
NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_4, "LogThreadPoolWorkerThreadAdjustmentSample", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample))
NOHANDLES(ICALL(NATIVE_RUNTIME_EVENT_SOURCE_5, "LogThreadPoolWorkerThreadAdjustmentStats", ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats))
diff --git a/src/mono/mono/metadata/icall-eventpipe.c b/src/mono/mono/metadata/icall-eventpipe.c
index 7165efd3805890..78dba38de681f9 100644
--- a/src/mono/mono/metadata/icall-eventpipe.c
+++ b/src/mono/mono/metadata/icall-eventpipe.c
@@ -465,6 +465,18 @@ ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorki
clr_instance_id);
}
+void
+ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack (
+ intptr_t native_overlapped,
+ intptr_t overlapped,
+ uint16_t clr_instance_id)
+{
+ mono_component_event_pipe ()->write_event_threadpool_io_pack (
+ native_overlapped,
+ overlapped,
+ clr_instance_id);
+}
+
#else /* ENABLE_PERFTRACING */
gconstpointer
@@ -703,4 +715,15 @@ ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolWorki
mono_error_set_pending_exception (error);
}
+void
+ves_icall_System_Diagnostics_Tracing_NativeRuntimeEventSource_LogThreadPoolIOPack (
+ intptr_t native_overlapped,
+ intptr_t overlapped,
+ uint16_t clr_instance_id)
+{
+ ERROR_DECL (error);
+ mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.NativeRuntimeEventSource.LogThreadPoolIOPack");
+ mono_error_set_pending_exception (error);
+}
+
#endif /* ENABLE_PERFTRACING */
diff --git a/src/tests/issues.targets b/src/tests/issues.targets
index 820103fd248d0f..6f1e717a113921 100644
--- a/src/tests/issues.targets
+++ b/src/tests/issues.targets
@@ -1426,8 +1426,9 @@
https://github.com/dotnet/runtime/issues/54185
-
-
+
+ https://github.com/dotnet/runtime/issues/68032
+
Mono does not define out of range fp to int conversions
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 e6fab390492fd7..11c39d9a439b55 100644
--- a/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj
+++ b/src/tests/tracing/runtimeeventsource/nativeruntimeeventsource.csproj
@@ -5,15 +5,9 @@
true
true
-
- true
-
+