From: danmosemsft Date: Fri, 27 Jan 2017 23:19:04 +0000 (-0800) Subject: Revert `Remove FEATURE_MANAGED_ETW_CHANNELS` X-Git-Tag: accepted/tizen/base/20180629.140029~2455^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ebad4067f3ae31c667dc807c64a1c3db419a54cb;p=platform%2Fupstream%2Fcoreclr.git Revert `Remove FEATURE_MANAGED_ETW_CHANNELS` --- diff --git a/clr.coreclr.props b/clr.coreclr.props index ed5dd1a..9211976 100644 --- a/clr.coreclr.props +++ b/clr.coreclr.props @@ -50,6 +50,7 @@ true true + true true true true diff --git a/clr.defines.targets b/clr.defines.targets index c3bb70d..689fa06 100644 --- a/clr.defines.targets +++ b/clr.defines.targets @@ -40,6 +40,7 @@ $(CDefines);FEATURE_LEGACYNETCF_DBG_HOST_CONTROL $(CDefines);FEATURE_MACL $(CDefines);FEATURE_MANAGED_ETW + $(CDefines);FEATURE_MANAGED_ETW_CHANNELS $(CDefines);MDA_SUPPORTED $(CDefines);FEATURE_MERGE_CULTURE_SUPPORT_AND_ENGINE $(CDefines);FEATURE_MERGE_JIT_AND_ENGINE @@ -117,6 +118,7 @@ $(DefineConstants);FEATURE_ISOSTORE_LIGHT $(DefineConstants);FEATURE_MACL $(DefineConstants);FEATURE_MANAGED_ETW + $(DefineConstants);FEATURE_MANAGED_ETW_CHANNELS $(DefineConstants);FEATURE_MULTIMODULE_ASSEMBLIES $(DefineConstants);FEATURE_NONGENERIC_COLLECTIONS $(DefineConstants);FEATURE_PAL diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs index dc2c2b6..405fbb2 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs @@ -15,6 +15,7 @@ #endif // !PLATFORM_UNIX #if ES_BUILD_STANDALONE +#define FEATURE_MANAGED_ETW_CHANNELS // #define FEATURE_ADVANCED_MANAGED_ETW_CHANNELS #endif @@ -2346,7 +2347,11 @@ namespace System.Diagnostics.Tracing EventLevel eventLevel = (EventLevel)m_eventData[eventNum].Descriptor.Level; EventKeywords eventKeywords = unchecked((EventKeywords)((ulong)m_eventData[eventNum].Descriptor.Keywords & (~(SessionMask.All.ToEventKeywords())))); +#if FEATURE_MANAGED_ETW_CHANNELS EventChannel channel = unchecked((EventChannel)m_eventData[eventNum].Descriptor.Channel); +#else + EventChannel channel = EventChannel.None; +#endif return IsEnabledCommon(enable, currentLevel, currentMatchAnyKeyword, eventLevel, eventKeywords, channel); } @@ -2364,6 +2369,7 @@ namespace System.Diagnostics.Tracing // if yes, does it pass the keywords test? if (currentMatchAnyKeyword != 0 && eventKeywords != 0) { +#if FEATURE_MANAGED_ETW_CHANNELS // is there a channel with keywords that match currentMatchAnyKeyword? if (eventChannel != EventChannel.None && this.m_channelData != null && this.m_channelData.Length > (int)eventChannel) { @@ -2372,6 +2378,7 @@ namespace System.Diagnostics.Tracing return false; } else +#endif { if ((unchecked((ulong)eventKeywords & (ulong)currentMatchAnyKeyword)) == 0) return false; @@ -3322,7 +3329,7 @@ namespace System.Diagnostics.Tracing } // Collect task, opcode, keyword and channel information -#if FEATURE_ADVANCED_MANAGED_ETW_CHANNELS +#if FEATURE_MANAGED_ETW_CHANNELS && FEATURE_ADVANCED_MANAGED_ETW_CHANNELS foreach (var providerEnumKind in new string[] { "Keywords", "Tasks", "Opcodes", "Channels" }) #else foreach (var providerEnumKind in new string[] { "Keywords", "Tasks", "Opcodes" }) @@ -3488,6 +3495,7 @@ namespace System.Diagnostics.Tracing // Do checking for user errors (optional, but not a big deal so we do it). DebugCheckEvent(ref eventsByName, eventData, method, eventAttribute, manifest, flags); +#if FEATURE_MANAGED_ETW_CHANNELS // add the channel keyword for Event Viewer channel based filters. This is added for creating the EventDescriptors only // and is not required for the manifest if (eventAttribute.Channel != EventChannel.None) @@ -3497,6 +3505,7 @@ namespace System.Diagnostics.Tracing eventAttribute.Keywords |= (EventKeywords)manifest.GetChannelKeyword(eventAttribute.Channel, (ulong)eventAttribute.Keywords); } } +#endif string eventKey = "event_" + eventName; string msg = manifest.GetLocalizedMessage(eventKey, CultureInfo.CurrentUICulture, etwFormat: false); // overwrite inline message with the localized message @@ -3514,14 +3523,18 @@ namespace System.Diagnostics.Tracing { TrimEventDescriptors(ref eventData); source.m_eventData = eventData; // officially initialize it. We do this at most once (it is racy otherwise). +#if FEATURE_MANAGED_ETW_CHANNELS source.m_channelData = manifest.GetChannelData(); +#endif } // if this is an abstract event source we've already performed all the validation we can if (!eventSourceType.IsAbstract() && (source == null || !source.SelfDescribingEvents)) { bNeedsManifest = (flags & EventManifestOptions.OnlyIfNeededForRegistration) == 0 +#if FEATURE_MANAGED_ETW_CHANNELS || manifest.GetChannelData().Length > 0 +#endif ; // if the manifest is not needed and we're not requested to validate the event source return early @@ -3603,7 +3616,7 @@ namespace System.Diagnostics.Tracing ulong value = unchecked((ulong)(long)staticField.GetRawConstantValue()); manifest.AddKeyword(staticField.Name, value); } -#if FEATURE_ADVANCED_MANAGED_ETW_CHANNELS +#if FEATURE_MANAGED_ETW_CHANNELS && FEATURE_ADVANCED_MANAGED_ETW_CHANNELS else if (!reflectionOnly && (staticFieldType == typeof(EventChannel)) || AttributeTypeNamesMatch(staticFieldType, typeof(EventChannel))) { if (providerEnumKind != "Channels") goto Error; @@ -3633,7 +3646,11 @@ namespace System.Diagnostics.Tracing eventData[eventAttribute.EventId].Descriptor = new EventDescriptor( eventAttribute.EventId, eventAttribute.Version, +#if FEATURE_MANAGED_ETW_CHANNELS (byte)eventAttribute.Channel, +#else + (byte)0, +#endif (byte)eventAttribute.Level, (byte)eventAttribute.Opcode, (int)eventAttribute.Task, @@ -4053,7 +4070,9 @@ namespace System.Diagnostics.Tracing [ThreadStatic] private static bool m_EventSourceInDecodeObject = false; +#if FEATURE_MANAGED_ETW_CHANNELS internal volatile ulong[] m_channelData; +#endif #if FEATURE_ACTIVITYSAMPLING private SessionMask m_curLiveSessions; // the activity-tracing aware sessions' bits @@ -4875,6 +4894,7 @@ namespace System.Diagnostics.Tracing } +#if FEATURE_MANAGED_ETW_CHANNELS /// /// Gets the channel for the event. /// @@ -4887,6 +4907,7 @@ namespace System.Diagnostics.Tracing return (EventChannel)m_eventSource.m_eventData[EventId].Descriptor.Channel; } } +#endif /// /// Gets the version of the event. @@ -5014,8 +5035,10 @@ namespace System.Diagnostics.Tracing /// Event's task: allows logical grouping of events public EventTask Task { get; set; } +#if FEATURE_MANAGED_ETW_CHANNELS /// Event's channel: defines an event log as an additional destination for the event public EventChannel Channel { get; set; } +#endif /// Event's version public byte Version { get; set; } @@ -5058,6 +5081,7 @@ namespace System.Diagnostics.Tracing } // FUTURE we may want to expose this at some point once we have a partner that can help us validate the design. +#if FEATURE_MANAGED_ETW_CHANNELS /// /// EventChannelAttribute allows customizing channels supported by an EventSource. This attribute must be /// applied to an member of type EventChannel defined in a Channels class nested in the EventSource class: @@ -5153,6 +5177,7 @@ namespace System.Diagnostics.Tracing Custom, } #endif +#endif /// /// Describes the pre-defined command (EventCommandEventArgs.Command property) that is passed to the OnEventCommand callback. @@ -5970,7 +5995,9 @@ namespace System.Diagnostics.Tracing public ManifestBuilder(string providerName, Guid providerGuid, string dllName, ResourceManager resources, EventManifestOptions flags) { +#if FEATURE_MANAGED_ETW_CHANNELS this.providerName = providerName; +#endif this.flags = flags; this.resources = resources; @@ -6052,6 +6079,7 @@ namespace System.Diagnostics.Tracing keywordTab[value] = name; } +#if FEATURE_MANAGED_ETW_CHANNELS /// /// Add a channel. channelAttribute can be null /// @@ -6121,6 +6149,7 @@ namespace System.Diagnostics.Tracing return channelMask; } +#endif public void StartEvent(string eventName, EventAttribute eventAttribute) { Debug.Assert(numParams == 0); @@ -6146,10 +6175,12 @@ namespace System.Diagnostics.Tracing events.Append(" opcode=\"").Append(GetOpcodeName(eventAttribute.Opcode, eventName)).Append("\""); if (eventAttribute.Task != 0) events.Append(" task=\"").Append(GetTaskName(eventAttribute.Task, eventName)).Append("\""); +#if FEATURE_MANAGED_ETW_CHANNELS if (eventAttribute.Channel != 0) { events.Append(" channel=\"").Append(GetChannelName(eventAttribute.Channel, eventName, eventAttribute.Message)).Append("\""); } +#endif } public void AddEventParameter(Type type, string name) @@ -6215,6 +6246,7 @@ namespace System.Diagnostics.Tracing byteArrArgIndices = null; } +#if FEATURE_MANAGED_ETW_CHANNELS // Channel keywords are generated one per channel to allow channel based filtering in event viewer. These keywords are autogenerated // by mc.exe for compiling a manifest and are based on the order of the channels (fields) in the Channels inner class (when advanced // channel support is enabled), or based on the order the predefined channels appear in the EventAttribute properties (for simple @@ -6254,6 +6286,7 @@ namespace System.Diagnostics.Tracing return channelKeyword; } +#endif public byte[] CreateManifest() { @@ -6281,6 +6314,7 @@ namespace System.Diagnostics.Tracing private string CreateManifestString() { +#if FEATURE_MANAGED_ETW_CHANNELS // Write out the channels if (channelTab != null) { @@ -6342,6 +6376,7 @@ namespace System.Diagnostics.Tracing } sb.Append(" ").AppendLine(); } +#endif // Write out the tasks if (taskTab != null) @@ -6564,6 +6599,7 @@ namespace System.Diagnostics.Tracing return (((int)level >= 16) ? "" : "win:") + level.ToString(); } +#if FEATURE_MANAGED_ETW_CHANNELS private string GetChannelName(EventChannel channel, string eventName, string eventMessage) { ChannelInfo info = null; @@ -6592,6 +6628,7 @@ namespace System.Diagnostics.Tracing ManifestError(Resources.GetResourceString("EventSource_EventWithAdminChannelMustHaveMessage", eventName, info.Name)); return info.Name; } +#endif private string GetTaskName(EventTask task, string eventName) { if (task == EventTask.None) @@ -6787,21 +6824,26 @@ namespace System.Diagnostics.Tracing return idx + 1; } +#if FEATURE_MANAGED_ETW_CHANNELS class ChannelInfo { public string Name; public ulong Keywords; public EventChannelAttribute Attribs; } +#endif Dictionary opcodeTab; Dictionary taskTab; +#if FEATURE_MANAGED_ETW_CHANNELS Dictionary channelTab; +#endif Dictionary keywordTab; Dictionary mapsTab; Dictionary stringTab; // Maps unlocalized strings to localized ones +#if FEATURE_MANAGED_ETW_CHANNELS // WCF used EventSource to mimic a existing ETW manifest. To support this // in just their case, we allowed them to specify the keywords associated // with their channels explicitly. ValidPredefinedChannelKeywords is @@ -6810,12 +6852,15 @@ namespace System.Diagnostics.Tracing internal const ulong ValidPredefinedChannelKeywords = 0xF000000000000000; ulong nextChannelKeywordBit = 0x8000000000000000; // available Keyword bit to be used for next channel definition, grows down const int MaxCountChannels = 8; // a manifest can defined at most 8 ETW channels +#endif StringBuilder sb; // Holds the provider information. StringBuilder events; // Holds the events. StringBuilder templates; +#if FEATURE_MANAGED_ETW_CHANNELS string providerName; +#endif ResourceManager resources; // Look up localized strings here. EventManifestOptions flags; IList errors; // list of currently encountered errors diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs index 28a93f4..07a5675 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs @@ -14,6 +14,7 @@ #endif // PLATFORM_UNIX #if ES_BUILD_STANDALONE +#define FEATURE_MANAGED_ETW_CHANNELS // #define FEATURE_ADVANCED_MANAGED_ETW_CHANNELS #endif diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/Winmeta.cs b/src/mscorlib/src/System/Diagnostics/Eventing/Winmeta.cs index d8689b6..c93e745 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/Winmeta.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/Winmeta.cs @@ -10,6 +10,9 @@ ** environment. ** ============================================================*/ +#if ES_BUILD_STANDALONE +#define FEATURE_MANAGED_ETW_CHANNELS +#endif #if ES_BUILD_STANDALONE namespace Microsoft.Diagnostics.Tracing