Revert `Remove FEATURE_MANAGED_ETW_CHANNELS`
authordanmosemsft <danmose@microsoft.com>
Fri, 27 Jan 2017 23:19:04 +0000 (15:19 -0800)
committerdanmosemsft <danmose@microsoft.com>
Fri, 27 Jan 2017 23:24:47 +0000 (15:24 -0800)
clr.coreclr.props
clr.defines.targets
src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs
src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs
src/mscorlib/src/System/Diagnostics/Eventing/Winmeta.cs

index ed5dd1a..9211976 100644 (file)
@@ -50,6 +50,7 @@
     <!-- The rejit feature is available only on supported architectures (x86 & x64) -->
     <FeatureReJIT Condition="('$(TargetArch)' == 'i386') or ('$(TargetArch)' == 'amd64')">true</FeatureReJIT>
     <FeatureManagedEtw>true</FeatureManagedEtw>
+    <FeatureManagedEtwChannels>true</FeatureManagedEtwChannels>
     <BinderDebugLog Condition="'$(_BuildType)'=='dbg'">true</BinderDebugLog>
     <FeatureAppX>true</FeatureAppX>
     <FeatureWinMDResilient>true</FeatureWinMDResilient>
index c3bb70d..689fa06 100644 (file)
@@ -40,6 +40,7 @@
         <CDefines Condition="'$(FeatureLegacyNetCFDbgHostControl)' == 'true'">$(CDefines);FEATURE_LEGACYNETCF_DBG_HOST_CONTROL</CDefines> 
         <CDefines Condition="'$(FeatureMacl)' == 'true'">$(CDefines);FEATURE_MACL</CDefines>
         <CDefines Condition="'$(FeatureManagedEtw)' == 'true'">$(CDefines);FEATURE_MANAGED_ETW</CDefines>
+        <CDefines Condition="'$(FeatureManagedEtwChannels)' == 'true'">$(CDefines);FEATURE_MANAGED_ETW_CHANNELS</CDefines>
         <CDefines Condition="'$(FeatureMdaSupported)' == 'true'">$(CDefines);MDA_SUPPORTED</CDefines>
         <CDefines Condition="'$(FeatureMergeCultureSupportAndEngine)' == 'true'">$(CDefines);FEATURE_MERGE_CULTURE_SUPPORT_AND_ENGINE</CDefines>
         <CDefines Condition="'$(FeatureMergeJitAndEngine)' == 'true'">$(CDefines);FEATURE_MERGE_JIT_AND_ENGINE</CDefines>
         <DefineConstants Condition="'$(FeatureIsostoreLight)' == 'true'">$(DefineConstants);FEATURE_ISOSTORE_LIGHT</DefineConstants>
         <DefineConstants Condition="'$(FeatureMacl)' == 'true'">$(DefineConstants);FEATURE_MACL</DefineConstants>
         <DefineConstants Condition="'$(FeatureManagedEtw)' == 'true'">$(DefineConstants);FEATURE_MANAGED_ETW</DefineConstants>
+        <DefineConstants Condition="'$(FeatureManagedEtwChannels)' == 'true'">$(DefineConstants);FEATURE_MANAGED_ETW_CHANNELS</DefineConstants>
         <DefineConstants Condition="'$(FeatureMultiModuleAssemblies)' == 'true'">$(DefineConstants);FEATURE_MULTIMODULE_ASSEMBLIES</DefineConstants>
         <DefineConstants Condition="'$(FeatureNongenericCollections)' == 'true'">$(DefineConstants);FEATURE_NONGENERIC_COLLECTIONS</DefineConstants>
         <DefineConstants Condition="'$(FeaturePal)' == 'true'">$(DefineConstants);FEATURE_PAL</DefineConstants>
index dc2c2b6..405fbb2 100644 (file)
@@ -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
         /// <summary>
         /// Gets the channel for the event.
         /// </summary>
@@ -4887,6 +4907,7 @@ namespace System.Diagnostics.Tracing
                 return (EventChannel)m_eventSource.m_eventData[EventId].Descriptor.Channel;
             }
         }
+#endif
 
         /// <summary>
         /// Gets the version of the event.
@@ -5014,8 +5035,10 @@ namespace System.Diagnostics.Tracing
 
         /// <summary>Event's task: allows logical grouping of events</summary>
         public EventTask Task { get; set; }
+#if FEATURE_MANAGED_ETW_CHANNELS
         /// <summary>Event's channel: defines an event log as an additional destination for the event</summary>
         public EventChannel Channel { get; set; }
+#endif
         /// <summary>Event's version</summary>
         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
     /// <summary>
     /// 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
 
     /// <summary>
     /// 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
         /// <summary>
         /// Add a channel.  channelAttribute can be null
         /// </summary>
@@ -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(" </channels>").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<int, string> opcodeTab;
         Dictionary<int, string> taskTab;
+#if FEATURE_MANAGED_ETW_CHANNELS
         Dictionary<int, ChannelInfo> channelTab;
+#endif
         Dictionary<ulong, string> keywordTab;
         Dictionary<string, Type> mapsTab;
 
         Dictionary<string, string> 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<string> errors;           // list of currently encountered errors
index d8689b6..c93e745 100644 (file)
@@ -10,6 +10,9 @@
 ** environment.
 ** 
 ============================================================*/
+#if ES_BUILD_STANDALONE
+#define FEATURE_MANAGED_ETW_CHANNELS
+#endif
 
 #if ES_BUILD_STANDALONE
 namespace Microsoft.Diagnostics.Tracing