summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Diagnostics
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2017-06-13 18:47:36 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2017-06-13 18:47:36 +0900
commit61d6a817e39d3bae0f47dbc09838d51db22a5d30 (patch)
treecb37caa1784bc738b976273335d6ed04a7cc80b0 /src/mscorlib/src/System/Diagnostics
parent5b975f8233e8c8d17b215372f89ca713b45d6a0b (diff)
downloadcoreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.gz
coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.bz2
coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.zip
Imported Upstream version 2.0.0.11992upstream/2.0.0.11992
Diffstat (limited to 'src/mscorlib/src/System/Diagnostics')
-rw-r--r--src/mscorlib/src/System/Diagnostics/AssertFilter.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/AssertFilters.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs13
-rw-r--r--src/mscorlib/src/System/Diagnostics/Debug.Unix.cs95
-rw-r--r--src/mscorlib/src/System/Diagnostics/Debugger.cs114
-rw-r--r--src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs3
-rw-r--r--src/mscorlib/src/System/Diagnostics/EditAndContinueHelper.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/EventPipe.cs175
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/EventPipeEventProvider.cs116
-rw-r--r--src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs20
-rw-r--r--src/mscorlib/src/System/Diagnostics/LogSwitch.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/LoggingLevels.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Stackframe.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/Stacktrace.cs2
-rw-r--r--src/mscorlib/src/System/Diagnostics/SymbolStore/SymAddressKind.cs1
-rw-r--r--src/mscorlib/src/System/Diagnostics/log.cs2
16 files changed, 349 insertions, 198 deletions
diff --git a/src/mscorlib/src/System/Diagnostics/AssertFilter.cs b/src/mscorlib/src/System/Diagnostics/AssertFilter.cs
index 7c861de58e..39ce93ff51 100644
--- a/src/mscorlib/src/System/Diagnostics/AssertFilter.cs
+++ b/src/mscorlib/src/System/Diagnostics/AssertFilter.cs
@@ -15,7 +15,6 @@ namespace System.Diagnostics
//
// The default filter brings up a simple Win32 dialog with 3 buttons.
- [Serializable]
abstract internal class AssertFilter
{
// Called when an assert fails. This should be overridden with logic which
diff --git a/src/mscorlib/src/System/Diagnostics/AssertFilters.cs b/src/mscorlib/src/System/Diagnostics/AssertFilters.cs
index 0f34b41dba..a97e8839ae 100644
--- a/src/mscorlib/src/System/Diagnostics/AssertFilters.cs
+++ b/src/mscorlib/src/System/Diagnostics/AssertFilters.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Diagnostics
{
- [Serializable]
internal enum AssertFilters
{
FailDebug = 0,
diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
index 09d1e6baca..d29b860bd1 100644
--- a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
+++ b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs
@@ -186,7 +186,6 @@ namespace System.Diagnostics.Contracts
}
}
- [Serializable]
[SuppressMessage("Microsoft.Design", "CA1064:ExceptionsShouldBePublic")]
internal sealed class ContractException : Exception
{
@@ -218,21 +217,9 @@ namespace System.Diagnostics.Contracts
_Condition = condition;
}
- private ContractException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- _Kind = (ContractFailureKind)info.GetInt32("Kind");
- _UserMessage = info.GetString("UserMessage");
- _Condition = info.GetString("Condition");
- }
-
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
{
base.GetObjectData(info, context);
-
- info.AddValue("Kind", _Kind);
- info.AddValue("UserMessage", _UserMessage);
- info.AddValue("Condition", _Condition);
}
}
}
diff --git a/src/mscorlib/src/System/Diagnostics/Debug.Unix.cs b/src/mscorlib/src/System/Diagnostics/Debug.Unix.cs
deleted file mode 100644
index 495f2f713c..0000000000
--- a/src/mscorlib/src/System/Diagnostics/Debug.Unix.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.Win32.SafeHandles;
-
-namespace System.Diagnostics
-{
- public static partial class Debug
- {
- private static readonly bool s_shouldWriteToStdErr = Environment.GetEnvironmentVariable("COMPlus_DebugWriteToStdErr") == "1";
-
- private static void ShowAssertDialog(string stackTrace, string message, string detailMessage)
- {
- if (Debugger.IsAttached)
- {
- Debugger.Break();
- }
- else
- {
- // In Core, we do not show a dialog.
- // Fail in order to avoid anyone catching an exception and masking
- // an assert failure.
- var ex = new DebugAssertException(message, detailMessage, stackTrace);
- Environment.FailFast(ex.Message, ex);
- }
- }
-
- private static void WriteCore(string message)
- {
- WriteToDebugger(message);
-
- if (s_shouldWriteToStdErr)
- {
- WriteToStderr(message);
- }
- }
-
- private static void WriteToDebugger(string message)
- {
- if (Debugger.IsLogging())
- {
- Debugger.Log(0, null, message);
- }
- else
- {
- Interop.Sys.SysLog(Interop.Sys.SysLogPriority.LOG_USER | Interop.Sys.SysLogPriority.LOG_DEBUG, "%s", message);
- }
- }
-
- private static void WriteToStderr(string message)
- {
- // We don't want to write UTF-16 to a file like standard error. Ideally we would transcode this
- // to UTF8, but the downside of that is it pulls in a bunch of stuff into what is ideally
- // a path with minimal dependencies (as to prevent re-entrency), so we'll take the strategy
- // of just throwing away any non ASCII characters from the message and writing the rest
-
- const int BufferLength = 256;
-
- unsafe
- {
- byte* buf = stackalloc byte[BufferLength];
- int bufCount;
- int i = 0;
-
- while (i < message.Length)
- {
- for (bufCount = 0; bufCount < BufferLength && i < message.Length; i++)
- {
- if (message[i] <= 0x7F)
- {
- buf[bufCount] = (byte)message[i];
- bufCount++;
- }
- }
-
- int totalBytesWritten = 0;
- while (bufCount > 0)
- {
- int bytesWritten = Interop.Sys.Write(2 /* stderr */, buf + totalBytesWritten, bufCount);
- if (bytesWritten < 0)
- {
- // On error, simply stop writing the debug output. This could commonly happen if stderr
- // was piped to a program that ended before this program did, resulting in EPIPE errors.
- return;
- }
-
- bufCount -= bytesWritten;
- totalBytesWritten += bytesWritten;
- }
- }
- }
- }
- }
-}
diff --git a/src/mscorlib/src/System/Diagnostics/Debugger.cs b/src/mscorlib/src/System/Diagnostics/Debugger.cs
index 92df7e7f5f..cda3c4e729 100644
--- a/src/mscorlib/src/System/Diagnostics/Debugger.cs
+++ b/src/mscorlib/src/System/Diagnostics/Debugger.cs
@@ -5,101 +5,63 @@
// The Debugger class is a part of the System.Diagnostics package
// and is used for communicating with a debugger.
-using System;
-using System.IO;
-using System.Collections;
-using System.Reflection;
using System.Runtime.CompilerServices;
-using System.Security;
-using System.Runtime.Versioning;
namespace System.Diagnostics
{
- // No data, does not need to be marked with the serializable attribute
- public sealed class Debugger
+ public static class Debugger
{
- // This should have been a static class, but wasn't as of v3.5. Clearly, this is
- // broken. We'll keep this in V4 for binary compat, but marked obsolete as error
- // so migrated source code gets fixed.
- [Obsolete("Do not create instances of the Debugger class. Call the static methods directly on this type instead", true)]
- public Debugger()
- {
- // Should not have been instantiable - here for binary compatibility in V4.
- }
-
// Break causes a breakpoint to be signalled to an attached debugger. If no debugger
- // is attached, the user is asked if he wants to attach a debugger. If yes, then the
+ // is attached, the user is asked if he wants to attach a debugger. If yes, then the
// debugger is launched.
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
- public static void Break()
- {
- // Causing a break is now allowed.
- BreakInternal();
- }
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void Break() => BreakInternal();
- private static void BreakCanThrow()
- {
- BreakInternal();
- }
+ // The VM depends on this private method.
+ private static void BreakCanThrow() => BreakInternal();
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ [MethodImpl(MethodImplOptions.InternalCall)]
private static extern void BreakInternal();
// Launch launches & attaches a debugger to the process. If a debugger is already attached,
- // nothing happens.
+ // nothing happens.
//
- public static bool Launch()
- {
- if (Debugger.IsAttached)
- return (true);
-
- // Causing the debugger to launch is now allowed.
- return (LaunchInternal());
- }
+ public static bool Launch() => IsAttached ? true : LaunchInternal();
// This class implements code:ICustomDebuggerNotification and provides a type to be used to notify
- // the debugger that execution is about to enter a path that involves a cross-thread dependency.
- // See code:NotifyOfCrossThreadDependency for more details.
- private class CrossThreadDependencyNotification : ICustomDebuggerNotification
- {
- // constructor
- public CrossThreadDependencyNotification()
- {
- }
- }
-
- // Do not inline the slow path
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
- private static void NotifyOfCrossThreadDependencySlow()
- {
- CrossThreadDependencyNotification notification = new CrossThreadDependencyNotification();
- CustomNotification(notification);
- }
-
- // Sends a notification to the debugger to indicate that execution is about to enter a path
- // involving a cross thread dependency. A debugger that has opted into this type of notification
- // can take appropriate action on receipt. For example, performing a funceval normally requires
- // freezing all threads but the one performing the funceval. If the funceval requires execution on
- // more than one thread, as might occur in remoting scenarios, the funceval will block. This
- // notification will apprise the debugger that it will need to slip a thread or abort the funceval
- // in such a situation. The notification is subject to collection after this function returns.
- //
+ // the debugger that execution is about to enter a path that involves a cross-thread dependency.
+ // See code:NotifyOfCrossThreadDependency for more details.
+ private class CrossThreadDependencyNotification : ICustomDebuggerNotification { }
+
+ // Do not inline the slow path
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void NotifyOfCrossThreadDependencySlow() =>
+ CustomNotification(new CrossThreadDependencyNotification());
+
+ // Sends a notification to the debugger to indicate that execution is about to enter a path
+ // involving a cross thread dependency. A debugger that has opted into this type of notification
+ // can take appropriate action on receipt. For example, performing a funceval normally requires
+ // freezing all threads but the one performing the funceval. If the funceval requires execution on
+ // more than one thread, as might occur in remoting scenarios, the funceval will block. This
+ // notification will apprise the debugger that it will need to slip a thread or abort the funceval
+ // in such a situation. The notification is subject to collection after this function returns.
+ //
public static void NotifyOfCrossThreadDependency()
{
- if (Debugger.IsAttached)
+ if (IsAttached)
{
NotifyOfCrossThreadDependencySlow();
}
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ [MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool LaunchInternal();
// Returns whether or not a debugger is attached to the process.
//
public static extern bool IsAttached
{
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ [MethodImpl(MethodImplOptions.InternalCall)]
get;
}
@@ -108,26 +70,26 @@ namespace System.Diagnostics
// An attached debugger can enable or disable which messages will
// actually be reported to the user through the COM+ debugger
// services API. This info is communicated to the runtime so only
- // desired events are actually reported to the debugger.
+ // desired events are actually reported to the debugger.
//
// Constant representing the default category
- public static readonly String DefaultCategory = null;
+ public static readonly string DefaultCategory = null;
// Posts a message for the attached debugger. If there is no
// debugger attached, has no effect. The debugger may or may not
- // report the message depending on its settings.
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern void Log(int level, String category, String message);
+ // report the message depending on its settings.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern void Log(int level, string category, string message);
// Checks to see if an attached debugger has logging enabled
- //
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ //
+ [MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool IsLogging();
// Posts a custom notification for the attached debugger. If there is no
// debugger attached, has no effect. The debugger may or may not
- // report the notification depending on its settings.
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ // report the notification depending on its settings.
+ [MethodImpl(MethodImplOptions.InternalCall)]
private static extern void CustomNotification(ICustomDebuggerNotification data);
}
}
diff --git a/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs b/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
index 5e1dfd82a5..34e65bcb3e 100644
--- a/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
+++ b/src/mscorlib/src/System/Diagnostics/DebuggerAttributes.cs
@@ -18,21 +18,18 @@ using System.Diagnostics.Contracts;
namespace System.Diagnostics
{
- [Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
public sealed class DebuggerStepThroughAttribute : Attribute
{
public DebuggerStepThroughAttribute() { }
}
- [Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false)]
public sealed class DebuggerHiddenAttribute : Attribute
{
public DebuggerHiddenAttribute() { }
}
- [Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor | AttributeTargets.Struct, Inherited = false)]
public sealed class DebuggerNonUserCodeAttribute : Attribute
{
diff --git a/src/mscorlib/src/System/Diagnostics/EditAndContinueHelper.cs b/src/mscorlib/src/System/Diagnostics/EditAndContinueHelper.cs
index 8ad4fec082..6b8c150ab8 100644
--- a/src/mscorlib/src/System/Diagnostics/EditAndContinueHelper.cs
+++ b/src/mscorlib/src/System/Diagnostics/EditAndContinueHelper.cs
@@ -16,7 +16,6 @@ using System;
namespace System.Diagnostics
{
- [Serializable]
internal sealed class EditAndContinueHelper
{
#pragma warning disable 169
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventPipe.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventPipe.cs
new file mode 100644
index 0000000000..2f6fdf62ef
--- /dev/null
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventPipe.cs
@@ -0,0 +1,175 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Security;
+using Microsoft.Win32;
+
+namespace System.Diagnostics.Tracing
+{
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct EventPipeProviderConfiguration
+ {
+ [MarshalAs(UnmanagedType.LPWStr)]
+ private string m_providerName;
+ private UInt64 m_keywords;
+ private uint m_loggingLevel;
+
+ internal EventPipeProviderConfiguration(
+ string providerName,
+ UInt64 keywords,
+ uint loggingLevel)
+ {
+ if(string.IsNullOrEmpty(providerName))
+ {
+ throw new ArgumentNullException(nameof(providerName));
+ }
+ if(loggingLevel > 5) // 5 == Verbose, the highest value in EventPipeLoggingLevel.
+ {
+ throw new ArgumentOutOfRangeException(nameof(loggingLevel));
+ }
+ m_providerName = providerName;
+ m_keywords = keywords;
+ m_loggingLevel = loggingLevel;
+ }
+
+ internal string ProviderName
+ {
+ get { return m_providerName; }
+ }
+
+ internal UInt64 Keywords
+ {
+ get { return m_keywords; }
+ }
+
+ internal uint LoggingLevel
+ {
+ get { return m_loggingLevel; }
+ }
+ }
+
+ internal sealed class EventPipeConfiguration
+ {
+ private string m_outputFile;
+ private uint m_circularBufferSizeInMB;
+ private List<EventPipeProviderConfiguration> m_providers;
+ private TimeSpan m_minTimeBetweenSamples = TimeSpan.FromMilliseconds(1);
+
+ internal EventPipeConfiguration(
+ string outputFile,
+ uint circularBufferSizeInMB)
+ {
+ if(string.IsNullOrEmpty(outputFile))
+ {
+ throw new ArgumentNullException(nameof(outputFile));
+ }
+ if(circularBufferSizeInMB == 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(circularBufferSizeInMB));
+ }
+ m_outputFile = outputFile;
+ m_circularBufferSizeInMB = circularBufferSizeInMB;
+ m_providers = new List<EventPipeProviderConfiguration>();
+ }
+
+ internal string OutputFile
+ {
+ get { return m_outputFile; }
+ }
+
+ internal uint CircularBufferSizeInMB
+ {
+ get { return m_circularBufferSizeInMB; }
+ }
+
+ internal EventPipeProviderConfiguration[] Providers
+ {
+ get { return m_providers.ToArray(); }
+ }
+
+ internal long ProfilerSamplingRateInNanoseconds
+ {
+ // 100 nanoseconds == 1 tick.
+ get { return m_minTimeBetweenSamples.Ticks * 100; }
+ }
+
+ internal void EnableProvider(string providerName, UInt64 keywords, uint loggingLevel)
+ {
+ m_providers.Add(new EventPipeProviderConfiguration(
+ providerName,
+ keywords,
+ loggingLevel));
+ }
+
+ internal void SetProfilerSamplingRate(TimeSpan minTimeBetweenSamples)
+ {
+ if(minTimeBetweenSamples.Ticks <= 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(minTimeBetweenSamples));
+ }
+
+ m_minTimeBetweenSamples = minTimeBetweenSamples;
+ }
+ }
+
+ internal static class EventPipe
+ {
+ internal static void Enable(EventPipeConfiguration configuration)
+ {
+ if(configuration == null)
+ {
+ throw new ArgumentNullException(nameof(configuration));
+ }
+
+ EventPipeProviderConfiguration[] providers = configuration.Providers;
+
+ EventPipeInternal.Enable(
+ configuration.OutputFile,
+ configuration.CircularBufferSizeInMB,
+ configuration.ProfilerSamplingRateInNanoseconds,
+ providers,
+ providers.Length);
+ }
+
+ internal static void Disable()
+ {
+ EventPipeInternal.Disable();
+ }
+ }
+
+ internal static class EventPipeInternal
+ {
+ //
+ // These PInvokes are used by the configuration APIs to interact with EventPipe.
+ //
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern void Enable(string outputFile, uint circularBufferSizeInMB, long profilerSamplingRateInNanoseconds, EventPipeProviderConfiguration[] providers, int numProviders);
+
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern void Disable();
+
+ //
+ // These PInvokes are used by EventSource to interact with the EventPipe.
+ //
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern IntPtr CreateProvider(Guid providerID, UnsafeNativeMethods.ManifestEtw.EtwEnableCallback callbackFunc);
+
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern unsafe IntPtr DefineEvent(IntPtr provHandle, uint eventID, Int64 keywords, uint eventVersion, uint level, void *pMetadata, uint metadataLength);
+
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern void DeleteProvider(IntPtr provHandle);
+
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern unsafe void WriteEvent(IntPtr eventHandle, uint eventID, void* pData, uint length, Guid* activityId, Guid* relatedActivityId);
+ }
+}
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventPipeEventProvider.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventPipeEventProvider.cs
new file mode 100644
index 0000000000..d5bc4c2889
--- /dev/null
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventPipeEventProvider.cs
@@ -0,0 +1,116 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System.Collections.Concurrent;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Security;
+using Microsoft.Win32;
+using System.Diagnostics;
+using System.Collections.Generic;
+
+namespace System.Diagnostics.Tracing
+{
+ internal sealed class EventPipeEventProvider : IEventProvider
+ {
+ // The EventPipeProvider handle.
+ private IntPtr m_provHandle = IntPtr.Zero;
+
+ // Register an event provider.
+ unsafe uint IEventProvider.EventRegister(
+ ref Guid providerId,
+ UnsafeNativeMethods.ManifestEtw.EtwEnableCallback enableCallback,
+ void* callbackContext,
+ ref long registrationHandle)
+ {
+ uint returnStatus = 0;
+ m_provHandle = EventPipeInternal.CreateProvider(providerId, enableCallback);
+ if(m_provHandle != IntPtr.Zero)
+ {
+ // Fixed registration handle because a new EventPipeEventProvider
+ // will be created for each new EventSource.
+ registrationHandle = 1;
+ }
+ else
+ {
+ // Unable to create the provider.
+ returnStatus = 1;
+ }
+
+ return returnStatus;
+ }
+
+ // Unregister an event provider.
+ uint IEventProvider.EventUnregister(long registrationHandle)
+ {
+ EventPipeInternal.DeleteProvider(m_provHandle);
+ return 0;
+ }
+
+ // Write an event.
+ unsafe int IEventProvider.EventWriteTransferWrapper(
+ long registrationHandle,
+ ref EventDescriptor eventDescriptor,
+ IntPtr eventHandle,
+ Guid* activityId,
+ Guid* relatedActivityId,
+ int userDataCount,
+ EventProvider.EventData* userData)
+ {
+ uint eventID = (uint)eventDescriptor.EventId;
+ if(eventID != 0 && eventHandle != IntPtr.Zero)
+ {
+ if (userDataCount == 0)
+ {
+ EventPipeInternal.WriteEvent(eventHandle, eventID, null, 0, activityId, relatedActivityId);
+ return 0;
+ }
+
+ uint length = 0;
+ for (int i = 0; i < userDataCount; i++)
+ {
+ length += userData[i].Size;
+ }
+
+ byte[] data = new byte[length];
+ fixed (byte *pData = data)
+ {
+ uint offset = 0;
+ for (int i = 0; i < userDataCount; i++)
+ {
+ byte * singleUserDataPtr = (byte *)(userData[i].Ptr);
+ uint singleUserDataSize = userData[i].Size;
+ WriteToBuffer(pData, length, ref offset, singleUserDataPtr, singleUserDataSize);
+ }
+ EventPipeInternal.WriteEvent(eventHandle, eventID, pData, length, activityId, relatedActivityId);
+ }
+ }
+ return 0;
+ }
+
+ // Get or set the per-thread activity ID.
+ int IEventProvider.EventActivityIdControl(UnsafeNativeMethods.ManifestEtw.ActivityControl ControlCode, ref Guid ActivityId)
+ {
+ return 0;
+ }
+
+ // Define an EventPipeEvent handle.
+ unsafe IntPtr IEventProvider.DefineEventHandle(uint eventID, string eventName, Int64 keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength)
+ {
+ IntPtr eventHandlePtr = EventPipeInternal.DefineEvent(m_provHandle, eventID, keywords, eventVersion, level, pMetadata, metadataLength);
+ return eventHandlePtr;
+ }
+
+ // Copy src to buffer and modify the offset.
+ // Note: We know the buffer size ahead of time to make sure no buffer overflow.
+ private static unsafe void WriteToBuffer(byte *buffer, uint bufferLength, ref uint offset, byte *src, uint srcLength)
+ {
+ Debug.Assert(bufferLength >= (offset + srcLength));
+ for (int i = 0; i < srcLength; i++)
+ {
+ *(byte *)(buffer + offset + i) = *(byte *)(src + i);
+ }
+ offset += srcLength;
+ }
+ }
+}
diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs
index b691dd38b9..01aac72cf6 100644
--- a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs
+++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs
@@ -11,6 +11,13 @@ namespace System.Diagnostics.Tracing
{
public partial class EventSource
{
+#if FEATURE_MANAGED_ETW && FEATURE_PERFTRACING
+ // For non-Windows, we use a thread-local variable to hold the activity ID.
+ // On Windows, ETW has it's own thread-local variable and we participate in its use.
+ [ThreadStatic]
+ private static Guid s_currentThreadActivityId;
+#endif // FEATURE_MANAGED_ETW && FEATURE_PERFTRACING
+
// ActivityID support (see also WriteEventWithRelatedActivityIdCore)
/// <summary>
/// When a thread starts work that is on behalf of 'something else' (typically another
@@ -40,9 +47,13 @@ namespace System.Diagnostics.Tracing
// We ignore errors to keep with the convention that EventSources do not throw errors.
// Note we can't access m_throwOnWrites because this is a static method.
+#if FEATURE_PERFTRACING
+ s_currentThreadActivityId = activityId;
+#elif PLATFORM_WINDOWS
if (UnsafeNativeMethods.ManifestEtw.EventActivityIdControl(
UnsafeNativeMethods.ManifestEtw.ActivityControl.EVENT_ACTIVITY_CTRL_GET_SET_ID,
ref activityId) == 0)
+#endif // FEATURE_PERFTRACING
{
#if FEATURE_ACTIVITYSAMPLING
var activityDying = s_activityDying;
@@ -86,9 +97,14 @@ namespace System.Diagnostics.Tracing
// We ignore errors to keep with the convention that EventSources do not throw errors.
// Note we can't access m_throwOnWrites because this is a static method.
+#if FEATURE_PERFTRACING
+ oldActivityThatWillContinue = s_currentThreadActivityId;
+ s_currentThreadActivityId = activityId;
+#elif PLATFORM_WINDOWS
UnsafeNativeMethods.ManifestEtw.EventActivityIdControl(
UnsafeNativeMethods.ManifestEtw.ActivityControl.EVENT_ACTIVITY_CTRL_GET_SET_ID,
ref oldActivityThatWillContinue);
+#endif // FEATURE_PERFTRACING
#endif // FEATURE_MANAGED_ETW
// We don't call the activityDying callback here because the caller has declared that
@@ -108,9 +124,13 @@ namespace System.Diagnostics.Tracing
// errors. Note we can't access m_throwOnWrites because this is a static method.
Guid retVal = new Guid();
#if FEATURE_MANAGED_ETW
+#if FEATURE_PERFTRACING
+ retVal = s_currentThreadActivityId;
+#elif PLATFORM_WINDOWS
UnsafeNativeMethods.ManifestEtw.EventActivityIdControl(
UnsafeNativeMethods.ManifestEtw.ActivityControl.EVENT_ACTIVITY_CTRL_GET_ID,
ref retVal);
+#endif // FEATURE_PERFTRACING
#endif // FEATURE_MANAGED_ETW
return retVal;
}
diff --git a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs
index 29d6a1d4e6..d3994d48b8 100644
--- a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs
+++ b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs
@@ -11,7 +11,6 @@ using System.Diagnostics.CodeAnalysis;
namespace System.Diagnostics
{
- [Serializable]
internal class LogSwitch
{
// ! WARNING !
diff --git a/src/mscorlib/src/System/Diagnostics/LoggingLevels.cs b/src/mscorlib/src/System/Diagnostics/LoggingLevels.cs
index 6b5ea85ee1..22d6c95a97 100644
--- a/src/mscorlib/src/System/Diagnostics/LoggingLevels.cs
+++ b/src/mscorlib/src/System/Diagnostics/LoggingLevels.cs
@@ -21,7 +21,6 @@ namespace System.Diagnostics
// Constants representing the importance level of messages to be logged.
// This level can be used to organize messages, and also to filter which
// messages are displayed.
- [Serializable]
internal enum LoggingLevels
{
TraceLevel0 = 0,
diff --git a/src/mscorlib/src/System/Diagnostics/Stackframe.cs b/src/mscorlib/src/System/Diagnostics/Stackframe.cs
index b555a609e7..a6a7067af3 100644
--- a/src/mscorlib/src/System/Diagnostics/Stackframe.cs
+++ b/src/mscorlib/src/System/Diagnostics/Stackframe.cs
@@ -12,7 +12,6 @@ using System.Diagnostics.Contracts;
namespace System.Diagnostics
{
// There is no good reason for the methods of this class to be virtual.
- [Serializable]
public class StackFrame
{
private MethodBase method;
diff --git a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
index cdedb66ed8..6a138de327 100644
--- a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
+++ b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
@@ -22,7 +22,6 @@ namespace System.Diagnostics
// Modifying the order or fields of this object may require other changes
// to the unmanaged definition of the StackFrameHelper class, in
// VM\DebugDebugger.h. The binder will catch some of these layout problems.
- [Serializable]
internal class StackFrameHelper : IDisposable
{
[NonSerialized]
@@ -251,7 +250,6 @@ namespace System.Diagnostics
// In order to ensure trusted code can trust the data it gets from a
// StackTrace, we use an InheritanceDemand to prevent partially-trusted
// subclasses.
- [Serializable]
public class StackTrace
{
private StackFrame[] frames;
diff --git a/src/mscorlib/src/System/Diagnostics/SymbolStore/SymAddressKind.cs b/src/mscorlib/src/System/Diagnostics/SymbolStore/SymAddressKind.cs
index c4c1ede525..15b3c7f4f7 100644
--- a/src/mscorlib/src/System/Diagnostics/SymbolStore/SymAddressKind.cs
+++ b/src/mscorlib/src/System/Diagnostics/SymbolStore/SymAddressKind.cs
@@ -17,7 +17,6 @@ using System;
namespace System.Diagnostics.SymbolStore
{
- [Serializable]
internal enum SymAddressKind
{
// ILOffset: addr1 = IL local var or param index.
diff --git a/src/mscorlib/src/System/Diagnostics/log.cs b/src/mscorlib/src/System/Diagnostics/log.cs
index b62ea493e7..5ed3a3e502 100644
--- a/src/mscorlib/src/System/Diagnostics/log.cs
+++ b/src/mscorlib/src/System/Diagnostics/log.cs
@@ -4,7 +4,6 @@
namespace System.Diagnostics
{
- using System.Runtime.Remoting;
using System;
using System.IO;
using System.Collections;
@@ -20,7 +19,6 @@ namespace System.Diagnostics
// NOTE: These are NOT triggered when the log switch setting is changed from the
// attached debugger.
//
- [Serializable]
internal delegate void LogSwitchLevelHandler(LogSwitch ls, LoggingLevels newLevel);