Fixing tracelogging on linux
authorDavid Mason <davmason@microsoft.com>
Fri, 25 Mar 2016 18:26:33 +0000 (11:26 -0700)
committerDavid Mason <davmason@microsoft.com>
Fri, 25 Mar 2016 19:52:24 +0000 (12:52 -0700)
src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventSource.cs

index 2fde223..95cadbc 100644 (file)
@@ -5,11 +5,13 @@
 // This program uses code hyperlinks available as part of the HyperAddin Visual Studio plug-in.
 // It is available from http://www.codeplex.com/hyperAddin 
 
+#if !PLATFORM_UNIX
 #define FEATURE_MANAGED_ETW
 
 #if !ES_BUILD_STANDALONE
 #define FEATURE_ACTIVITYSAMPLING
 #endif
+#endif // PLATFORM_UNIX
 
 #if ES_BUILD_STANDALONE
 #define FEATURE_MANAGED_ETW_CHANNELS
@@ -44,7 +46,9 @@ namespace System.Diagnostics.Tracing
 {
     public partial class EventSource
     {
+#if FEATURE_MANAGED_ETW
         private byte[] providerMetadata;
+#endif
 
         /// <summary>
         /// Construct an EventSource with a given name for non-contract based events (e.g. those using the Write() API).
@@ -420,6 +424,7 @@ namespace System.Diagnostics.Tracing
             Guid* childActivityID,
             params object[] values)
         {
+#if FEATURE_MANAGED_ETW
             int identity = 0;
             byte level = (options.valuesSet & EventSourceOptions.levelSet) != 0
                 ? options.level
@@ -488,7 +493,7 @@ namespace System.Diagnostics.Tracing
                     this.WriteCleanup(pins, pinCount);
                 }
             }
-
+#endif // FEATURE_MANAGED_ETW
         }
 
         /// <summary>
@@ -530,6 +535,7 @@ namespace System.Diagnostics.Tracing
             Guid* childActivityID,
             EventData* data)
         {
+#if FEATURE_MANAGED_ETW
             if (!this.IsEnabled())
             {
                 return;
@@ -595,6 +601,7 @@ namespace System.Diagnostics.Tracing
                         (IntPtr)descriptors);
                 }
             }
+#endif // FEATURE_MANAGED_ETW
         }
 
         [SecuritySafeCritical]
@@ -618,6 +625,7 @@ namespace System.Diagnostics.Tracing
                         return;
                     }
 
+#if FEATURE_MANAGED_ETW
                     var pinCount = eventTypes.pinCount;
                     var scratch = stackalloc byte[eventTypes.scratchSize];
                     var descriptors = stackalloc EventData[eventTypes.dataCount + 3];
@@ -631,6 +639,7 @@ namespace System.Diagnostics.Tracing
                         descriptors[0].SetMetadata(pMetadata0, this.providerMetadata.Length, 2);
                         descriptors[1].SetMetadata(pMetadata1, nameInfo.nameMetadata.Length, 1);
                         descriptors[2].SetMetadata(pMetadata2, eventTypes.typeMetadata.Length, 1);
+#endif // FEATURE_MANAGED_ETW
 
 #if (!ES_BUILD_PCL && !PROJECTN)
                         System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
@@ -658,6 +667,7 @@ namespace System.Diagnostics.Tracing
 
                         try
                         {
+#if FEATURE_MANAGED_ETW
                             DataCollector.ThreadInstance.Enable(
                                 scratch,
                                 eventTypes.scratchSize,
@@ -676,6 +686,7 @@ namespace System.Diagnostics.Tracing
                                 pRelatedActivityId,
                                 (int)(DataCollector.ThreadInstance.Finish() - descriptors),
                                 (IntPtr)descriptors);
+#endif // FEATURE_MANAGED_ETW
 
                             // TODO enable filtering for listeners.
                             if (m_Dispatchers != null)
@@ -692,11 +703,13 @@ namespace System.Diagnostics.Tracing
                             else
                                 ThrowEventSourceException(eventName, ex);
                         }
+#if FEATURE_MANAGED_ETW
                         finally
                         {
                             this.WriteCleanup(pins, pinCount);
                         }
                     }
+#endif // FEATURE_MANAGED_ETW
                 }
             }
             catch (Exception ex)
@@ -754,6 +767,7 @@ namespace System.Diagnostics.Tracing
 
         private void InitializeProviderMetadata()
         {
+#if FEATURE_MANAGED_ETW
             if (m_traits != null)
             {
                 List<byte> traitMetaData = new List<byte>(100);
@@ -791,6 +805,7 @@ namespace System.Diagnostics.Tracing
             }
             else
                 providerMetadata = Statics.MetadataForString(this.Name, 0, 0, 0);
+#endif //FEATURE_MANAGED_ETW
         }
 
         private static int AddValueToMetaData(List<byte> metaData, string value)