Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clr.coreclr.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<FeatureICastable>true</FeatureICastable>
<FeatureManagedEtwChannels>true</FeatureManagedEtwChannels>
<FeatureManagedEtw>true</FeatureManagedEtw>

<FeaturePerfTracing>true</FeaturePerfTracing>
<ProfilingSupportedBuild>true</ProfilingSupportedBuild>
</PropertyGroup>

Expand All @@ -17,7 +17,6 @@
<FeatureStubsAsIL>true</FeatureStubsAsIL>

<FeatureCoreFxGlobalization>true</FeatureCoreFxGlobalization>
<FeaturePerfTracing>true</FeaturePerfTracing>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetsWindows)' == 'true'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ namespace Microsoft.Diagnostics.Tracing
namespace System.Diagnostics.Tracing
#endif
{
internal enum EventProviderType
{
None = 0,
ETW,
EventPipe
};

// New in CLR4.0
internal enum ControllerCommand
{
Expand Down Expand Up @@ -120,15 +127,28 @@ public enum WriteEventErrorCode : int
// it registers a callback from native code you MUST dispose it BEFORE shutdown, otherwise
// you may get native callbacks during shutdown when we have destroyed the delegate.
// EventSource has special logic to do this, no one else should be calling EventProvider.
internal EventProvider()
internal EventProvider(EventProviderType providerType)
{
switch (providerType)
{
case EventProviderType.ETW:
#if PLATFORM_WINDOWS
m_eventProvider = new EtwEventProvider();
#elif FEATURE_PERFTRACING
m_eventProvider = new EventPipeEventProvider();
m_eventProvider = new EtwEventProvider();
#else
m_eventProvider = new NoOpEventProvider();
m_eventProvider = new NoOpEventProvider();
#endif
break;
case EventProviderType.EventPipe:
#if FEATURE_PERFTRACING
m_eventProvider = new EventPipeEventProvider();
#else
m_eventProvider = new NoOpEventProvider();
#endif
break;
default:
m_eventProvider = new NoOpEventProvider();
break;
};
}

/// <summary>
Expand Down Expand Up @@ -475,7 +495,7 @@ private unsafe void GetSessionInfo(SessionInfoCallback action, ref List<SessionI
var structBase = (byte*)providerInstance;
providerInstance = (UnsafeNativeMethods.ManifestEtw.TRACE_PROVIDER_INSTANCE_INFO*)&structBase[providerInstance->NextOffset];
}
#else
#else
#if !ES_BUILD_PCL && PLATFORM_WINDOWS // TODO command arguments don't work on PCL builds...
// This code is only used in the Nuget Package Version of EventSource. because
// the code above is using APIs baned from UWP apps.
Expand Down Expand Up @@ -1276,8 +1296,7 @@ unsafe IntPtr IEventProvider.DefineEventHandle(uint eventID, string eventName, I
}
}

#elif !FEATURE_PERFTRACING

#endif
internal sealed class NoOpEventProvider : IEventProvider
{
unsafe uint IEventProvider.EventRegister(
Expand Down Expand Up @@ -1314,10 +1333,8 @@ int IEventProvider.EventActivityIdControl(UnsafeNativeMethods.ManifestEtw.Activi
// Define an EventPipeEvent handle.
unsafe IntPtr IEventProvider.DefineEventHandle(uint eventID, string eventName, Int64 keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength)
{
throw new System.NotSupportedException();
return IntPtr.Zero;
}
}

#endif
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private unsafe void WriteMultiMergeInner(
EventDescriptor descriptor = new EventDescriptor(identity, level, opcode, (long)keywords);

#if FEATURE_PERFTRACING
IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_provider, m_eventHandleMap, descriptor, eventTypes);
IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_eventPipeProvider, m_eventHandleMap, descriptor, eventTypes);
Debug.Assert(eventHandle != IntPtr.Zero);
#else
IntPtr eventHandle = IntPtr.Zero;
Expand Down Expand Up @@ -552,7 +552,7 @@ internal unsafe void WriteMultiMerge(
}

#if FEATURE_PERFTRACING
IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_provider, m_eventHandleMap, descriptor, eventTypes);
IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_eventPipeProvider, m_eventHandleMap, descriptor, eventTypes);
Debug.Assert(eventHandle != IntPtr.Zero);
#else
IntPtr eventHandle = IntPtr.Zero;
Expand Down Expand Up @@ -621,7 +621,7 @@ private unsafe void WriteImpl(
}

#if FEATURE_PERFTRACING
IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_provider, m_eventHandleMap, descriptor, eventTypes);
IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_eventPipeProvider, m_eventHandleMap, descriptor, eventTypes);
Debug.Assert(eventHandle != IntPtr.Zero);
#else
IntPtr eventHandle = IntPtr.Zero;
Expand Down
4 changes: 2 additions & 2 deletions src/vm/eventpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ EventPipeProvider* EventPipe::CreateProvider(const SString &providerName, EventP
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
Expand Down Expand Up @@ -554,7 +554,6 @@ void EventPipe::WriteEventInternal(EventPipeEvent &event, EventPipeEventPayload
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(s_pSession != NULL);
}
CONTRACTL_END;

Expand All @@ -577,6 +576,7 @@ void EventPipe::WriteEventInternal(EventPipeEvent &event, EventPipeEventPayload
// We can't procede without a configuration
return;
}
_ASSERTE(s_pSession != NULL);

// If the activity id isn't specified, pull it from the current thread.
if(pActivityId == NULL)
Expand Down
12 changes: 6 additions & 6 deletions src/vm/eventpipeconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void EventPipeConfiguration::Initialize()
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
Expand All @@ -108,7 +108,7 @@ EventPipeProvider* EventPipeConfiguration::CreateProvider(const SString &provide
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
Expand Down Expand Up @@ -151,7 +151,7 @@ bool EventPipeConfiguration::RegisterProvider(EventPipeProvider &provider)
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
Expand Down Expand Up @@ -346,7 +346,7 @@ void EventPipeConfiguration::Enable(EventPipeSession *pSession)
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
PRECONDITION(pSession != NULL);
// Lock must be held by EventPipe::Enable.
Expand Down Expand Up @@ -385,7 +385,7 @@ void EventPipeConfiguration::Disable(EventPipeSession *pSession)
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
// TODO: Multiple session support will require that the session be specified.
PRECONDITION(pSession != NULL);
Expand Down Expand Up @@ -431,7 +431,7 @@ void EventPipeConfiguration::EnableRundown(EventPipeSession *pSession)
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
PRECONDITION(pSession != NULL);
// Lock must be held by EventPipe::Disable.
Expand Down
2 changes: 1 addition & 1 deletion src/vm/eventpipeeventsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ EventPipeEventSource::EventPipeEventSource()
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
Expand Down
4 changes: 2 additions & 2 deletions src/vm/eventpipeprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void EventPipeProvider::SetConfiguration(bool providerEnabled, INT64 keywords, E
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
PRECONDITION(EventPipe::GetLock()->OwnedByCurrentThread());
}
Expand Down Expand Up @@ -191,7 +191,7 @@ void EventPipeProvider::InvokeCallback()
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
GC_TRIGGERS;
MODE_ANY;
PRECONDITION(EventPipe::GetLock()->OwnedByCurrentThread());
}
Expand Down
12 changes: 2 additions & 10 deletions tests/issues.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1725,16 +1725,8 @@
<ExcludeList Include="$(XunitTestBinBase)\managed\Compilation\Compilation\Compilation.cmd">
<Issue>needs triage</Issue>
</ExcludeList>
</ItemGroup>

<!-- The following are tests that fail on Windows -->

<ItemGroup Condition="'$(XunitTestBinBase)' != '' and '$(TargetsWindows)' == 'true'">
<ExcludeList Include="$(XunitTestBinBase)\tracing\eventsourcetrace\eventsourcetrace\eventsourcetrace.cmd">
<Issue>15494</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)\tracing\tracevalidation\tracelogging\tracelogging\tracelogging.cmd">
<Issue>15494</Issue>
<ExcludeList Include="$(XunitTestBinBase)\tracing\eventsource\eventpipeandetw\eventpipeandetw\eventpipeandetw.cmd">
<Issue>by design Windows only</Issue>
</ExcludeList>
</ItemGroup>

Expand Down
33 changes: 33 additions & 0 deletions tests/src/tracing/common/EtlFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.IO;

namespace Tracing.Tests.Common
{
public class EtlFile : IDisposable
{
public string Path { get; }
private bool KeepOutput { get; }

private EtlFile(string fileName, bool keep)
{
Path = fileName;
KeepOutput = keep;
}

public void Dispose()
{
if (KeepOutput)
Console.WriteLine("\n\tOutput file: {0}", Path);
else
File.Delete(Path);
}

public static EtlFile Create(string[] args)
{
if (args.Length >= 1)
return new EtlFile(args[0], true);

return new EtlFile(System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".etl", false);
}
}
}
1 change: 1 addition & 0 deletions tests/src/tracing/common/common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Assert.cs" />
<Compile Include="EtlFile.cs" />
<Compile Include="NetPerfFile.cs" />
<Compile Include="TraceControl.cs" />
<Compile Include="TraceConfiguration.cs" />
Expand Down
Loading