- name: timeoutPerTestCollectionInMinutes
value: 180
jobParameters:
- timeoutInMinutes: 120
+ timeoutInMinutes: 180
nameSuffix: NativeAOT
buildArgs: -s clr.aot+host.native+libs -rc $(_BuildConfig) -lc Release -hc Release
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;tracing/eventpipe/processenvironment;tracing/eventpipe/simpleruntimeeventvalidation;tracing/eventpipe/processinfo2;" test tracing/eventcounter/runtimecounters.csproj /p:BuildNativeAotFrameworkObjects=true'
+ testBuildArgs: 'nativeaot tree ";nativeaot;Loader;Interop;tracing;" /p:BuildNativeAotFrameworkObjects=true'
liveLibrariesBuildConfig: Release
testRunNamePrefixSuffix: NativeAOT_$(_BuildConfig)
extraVariablesTemplates:
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);
+ EventPipeEventThreadPoolIOPack = EventPipeAdapter::AddEvent(EventPipeProviderDotNETRuntime,65,65536,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);
return ThreadStore::GetCurrentThreadIfAvailable();
}
+ep_rt_thread_handle_t ep_rt_aot_setup_thread (void)
+{
+ // This is expensive but need a valid thread that will only be used by EventPipe
+ ThreadStore::AttachCurrentThread();
+ return ThreadStore::GetCurrentThread();
+}
+
ep_rt_thread_id_t ep_rt_aot_thread_get_id (ep_rt_thread_handle_t thread_handle)
{
return thread_handle->GetPalThreadIdForLogging();
ep_rt_thread_params_t* thread_params = reinterpret_cast<ep_rt_thread_params_t *>(data);
- // The session and sampling threads both assert that the incoming thread handle is
- // non-null, but do not necessarily rely on it otherwise; just pass a meaningless non-null
- // value until testing shows that a meaningful value is needed.
- thread_params->thread = reinterpret_cast<ep_rt_thread_handle_t>(1);
+ // We will create a new thread. cannot call ep_rt_aot_thread_get_handle since that will return null
+ extern ep_rt_thread_handle_t ep_rt_aot_setup_thread (void);
+ thread_params->thread = ep_rt_aot_setup_thread ();
size_t result = thread_params->thread_func (thread_params);
delete thread_params;
{
STATIC_CONTRACT_NOTHROW;
-#ifndef TARGET_UNIX
- extern uint32_t *_ep_rt_aot_proc_group_offsets;
- if (_ep_rt_aot_proc_group_offsets) {
- // PROCESSOR_NUMBER proc;
- // GetCurrentProcessorNumberEx (&proc);
- // return _ep_rt_aot_proc_group_offsets [proc.Group] + proc.Number;
- // PalDebugBreak();
- }
-#endif
+ // Follows the mono implementation
return 0xFFFFFFFF;
}
ep_rt_thread_has_started (ep_rt_thread_handle_t thread_handle)
{
STATIC_CONTRACT_NOTHROW;
- // shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase
- // TODO: Implement thread creation/management if needed
- // return thread_handle != NULL && thread_handle->HasStarted ();
- return true;
+ return thread_handle != NULL;
}
static
}
}
+// All the runtime redefine this enum, should move to commmon code.
+// https://github.com/dotnet/runtime/issues/87069
+enum class ActivityControlCode
+{
+ EVENT_ACTIVITY_CONTROL_GET_ID = 1,
+ EVENT_ACTIVITY_CONTROL_SET_ID = 2,
+ EVENT_ACTIVITY_CONTROL_CREATE_ID = 3,
+ EVENT_ACTIVITY_CONTROL_GET_SET_ID = 4,
+ EVENT_ACTIVITY_CONTROL_CREATE_SET_ID = 5
+};
+
EXTERN_C NATIVEAOT_API int __cdecl RhEventPipeInternal_EventActivityIdControl(uint32_t controlCode, GUID *pActivityId)
{
- return 0;
+ int retVal = 0;
+ ep_rt_thread_activity_id_handle_t activityIdHandle = ep_thread_get_activity_id_handle ();
+ if (activityIdHandle == NULL || pActivityId == NULL)
+ {
+ retVal = 1;
+ }
+ else
+ {
+ ActivityControlCode activityControlCode = (ActivityControlCode)controlCode;
+ GUID currentActivityId;
+ switch (activityControlCode)
+ {
+ case ActivityControlCode::EVENT_ACTIVITY_CONTROL_GET_ID:
+
+ ep_rt_thread_get_activity_id (activityIdHandle, reinterpret_cast<uint8_t *>(pActivityId), EP_ACTIVITY_ID_SIZE);
+ break;
+
+ case ActivityControlCode::EVENT_ACTIVITY_CONTROL_SET_ID:
+
+ ep_rt_thread_set_activity_id (activityIdHandle, reinterpret_cast<uint8_t *>(pActivityId), EP_ACTIVITY_ID_SIZE);
+ break;
+
+ case ActivityControlCode::EVENT_ACTIVITY_CONTROL_CREATE_ID:
+
+ ep_rt_create_activity_id(reinterpret_cast<uint8_t *>(pActivityId), EP_ACTIVITY_ID_SIZE);
+ break;
+
+ case ActivityControlCode::EVENT_ACTIVITY_CONTROL_GET_SET_ID:
+
+ ep_rt_thread_get_activity_id (activityIdHandle, reinterpret_cast<uint8_t *>(¤tActivityId), EP_ACTIVITY_ID_SIZE);
+ ep_rt_thread_set_activity_id (activityIdHandle, reinterpret_cast<uint8_t *>(pActivityId), EP_ACTIVITY_ID_SIZE);
+ *pActivityId = currentActivityId;
+
+ break;
+
+ case ActivityControlCode::EVENT_ACTIVITY_CONTROL_CREATE_SET_ID:
+
+ ep_rt_thread_get_activity_id (activityIdHandle, reinterpret_cast<uint8_t *>(pActivityId), EP_ACTIVITY_ID_SIZE);
+ ep_rt_create_activity_id(reinterpret_cast<uint8_t *>(¤tActivityId), EP_ACTIVITY_ID_SIZE);
+ ep_rt_thread_set_activity_id (activityIdHandle, reinterpret_cast<uint8_t *>(¤tActivityId), EP_ACTIVITY_ID_SIZE);
+ break;
+
+ default:
+ retVal = 1;
+ }
+ }
+
+ return retVal;
}
EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_WriteEventData(
BOOL ETW::GCLog::ShouldWalkHeapObjectsForEtw()
{
- LIMITED_METHOD_CONTRACT;
- return RUNTIME_PROVIDER_CATEGORY_ENABLED(
- TRACE_LEVEL_INFORMATION,
- CLR_GCHEAPDUMP_KEYWORD);
+ // @TODO: until the below issue is fixed correctly
+ // https://github.com/dotnet/runtime/issues/88491
+ return FALSE;
}
BOOL ETW::GCLog::ShouldWalkHeapRootsForEtw()
{
- LIMITED_METHOD_CONTRACT;
- return RUNTIME_PROVIDER_CATEGORY_ENABLED(
- TRACE_LEVEL_INFORMATION,
- CLR_GCHEAPDUMP_KEYWORD);
+ // @TODO: until the below issue is fixed correctly
+ // https://github.com/dotnet/runtime/issues/88491
+ return FALSE;
}
BOOL ETW::GCLog::ShouldTrackMovementForEtw()
<ExcludeList Include="$(XunitTestBinBase)/reflection/SetValue/TrySetReadonlyStaticField/*">
<Issue>https://github.com/dotnet/runtimelab/issues/200</Issue>
</ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventcounter/eventcounter/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventcounter/gh53564/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventcounter/incrementingeventcounter/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventcounter/incrementingpollingcounter/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventcounter/pollingcounter/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventcounter/regression-25709/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventcounter/regression-46938/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventactivityidcontrol/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventlistener/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/bigevent/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/buffersize/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/enabledisable/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/eventsourceerror/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
+ <ExcludeList Include="$(XunitTestBinBase)/tracing/eventlistener/EventListenerThreadPool/**">
+ <Issue>https://github.com/dotnet/runtime/issues/83051: Waiting for PR_88894 to be merged</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/gcdump/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/pauseonstart/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/processenvironment/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/processinfo/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/processinfo2/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/processinfo3/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/providervalidation/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
- </ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/reverseouter/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
+ <Issue>https://github.com/dotnet/runtime/issues/83051: not supported in net8</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/rundownvalidation/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
+ <Issue>https://github.com/dotnet/runtime/issues/83051: not supported in net8</Issue>
</ExcludeList>
- <ExcludeList Include="$(XunitTestBinBase)/tracing/runtimeeventsource/**">
- <Issue>https://github.com/dotnet/runtime/issues/83051</Issue>
+ <ExcludeList Include="$(XunitTestBinBase)/tracing/runtimeeventsource/nativeruntimeeventsource/**">
+ <Issue>https://github.com/dotnet/runtime/issues/90021</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b426654/b426654/*">
<Issue>https://github.com/dotnet/runtimelab/issues/208</Issue>
<Compile Include="EventActivityIdControl.cs" />
<ProjectReference Include="../common/common.csproj" />
</ItemGroup>
+ <ItemGroup Condition="'$(TestBuildMode)' == 'nativeaot'">
+ <RdXmlFile Include="rd.xml" />
+ </ItemGroup>
</Project>
--- /dev/null
+<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
+ <Application>
+ <Assembly Name="System.Private.CoreLib">
+ <Type Name="System.Diagnostics.Tracing.EventPipeEventProvider">
+ <Method Name="EventActivityIdControl" />
+ </Type>
+ </Assembly>
+ </Application>
+</Directives>
\ No newline at end of file
IpcAdvertise advertise = IpcAdvertise.Parse(stream);
Logger.logger.Log(advertise.ToString());
+ // Native AOT doesn't use the private provider / EEStartupStart event, so the subprocess
+ // writes a sentinel event to signal that the runtime has resumed and run the application
+ Provider provider = TestLibrary.Utilities.IsNativeAot ? new Provider(nameof(SentinelEventSource)) : new Provider("Microsoft-Windows-DotNETRuntimePrivate", 0x80000000, EventLevel.Verbose);
var config = new SessionConfiguration(
circularBufferSizeMB: 1000,
format: EventPipeSerializationFormat.NetTrace,
providers: new List<Provider> {
- new Provider("Microsoft-Windows-DotNETRuntimePrivate", 0x80000000, EventLevel.Verbose)
+ provider
});
+
Logger.logger.Log("Starting EventPipeSession over standard connection");
using Stream eventStream = EventPipeClient.CollectTracing(pid, config, out var sessionId);
Logger.logger.Log($"Started EventPipeSession over standard connection with session id: 0x{sessionId:x}");
using var source = new EventPipeEventSource(memoryStream);
var parser = new ClrPrivateTraceEventParser(source);
bool isStartupEventPresent= false;
- parser.StartupEEStartupStart += (eventData) => isStartupEventPresent = true;
+ if (TestLibrary.Utilities.IsNativeAot)
+ {
+ source.Dynamic.All += (eventData) => isStartupEventPresent = true;
+ }
+ else
+ {
+ parser.StartupEEStartupStart += (eventData) => isStartupEventPresent = true;
+ }
source.Process();
Logger.logger.Log($"isStartupEventPresent: {isStartupEventPresent}");
IpcAdvertise advertise = IpcAdvertise.Parse(stream);
Logger.logger.Log(advertise.ToString());
+ // Native AOT doesn't use the private provider / EEStartupStart event, so the subprocess
+ // writes a sentinel event to signal that the runtime has resumed and run the application
+ Provider provider = TestLibrary.Utilities.IsNativeAot ? new Provider(nameof(SentinelEventSource)) : new Provider("Microsoft-Windows-DotNETRuntimePrivate", 0x80000000, EventLevel.Verbose);
var config = new SessionConfiguration(
circularBufferSizeMB: 1000,
format: EventPipeSerializationFormat.NetTrace,
providers: new List<Provider> {
- new Provider("Microsoft-Windows-DotNETRuntimePrivate", 0x80000000, EventLevel.Verbose)
+ provider
});
Logger.logger.Log("Starting EventPipeSession over standard connection");
using (var source = new EventPipeEventSource(memoryStream1))
{
var parser = new ClrPrivateTraceEventParser(source);
- parser.StartupEEStartupStart += (eventData) => nStartupEventsSeen++;
+ if (TestLibrary.Utilities.IsNativeAot)
+ {
+ source.Dynamic.All += (eventData) =>
+ {
+ if(eventData.EventName.Equals("SentinelEvent"))
+ nStartupEventsSeen++;
+ };
+ }
+ else
+ {
+ parser.StartupEEStartupStart += (eventData) => nStartupEventsSeen++;
+ }
source.Process();
}
using (var source = new EventPipeEventSource(memoryStream2))
{
var parser = new ClrPrivateTraceEventParser(source);
- parser.StartupEEStartupStart += (eventData) => nStartupEventsSeen++;
+ if (TestLibrary.Utilities.IsNativeAot)
+ {
+ source.Dynamic.All += (eventData) =>
+ {
+ if(eventData.EventName.Equals("SentinelEvent"))
+ nStartupEventsSeen++;
+ };
+ }
+ else
+ {
+ parser.StartupEEStartupStart += (eventData) => nStartupEventsSeen++;
+ }
source.Process();
}
using (var source = new EventPipeEventSource(memoryStream3))
{
var parser = new ClrPrivateTraceEventParser(source);
- parser.StartupEEStartupStart += (eventData) => nStartupEventsSeen++;
+ if (TestLibrary.Utilities.IsNativeAot)
+ {
+ source.Dynamic.All += (eventData) =>
+ {
+ if(eventData.EventName.Equals("SentinelEvent"))
+ nStartupEventsSeen++;
+ };
+ }
+ else
+ {
+ parser.StartupEEStartupStart += (eventData) => nStartupEventsSeen++;
+ }
source.Process();
}
return fSuccess;
}
+ public sealed class SentinelEventSource : EventSource
+ {
+ private SentinelEventSource() {}
+ public static SentinelEventSource Log = new SentinelEventSource();
+ public void SentinelEvent() { WriteEvent(1, nameof(SentinelEvent)); }
+ }
+
public static async Task<int> Main(string[] args)
{
if (args.Length >= 1)
{
+ // Native AOT test uses this event source as a signal that the runtime has resumed and gone on to run the application
+ if (TestLibrary.Utilities.IsNativeAot)
+ SentinelEventSource.Log.SentinelEvent();
+
Console.Out.WriteLine("Subprocess started! Waiting for input...");
var input = Console.In.ReadLine(); // will block until data is sent across stdin
Console.Out.WriteLine($"Received '{input}'. Exiting...");
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
<ProjectReference Include="../common/common.csproj" />
+ <ProjectReference Include="$(TestSourceDir)Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj" />
</ItemGroup>
</Project>
// /path/to/corerun /path/to/processinfo.dll
// or
// "C:\path\to\CoreRun.exe" C:\path\to\processinfo.dll
- string currentProcessCommandLine = $"{currentProcess.MainModule.FileName} {System.Reflection.Assembly.GetExecutingAssembly().Location}";
+ string currentProcessCommandLine = TestLibrary.Utilities.IsSingleFile
+ ? currentProcess.MainModule.FileName
+ : $"{currentProcess.MainModule.FileName} {System.Reflection.Assembly.GetExecutingAssembly().Location}";
string receivedCommandLine = NormalizeCommandLine(commandLine);
Utils.Assert(currentProcessCommandLine.Equals(receivedCommandLine, StringComparison.OrdinalIgnoreCase), $"CommandLine must match current process. Expected: {currentProcessCommandLine}, Received: {receivedCommandLine} (original: {commandLine})");
}
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
<ProjectReference Include="../common/common.csproj" />
+ <ProjectReference Include="$(TestSourceDir)Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj" />
</ItemGroup>
</Project>