Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<IsNETCoreApp>true</IsNETCoreApp>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netcoreapp;
uap;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,211 @@
// 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.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
namespace System.Diagnostics
{
public partial class StackFrame
{
public StackFrame() { }
public StackFrame(bool fNeedFileInfo) { }
public StackFrame(int skipFrames) { }
public StackFrame(int skipFrames, bool fNeedFileInfo) { }
public StackFrame(string fileName, int lineNumber) { }
public StackFrame(string fileName, int lineNumber, int colNumber) { }
public const int OFFSET_UNKNOWN = -1;
public virtual int GetFileColumnNumber() { throw null; }
public virtual int GetFileLineNumber() { throw null; }
public virtual string GetFileName() { throw null; }
public virtual int GetILOffset() { throw null; }
public virtual System.Reflection.MethodBase GetMethod() { throw null; }
public override string ToString() { throw null; }
public virtual int GetNativeOffset() { throw null; }
}
public static partial class StackFrameExtensions
{
public static System.IntPtr GetNativeImageBase(this System.Diagnostics.StackFrame stackFrame) { throw null; }
public static System.IntPtr GetNativeIP(this System.Diagnostics.StackFrame stackFrame) { throw null; }
public static bool HasILOffset(this System.Diagnostics.StackFrame stackFrame) { throw null; }
public static bool HasMethod(this System.Diagnostics.StackFrame stackFrame) { throw null; }
public static bool HasNativeImage(this System.Diagnostics.StackFrame stackFrame) { throw null; }
public static bool HasSource(this System.Diagnostics.StackFrame stackFrame) { throw null; }
}
public partial class StackTrace
{
public const int METHODS_TO_SKIP = 0;
public StackTrace() { }
public StackTrace(bool fNeedFileInfo) { }
public StackTrace(StackFrame frame) { }
public StackTrace(System.Exception e) { }
public StackTrace(System.Exception e, bool fNeedFileInfo) { }
public StackTrace(System.Exception e, int skipFrames) { }
public StackTrace(System.Exception e, int skipFrames, bool fNeedFileInfo) { }
public StackTrace(int skipFrames) { }
public StackTrace(int skipFrames, bool fNeedFileInfo) { }
public virtual int FrameCount { get { throw null; } }
public virtual System.Diagnostics.StackFrame[] GetFrames() { throw null; }
public virtual System.Diagnostics.StackFrame GetFrame(int index) { throw null; }
public override string ToString() { throw null; }
}
}
namespace System.Diagnostics.SymbolStore
{
public partial interface ISymbolBinder
{
[System.ObsoleteAttribute("The recommended alternative is ISymbolBinder1.GetReader. ISymbolBinder1.GetReader takes the importer interface pointer as an IntPtr instead of an Int32, and thus works on both 32-bit and 64-bit architectures. http://go.microsoft.com/fwlink/?linkid=14202=14202")]
System.Diagnostics.SymbolStore.ISymbolReader GetReader(int importer, string filename, string searchPath);
}
public partial interface ISymbolBinder1
{
System.Diagnostics.SymbolStore.ISymbolReader GetReader(System.IntPtr importer, string filename, string searchPath);
}
public partial interface ISymbolDocument
{
System.Guid CheckSumAlgorithmId { get; }
System.Guid DocumentType { get; }
bool HasEmbeddedSource { get; }
System.Guid Language { get; }
System.Guid LanguageVendor { get; }
int SourceLength { get; }
string URL { get; }
int FindClosestLine(int line);
byte[] GetCheckSum();
byte[] GetSourceRange(int startLine, int startColumn, int endLine, int endColumn);
}
public partial interface ISymbolDocumentWriter
{
void SetCheckSum(System.Guid algorithmId, byte[] checkSum);
void SetSource(byte[] source);
}
public partial interface ISymbolMethod
{
System.Diagnostics.SymbolStore.ISymbolScope RootScope { get; }
int SequencePointCount { get; }
System.Diagnostics.SymbolStore.SymbolToken Token { get; }
System.Diagnostics.SymbolStore.ISymbolNamespace GetNamespace();
int GetOffset(System.Diagnostics.SymbolStore.ISymbolDocument document, int line, int column);
System.Diagnostics.SymbolStore.ISymbolVariable[] GetParameters();
int[] GetRanges(System.Diagnostics.SymbolStore.ISymbolDocument document, int line, int column);
System.Diagnostics.SymbolStore.ISymbolScope GetScope(int offset);
void GetSequencePoints(int[] offsets, System.Diagnostics.SymbolStore.ISymbolDocument[] documents, int[] lines, int[] columns, int[] endLines, int[] endColumns);
bool GetSourceStartEnd(System.Diagnostics.SymbolStore.ISymbolDocument[] docs, int[] lines, int[] columns);
}
public partial interface ISymbolNamespace
{
string Name { get; }
System.Diagnostics.SymbolStore.ISymbolNamespace[] GetNamespaces();
System.Diagnostics.SymbolStore.ISymbolVariable[] GetVariables();
}
public partial interface ISymbolReader
{
System.Diagnostics.SymbolStore.SymbolToken UserEntryPoint { get; }
System.Diagnostics.SymbolStore.ISymbolDocument GetDocument(string url, System.Guid language, System.Guid languageVendor, System.Guid documentType);
System.Diagnostics.SymbolStore.ISymbolDocument[] GetDocuments();
System.Diagnostics.SymbolStore.ISymbolVariable[] GetGlobalVariables();
System.Diagnostics.SymbolStore.ISymbolMethod GetMethod(System.Diagnostics.SymbolStore.SymbolToken method);
System.Diagnostics.SymbolStore.ISymbolMethod GetMethod(System.Diagnostics.SymbolStore.SymbolToken method, int version);
System.Diagnostics.SymbolStore.ISymbolMethod GetMethodFromDocumentPosition(System.Diagnostics.SymbolStore.ISymbolDocument document, int line, int column);
System.Diagnostics.SymbolStore.ISymbolNamespace[] GetNamespaces();
byte[] GetSymAttribute(System.Diagnostics.SymbolStore.SymbolToken parent, string name);
System.Diagnostics.SymbolStore.ISymbolVariable[] GetVariables(System.Diagnostics.SymbolStore.SymbolToken parent);
}
public partial interface ISymbolScope
{
int EndOffset { get; }
System.Diagnostics.SymbolStore.ISymbolMethod Method { get; }
System.Diagnostics.SymbolStore.ISymbolScope Parent { get; }
int StartOffset { get; }
System.Diagnostics.SymbolStore.ISymbolScope[] GetChildren();
System.Diagnostics.SymbolStore.ISymbolVariable[] GetLocals();
System.Diagnostics.SymbolStore.ISymbolNamespace[] GetNamespaces();
}
public partial interface ISymbolVariable
{
int AddressField1 { get; }
int AddressField2 { get; }
int AddressField3 { get; }
System.Diagnostics.SymbolStore.SymAddressKind AddressKind { get; }
object Attributes { get; }
int EndOffset { get; }
string Name { get; }
int StartOffset { get; }
byte[] GetSignature();
}
public partial interface ISymbolWriter
{
void Close();
void CloseMethod();
void CloseNamespace();
void CloseScope(int endOffset);
System.Diagnostics.SymbolStore.ISymbolDocumentWriter DefineDocument(string url, System.Guid language, System.Guid languageVendor, System.Guid documentType);
void DefineField(System.Diagnostics.SymbolStore.SymbolToken parent, string name, System.Reflection.FieldAttributes attributes, byte[] signature, System.Diagnostics.SymbolStore.SymAddressKind addrKind, int addr1, int addr2, int addr3);
void DefineGlobalVariable(string name, System.Reflection.FieldAttributes attributes, byte[] signature, System.Diagnostics.SymbolStore.SymAddressKind addrKind, int addr1, int addr2, int addr3);
void DefineLocalVariable(string name, System.Reflection.FieldAttributes attributes, byte[] signature, System.Diagnostics.SymbolStore.SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset);
void DefineParameter(string name, System.Reflection.ParameterAttributes attributes, int sequence, System.Diagnostics.SymbolStore.SymAddressKind addrKind, int addr1, int addr2, int addr3);
void DefineSequencePoints(System.Diagnostics.SymbolStore.ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns);
void Initialize(System.IntPtr emitter, string filename, bool fFullBuild);
void OpenMethod(System.Diagnostics.SymbolStore.SymbolToken method);
void OpenNamespace(string name);
int OpenScope(int startOffset);
void SetMethodSourceRange(System.Diagnostics.SymbolStore.ISymbolDocumentWriter startDoc, int startLine, int startColumn, System.Diagnostics.SymbolStore.ISymbolDocumentWriter endDoc, int endLine, int endColumn);
void SetScopeRange(int scopeID, int startOffset, int endOffset);
void SetSymAttribute(System.Diagnostics.SymbolStore.SymbolToken parent, string name, byte[] data);
void SetUnderlyingWriter(System.IntPtr underlyingWriter);
void SetUserEntryPoint(System.Diagnostics.SymbolStore.SymbolToken entryMethod);
void UsingNamespace(string fullName);
}
public enum SymAddressKind
{
BitField = 9,
ILOffset = 1,
NativeOffset = 5,
NativeRegister = 3,
NativeRegisterRegister = 6,
NativeRegisterRelative = 4,
NativeRegisterStack = 7,
NativeRVA = 2,
NativeSectionOffset = 10,
NativeStackRegister = 8,
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct SymbolToken
{
public SymbolToken(int val) { throw null; }
public bool Equals(System.Diagnostics.SymbolStore.SymbolToken obj) { throw null; }
public override bool Equals(object obj) { throw null; }
public override int GetHashCode() { throw null; }
public int GetToken() { throw null; }
public static bool operator ==(System.Diagnostics.SymbolStore.SymbolToken a, System.Diagnostics.SymbolStore.SymbolToken b) { throw null; }
public static bool operator !=(System.Diagnostics.SymbolStore.SymbolToken a, System.Diagnostics.SymbolStore.SymbolToken b) { throw null; }
}
public partial class SymDocumentType
{
public static readonly System.Guid Text;
public SymDocumentType() { }
}
public partial class SymLanguageType
{
public static readonly System.Guid Basic;
public static readonly System.Guid C;
public static readonly System.Guid Cobol;
public static readonly System.Guid CPlusPlus;
public static readonly System.Guid CSharp;
public static readonly System.Guid ILAssembly;
public static readonly System.Guid Java;
public static readonly System.Guid JScript;
public static readonly System.Guid MCPlusPlus;
public static readonly System.Guid Pascal;
public static readonly System.Guid SMC;
public SymLanguageType() { }
}
public partial class SymLanguageVendor
{
public static readonly System.Guid Microsoft;
public SymLanguageVendor() { }
}
}

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.Diagnostics.StackTrace.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Runtime.Extensions\ref\System.Runtime.Extensions.csproj" />
<ProjectReference Include="..\..\System.Reflection\ref\System.Reflection.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,30 @@
Compat issues with assembly System.Diagnostics.StackTrace:
CannotSealType : Type 'System.Diagnostics.StackFrame' is sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Diagnostics.StackFrame..ctor()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackFrame..ctor(System.Boolean)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackFrame..ctor(System.Int32)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackFrame..ctor(System.Int32, System.Boolean)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackFrame..ctor(System.String, System.Int32)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackFrame..ctor(System.String, System.Int32, System.Int32)' does not exist in the implementation but it does exist in the contract.
CannotMakeMemberNonVirtual : Member 'System.Diagnostics.StackFrame.GetFileColumnNumber()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Diagnostics.StackFrame.GetFileLineNumber()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Diagnostics.StackFrame.GetFileName()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Diagnostics.StackFrame.GetILOffset()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Diagnostics.StackFrame.GetMethod()' is non-virtual in the implementation but is virtual in the contract.
MembersMustExist : Member 'System.Diagnostics.StackFrame.GetNativeOffset()' does not exist in the implementation but it does exist in the contract.
CannotMakeMemberNonVirtual : Member 'System.Diagnostics.StackFrame.ToString()' is non-virtual in the implementation but is virtual in the contract.
CannotSealType : Type 'System.Diagnostics.StackTrace' is sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Int32 System.Diagnostics.StackTrace.METHODS_TO_SKIP' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace..ctor()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace..ctor(System.Boolean)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace..ctor(System.Diagnostics.StackFrame)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace..ctor(System.Exception)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace..ctor(System.Exception, System.Int32)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace..ctor(System.Exception, System.Int32, System.Boolean)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace..ctor(System.Int32)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace..ctor(System.Int32, System.Boolean)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace.FrameCount.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Diagnostics.StackTrace.GetFrame(System.Int32)' does not exist in the implementation but it does exist in the contract.
CannotMakeMemberNonVirtual : Member 'System.Diagnostics.StackTrace.GetFrames()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Diagnostics.StackTrace.ToString()' is non-virtual in the implementation but is virtual in the contract.
Total Issues: 28

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
net463-Windows_NT;
uap101aot-Windows_NT;
netcoreapp-Windows_NT;
netcoreapp-Unix;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AssemblyName>System.Diagnostics.StackTrace</AssemblyName>
<ProjectGuid>{02304469-722E-4723-92A1-820B9A37D275}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)'=='netcoreapp' or '$(TargetGroup)' == 'net463'">true</IsPartialFacadeAssembly>
<!-- Disable 1685 (aka multiple type definitions) warning so it doesn't turn into an error -->
<NoWarn>$(NoWarn);1685</NoWarn>
</PropertyGroup>
<!-- Default configurations to help VS understand the options -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net463-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net463-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap101aot-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap101aot-Windows_NT-Release|AnyCPU'" />
<ItemGroup>
<TargetingPackReference Include="mscorlib" Condition="'$(TargetGroup)' == 'net463'" />
<TargetingPackReference Include="System.Private.CoreLib" Condition="'$(TargetGroup)' != 'net463'" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='uap101aot'">
<TargetingPackReference Include="System.Private.Reflection" />
</ItemGroup>
<ItemGroup>
<Compile Include="System\Diagnostics\StackFrameExtensions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' or '$(TargetGroup)' == 'uap101aot'">
<Compile Include="System\Diagnostics\SymbolStore\ISymbolBinder.cs" />
<Compile Include="System\Diagnostics\SymbolStore\ISymbolDocument.cs" />
<Compile Include="System\Diagnostics\SymbolStore\ISymbolMethod.cs" />
<Compile Include="System\Diagnostics\SymbolStore\ISymbolNamespace.cs" />
<Compile Include="System\Diagnostics\SymbolStore\ISymbolReader.cs" />
<Compile Include="System\Diagnostics\SymbolStore\ISymbolScope.cs" />
<Compile Include="System\Diagnostics\SymbolStore\ISymbolVariable.cs" />
<Compile Include="System\Diagnostics\SymbolStore\ISymbolWriter.cs" />
<Compile Include="System\Diagnostics\SymbolStore\SymbolToken.cs" />
<Compile Include="System\Diagnostics\SymbolStore\SymAddressKind.cs" />
<Compile Include="System\Diagnostics\SymbolStore\SymDocumentType.cs" />
<Compile Include="System\Diagnostics\SymbolStore\SymLanguageType.cs" />
<Compile Include="System\Diagnostics\SymbolStore\SymLanguageVendor.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='netcoreapp'">
<Compile Include="System\Diagnostics\StackTraceSymbols.CoreCLR.cs" />
<ProjectReference Include="..\..\System.Collections\src\System.Collections.csproj" />
<ProjectReference Include="..\..\System.Diagnostics.Debug\src\System.Diagnostics.Debug.csproj" />
<ProjectReference Include="..\..\System.IO\src\System.IO.csproj" />
<ProjectReference Include="..\..\System.IO.FileSystem\src\System.IO.FileSystem.csproj" />
<ProjectReference Include="..\..\System.Runtime\src\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj">
</ProjectReference>
<ProjectReference Include="..\..\System.Reflection.Metadata\src\System.Reflection.Metadata.csproj" />
<ProjectReference Include="..\..\System.Collections.Immutable\src\System.Collections.Immutable.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='netcoreapp' or '$(TargetGroup)' == 'net463'">
<Compile Include="System\Diagnostics\StackFrameExtensions.CoreCLR.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='uap101aot'">
<Compile Include="System\Diagnostics\StackTrace.CoreRT.cs" />
<Compile Include="System\Diagnostics\StackFrame.CoreRT.cs" />
<Compile Include="System\Diagnostics\StackFrameExtensions.CoreRT.cs" />
<Compile Include="System\Diagnostics\SymbolStore\ISymbolDocumentWriter.cs" />
</ItemGroup>
<ItemGroup>
<ReferenceFromRuntime Include="System.Private.CoreLib" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,83 @@
// 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;
using System.Reflection;
using Internal.Diagnostics;
using Internal.Runtime.Augments;
namespace System.Diagnostics
{
public sealed class StackFrame
{
private readonly IntPtr _ip;
private readonly bool _includeFileInfo;
private bool _fetchedFileInfo;
private string _fileName;
private int _lineNumber;
private int _columnNumber;
public const int OFFSET_UNKNOWN = -1;
internal StackFrame(IntPtr ip, bool includeFileInfo)
{
_ip = ip;
_includeFileInfo = includeFileInfo;
}
public int GetILOffset()
{
return OFFSET_UNKNOWN;
}
public int GetFileColumnNumber()
{
EnsureSourceFileInfo();
return _columnNumber;
}
public int GetFileLineNumber()
{
EnsureSourceFileInfo();
return _lineNumber;
}
public string GetFileName()
{
EnsureSourceFileInfo();
return _fileName;
}
public MethodBase GetMethod()
{
return null;
}
public override string ToString()
{
return StackTraceHelper.FormatStackFrame(_ip, _includeFileInfo);
}
internal IntPtr GetNativeIP()
{
return _ip;
}
internal IntPtr GetNativeImageBase()
{
return _ip - RuntimeAugments.ConvertIpToRva(_ip);
}
private void EnsureSourceFileInfo()
{
//this isn't thread-safe and that is OK
if (!_fetchedFileInfo && _includeFileInfo)
{
StackTraceHelper.TryGetSourceLineInfo(_ip, out _fileName, out _lineNumber, out _columnNumber);
//Even if we didn't get all the data, this is the best we'll get and we shouldn't try again
_fetchedFileInfo = true;
}
}
}
}

View File

@@ -0,0 +1,21 @@
// 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;
namespace System.Diagnostics
{
public static partial class StackFrameExtensions
{
public static IntPtr GetNativeIP(this StackFrame stackFrame)
{
return IntPtr.Zero;
}
public static IntPtr GetNativeImageBase(this StackFrame stackFrame)
{
return IntPtr.Zero;
}
}
}

View File

@@ -0,0 +1,21 @@
// 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;
namespace System.Diagnostics
{
public static partial class StackFrameExtensions
{
public static IntPtr GetNativeIP(this StackFrame stackFrame)
{
return stackFrame.GetNativeIP();
}
public static IntPtr GetNativeImageBase(this StackFrame stackFrame)
{
return stackFrame.GetNativeImageBase();
}
}
}

View File

@@ -0,0 +1,31 @@
// 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;
namespace System.Diagnostics
{
public static partial class StackFrameExtensions
{
public static bool HasNativeImage(this StackFrame stackFrame)
{
return stackFrame.GetNativeImageBase() != IntPtr.Zero;
}
public static bool HasMethod(this StackFrame stackFrame)
{
return stackFrame.GetMethod() != null;
}
public static bool HasILOffset(this StackFrame stackFrame)
{
return stackFrame.GetILOffset() != StackFrame.OFFSET_UNKNOWN;
}
public static bool HasSource(this StackFrame stackFrame)
{
return stackFrame.GetFileName() != null;
}
}
}

View File

@@ -0,0 +1,52 @@
// 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;
using Internal.Diagnostics;
namespace System.Diagnostics
{
public sealed class StackTrace
{
private readonly IntPtr[] _ips;
private readonly bool _needFileInfo;
public StackTrace(Exception e, bool needFileInfo)
{
if (e == null)
{
throw new ArgumentNullException(nameof(e));
}
_ips = ExceptionExtensions.GetStackIPs(e);
_needFileInfo = needFileInfo;
}
public StackFrame[] GetFrames()
{
// There are special IPs mixed in to the list that aren't intended to be exposed as StackFrames
// Deliberately doing this without Linq to keep the dependency set down.
StackFrame[] frames = new StackFrame[_ips.Length];
int countNonSpecialIPs = 0;
for (int i = 0; i < _ips.Length; i++)
{
if (_ips[i] != StackTraceHelper.SpecialIP.EdiSeparator)
{
frames[countNonSpecialIPs++] = new StackFrame(_ips[i], _needFileInfo);
}
}
//for compat with CoreCLR, we always return null instead of 0 length array
if (countNonSpecialIPs == 0)
{
return null;
}
Array.Resize(ref frames, countNonSpecialIPs);
return frames;
}
public override string ToString()
{
return StackTraceHelper.FormatStackTrace(_ips, _needFileInfo);
}
}
}

View File

@@ -0,0 +1,227 @@
// 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.IO;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
namespace System.Diagnostics
{
internal class StackTraceSymbols : IDisposable
{
private readonly Dictionary<IntPtr, MetadataReaderProvider> _metadataCache;
/// <summary>
/// Create an instance of this class.
/// </summary>
public StackTraceSymbols()
{
_metadataCache = new Dictionary<IntPtr, MetadataReaderProvider>();
}
/// <summary>
/// Clean up any cached providers.
/// </summary>
void IDisposable.Dispose()
{
foreach (MetadataReaderProvider provider in _metadataCache.Values)
{
provider.Dispose();
}
_metadataCache.Clear();
}
/// <summary>
/// Returns the source file and line number information for the method.
/// </summary>
/// <param name="assemblyPath">file path of the assembly or null</param>
/// <param name="loadedPeAddress">loaded PE image address or zero</param>
/// <param name="loadedPeSize">loaded PE image size</param>
/// <param name="inMemoryPdbAddress">in memory PDB address or zero</param>
/// <param name="inMemoryPdbSize">in memory PDB size</param>
/// <param name="methodToken">method token</param>
/// <param name="ilOffset">il offset of the stack frame</param>
/// <param name="sourceFile">source file return</param>
/// <param name="sourceLine">line number return</param>
/// <param name="sourceColumn">column return</param>
internal void GetSourceLineInfo(string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize,
IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset,
out string sourceFile, out int sourceLine, out int sourceColumn)
{
sourceFile = null;
sourceLine = 0;
sourceColumn = 0;
MetadataReader reader = TryGetReader(assemblyPath, loadedPeAddress, loadedPeSize, inMemoryPdbAddress, inMemoryPdbSize);
if (reader != null)
{
Handle handle = MetadataTokens.Handle(methodToken);
if (handle.Kind == HandleKind.MethodDefinition)
{
MethodDebugInformationHandle methodDebugHandle = ((MethodDefinitionHandle)handle).ToDebugInformationHandle();
MethodDebugInformation methodInfo = reader.GetMethodDebugInformation(methodDebugHandle);
if (!methodInfo.SequencePointsBlob.IsNil)
{
SequencePointCollection sequencePoints = methodInfo.GetSequencePoints();
SequencePoint? bestPointSoFar = null;
foreach (SequencePoint point in sequencePoints)
{
if (point.Offset > ilOffset)
break;
if (point.StartLine != SequencePoint.HiddenLine)
bestPointSoFar = point;
}
if (bestPointSoFar.HasValue)
{
sourceLine = bestPointSoFar.Value.StartLine;
sourceColumn = bestPointSoFar.Value.StartColumn;
sourceFile = reader.GetString(reader.GetDocument(bestPointSoFar.Value.Document).Name);
}
}
}
}
}
/// <summary>
/// Returns the portable PDB reader for the assembly path
/// </summary>
/// <param name="assemblyPath">
/// File path of the assembly or null if the module is dynamic (generated by Reflection.Emit).
/// </param>
/// <param name="loadedPeAddress">
/// Loaded PE image address or zero if the module is dynamic (generated by Reflection.Emit).
/// Dynamic modules have their PDBs (if any) generated to an in-memory stream
/// (pointed to by <paramref name="inMemoryPdbAddress"/> and <paramref name="inMemoryPdbSize"/>).
/// </param>
/// <param name="loadedPeSize">loaded PE image size</param>
/// <param name="inMemoryPdbAddress">in memory PDB address or zero</param>
/// <param name="inMemoryPdbSize">in memory PDB size</param>
/// <param name="reader">returns the reader</param>
/// <returns>reader</returns>
/// <remarks>
/// Assumes that neither PE image nor PDB loaded into memory can be unloaded or moved around.
/// </remarks>
private unsafe MetadataReader TryGetReader(string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize, IntPtr inMemoryPdbAddress, int inMemoryPdbSize)
{
if ((loadedPeAddress == IntPtr.Zero || assemblyPath == null) && inMemoryPdbAddress == IntPtr.Zero)
{
// Dynamic or in-memory module without symbols (they would be in-memory if they were available).
return null;
}
IntPtr cacheKey = (inMemoryPdbAddress != IntPtr.Zero) ? inMemoryPdbAddress : loadedPeAddress;
MetadataReaderProvider provider;
if (_metadataCache.TryGetValue(cacheKey, out provider))
{
return provider.GetMetadataReader();
}
provider = (inMemoryPdbAddress != IntPtr.Zero) ?
TryOpenReaderForInMemoryPdb(inMemoryPdbAddress, inMemoryPdbSize) :
TryOpenReaderFromAssemblyFile(assemblyPath, loadedPeAddress, loadedPeSize);
if (provider == null)
{
return null;
}
_metadataCache.Add(cacheKey, provider);
// The reader has already been open, so this doesn't throw:
return provider.GetMetadataReader();
}
private static unsafe MetadataReaderProvider TryOpenReaderForInMemoryPdb(IntPtr inMemoryPdbAddress, int inMemoryPdbSize)
{
Debug.Assert(inMemoryPdbAddress != IntPtr.Zero);
// quick check to avoid throwing exceptions below in common cases:
const uint ManagedMetadataSignature = 0x424A5342;
if (inMemoryPdbSize < sizeof(uint) || *(uint*)inMemoryPdbAddress != ManagedMetadataSignature)
{
// not a Portable PDB
return null;
}
var provider = MetadataReaderProvider.FromMetadataImage((byte*)inMemoryPdbAddress, inMemoryPdbSize);
try
{
// may throw if the metadata is invalid
provider.GetMetadataReader();
return provider;
}
catch (BadImageFormatException)
{
provider.Dispose();
return null;
}
}
private static unsafe PEReader TryGetPEReader(string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize)
{
// TODO: https://github.com/dotnet/corefx/issues/11406
//if (loadedPeAddress != IntPtr.Zero && loadedPeSize > 0)
//{
// return new PEReader((byte*)loadedPeAddress, loadedPeSize, isLoadedImage: true);
//}
Stream peStream = TryOpenFile(assemblyPath);
if (peStream != null)
{
return new PEReader(peStream);
}
return null;
}
private static MetadataReaderProvider TryOpenReaderFromAssemblyFile(string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize)
{
using (var peReader = TryGetPEReader(assemblyPath, loadedPeAddress, loadedPeSize))
{
if (peReader == null)
{
return null;
}
string pdbPath;
MetadataReaderProvider provider;
if (peReader.TryOpenAssociatedPortablePdb(assemblyPath, TryOpenFile, out provider, out pdbPath))
{
// TODO:
// Consider caching the provider in a global cache (accross stack traces) if the PDB is embedded (pdbPath == null),
// as decompressing embedded PDB takes some time.
return provider;
}
}
return null;
}
private static Stream TryOpenFile(string path)
{
if (!File.Exists(path))
{
return null;
}
try
{
return File.OpenRead(path);
}
catch
{
return null;
}
}
}
}

View File

@@ -0,0 +1,19 @@
// 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.
namespace System.Diagnostics.SymbolStore
{
public interface ISymbolBinder
{
// The importer parameter should be an IntPtr, not an int. This interface can not be modified without
// a breaking change, and so ISymbolBinderEx.GetReader() has been added with the correct marshalling layout.
[Obsolete("The recommended alternative is ISymbolBinder1.GetReader. ISymbolBinder1.GetReader takes the importer interface pointer as an IntPtr instead of an Int32, and thus works on both 32-bit and 64-bit architectures. http://go.microsoft.com/fwlink/?linkid=14202=14202")]
ISymbolReader GetReader(int importer, string filename, string searchPath);
}
public interface ISymbolBinder1
{
ISymbolReader GetReader(IntPtr importer, string filename, string searchPath);
}
}

View File

@@ -0,0 +1,31 @@
// 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.
namespace System.Diagnostics.SymbolStore
{
public interface ISymbolDocument
{
// Properties of the document.
string URL { get; }
Guid DocumentType { get; }
// Language of the document.
Guid Language { get; }
Guid LanguageVendor { get; }
// Check sum information.
Guid CheckSumAlgorithmId { get; }
byte[] GetCheckSum();
// Given a line in this document that may or may not be a sequence
// point, return the closest line that is a sequence point.
int FindClosestLine(int line);
// Access to embedded source.
bool HasEmbeddedSource { get; }
int SourceLength { get; }
byte[] GetSourceRange(int startLine, int startColumn,
int endLine, int endColumn);
}
}

View File

@@ -0,0 +1,12 @@
// 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.
namespace System.Diagnostics.SymbolStore
{
public interface ISymbolDocumentWriter
{
void SetCheckSum(System.Guid algorithmId, byte[] checkSum);
void SetSource(byte[] source);
}
}

View File

@@ -0,0 +1,69 @@
// 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.
namespace System.Diagnostics.SymbolStore
{
public interface ISymbolMethod
{
// Get the token for this method.
SymbolToken Token { get; }
// Get the count of sequence points.
int SequencePointCount { get; }
// Get the sequence points for this method. The sequence points
// are sorted by offset and are for all documents in the
// method. Use GetSequencePointCount to retrieve the count of all
// sequence points and create arrays of the proper size.
// GetSequencePoints will verify the size of each array and place
// the sequence point information into each. If any array is NULL,
// then the data for that array is simply not returned.
void GetSequencePoints(int[] offsets,
ISymbolDocument[] documents,
int[] lines,
int[] columns,
int[] endLines,
int[] endColumns);
// Get the root lexical scope for this method. This scope encloses
// the entire method.
ISymbolScope RootScope { get; }
// Given an offset within the method, returns the most enclosing
// lexical scope. This can be used to start local variable
// searches.
ISymbolScope GetScope(int offset);
// Given a position in a document, return the offset within the
// method that corresponds to the position.
int GetOffset(ISymbolDocument document,
int line,
int column);
// Given a position in a document, return an array of start/end
// offset paris that correspond to the ranges of IL that the
// position covers within this method. The array is an array of
// integers and is [start,end,start,end]. The number of range
// pairs is the length of the array / 2.
int[] GetRanges(ISymbolDocument document,
int line,
int column);
// Get the parameters for this method. The paraemeters are
// returned in the order they are defined within the method's
// signature.
ISymbolVariable[] GetParameters();
// Get the namespace that this method is defined within.
ISymbolNamespace GetNamespace();
// Get the start/end document positions for the source of this
// method. The first array position is the start while the second
// is the end. Returns true if positions were defined, false
// otherwise.
bool GetSourceStartEnd(ISymbolDocument[] docs,
int[] lines,
int[] columns);
}
}

View File

@@ -0,0 +1,18 @@
// 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.
namespace System.Diagnostics.SymbolStore
{
public interface ISymbolNamespace
{
// Get the name of this namespace
string Name { get; }
// Get the children of this namespace
ISymbolNamespace[] GetNamespaces();
// Get the variables in this namespace
ISymbolVariable[] GetVariables();
}
}

View File

@@ -0,0 +1,53 @@
// 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.
namespace System.Diagnostics.SymbolStore
{
public interface ISymbolReader
{
// Find a document. Language, vendor, and document type are
// optional.
ISymbolDocument GetDocument(string url,
Guid language,
Guid languageVendor,
Guid documentType);
// Return an array of all of the documents defined in the symbol
// store.
ISymbolDocument[] GetDocuments();
// Return the method that was specified as the user entry point
// for the module, if any. This would be, perhaps, the user's main
// method rather than compiler generated stubs before main.
SymbolToken UserEntryPoint { get; }
// Get a symbol reader method given the id of a method.
ISymbolMethod GetMethod(SymbolToken method);
// Get a symbol reader method given the id of a method and an E&C
// version number. Version numbers start a 1 and are incremented
// each time the method is changed due to an E&C operation.
ISymbolMethod GetMethod(SymbolToken method, int version);
// Return a non-local variable given its parent and name.
ISymbolVariable[] GetVariables(SymbolToken parent);
// Return a non-local variable given its parent and name.
ISymbolVariable[] GetGlobalVariables();
// Given a position in a document, return the ISymbolMethod that
// contains that position.
ISymbolMethod GetMethodFromDocumentPosition(ISymbolDocument document,
int line,
int column);
// Gets a custom attribute based upon its name. Not to be
// confused with Metadata custom attributes, these attributes are
// held in the symbol store.
byte[] GetSymAttribute(SymbolToken parent, string name);
// Get the namespaces defined at global scope within this symbol store.
ISymbolNamespace[] GetNamespaces();
}
}

View File

@@ -0,0 +1,31 @@
// 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.
namespace System.Diagnostics.SymbolStore
{
public interface ISymbolScope
{
// Get the method that contains this scope.
ISymbolMethod Method { get; }
// Get the parent scope of this scope.
ISymbolScope Parent { get; }
// Get any child scopes of this scope.
ISymbolScope[] GetChildren();
// Get the start and end offsets for this scope.
int StartOffset { get; }
int EndOffset { get; }
// Get the locals within this scope. They are returned in no
// particular order. Note: if a local variable changes its address
// within this scope then that variable will be returned multiple
// times, each with a different offset range.
ISymbolVariable[] GetLocals();
// Get the namespaces that are being "used" within this scope.
ISymbolNamespace[] GetNamespaces();
}
}

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