Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,25 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: ICustomDebuggerNotification
**
** This interface is implemented by classes that support custom debugger notifications.
**
===========================================================*/
namespace System.Diagnostics {
using System;
// Defines an interface indicating that a custom debugger notification is requested under specific
// conditions. Users should implement this interface to be used as an argument to
// System.Diagnostics.Debugger.CustomNotification.
//
// @dbgtodo [....]: when this goes public, it must be replaced by a custom attribute
internal interface ICustomDebuggerNotification
{
// Interface does not need to be marked with the serializable attribute
}
}

View File

@@ -0,0 +1,127 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Diagnostics {
using System;
using System.Security.Permissions;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
// Class which handles code asserts. Asserts are used to explicitly protect
// assumptions made in the code. In general if an assert fails, it indicates
// a program bug so is immediately called to the attention of the user.
// Only static data members, does not need to be marked with the serializable attribute
internal static class Assert
{
internal const int COR_E_FAILFAST = unchecked((int) 0x80131623);
private static AssertFilter Filter;
static Assert()
{
Filter = new DefaultFilter();
}
// Called when an assertion is being made.
//
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
internal static void Check(bool condition, String conditionString, String message)
{
if (!condition)
{
Fail (conditionString, message, null, COR_E_FAILFAST);
}
}
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
internal static void Check(bool condition, String conditionString, String message, int exitCode)
{
if (!condition)
{
Fail(conditionString, message, null, exitCode);
}
}
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
internal static void Fail(String conditionString, String message)
{
Fail(conditionString, message, null, COR_E_FAILFAST);
}
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Process)]
internal static void Fail(String conditionString, String message, String windowTitle, int exitCode)
{
Fail(conditionString, message, windowTitle, exitCode, StackTrace.TraceFormat.Normal, 0);
}
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Process)]
internal static void Fail(String conditionString, String message, int exitCode, StackTrace.TraceFormat stackTraceFormat)
{
Fail(conditionString, message, null, exitCode, stackTraceFormat, 0);
}
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Process)]
internal static void Fail(String conditionString, String message, String windowTitle, int exitCode, StackTrace.TraceFormat stackTraceFormat, int numStackFramesToSkip)
{
// get the stacktrace
StackTrace st = new StackTrace(numStackFramesToSkip, true);
AssertFilters iResult = Filter.AssertFailure (conditionString, message, st, stackTraceFormat, windowTitle);
if (iResult == AssertFilters.FailDebug)
{
if (Debugger.IsAttached == true)
Debugger.Break();
else
{
if (Debugger.Launch() == false)
{
throw new InvalidOperationException(
Environment.GetResourceString("InvalidOperation_DebuggerLaunchFailed"));
}
}
}
else if (iResult == AssertFilters.FailTerminate)
{
#if FEATURE_CORECLR
// We want to exit the Silverlight application, after displaying a message.
// Our best known way to emulate this is to exit the process with a known
// error code. Jolt may not be prepared for an appdomain to be unloaded.
Environment._Exit(exitCode);
#else
// This assert dialog will be common for code contract failures. If a code contract failure
// occurs on an end user machine, we believe the right experience is to do a FailFast, which
// will report this error via Watson, so someone could theoretically fix the bug.
// However, in CLR v4, Environment.FailFast when a debugger is attached gives you an MDA
// saying you've hit a bug in the runtime or unsafe managed code, and this is most likely caused
// by heap corruption or a stack imbalance from COM Interop or P/Invoke. That extremely
// misleading error isn't right, and we can temporarily work around this by using Environment.Exit
// if a debugger is attached. The right fix is to plumb FailFast correctly through our native
// Watson code, adding in a TypeOfReportedError for fatal managed errors.
if (Debugger.IsAttached)
Environment._Exit(exitCode);
else
Environment.FailFast(message, unchecked((uint) exitCode));
#endif
}
}
// Called when an assert happens.
// windowTitle can be null.
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Process)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static int ShowDefaultAssertDialog(String conditionString, String message, String stackTrace, String windowTitle);
}
}

View File

@@ -0,0 +1,49 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Diagnostics {
using System;
using System.Runtime.Versioning;
// A Filter is used to decide whether an assert failure
// should terminate the program (or invoke the debugger).
// Typically this is done by popping up a dialog & asking the user.
//
// 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
// determines whether the program should terminate or not. Typically this
// is done by asking the user.
//
// The windowTitle can be null.
abstract public AssertFilters AssertFailure(String condition, String message,
StackTrace location, StackTrace.TraceFormat stackTraceFormat, String windowTitle);
}
// No data, does not need to be marked with the serializable attribute
internal class DefaultFilter : AssertFilter
{
internal DefaultFilter()
{
}
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Process)]
public override AssertFilters AssertFailure(String condition, String message,
StackTrace location, StackTrace.TraceFormat stackTraceFormat,
String windowTitle)
{
return (AssertFilters) Assert.ShowDefaultAssertDialog (condition, message, location.ToString(stackTraceFormat), windowTitle);
}
}
}

View File

@@ -0,0 +1,25 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Diagnostics {
/*
* FailDebug indicates the debugger should be invoked
* FailIgnore indicates the failure should be ignored & the
* program continued
* FailTerminate indicates that the program should be terminated
* FailContinue indicates that no decision is made -
* the previous Filter should be invoked
*/
using System;
[Serializable]
internal enum AssertFilters
{
FailDebug = 0,
FailIgnore = 1,
FailTerminate = 2,
FailContinueFilter = 3,
}
}

View File

@@ -0,0 +1,78 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: SuppressMessageAttribute
**
**
** An attribute to suppress violation messages/warnings
** by static code analysis tools.
**
**
===========================================================*/
using System;
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(
AttributeTargets.All,
Inherited = false,
AllowMultiple = true
)
]
[Conditional("CODE_ANALYSIS")]
public sealed class SuppressMessageAttribute : Attribute
{
private string category;
private string justification;
private string checkId;
private string scope;
private string target;
private string messageId;
public SuppressMessageAttribute(string category, string checkId)
{
this.category = category;
this.checkId = checkId;
}
public string Category
{
get { return category; }
}
public string CheckId
{
get { return checkId; }
}
public string Scope
{
get { return scope; }
set { scope = value; }
}
public string Target
{
get { return target; }
set { target = value; }
}
public string MessageId
{
get { return messageId; }
set { messageId = value; }
}
public string Justification
{
get { return justification; }
set { justification = value; }
}
}
}

View File

@@ -0,0 +1,27 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
using System;
namespace System.Diagnostics {
[Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple=true)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ConditionalAttribute : Attribute
{
public ConditionalAttribute(String conditionString)
{
m_conditionString = conditionString;
}
public String ConditionString {
get {
return m_conditionString;
}
}
private String m_conditionString;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,208 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// The Debugger class is a part of the System.Diagnostics package
// and is used for communicating with a debugger.
namespace System.Diagnostics
{
using System;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Runtime.Versioning;
// No data, does not need to be marked with the serializable attribute
[System.Runtime.InteropServices.ComVisible(true)]
public sealed 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
// debugger is launched.
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Process)]
public static void Break()
{
if (!IsDebuggerAttached())
{
// Try and demand UnmanagedCodePermission. This is done in a try block because if this
// fails we want to be able to silently eat the exception and just return so
// that the call to Break does not possibly cause an unhandled exception.
// The idea here is that partially trusted code shouldn't be able to launch a debugger
// without the user going through Watson.
try
{
#pragma warning disable 618
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
#pragma warning restore 618
}
// If we enter this block, we do not have permission to break into the debugger
// and so we just return.
catch (SecurityException)
{
return;
}
}
// Causing a break is now allowed.
BreakInternal();
}
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Process)]
static void BreakCanThrow()
{
if (!IsDebuggerAttached())
{
#pragma warning disable 618
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
#pragma warning restore 618
}
// Causing a break is now allowed.
BreakInternal();
}
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Process)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void BreakInternal();
// Launch launches & attaches a debugger to the process. If a debugger is already attached,
// nothing happens.
//
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
public static bool Launch()
{
if (IsDebuggerAttached())
return (true);
// Try and demand UnmanagedCodePermission. This is done in a try block because if this
// fails we want to be able to silently eat the exception and just return so
// that the call to Break does not possibly cause an unhandled exception.
// The idea here is that partially trusted code shouldn't be able to launch a debugger
// without the user going through Watson.
try
{
#pragma warning disable 618
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
#pragma warning restore 618
}
// If we enter this block, we do not have permission to break into the debugger
// and so we just return.
catch (SecurityException)
{
return (false);
}
// Causing the debugger to launch is now allowed.
return (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()
{
}
}
// 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.
//
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Process)]
[method:System.Runtime.InteropServices.ComVisible(false)]
public static void NotifyOfCrossThreadDependency()
{
if (Debugger.IsAttached)
{
CrossThreadDependencyNotification notification = new CrossThreadDependencyNotification();
CustomNotification(notification);
}
}
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool LaunchInternal();
// Returns whether or not a debugger is attached to the process.
//
public static bool IsAttached
{
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Process)]
get { return IsDebuggerAttached(); }
}
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.Process)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool IsDebuggerAttached();
// Constants representing the importance level of messages to be logged.
//
// 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.
//
// Constant representing the default category
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.
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void Log(int level, String category, String message);
// Checks to see if an attached debugger has logging enabled
//
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(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.
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void CustomNotification(ICustomDebuggerNotification data);
}
}

View File

@@ -0,0 +1,380 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: DebuggerAttributes
**
**
** Purpose: Attributes for debugger
**
**
===========================================================*/
namespace System.Diagnostics {
using System;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
[Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
[ComVisible(true)]
public sealed class DebuggerStepThroughAttribute : Attribute
{
public DebuggerStepThroughAttribute () {}
}
[Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
[ComVisible(true)]
public sealed class DebuggerStepperBoundaryAttribute : Attribute
{
public DebuggerStepperBoundaryAttribute () {}
}
[Serializable]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false)]
[ComVisible(true)]
public sealed class DebuggerHiddenAttribute : Attribute
{
public DebuggerHiddenAttribute () {}
}
[Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor |AttributeTargets.Struct, Inherited = false)]
[ComVisible(true)]
public sealed class DebuggerNonUserCodeAttribute : Attribute
{
public DebuggerNonUserCodeAttribute () {}
}
// Attribute class used by the compiler to mark modules.
// If present, then debugging information for everything in the
// assembly was generated by the compiler, and will be preserved
// by the Runtime so that the debugger can provide full functionality
// in the case of JIT attach. If not present, then the compiler may
// or may not have included debugging information, and the Runtime
// won't preserve the debugging info, which will make debugging after
// a JIT attach difficult.
[AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Module, AllowMultiple = false)]
[ComVisible(true)]
public sealed class DebuggableAttribute : Attribute
{
[Flags]
[ComVisible(true)]
public enum DebuggingModes
{
None = 0x0,
Default = 0x1,
DisableOptimizations = 0x100,
IgnoreSymbolStoreSequencePoints = 0x2,
EnableEditAndContinue = 0x4
}
private DebuggingModes m_debuggingModes;
public DebuggableAttribute(bool isJITTrackingEnabled,
bool isJITOptimizerDisabled)
{
m_debuggingModes = 0;
if (isJITTrackingEnabled)
{
m_debuggingModes |= DebuggingModes.Default;
}
if (isJITOptimizerDisabled)
{
m_debuggingModes |= DebuggingModes.DisableOptimizations;
}
}
public DebuggableAttribute(DebuggingModes modes)
{
m_debuggingModes = modes;
}
public bool IsJITTrackingEnabled
{
get { return ((m_debuggingModes & DebuggingModes.Default) != 0); }
}
public bool IsJITOptimizerDisabled
{
get { return ((m_debuggingModes & DebuggingModes.DisableOptimizations) != 0); }
}
public DebuggingModes DebuggingFlags
{
get { return m_debuggingModes; }
}
}
// DebuggerBrowsableState states are defined as follows:
// Never never show this element
// Expanded expansion of the class is done, so that all visible internal members are shown
// Collapsed expansion of the class is not performed. Internal visible members are hidden
// RootHidden The target element itself should not be shown, but should instead be
// automatically expanded to have its members displayed.
// Default value is collapsed
// Please also change the code which validates DebuggerBrowsableState variable (in this file)
// if you change this enum.
[ComVisible(true)]
public enum DebuggerBrowsableState
{
Never = 0,
//Expanded is not supported in this release
//Expanded = 1,
Collapsed = 2,
RootHidden = 3
}
// the one currently supported with the csee.dat
// (mcee.dat, autoexp.dat) file.
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
[ComVisible(true)]
public sealed class DebuggerBrowsableAttribute: Attribute
{
private DebuggerBrowsableState state;
public DebuggerBrowsableAttribute(DebuggerBrowsableState state)
{
if( state < DebuggerBrowsableState.Never || state > DebuggerBrowsableState.RootHidden)
throw new ArgumentOutOfRangeException("state");
Contract.EndContractBlock();
this.state = state;
}
public DebuggerBrowsableState State
{
get { return state; }
}
}
// DebuggerTypeProxyAttribute
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
[ComVisible(true)]
public sealed class DebuggerTypeProxyAttribute: Attribute
{
private string typeName;
private string targetName;
private Type target;
public DebuggerTypeProxyAttribute(Type type)
{
if (type == null) {
throw new ArgumentNullException("type");
}
Contract.EndContractBlock();
this.typeName = type.AssemblyQualifiedName;
}
public DebuggerTypeProxyAttribute(string typeName)
{
this.typeName = typeName;
}
public string ProxyTypeName
{
get { return typeName; }
}
public Type Target
{
set {
if( value == null) {
throw new ArgumentNullException("value");
}
Contract.EndContractBlock();
targetName = value.AssemblyQualifiedName;
target = value;
}
get { return target; }
}
public string TargetTypeName
{
get { return targetName; }
set { targetName = value; }
}
}
// This attribute is used to control what is displayed for the given class or field
// in the data windows in the debugger. The single argument to this attribute is
// the string that will be displayed in the value column for instances of the type.
// This string can include text between { and } which can be either a field,
// property or method (as will be documented in mscorlib). In the C# case,
// a general expression will be allowed which only has implicit access to the this pointer
// for the current instance of the target type. The expression will be limited,
// however: there is no access to aliases, locals, or pointers.
// In addition, attributes on properties referenced in the expression are not processed.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Assembly, AllowMultiple = true)]
[ComVisible(true)]
public sealed class DebuggerDisplayAttribute : Attribute
{
private string name;
private string value;
private string type;
private string targetName;
private Type target;
public DebuggerDisplayAttribute(string value)
{
if( value == null ) {
this.value = "";
}
else {
this.value = value;
}
name = "";
type = "";
}
public string Value
{
get { return this.value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public string Type
{
get { return type; }
set { type = value; }
}
public Type Target
{
set {
if( value == null) {
throw new ArgumentNullException("value");
}
Contract.EndContractBlock();
targetName = value.AssemblyQualifiedName;
target = value;
}
get { return target; }
}
public string TargetTypeName
{
get { return targetName; }
set { targetName = value; }
}
}
/// <summary>
/// Signifies that the attributed type has a visualizer which is pointed
/// to by the parameter type name strings.
/// </summary>
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
[ComVisible(true)]
public sealed class DebuggerVisualizerAttribute: Attribute
{
private string visualizerObjectSourceName;
private string visualizerName;
private string description;
private string targetName;
private Type target;
public DebuggerVisualizerAttribute(string visualizerTypeName)
{
this.visualizerName = visualizerTypeName;
}
public DebuggerVisualizerAttribute(string visualizerTypeName, string visualizerObjectSourceTypeName)
{
this.visualizerName = visualizerTypeName;
this.visualizerObjectSourceName = visualizerObjectSourceTypeName;
}
public DebuggerVisualizerAttribute(string visualizerTypeName, Type visualizerObjectSource)
{
if (visualizerObjectSource == null) {
throw new ArgumentNullException("visualizerObjectSource");
}
Contract.EndContractBlock();
this.visualizerName = visualizerTypeName;
this.visualizerObjectSourceName = visualizerObjectSource.AssemblyQualifiedName;
}
public DebuggerVisualizerAttribute(Type visualizer)
{
if (visualizer == null) {
throw new ArgumentNullException("visualizer");
}
Contract.EndContractBlock();
this.visualizerName = visualizer.AssemblyQualifiedName;
}
public DebuggerVisualizerAttribute(Type visualizer, Type visualizerObjectSource)
{
if (visualizer == null) {
throw new ArgumentNullException("visualizer");
}
if (visualizerObjectSource == null) {
throw new ArgumentNullException("visualizerObjectSource");
}
Contract.EndContractBlock();
this.visualizerName = visualizer.AssemblyQualifiedName;
this.visualizerObjectSourceName = visualizerObjectSource.AssemblyQualifiedName;
}
public DebuggerVisualizerAttribute(Type visualizer, string visualizerObjectSourceTypeName)
{
if (visualizer == null) {
throw new ArgumentNullException("visualizer");
}
Contract.EndContractBlock();
this.visualizerName = visualizer.AssemblyQualifiedName;
this.visualizerObjectSourceName = visualizerObjectSourceTypeName;
}
public string VisualizerObjectSourceTypeName
{
get { return visualizerObjectSourceName; }
}
public string VisualizerTypeName
{
get { return visualizerName; }
}
public string Description
{
get { return description; }
set { description = value; }
}
public Type Target
{
set {
if( value == null) {
throw new ArgumentNullException("value");
}
Contract.EndContractBlock();
targetName = value.AssemblyQualifiedName;
target = value;
}
get { return target; }
}
public string TargetTypeName
{
set { targetName = value; }
get { return targetName; }
}
}
}

View File

@@ -0,0 +1,31 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*=============================================================================
**
** Class: EditAndContinueHelper
**
**
** Purpose: Helper for EditAndContinue
**
**
=============================================================================*/
namespace System.Diagnostics {
using System;
#if !FEATURE_PAL
[Serializable]
internal sealed class EditAndContinueHelper
{
#pragma warning disable 169
#pragma warning disable 414 // Field is not used from managed.
private Object _objectReference;
#pragma warning restore 414
#pragma warning restore 169
}
#endif // !FEATURE_PAL
}

View File

@@ -0,0 +1,160 @@
//------------------------------------------------------------------------------
// <copyright file="etwprovider.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <OWNER>[....]</OWNER>
//------------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
namespace System.Diagnostics.Tracing
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
internal struct EventDescriptor
{
# region private
[FieldOffset(0)]
private ushort m_id;
[FieldOffset(2)]
private byte m_version;
[FieldOffset(3)]
private byte m_channel;
[FieldOffset(4)]
private byte m_level;
[FieldOffset(5)]
private byte m_opcode;
[FieldOffset(6)]
private ushort m_task;
[FieldOffset(8)]
private long m_keywords;
#endregion
public EventDescriptor(
int id,
byte version,
byte channel,
byte level,
byte opcode,
int task,
long keywords
)
{
if (id < 0)
{
throw new ArgumentOutOfRangeException("id", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
}
if (id > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException("id", Environment.GetResourceString("ArgumentOutOfRange_NeedValidId", 1, ushort.MaxValue));
}
m_id = (ushort)id;
m_version = version;
m_channel = channel;
m_level = level;
m_opcode = opcode;
m_keywords = keywords;
if (id < 0)
{
throw new ArgumentOutOfRangeException("task", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
}
if (id > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException("task", Environment.GetResourceString("ArgumentOutOfRange_NeedValidId", 1, ushort.MaxValue));
}
m_task = (ushort)task;
}
public int EventId {
get {
return m_id;
}
}
public byte Version
{
get
{
return m_version;
}
}
public byte Channel
{
get
{
return m_channel;
}
}
public byte Level
{
get
{
return m_level;
}
}
public byte Opcode
{
get
{
return m_opcode;
}
}
public int Task
{
get
{
return m_task;
}
}
public long Keywords
{
get
{
return m_keywords;
}
}
public override bool Equals(object obj)
{
if (!(obj is EventDescriptor))
return false;
return Equals((EventDescriptor) obj);
}
public override int GetHashCode()
{
return m_id ^ m_version ^ m_channel ^ m_level ^ m_opcode ^ m_task ^ (int)m_keywords;
}
public bool Equals(EventDescriptor other)
{
if ((m_id != other.m_id) ||
(m_version != other.m_version) ||
(m_channel != other.m_channel) ||
(m_level != other.m_level) ||
(m_opcode != other.m_opcode) ||
(m_task != other.m_task) ||
(m_keywords != other.m_keywords))
{
return false;
}
return true;
}
public static bool operator ==(EventDescriptor event1, EventDescriptor event2)
{
return event1.Equals(event2);
}
public static bool operator !=(EventDescriptor event1, EventDescriptor event2)
{
return !event1.Equals(event2);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
b1b7786df7e252f1c86a96303144059702326bfa

View File

@@ -0,0 +1,27 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// <OWNER>[....]</OWNER>
/*============================================================
**
** File: EventSourceException.cs
**
============================================================*/
using System;
using System.Runtime.Serialization;
namespace System.Diagnostics.Tracing
{
[Serializable]
public class EventSourceException : Exception
{
public EventSourceException() : base(Environment.GetResourceString("EventSource_ListenerWriteFailure")) { }
public EventSourceException(string message) : base(message) { }
public EventSourceException(string message, Exception innerException) : base(message, innerException) { }
protected EventSourceException(SerializationInfo info, StreamingContext context) : base(info, context) { }
internal EventSourceException(Exception innerException) : base(Environment.GetResourceString("EventSource_ListenerWriteFailure"), innerException) { }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// <OWNER>[....]</OWNER>
/*============================================================
**
** File: winmeta.cs
**
** Purpose:
** Contains eventing constants defined by the Windows
** environment.
**
============================================================*/
namespace System.Diagnostics.Tracing {
/// <summary>
/// WindowsEventLevel
/// </summary>
public enum EventLevel {
/// <summary>
/// Log always
/// </summary>
LogAlways = 0,
/// <summary>
/// Only critical errors
/// </summary>
Critical,
/// <summary>
/// All errors, including previous levels
/// </summary>
Error,
/// <summary>
/// All warnings, including previous levels
/// </summary>
Warning,
/// <summary>
/// All informational events, including previous levels
/// </summary>
Informational,
/// <summary>
/// All events, including previous levels
/// </summary>
Verbose
}
/// <summary>
/// WindowsEventTask
/// </summary>
[System.Runtime.CompilerServices.FriendAccessAllowed]
public enum EventTask {
/// <summary>
/// Undefined task
/// </summary>
None = 0
}
/// <summary>
/// EventOpcode
/// </summary>
[System.Runtime.CompilerServices.FriendAccessAllowed]
public enum EventOpcode {
/// <summary>
/// An informational event
/// </summary>
Info = 0,
/// <summary>
/// An activity start event
/// </summary>
Start,
/// <summary>
/// An activity end event
/// </summary>
Stop,
/// <summary>
/// A trace collection start event
/// </summary>
DataCollectionStart,
/// <summary>
/// A trace collection end event
/// </summary>
DataCollectionStop,
/// <summary>
/// An extensional event
/// </summary>
Extension,
/// <summary>
/// A reply event
/// </summary>
Reply,
/// <summary>
/// An event representing the activity resuming from the suspension
/// </summary>
Resume,
/// <summary>
/// An event representing the activity is suspended, pending another activity's completion
/// </summary>
Suspend,
/// <summary>
/// An event representing the activity is transferred to another component, and can continue to work
/// </summary>
Send,
/// <summary>
/// An event representing receiving an activity transfer from another component
/// </summary>
Receive = 240
}
#if FEARURE_MANAGED_ETW_CHANNELS
// Added for CLR V4
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32", Justification="Backwards compatibility")]
[System.Runtime.CompilerServices.FriendAccessAllowed]
public enum EventChannel : byte
{
Default = 0,
};
#endif
/// <summary>
/// EventOpcode
/// </summary>
[Flags]
public enum EventKeywords : long {
/// <summary>
/// Wild card value
/// </summary>
None = 0x0,
/// <summary>
/// WDI context events
/// </summary>
WdiContext = 0x02000000000000,
/// <summary>
/// WDI diagnostic events
/// </summary>
WdiDiagnostic = 0x04000000000000,
/// <summary>
/// SQM events
/// </summary>
Sqm = 0x08000000000000,
/// <summary>
/// FAiled security audits
/// </summary>
AuditFailure = 0x10000000000000,
/// <summary>
/// Successful security audits
/// </summary>
AuditSuccess = 0x20000000000000,
/// <summary>
/// Transfer events where the related Activity ID is a computed value and not a GUID
/// </summary>
CorrelationHint = 0x10000000000000,
/// <summary>
/// Events raised using classic eventlog API
/// </summary>
EventLogClassic = 0x80000000000000
}
}

View File

@@ -0,0 +1,256 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Diagnostics {
using System.Runtime.Remoting;
using System;
using System.Security.Permissions;
using System.IO;
using System.Collections;
using System.Runtime.CompilerServices;
using Encoding = System.Text.Encoding;
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
// LogMessageEventHandlers are triggered when a message is generated which is
// "on" per its switch.
//
// By default, the debugger (if attached) is the only event handler.
// There is also a "built-in" console device which can be enabled
// programatically, by registry (specifics....) or environment
// variables.
[Serializable]
[HostProtection(Synchronization=true, ExternalThreading=true)]
internal delegate void LogMessageEventHandler(LoggingLevels level, LogSwitch category,
String message,
StackTrace location);
// LogSwitchLevelHandlers are triggered when the level of a LogSwitch is modified
// 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);
internal static class Log
{
// Switches allow relatively fine level control of which messages are
// actually shown. Normally most debugging messages are not shown - the
// user will typically enable those which are relevant to what is being
// investigated.
//
// 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.
internal static Hashtable m_Hashtable;
private static volatile bool m_fConsoleDeviceEnabled;
private static LogMessageEventHandler _LogMessageEventHandler;
private static volatile LogSwitchLevelHandler _LogSwitchLevelHandler;
private static Object locker;
// Constant representing the global switch
public static readonly LogSwitch GlobalSwitch;
static Log()
{
m_Hashtable = new Hashtable();
m_fConsoleDeviceEnabled = false;
//pConsole = null;
//iNumOfMsgHandlers = 0;
//iMsgHandlerArraySize = 0;
locker = new Object();
// allocate the GlobalSwitch object
GlobalSwitch = new LogSwitch ("Global", "Global Switch for this log");
GlobalSwitch.MinimumLevel = LoggingLevels.ErrorLevel;
}
public static void AddOnLogMessage(LogMessageEventHandler handler)
{
lock (locker)
_LogMessageEventHandler =
(LogMessageEventHandler) MulticastDelegate.Combine(_LogMessageEventHandler, handler);
}
public static void RemoveOnLogMessage(LogMessageEventHandler handler)
{
lock (locker)
_LogMessageEventHandler =
(LogMessageEventHandler) MulticastDelegate.Remove(_LogMessageEventHandler, handler);
}
public static void AddOnLogSwitchLevel(LogSwitchLevelHandler handler)
{
lock (locker)
_LogSwitchLevelHandler =
(LogSwitchLevelHandler) MulticastDelegate.Combine(_LogSwitchLevelHandler, handler);
}
public static void RemoveOnLogSwitchLevel(LogSwitchLevelHandler handler)
{
lock (locker)
_LogSwitchLevelHandler =
(LogSwitchLevelHandler) MulticastDelegate.Remove(_LogSwitchLevelHandler, handler);
}
internal static void InvokeLogSwitchLevelHandlers (LogSwitch ls, LoggingLevels newLevel)
{
LogSwitchLevelHandler handler = _LogSwitchLevelHandler;
if (handler != null)
handler(ls, newLevel);
}
// Property to Enable/Disable ConsoleDevice. Enabling the console device
// adds the console device as a log output, causing any
// log messages which make it through filters to be written to the
// application console. The console device is enabled by default if the
// ??? registry entry or ??? environment variable is set.
public static bool IsConsoleEnabled
{
get { return m_fConsoleDeviceEnabled; }
set { m_fConsoleDeviceEnabled = value; }
}
// Generates a log message. If its switch (or a parent switch) allows the
// level for the message, it is "broadcast" to all of the log
// devices.
//
public static void LogMessage(LoggingLevels level, String message)
{
LogMessage (level, GlobalSwitch, message);
}
// Generates a log message. If its switch (or a parent switch) allows the
// level for the message, it is "broadcast" to all of the log
// devices.
//
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
public static void LogMessage(LoggingLevels level, LogSwitch logswitch, String message)
{
if (logswitch == null)
throw new ArgumentNullException ("LogSwitch");
if (level < 0)
throw new ArgumentOutOfRangeException("level", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
Contract.EndContractBlock();
// Is logging for this level for this switch enabled?
if (logswitch.CheckLevel (level) == true)
{
// Send message for logging
// first send it to the debugger
Debugger.Log ((int) level, logswitch.strName, message);
// Send to the console device
if (m_fConsoleDeviceEnabled)
{
Console.Write(message);
}
}
}
/*
* Following are convenience entry points; all go through Log()
* Note that the (Switch switch, String message) variations
* are preferred.
*/
public static void Trace(LogSwitch logswitch, String message)
{
LogMessage (LoggingLevels.TraceLevel0, logswitch, message);
}
public static void Trace(String switchname, String message)
{
LogSwitch ls;
ls = LogSwitch.GetSwitch (switchname);
LogMessage (LoggingLevels.TraceLevel0, ls, message);
}
public static void Trace(String message)
{
LogMessage (LoggingLevels.TraceLevel0, GlobalSwitch, message);
}
public static void Status(LogSwitch logswitch, String message)
{
LogMessage (LoggingLevels.StatusLevel0, logswitch, message);
}
public static void Status(String switchname, String message)
{
LogSwitch ls;
ls = LogSwitch.GetSwitch (switchname);
LogMessage (LoggingLevels.StatusLevel0, ls, message);
}
public static void Status(String message)
{
LogMessage (LoggingLevels.StatusLevel0, GlobalSwitch, message);
}
public static void Warning(LogSwitch logswitch, String message)
{
LogMessage (LoggingLevels.WarningLevel, logswitch, message);
}
public static void Warning(String switchname, String message)
{
LogSwitch ls;
ls = LogSwitch.GetSwitch (switchname);
LogMessage (LoggingLevels.WarningLevel, ls, message);
}
public static void Warning(String message)
{
LogMessage (LoggingLevels.WarningLevel, GlobalSwitch, message);
}
public static void Error(LogSwitch logswitch, String message)
{
LogMessage (LoggingLevels.ErrorLevel, logswitch, message);
}
public static void Error(String switchname, String message)
{
LogSwitch ls;
ls = LogSwitch.GetSwitch (switchname);
LogMessage (LoggingLevels.ErrorLevel, ls, message);
}
public static void Error(String message)
{
LogMessage (LoggingLevels.ErrorLevel, GlobalSwitch, message);
}
public static void Panic(String message)
{
LogMessage (LoggingLevels.PanicLevel, GlobalSwitch, message);
}
// Native method to inform the EE about the creation of a new LogSwitch
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void AddLogSwitch(LogSwitch logSwitch);
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void ModifyLogSwitch (int iNewLevel, String strSwitchName, String strParentName);
}
}

View File

@@ -0,0 +1,46 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Diagnostics {
using System;
// 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.
//
// 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.
// <EMAIL>AtulC:</EMAIL> NOTE: The following constants mirror the constants
// declared in the EE code (DebugDebugger.h). Any changes here will also
// need to be made there.
// 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,
TraceLevel1 = 1,
TraceLevel2 = 2,
TraceLevel3 = 3,
TraceLevel4 = 4,
StatusLevel0 = 20,
StatusLevel1 = 21,
StatusLevel2 = 22,
StatusLevel3 = 23,
StatusLevel4 = 24,
WarningLevel = 40,
ErrorLevel = 50,
PanicLevel = 100,
}
}

View File

@@ -0,0 +1,145 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Diagnostics {
using System;
using System.IO;
using System.Collections;
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
[Serializable]
internal class LogSwitch
{
// ! WARNING !
// If any fields are added/deleted/modified, perform the
// same in the EE code (debugdebugger.cpp/debugdebugger.h)
internal String strName;
internal String strDescription;
private LogSwitch ParentSwitch;
internal volatile LoggingLevels iLevel;
internal volatile LoggingLevels iOldLevel;
// ! END WARNING !
private LogSwitch ()
{
}
// Constructs a LogSwitch. A LogSwitch is used to categorize log messages.
//
// All switches (except for the global LogSwitch) have a parent LogSwitch.
//
[System.Security.SecuritySafeCritical] // auto-generated
public LogSwitch(String name, String description, LogSwitch parent)
{
if (name != null && name.Length == 0)
throw new ArgumentOutOfRangeException("Name", Environment.GetResourceString("Argument_StringZeroLength"));
Contract.EndContractBlock();
if ((name != null) && (parent != null))
{
strName = name;
strDescription = description;
iLevel = LoggingLevels.ErrorLevel;
iOldLevel = iLevel;
ParentSwitch = parent;
Log.m_Hashtable.Add (strName, this);
// Call into the EE to let it know about the creation of
// this switch
Log.AddLogSwitch (this);
}
else
throw new ArgumentNullException ((name==null ? "name" : "parent"));
}
[System.Security.SecuritySafeCritical] // auto-generated
internal LogSwitch(String name, String description)
{
strName = name;
strDescription = description;
iLevel = LoggingLevels.ErrorLevel;
iOldLevel = iLevel;
ParentSwitch = null;
Log.m_Hashtable.Add (strName, this);
// Call into the EE to let it know about the creation of
// this switch
Log.AddLogSwitch (this);
}
// Get property returns the name of the switch
public virtual String Name
{
get { return strName;}
}
// Get property returns the description of the switch
public virtual String Description
{
get {return strDescription;}
}
// Get property returns the parent of the switch
public virtual LogSwitch Parent
{
get { return ParentSwitch; }
}
// Property to Get/Set the level of log messages which are "on" for the switch.
//
public virtual LoggingLevels MinimumLevel
{
get { return iLevel; }
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
set
{
iLevel = value;
iOldLevel = value;
String strParentName = ParentSwitch!=null ? ParentSwitch.Name : "";
if (Debugger.IsAttached)
Log.ModifyLogSwitch ((int)iLevel, strName, strParentName);
Log.InvokeLogSwitchLevelHandlers (this, iLevel);
}
}
// Checks if the given level is "on" for this switch or one of its parents.
//
public virtual bool CheckLevel(LoggingLevels level)
{
if (iLevel > level)
{
// recurse through the list till parent is hit.
if (this.ParentSwitch == null)
return false;
else
return this.ParentSwitch.CheckLevel (level);
}
else
return true;
}
// Returns a switch with the particular name, if any. Returns null if no
// such switch exists.
public static LogSwitch GetSwitch(String name)
{
return (LogSwitch)Log.m_Hashtable[name];
}
}
}

Some files were not shown because too many files have changed in this diff Show More