You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
4
external/cecil/symbols/pdb/.gitignore
vendored
4
external/cecil/symbols/pdb/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
bin
|
||||
obj
|
||||
*.xml
|
||||
*.user
|
0
external/cecil/symbols/pdb/Microsoft.Cci.Pdb/LICENSE
vendored
Executable file → Normal file
0
external/cecil/symbols/pdb/Microsoft.Cci.Pdb/LICENSE
vendored
Executable file → Normal file
@@ -24,6 +24,8 @@ namespace Microsoft.Cci.Pdb {
|
||||
// this.pageSize = pageSize;
|
||||
//}
|
||||
|
||||
const string MAGIC = "Microsoft C/C++ MSF 7.00";
|
||||
|
||||
internal PdbFileHeader(Stream reader, BitAccess bits) {
|
||||
bits.MinCapacity(56);
|
||||
reader.Seek(0, SeekOrigin.Begin);
|
||||
@@ -37,15 +39,18 @@ namespace Microsoft.Cci.Pdb {
|
||||
bits.ReadInt32(out this.directorySize); // 44..47
|
||||
bits.ReadInt32(out this.zero); // 48..51
|
||||
|
||||
if (Magic != MAGIC) {
|
||||
throw new InvalidOperationException("Magic is wrong.");
|
||||
}
|
||||
int directoryPages = ((((directorySize + pageSize - 1) / pageSize) * 4) + pageSize - 1) / pageSize;
|
||||
this.directoryRoot = new int[directoryPages];
|
||||
bits.FillBuffer(reader, directoryPages * 4);
|
||||
bits.ReadInt32(this.directoryRoot);
|
||||
}
|
||||
|
||||
//internal string Magic {
|
||||
// get { return StringFromBytesUTF8(magic); }
|
||||
//}
|
||||
string Magic {
|
||||
get { return StringFromBytesUTF8(magic, 0, MAGIC.Length); }
|
||||
}
|
||||
|
||||
//internal void Write(Stream writer, BitAccess bits) {
|
||||
// bits.MinCapacity(pageSize);
|
||||
@@ -63,18 +68,18 @@ namespace Microsoft.Cci.Pdb {
|
||||
|
||||
//////////////////////////////////////////////////// Helper Functions.
|
||||
//
|
||||
//internal static string StringFromBytesUTF8(byte[] bytes) {
|
||||
// return StringFromBytesUTF8(bytes, 0, bytes.Length);
|
||||
//}
|
||||
static string StringFromBytesUTF8(byte[] bytes) {
|
||||
return StringFromBytesUTF8(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
//internal static string StringFromBytesUTF8(byte[] bytes, int offset, int length) {
|
||||
// for (int i = 0; i < length; i++) {
|
||||
// if (bytes[offset + i] < ' ') {
|
||||
// length = i;
|
||||
// }
|
||||
// }
|
||||
// return Encoding.UTF8.GetString(bytes, offset, length);
|
||||
//}
|
||||
static string StringFromBytesUTF8(byte[] bytes, int offset, int length) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (bytes[offset + i] < ' ') {
|
||||
length = i;
|
||||
}
|
||||
}
|
||||
return Encoding.UTF8.GetString(bytes, offset, length);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////// Fields.
|
||||
//
|
||||
|
@@ -356,7 +356,7 @@ namespace Microsoft.Cci.Pdb {
|
||||
case 2: break; // this.ReadForwardedToModuleInfo(bits); break;
|
||||
case 3: this.ReadIteratorLocals(bits); break;
|
||||
case 4: this.ReadForwardIterator(bits); break;
|
||||
default: throw new PdbDebugException("Unknown custom metadata item kind: {0}", kind);
|
||||
// TODO: handle unknown custom metadata, 5 & 6 are new with roslyn, see https://roslyn.codeplex.com/workitem/54
|
||||
}
|
||||
bits.Position = savedPosition+(int)numberOfBytesInItem;
|
||||
}
|
||||
|
121
external/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj
vendored
121
external/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj
vendored
@@ -1,83 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">net_4_0_Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{63E6915C-7EA4-4D76-AB28-0D7191EEA626}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Mono.Cecil.Pdb</RootNamespace>
|
||||
<AssemblyName>Mono.Cecil.Pdb</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\mono.snk</AssemblyOriginatorKeyFile>
|
||||
<NoWarn>0649</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_2_0_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\net_2_0_Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_2_0_Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\net_2_0_Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_3_5_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\net_3_5_Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NET_3_5</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_3_5_Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\net_3_5_Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NET_3_5</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_0_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\net_4_0_Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NET_3_5;NET_4_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_0_Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\net_4_0_Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NET_3_5;NET_4_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(TargetFrameworkVersion)' != 'v2.0' ">
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Mono.Cecil.csproj">
|
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
|
||||
@@ -85,49 +13,10 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Microsoft.Cci.Pdb\BitAccess.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\BitSet.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\CvInfo.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\DataStream.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\DbiDbgHdr.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\DbiHeader.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\DbiModuleInfo.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\DbiSecCon.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\Interfaces.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\IntHashTable.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\MsfDirectory.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbConstant.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbDebugException.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbException.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbFile.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbFileHeader.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbFunction.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbLine.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbLines.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbReader.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbScope.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbSlot.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbSource.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\PdbTokenLine.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\SourceLocationProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Mono.Cecil.Pdb\AssemblyInfo.cs" />
|
||||
<Compile Include="Mono.Cecil.Pdb\ISymUnmanagedDocumentWriter.cs" />
|
||||
<Compile Include="Mono.Cecil.Pdb\ISymUnmanagedWriter2.cs" />
|
||||
<Compile Include="Mono.Cecil.Pdb\ModuleMetadata.cs" />
|
||||
<Compile Include="Mono.Cecil.Pdb\PdbHelper.cs" />
|
||||
<Compile Include="Mono.Cecil.Pdb\PdbReader.cs" />
|
||||
<Compile Include="Mono.Cecil.Pdb\PdbWriter.cs" />
|
||||
<Compile Include="Mono.Cecil.Pdb\SymDocumentWriter.cs" />
|
||||
<Compile Include="Mono.Cecil.Pdb\SymWriter.cs" />
|
||||
<Compile Include="..\..\ProjectInfo.cs" />
|
||||
<Compile Include="Microsoft.Cci.Pdb\*.cs" />
|
||||
<Compile Include="Mono.Cecil.Pdb\*.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<Import Project="..\..\Mono.Cecil.props" />
|
||||
<Import Project="$(MSBuildCSharpTargets)" />
|
||||
</Project>
|
@@ -1,41 +1,16 @@
|
||||
//
|
||||
// AssemblyInfo.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle ("Mono.Cecil.Pdb")]
|
||||
[assembly: AssemblyProduct ("Mono.Cecil")]
|
||||
[assembly: AssemblyCopyright ("Copyright <20> 2008 - 2011 Jb Evain")]
|
||||
|
||||
[assembly: CLSCompliant (false)]
|
||||
[assembly: ComVisible (false)]
|
||||
|
||||
[assembly: AssemblyVersion ("0.9.5.0")]
|
||||
[assembly: AssemblyFileVersion ("0.9.5.0")]
|
||||
|
@@ -1,28 +1,9 @@
|
||||
// ISymUnmanagedDocumentWriter.cs
|
||||
//
|
||||
// Author:
|
||||
// Juerg Billeter (j@bitron.ch)
|
||||
//
|
||||
// (C) 2008 Juerg Billeter
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
@@ -1,29 +1,10 @@
|
||||
//
|
||||
// ISymUnmanagedWriter2.cs
|
||||
//
|
||||
// Author:
|
||||
// Juerg Billeter (j@bitron.ch)
|
||||
//
|
||||
// (C) 2008 Juerg Billeter
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
@@ -487,7 +487,7 @@ namespace Mono.Cecil.Pdb {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WriteString (type.Name, szTypeDef, cchTypeDef, out pchTypeDef);
|
||||
WriteString (type.IsNested ? type.Name : type.FullName, szTypeDef, cchTypeDef, out pchTypeDef);
|
||||
WriteIntPtr (pdwTypeDefFlags, (uint) type.Attributes);
|
||||
return type.BaseType != null ? type.BaseType.MetadataToken.ToUInt32 () : 0;
|
||||
}
|
||||
|
@@ -1,43 +1,95 @@
|
||||
//
|
||||
// PdbHelper.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Mono.Cecil.Cil;
|
||||
|
||||
namespace Mono.Cecil.Pdb {
|
||||
|
||||
class PdbHelper {
|
||||
public sealed class NativePdbReaderProvider : ISymbolReaderProvider {
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckFileName (fileName);
|
||||
|
||||
return new PdbReader (Disposable.Owned (File.OpenRead (Mixin.GetPdbFileName (fileName)) as Stream));
|
||||
}
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckStream (symbolStream);
|
||||
|
||||
return new PdbReader (Disposable.NotOwned (symbolStream));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class PdbReaderProvider : ISymbolReaderProvider {
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckFileName (fileName);
|
||||
|
||||
return IsPortablePdb (Mixin.GetPdbFileName (fileName))
|
||||
? new PortablePdbReaderProvider ().GetSymbolReader (module, fileName)
|
||||
: new NativePdbReaderProvider ().GetSymbolReader (module, fileName);
|
||||
}
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckStream (symbolStream);
|
||||
Mixin.CheckReadSeek (symbolStream);
|
||||
|
||||
return IsPortablePdb (symbolStream)
|
||||
? new PortablePdbReaderProvider ().GetSymbolReader (module, symbolStream)
|
||||
: new NativePdbReaderProvider ().GetSymbolReader (module, symbolStream);
|
||||
}
|
||||
|
||||
static bool IsPortablePdb (string fileName)
|
||||
{
|
||||
using (var file = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.None))
|
||||
return IsPortablePdb (file);
|
||||
}
|
||||
|
||||
static bool IsPortablePdb (Stream stream)
|
||||
{
|
||||
const uint ppdb_signature = 0x424a5342;
|
||||
|
||||
var position = stream.Position;
|
||||
try {
|
||||
var reader = new BinaryReader (stream);
|
||||
return reader.ReadUInt32 () == ppdb_signature;
|
||||
} finally {
|
||||
stream.Position = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
public static SymWriter CreateWriter (ModuleDefinition module, string pdb)
|
||||
|
||||
public sealed class NativePdbWriterProvider : ISymbolWriterProvider {
|
||||
|
||||
public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckFileName (fileName);
|
||||
|
||||
return new PdbWriter (module, CreateWriter (module, Mixin.GetPdbFileName (fileName)));
|
||||
}
|
||||
|
||||
static SymWriter CreateWriter (ModuleDefinition module, string pdb)
|
||||
{
|
||||
var writer = new SymWriter ();
|
||||
|
||||
@@ -48,35 +100,6 @@ namespace Mono.Cecil.Pdb {
|
||||
|
||||
return writer;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static string GetPdbFileName (string assemblyFileName)
|
||||
{
|
||||
return Path.ChangeExtension (assemblyFileName, ".pdb");
|
||||
}
|
||||
}
|
||||
|
||||
public class PdbReaderProvider : ISymbolReaderProvider {
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName)
|
||||
{
|
||||
return new PdbReader (File.OpenRead (PdbHelper.GetPdbFileName (fileName)));
|
||||
}
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream)
|
||||
{
|
||||
return new PdbReader (symbolStream);
|
||||
}
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
|
||||
public class PdbWriterProvider : ISymbolWriterProvider {
|
||||
|
||||
public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName)
|
||||
{
|
||||
return new PdbWriter (module, PdbHelper.CreateWriter (module, PdbHelper.GetPdbFileName (fileName)));
|
||||
}
|
||||
|
||||
public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream)
|
||||
{
|
||||
@@ -84,123 +107,36 @@ namespace Mono.Cecil.Pdb {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
public sealed class PdbWriterProvider : ISymbolWriterProvider {
|
||||
|
||||
static class GuidMapping {
|
||||
|
||||
static readonly Dictionary<Guid, DocumentLanguage> guid_language = new Dictionary<Guid, DocumentLanguage> ();
|
||||
static readonly Dictionary<DocumentLanguage, Guid> language_guid = new Dictionary<DocumentLanguage, Guid> ();
|
||||
|
||||
static GuidMapping ()
|
||||
public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName)
|
||||
{
|
||||
AddMapping (DocumentLanguage.C, new Guid (0x63a08714, 0xfc37, 0x11d2, 0x90, 0x4c, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1));
|
||||
AddMapping (DocumentLanguage.Cpp, new Guid (0x3a12d0b7, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2));
|
||||
AddMapping (DocumentLanguage.CSharp, new Guid (0x3f5162f8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1));
|
||||
AddMapping (DocumentLanguage.Basic, new Guid (0x3a12d0b8, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2));
|
||||
AddMapping (DocumentLanguage.Java, new Guid (0x3a12d0b4, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2));
|
||||
AddMapping (DocumentLanguage.Cobol, new Guid (0xaf046cd1, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc));
|
||||
AddMapping (DocumentLanguage.Pascal, new Guid (0xaf046cd2, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc));
|
||||
AddMapping (DocumentLanguage.Cil, new Guid (0xaf046cd3, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc));
|
||||
AddMapping (DocumentLanguage.JScript, new Guid (0x3a12d0b6, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2));
|
||||
AddMapping (DocumentLanguage.Smc, new Guid (0xd9b9f7b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x0, 0x0, 0xf8, 0x8, 0x49, 0xbd));
|
||||
AddMapping (DocumentLanguage.MCpp, new Guid (0x4b35fde8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1));
|
||||
AddMapping (DocumentLanguage.FSharp, new Guid (0xab4f38c9, 0xb6e6, 0x43ba, 0xbe, 0x3b, 0x58, 0x08, 0x0b, 0x2c, 0xcc, 0xe3));
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckFileName (fileName);
|
||||
|
||||
if (HasPortablePdbSymbols (module))
|
||||
return new PortablePdbWriterProvider ().GetSymbolWriter (module, fileName);
|
||||
|
||||
return new NativePdbWriterProvider ().GetSymbolWriter (module, fileName);
|
||||
}
|
||||
|
||||
static void AddMapping (DocumentLanguage language, Guid guid)
|
||||
static bool HasPortablePdbSymbols (ModuleDefinition module)
|
||||
{
|
||||
guid_language.Add (guid, language);
|
||||
language_guid.Add (language, guid);
|
||||
return module.symbol_reader != null && module.symbol_reader is PortablePdbReader;
|
||||
}
|
||||
|
||||
static readonly Guid type_text = new Guid (0x5a869d0b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x00, 0x00, 0xf8, 0x08, 0x49, 0xbd);
|
||||
|
||||
public static DocumentType ToType (this Guid guid)
|
||||
public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream)
|
||||
{
|
||||
if (guid == type_text)
|
||||
return DocumentType.Text;
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckStream (symbolStream);
|
||||
Mixin.CheckReadSeek (symbolStream);
|
||||
|
||||
return DocumentType.Other;
|
||||
}
|
||||
if (HasPortablePdbSymbols (module))
|
||||
return new PortablePdbWriterProvider ().GetSymbolWriter (module, symbolStream);
|
||||
|
||||
public static Guid ToGuid (this DocumentType type)
|
||||
{
|
||||
if (type == DocumentType.Text)
|
||||
return type_text;
|
||||
|
||||
return new Guid ();
|
||||
}
|
||||
|
||||
static readonly Guid hash_md5 = new Guid (0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99);
|
||||
static readonly Guid hash_sha1 = new Guid (0xff1816ec, 0xaa5e, 0x4d10, 0x87, 0xf7, 0x6f, 0x49, 0x63, 0x83, 0x34, 0x60);
|
||||
|
||||
public static DocumentHashAlgorithm ToHashAlgorithm (this Guid guid)
|
||||
{
|
||||
if (guid == hash_md5)
|
||||
return DocumentHashAlgorithm.MD5;
|
||||
|
||||
if (guid == hash_sha1)
|
||||
return DocumentHashAlgorithm.SHA1;
|
||||
|
||||
return DocumentHashAlgorithm.None;
|
||||
}
|
||||
|
||||
public static Guid ToGuid (this DocumentHashAlgorithm hash_algo)
|
||||
{
|
||||
if (hash_algo == DocumentHashAlgorithm.MD5)
|
||||
return hash_md5;
|
||||
|
||||
if (hash_algo == DocumentHashAlgorithm.SHA1)
|
||||
return hash_sha1;
|
||||
|
||||
return new Guid ();
|
||||
}
|
||||
|
||||
public static DocumentLanguage ToLanguage (this Guid guid)
|
||||
{
|
||||
DocumentLanguage language;
|
||||
if (!guid_language.TryGetValue (guid, out language))
|
||||
return DocumentLanguage.Other;
|
||||
|
||||
return language;
|
||||
}
|
||||
|
||||
public static Guid ToGuid (this DocumentLanguage language)
|
||||
{
|
||||
Guid guid;
|
||||
if (!language_guid.TryGetValue (language, out guid))
|
||||
return new Guid ();
|
||||
|
||||
return guid;
|
||||
}
|
||||
|
||||
static readonly Guid vendor_ms = new Guid (0x994b45c4, 0xe6e9, 0x11d2, 0x90, 0x3f, 0x00, 0xc0, 0x4f, 0xa3, 0x02, 0xa1);
|
||||
|
||||
public static DocumentLanguageVendor ToVendor (this Guid guid)
|
||||
{
|
||||
if (guid == vendor_ms)
|
||||
return DocumentLanguageVendor.Microsoft;
|
||||
|
||||
return DocumentLanguageVendor.Other;
|
||||
}
|
||||
|
||||
public static Guid ToGuid (this DocumentLanguageVendor vendor)
|
||||
{
|
||||
if (vendor == DocumentLanguageVendor.Microsoft)
|
||||
return vendor_ms;
|
||||
|
||||
return new Guid ();
|
||||
return new NativePdbWriterProvider ().GetSymbolWriter (module, symbolStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !NET_3_5 && !NET_4_0
|
||||
|
||||
namespace System.Runtime.CompilerServices {
|
||||
|
||||
[AttributeUsage (AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
|
||||
sealed class ExtensionAttribute : Attribute {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@@ -1,35 +1,19 @@
|
||||
//
|
||||
// PdbReader.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
using Microsoft.Cci.Pdb;
|
||||
|
||||
using Mono.Cecil.Cil;
|
||||
@@ -41,11 +25,11 @@ namespace Mono.Cecil.Pdb {
|
||||
int age;
|
||||
Guid guid;
|
||||
|
||||
readonly Stream pdb_file;
|
||||
readonly Disposable<Stream> pdb_file;
|
||||
readonly Dictionary<string, Document> documents = new Dictionary<string, Document> ();
|
||||
readonly Dictionary<uint, PdbFunction> functions = new Dictionary<uint, PdbFunction> ();
|
||||
|
||||
internal PdbReader (Stream file)
|
||||
internal PdbReader (Disposable<Stream> file)
|
||||
{
|
||||
this.pdb_file = file;
|
||||
}
|
||||
@@ -59,6 +43,11 @@ namespace Mono.Cecil.Pdb {
|
||||
|
||||
public bool ProcessDebugHeader (ImageDebugDirectory directory, byte [] header)
|
||||
{
|
||||
if (directory.Type != 2) //IMAGE_DEBUG_TYPE_CODEVIEW
|
||||
return false;
|
||||
if (directory.MajorVersion != 0 || directory.MinorVersion != 0)
|
||||
return false;
|
||||
|
||||
if (header.Length < 24)
|
||||
return false;
|
||||
|
||||
@@ -91,7 +80,7 @@ namespace Mono.Cecil.Pdb {
|
||||
int age;
|
||||
Guid guid;
|
||||
|
||||
var funcs = PdbFile.LoadFunctions (pdb_file, out tokenToSourceMapping, out sourceServerData, out age, out guid);
|
||||
var funcs = PdbFile.LoadFunctions (pdb_file.value, out tokenToSourceMapping, out sourceServerData, out age, out guid);
|
||||
|
||||
if (this.guid != guid)
|
||||
return false;
|
||||
@@ -103,102 +92,99 @@ namespace Mono.Cecil.Pdb {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Read (MethodBody body, InstructionMapper mapper)
|
||||
public MethodDebugInformation Read (MethodDefinition method)
|
||||
{
|
||||
var method_token = body.Method.MetadataToken;
|
||||
var method_token = method.MetadataToken;
|
||||
|
||||
PdbFunction function;
|
||||
if (!functions.TryGetValue (method_token.ToUInt32 (), out function))
|
||||
return;
|
||||
return null;
|
||||
|
||||
ReadSequencePoints (function, mapper);
|
||||
ReadScopeAndLocals (function.scopes, null, body, mapper);
|
||||
var symbol = new MethodDebugInformation (method);
|
||||
|
||||
ReadSequencePoints (function, symbol);
|
||||
|
||||
if (function.scopes.Length > 1)
|
||||
throw new NotSupportedException ();
|
||||
else if (function.scopes.Length == 1)
|
||||
symbol.scope = ReadScopeAndLocals (function.scopes [0], symbol);
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
static void ReadScopeAndLocals (PdbScope [] scopes, Scope parent, MethodBody body, InstructionMapper mapper)
|
||||
static Collection<ScopeDebugInformation> ReadScopeAndLocals (PdbScope [] scopes, MethodDebugInformation info)
|
||||
{
|
||||
var symbols = new Collection<ScopeDebugInformation> (scopes.Length);
|
||||
|
||||
foreach (PdbScope scope in scopes)
|
||||
ReadScopeAndLocals (scope, parent, body, mapper);
|
||||
if (scope != null)
|
||||
symbols.Add (ReadScopeAndLocals (scope, info));
|
||||
|
||||
CreateRootScope (body);
|
||||
return symbols;
|
||||
}
|
||||
|
||||
static void CreateRootScope (MethodBody body)
|
||||
static ScopeDebugInformation ReadScopeAndLocals (PdbScope scope, MethodDebugInformation info)
|
||||
{
|
||||
if (!body.HasVariables)
|
||||
return;
|
||||
var parent = new ScopeDebugInformation ();
|
||||
parent.Start = new InstructionOffset ((int) scope.offset);
|
||||
parent.End = new InstructionOffset ((int) (scope.offset + scope.length));
|
||||
|
||||
var instructions = body.Instructions;
|
||||
if (!scope.slots.IsNullOrEmpty()) {
|
||||
parent.variables = new Collection<VariableDebugInformation> (scope.slots.Length);
|
||||
|
||||
var root = new Scope ();
|
||||
root.Start = instructions [0];
|
||||
root.End = instructions [instructions.Count - 1];
|
||||
|
||||
var variables = body.Variables;
|
||||
for (int i = 0; i < variables.Count; i++)
|
||||
root.Variables.Add (variables [i]);
|
||||
|
||||
body.Scope = root;
|
||||
}
|
||||
|
||||
static void ReadScopeAndLocals (PdbScope scope, Scope parent, MethodBody body, InstructionMapper mapper)
|
||||
{
|
||||
//Scope s = new Scope ();
|
||||
//s.Start = GetInstruction (body, instructions, (int) scope.address);
|
||||
//s.End = GetInstruction (body, instructions, (int) scope.length - 1);
|
||||
|
||||
//if (parent != null)
|
||||
// parent.Scopes.Add (s);
|
||||
//else
|
||||
// body.Scopes.Add (s);
|
||||
|
||||
if (scope == null)
|
||||
return;
|
||||
|
||||
foreach (PdbSlot slot in scope.slots) {
|
||||
int index = (int) slot.slot;
|
||||
if (index < 0 || index >= body.Variables.Count)
|
||||
continue;
|
||||
|
||||
VariableDefinition variable = body.Variables [index];
|
||||
variable.Name = slot.name;
|
||||
|
||||
//s.Variables.Add (variable);
|
||||
foreach (PdbSlot slot in scope.slots) {
|
||||
var index = (int) slot.slot;
|
||||
var variable = new VariableDebugInformation (index, slot.name);
|
||||
if (slot.flags == 4)
|
||||
variable.IsDebuggerHidden = true;
|
||||
parent.variables.Add (variable);
|
||||
}
|
||||
}
|
||||
|
||||
ReadScopeAndLocals (scope.scopes, null /* s */, body, mapper);
|
||||
if (!scope.constants.IsNullOrEmpty ()) {
|
||||
parent.constants = new Collection<ConstantDebugInformation> (scope.constants.Length);
|
||||
|
||||
foreach (var constant in scope.constants) {
|
||||
parent.constants.Add (new ConstantDebugInformation (
|
||||
constant.name,
|
||||
(TypeReference) info.method.Module.LookupToken ((int) constant.token),
|
||||
constant.value));
|
||||
}
|
||||
}
|
||||
|
||||
parent.scopes = ReadScopeAndLocals (scope.scopes, info);
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
void ReadSequencePoints (PdbFunction function, InstructionMapper mapper)
|
||||
void ReadSequencePoints (PdbFunction function, MethodDebugInformation info)
|
||||
{
|
||||
if (function.lines == null)
|
||||
return;
|
||||
|
||||
info.sequence_points = new Collection<SequencePoint> ();
|
||||
|
||||
foreach (PdbLines lines in function.lines)
|
||||
ReadLines (lines, mapper);
|
||||
ReadLines (lines, info);
|
||||
}
|
||||
|
||||
void ReadLines (PdbLines lines, InstructionMapper mapper)
|
||||
void ReadLines (PdbLines lines, MethodDebugInformation info)
|
||||
{
|
||||
var document = GetDocument (lines.file);
|
||||
|
||||
foreach (var line in lines.lines)
|
||||
ReadLine (line, document, mapper);
|
||||
ReadLine (line, document, info);
|
||||
}
|
||||
|
||||
static void ReadLine (PdbLine line, Document document, InstructionMapper mapper)
|
||||
static void ReadLine (PdbLine line, Document document, MethodDebugInformation info)
|
||||
{
|
||||
var instruction = mapper ((int) line.offset);
|
||||
if (instruction == null)
|
||||
return;
|
||||
|
||||
var sequence_point = new SequencePoint (document);
|
||||
var sequence_point = new SequencePoint ((int) line.offset, document);
|
||||
sequence_point.StartLine = (int) line.lineBegin;
|
||||
sequence_point.StartColumn = (int) line.colBegin;
|
||||
sequence_point.EndLine = (int) line.lineEnd;
|
||||
sequence_point.EndColumn = (int) line.colEnd;
|
||||
|
||||
instruction.SequencePoint = sequence_point;
|
||||
info.sequence_points.Add (sequence_point);
|
||||
}
|
||||
|
||||
Document GetDocument (PdbSource source)
|
||||
@@ -217,65 +203,9 @@ namespace Mono.Cecil.Pdb {
|
||||
return document;
|
||||
}
|
||||
|
||||
public void Read (MethodSymbols symbols)
|
||||
{
|
||||
PdbFunction function;
|
||||
if (!functions.TryGetValue (symbols.MethodToken.ToUInt32 (), out function))
|
||||
return;
|
||||
|
||||
ReadSequencePoints (function, symbols);
|
||||
ReadLocals (function.scopes, symbols);
|
||||
}
|
||||
|
||||
void ReadLocals (PdbScope [] scopes, MethodSymbols symbols)
|
||||
{
|
||||
foreach (var scope in scopes)
|
||||
ReadLocals (scope, symbols);
|
||||
}
|
||||
|
||||
void ReadLocals (PdbScope scope, MethodSymbols symbols)
|
||||
{
|
||||
if (scope == null)
|
||||
return;
|
||||
|
||||
foreach (var slot in scope.slots) {
|
||||
int index = (int) slot.slot;
|
||||
if (index < 0 || index >= symbols.Variables.Count)
|
||||
continue;
|
||||
|
||||
var variable = symbols.Variables [index];
|
||||
variable.Name = slot.name;
|
||||
}
|
||||
|
||||
ReadLocals (scope.scopes, symbols);
|
||||
}
|
||||
|
||||
void ReadSequencePoints (PdbFunction function, MethodSymbols symbols)
|
||||
{
|
||||
if (function.lines == null)
|
||||
return;
|
||||
|
||||
foreach (PdbLines lines in function.lines)
|
||||
ReadLines (lines, symbols);
|
||||
}
|
||||
|
||||
void ReadLines (PdbLines lines, MethodSymbols symbols)
|
||||
{
|
||||
for (int i = 0; i < lines.lines.Length; i++) {
|
||||
var line = lines.lines [i];
|
||||
|
||||
symbols.Instructions.Add (new InstructionSymbol ((int) line.offset, new SequencePoint (GetDocument (lines.file)) {
|
||||
StartLine = (int) line.lineBegin,
|
||||
StartColumn = (int) line.colBegin,
|
||||
EndLine = (int) line.lineEnd,
|
||||
EndColumn = (int) line.colEnd,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
pdb_file.Close ();
|
||||
pdb_file.Dispose ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,29 +1,11 @@
|
||||
//
|
||||
// PdbWriter.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -56,69 +38,55 @@ namespace Mono.Cecil.Pdb {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Write (MethodBody body)
|
||||
public void Write (MethodDebugInformation info)
|
||||
{
|
||||
var method_token = body.Method.MetadataToken;
|
||||
var method_token = info.method.MetadataToken;
|
||||
var sym_token = new SymbolToken (method_token.ToInt32 ());
|
||||
|
||||
var instructions = CollectInstructions (body);
|
||||
if (instructions.Count == 0)
|
||||
return;
|
||||
|
||||
var start_offset = 0;
|
||||
var end_offset = body.CodeSize;
|
||||
|
||||
writer.OpenMethod (sym_token);
|
||||
writer.OpenScope (start_offset);
|
||||
|
||||
DefineSequencePoints (instructions);
|
||||
DefineVariables (body, start_offset, end_offset);
|
||||
DefineSequencePoints (info.sequence_points);
|
||||
|
||||
if (info.scope != null)
|
||||
DefineScope (info.scope, info);
|
||||
|
||||
writer.CloseScope (end_offset);
|
||||
writer.CloseMethod ();
|
||||
}
|
||||
|
||||
Collection<Instruction> CollectInstructions (MethodBody body)
|
||||
void DefineScope (ScopeDebugInformation scope, MethodDebugInformation info)
|
||||
{
|
||||
var collection = new Collection<Instruction> ();
|
||||
var instructions = body.Instructions;
|
||||
var start_offset = scope.Start.Offset;
|
||||
var end_offset = scope.End.IsEndOfMethod
|
||||
? info.code_size
|
||||
: scope.End.Offset;
|
||||
|
||||
for (int i = 0; i < instructions.Count; i++) {
|
||||
var instruction = instructions [i];
|
||||
var sequence_point = instruction.SequencePoint;
|
||||
if (sequence_point == null)
|
||||
continue;
|
||||
writer.OpenScope (start_offset);
|
||||
|
||||
GetDocument (sequence_point.Document);
|
||||
collection.Add (instruction);
|
||||
var sym_token = new SymbolToken (info.local_var_token.ToInt32 ());
|
||||
|
||||
if (!scope.variables.IsNullOrEmpty ()) {
|
||||
for (int i = 0; i < scope.variables.Count; i++) {
|
||||
var variable = scope.variables [i];
|
||||
CreateLocalVariable (variable, sym_token, start_offset, end_offset);
|
||||
}
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
void DefineVariables (MethodBody body, int start_offset, int end_offset)
|
||||
{
|
||||
if (!body.HasVariables)
|
||||
return;
|
||||
|
||||
var sym_token = new SymbolToken (body.LocalVarToken.ToInt32 ());
|
||||
|
||||
var variables = body.Variables;
|
||||
for (int i = 0; i < variables.Count; i++) {
|
||||
var variable = variables [i];
|
||||
CreateLocalVariable (variable, sym_token, start_offset, end_offset);
|
||||
if (!scope.scopes.IsNullOrEmpty ()) {
|
||||
for (int i = 0; i < scope.scopes.Count; i++)
|
||||
DefineScope (scope.scopes [i], info);
|
||||
}
|
||||
|
||||
writer.CloseScope (end_offset);
|
||||
}
|
||||
|
||||
void DefineSequencePoints (Collection<Instruction> instructions)
|
||||
void DefineSequencePoints (Collection<SequencePoint> sequence_points)
|
||||
{
|
||||
for (int i = 0; i < instructions.Count; i++) {
|
||||
var instruction = instructions [i];
|
||||
var sequence_point = instruction.SequencePoint;
|
||||
for (int i = 0; i < sequence_points.Count; i++) {
|
||||
var sequence_point = sequence_points [i];
|
||||
|
||||
writer.DefineSequencePoints (
|
||||
GetDocument (sequence_point.Document),
|
||||
new [] { instruction.Offset },
|
||||
new [] { sequence_point.Offset },
|
||||
new [] { sequence_point.StartLine },
|
||||
new [] { sequence_point.StartColumn },
|
||||
new [] { sequence_point.EndLine },
|
||||
@@ -126,11 +94,11 @@ namespace Mono.Cecil.Pdb {
|
||||
}
|
||||
}
|
||||
|
||||
void CreateLocalVariable (VariableDefinition variable, SymbolToken local_var_token, int start_offset, int end_offset)
|
||||
void CreateLocalVariable (VariableDebugInformation variable, SymbolToken local_var_token, int start_offset, int end_offset)
|
||||
{
|
||||
writer.DefineLocalVariable2 (
|
||||
variable.Name,
|
||||
0,
|
||||
variable.Attributes,
|
||||
local_var_token,
|
||||
SymAddressKind.ILOffset,
|
||||
variable.Index,
|
||||
@@ -159,55 +127,6 @@ namespace Mono.Cecil.Pdb {
|
||||
return doc_writer;
|
||||
}
|
||||
|
||||
public void Write (MethodSymbols symbols)
|
||||
{
|
||||
var sym_token = new SymbolToken (symbols.MethodToken.ToInt32 ());
|
||||
|
||||
var start_offset = 0;
|
||||
var end_offset = symbols.CodeSize;
|
||||
|
||||
writer.OpenMethod (sym_token);
|
||||
writer.OpenScope (start_offset);
|
||||
|
||||
DefineSequencePoints (symbols);
|
||||
DefineVariables (symbols, start_offset, end_offset);
|
||||
|
||||
writer.CloseScope (end_offset);
|
||||
writer.CloseMethod ();
|
||||
}
|
||||
|
||||
void DefineSequencePoints (MethodSymbols symbols)
|
||||
{
|
||||
var instructions = symbols.instructions;
|
||||
|
||||
for (int i = 0; i < instructions.Count; i++) {
|
||||
var instruction = instructions [i];
|
||||
var sequence_point = instruction.SequencePoint;
|
||||
|
||||
writer.DefineSequencePoints (
|
||||
GetDocument (sequence_point.Document),
|
||||
new [] { instruction.Offset },
|
||||
new [] { sequence_point.StartLine },
|
||||
new [] { sequence_point.StartColumn },
|
||||
new [] { sequence_point.EndLine },
|
||||
new [] { sequence_point.EndColumn });
|
||||
}
|
||||
}
|
||||
|
||||
void DefineVariables (MethodSymbols symbols, int start_offset, int end_offset)
|
||||
{
|
||||
if (!symbols.HasVariables)
|
||||
return;
|
||||
|
||||
var sym_token = new SymbolToken (symbols.LocalVarToken.ToInt32 ());
|
||||
|
||||
var variables = symbols.Variables;
|
||||
for (int i = 0; i < variables.Count; i++) {
|
||||
var variable = variables [i];
|
||||
CreateLocalVariable (variable, sym_token, start_offset, end_offset);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
var entry_point = module.EntryPoint;
|
||||
|
@@ -1,29 +1,10 @@
|
||||
//
|
||||
// SymDocumentWriter.cs
|
||||
//
|
||||
// Author:
|
||||
// Juerg Billeter (j@bitron.ch)
|
||||
//
|
||||
// (C) 2008 Juerg Billeter
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
@@ -1,29 +1,10 @@
|
||||
//
|
||||
// SymWriter.cs
|
||||
//
|
||||
// Author:
|
||||
// Juerg Billeter (j@bitron.ch)
|
||||
//
|
||||
// (C) 2008 Juerg Billeter
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -78,7 +59,7 @@ namespace Mono.Cecil.Pdb
|
||||
|
||||
public void DefineLocalVariable2 (
|
||||
string name,
|
||||
FieldAttributes attributes,
|
||||
VariableAttributes attributes,
|
||||
SymbolToken sigToken,
|
||||
SymAddressKind addrKind,
|
||||
int addr1,
|
||||
|
4
external/cecil/symbols/pdb/Test/.gitignore
vendored
4
external/cecil/symbols/pdb/Test/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
bin
|
||||
obj
|
||||
*.xml
|
||||
*.user
|
@@ -1,77 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">net_4_0_Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Mono.Cecil.Pdb.Tests</RootNamespace>
|
||||
<AssemblyName>Mono.Cecil.Pdb.Tests</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_2_0_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\net_2_0_Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_2_0_Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\net_2_0_Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_3_5_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\net_3_5_Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NET_3_5</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_3_5_Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\net_3_5_Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NET_3_5</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_0_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\net_4_0_Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NET_3_5;NET_4_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_0_Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\net_4_0_Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NET_3_5;NET_4_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(TargetFrameworkVersion)' != 'v2.0' ">
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Mono.Cecil.csproj">
|
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
|
||||
@@ -87,38 +20,11 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Mono.Cecil.Tests\Addin.cs" />
|
||||
<Compile Include="Mono.Cecil.Tests\Linq.cs" />
|
||||
<Compile Include="Mono.Cecil.Tests\PdbTests.cs" />
|
||||
<Compile Include="Mono.Cecil.Tests\*.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\assemblies\fsapp.exe" />
|
||||
<Content Include="Resources\assemblies\fsapp.pdb" />
|
||||
<Content Include="Resources\assemblies\test.exe" />
|
||||
<Content Include="Resources\assemblies\test.pdb" />
|
||||
<Content Include="Resources\assemblies\VBConsApp.exe" />
|
||||
<Content Include="Resources\assemblies\VBConsApp.pdb" />
|
||||
<None Include="Resources\**\*" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.core">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core.interfaces">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.core.interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<Import Project="..\..\..\Mono.Cecil.Tests.props" />
|
||||
<Import Project="$(MSBuildCSharpTargets)" />
|
||||
</Project>
|
@@ -1,8 +0,0 @@
|
||||
using NUnit.Core.Extensibility;
|
||||
|
||||
namespace Mono.Cecil.Tests {
|
||||
|
||||
[NUnitAddin]
|
||||
public class CecilPdbAddin : CecilTestAddin {
|
||||
}
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if !NET_3_5 && !NET_4_0
|
||||
|
||||
namespace System {
|
||||
|
||||
delegate TResult Func<T, TResult> (T t);
|
||||
}
|
||||
|
||||
namespace System.Runtime.CompilerServices {
|
||||
|
||||
[AttributeUsage (AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
|
||||
sealed class ExtensionAttribute : Attribute {
|
||||
}
|
||||
}
|
||||
|
||||
namespace System.Linq {
|
||||
|
||||
static class Enumerable {
|
||||
|
||||
public static IEnumerable<TRet> Select<TItem, TRet> (this IEnumerable<TItem> self, Func<TItem, TRet> selector)
|
||||
{
|
||||
foreach (var item in self)
|
||||
yield return selector (item);
|
||||
}
|
||||
|
||||
public static IEnumerable<T> Where<T> (this IEnumerable<T> self, Func<T, bool> predicate)
|
||||
{
|
||||
foreach (var item in self)
|
||||
if (predicate (item))
|
||||
yield return item;
|
||||
}
|
||||
|
||||
public static T First<T> (this IEnumerable<T> self)
|
||||
{
|
||||
using (var enumerator = self.GetEnumerator ()) {
|
||||
if (!enumerator.MoveNext ())
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
return enumerator.Current;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -12,13 +12,14 @@ namespace Mono.Cecil.Tests {
|
||||
[TestFixture]
|
||||
public class PdbTests : BaseTestFixture {
|
||||
|
||||
[TestModule ("test.exe", SymbolReaderProvider = typeof (PdbReaderProvider), SymbolWriterProvider = typeof (PdbWriterProvider))]
|
||||
public void Main (ModuleDefinition module)
|
||||
[Test]
|
||||
public void Main ()
|
||||
{
|
||||
var type = module.GetType ("Program");
|
||||
var main = type.GetMethod ("Main");
|
||||
TestModule ("test.exe", module => {
|
||||
var type = module.GetType ("Program");
|
||||
var main = type.GetMethod ("Main");
|
||||
|
||||
AssertCode (@"
|
||||
AssertCode (@"
|
||||
.locals init (System.Int32 i, System.Int32 CS$1$0000, System.Boolean CS$4$0001)
|
||||
.line 6,6:2,3 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs'
|
||||
IL_0000: nop
|
||||
@@ -56,70 +57,106 @@ namespace Mono.Cecil.Tests {
|
||||
IL_0020: ldloc.1
|
||||
IL_0021: ret
|
||||
", main);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[TestModule ("test.exe", SymbolReaderProvider = typeof (PdbReaderProvider), SymbolWriterProvider = typeof (PdbWriterProvider))]
|
||||
public void Document (ModuleDefinition module)
|
||||
[Test]
|
||||
public void DebuggerHiddenVariable ()
|
||||
{
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
TestModule ("test.exe", module => {
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
|
||||
var sequence_point = method.Body.Instructions.Where (i => i.SequencePoint != null).First ().SequencePoint;
|
||||
var document = sequence_point.Document;
|
||||
var scope = method.DebugInformation.Scope;
|
||||
|
||||
Assert.IsNotNull (document);
|
||||
Assert.IsTrue (scope.HasVariables);
|
||||
var variables = scope.Variables;
|
||||
|
||||
Assert.AreEqual (@"c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.CSharp, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
Assert.AreEqual ("CS$1$0000", variables [0].Name);
|
||||
Assert.IsTrue (variables [0].IsDebuggerHidden);
|
||||
Assert.AreEqual ("CS$4$0001", variables [1].Name);
|
||||
Assert.IsTrue (variables [1].IsDebuggerHidden);
|
||||
|
||||
Assert.AreEqual (1, scope.Scopes.Count);
|
||||
scope = scope.Scopes [0];
|
||||
variables = scope.Variables;
|
||||
|
||||
Assert.AreEqual ("i", variables [0].Name);
|
||||
Assert.IsFalse (variables [0].IsDebuggerHidden);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[TestModule ("VBConsApp.exe", SymbolReaderProvider = typeof (PdbReaderProvider), SymbolWriterProvider = typeof (PdbWriterProvider))]
|
||||
public void BasicDocument (ModuleDefinition module)
|
||||
|
||||
[Test]
|
||||
public void Document ()
|
||||
{
|
||||
var type = module.GetType ("VBConsApp.Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
TestModule ("test.exe", module => {
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
|
||||
var sequence_point = method.Body.Instructions.Where (i => i.SequencePoint != null).First ().SequencePoint;
|
||||
var document = sequence_point.Document;
|
||||
var sequence_point = method.DebugInformation.SequencePoints.First (sp => sp != null);
|
||||
var document = sequence_point.Document;
|
||||
|
||||
Assert.IsNotNull (document);
|
||||
Assert.IsNotNull (document);
|
||||
|
||||
Assert.AreEqual (@"c:\tmp\VBConsApp\Program.vb", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.Basic, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
Assert.AreEqual (@"c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.CSharp, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[TestModule ("fsapp.exe", SymbolReaderProvider = typeof (PdbReaderProvider), SymbolWriterProvider = typeof (PdbWriterProvider))]
|
||||
public void FSharpDocument (ModuleDefinition module)
|
||||
[Test]
|
||||
public void BasicDocument ()
|
||||
{
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("fact");
|
||||
TestModule ("VBConsApp.exe", module => {
|
||||
var type = module.GetType ("VBConsApp.Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
|
||||
var sequence_point = method.Body.Instructions.Where (i => i.SequencePoint != null).First ().SequencePoint;
|
||||
var document = sequence_point.Document;
|
||||
var sequence_point = method.DebugInformation.SequencePoints.First (sp => sp != null);
|
||||
var document = sequence_point.Document;
|
||||
|
||||
Assert.IsNotNull (document);
|
||||
Assert.IsNotNull (document);
|
||||
|
||||
Assert.AreEqual (@"c:\tmp\fsapp\Program.fs", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.FSharp, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
Assert.AreEqual (@"c:\tmp\VBConsApp\Program.vb", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.Basic, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FSharpDocument ()
|
||||
{
|
||||
TestModule ("fsapp.exe", module => {
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("fact");
|
||||
|
||||
var sequence_point = method.DebugInformation.SequencePoints.First (sp => sp != null);
|
||||
var document = sequence_point.Document;
|
||||
|
||||
Assert.IsNotNull (document);
|
||||
|
||||
Assert.AreEqual (@"c:\tmp\fsapp\Program.fs", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.FSharp, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateMethodFromScratch ()
|
||||
{
|
||||
IgnoreOnMono ();
|
||||
|
||||
var module = ModuleDefinition.CreateModule ("Pan", ModuleKind.Dll);
|
||||
var type = new TypeDefinition ("Pin", "Pon", TypeAttributes.Public | TypeAttributes.Abstract | TypeAttributes.Sealed, module.Import (typeof (object)));
|
||||
var type = new TypeDefinition ("Pin", "Pon", TypeAttributes.Public | TypeAttributes.Abstract | TypeAttributes.Sealed, module.ImportReference (typeof (object)));
|
||||
module.Types.Add (type);
|
||||
|
||||
var method = new MethodDefinition ("Pang", MethodAttributes.Public | MethodAttributes.Static, module.Import (typeof (string)));
|
||||
var method = new MethodDefinition ("Pang", MethodAttributes.Public | MethodAttributes.Static, module.ImportReference (typeof (string)));
|
||||
type.Methods.Add (method);
|
||||
|
||||
var body = method.Body;
|
||||
@@ -127,7 +164,7 @@ namespace Mono.Cecil.Tests {
|
||||
body.InitLocals = true;
|
||||
|
||||
var il = body.GetILProcessor ();
|
||||
var temp = new VariableDefinition ("temp", module.Import (typeof (string)));
|
||||
var temp = new VariableDefinition (module.ImportReference (typeof (string)));
|
||||
body.Variables.Add (temp);
|
||||
|
||||
il.Emit (OpCodes.Nop);
|
||||
@@ -136,13 +173,19 @@ namespace Mono.Cecil.Tests {
|
||||
il.Emit (OpCodes.Ldloc, temp);
|
||||
il.Emit (OpCodes.Ret);
|
||||
|
||||
body.Instructions [0].SequencePoint = new SequencePoint (new Document (@"C:\test.cs")) {
|
||||
var sequence_point = new SequencePoint (body.Instructions [0], new Document (@"C:\test.cs")) {
|
||||
StartLine = 0,
|
||||
StartColumn = 0,
|
||||
EndLine = 0,
|
||||
EndColumn = 4,
|
||||
};
|
||||
|
||||
method.DebugInformation.SequencePoints.Add (sequence_point);
|
||||
|
||||
method.DebugInformation.Scope = new ScopeDebugInformation (body.Instructions [0], null) {
|
||||
Variables = { new VariableDebugInformation (temp, "temp") }
|
||||
};
|
||||
|
||||
var file = Path.Combine (Path.GetTempPath (), "Pan.dll");
|
||||
module.Write (file, new WriterParameters {
|
||||
SymbolWriterProvider = new PdbWriterProvider (),
|
||||
@@ -154,22 +197,7 @@ namespace Mono.Cecil.Tests {
|
||||
|
||||
method = module.GetType ("Pin.Pon").GetMethod ("Pang");
|
||||
|
||||
Assert.AreEqual ("temp", method.Body.Variables [0].Name);
|
||||
}
|
||||
|
||||
static void AssertCode (string expected, MethodDefinition method)
|
||||
{
|
||||
Assert.IsTrue (method.HasBody);
|
||||
Assert.IsNotNull (method.Body);
|
||||
|
||||
System.Console.WriteLine (Formatter.FormatMethodBody (method));
|
||||
|
||||
Assert.AreEqual (Normalize (expected), Normalize (Formatter.FormatMethodBody (method)));
|
||||
}
|
||||
|
||||
static string Normalize (string str)
|
||||
{
|
||||
return str.Trim ().Replace ("\r\n", "\n");
|
||||
Assert.AreEqual ("temp", method.DebugInformation.Scope.Variables [0].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
external/cecil/symbols/pdb/Test/Resources/assemblies/PdbTarget.pdb
vendored
Normal file
BIN
external/cecil/symbols/pdb/Test/Resources/assemblies/PdbTarget.pdb
vendored
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user