Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJb Evain <jb@evain.net>2015-04-25 14:52:23 +0300
committerJb Evain <jb@evain.net>2015-04-25 14:52:23 +0300
commit73bd4f2fc18d332ee13f895bcc6f5c792f253527 (patch)
treee8aaf4b1d58b7a97a48ff81f5bb7d9ed0e6227af /symbols
parent1472815cc068c4264a75a8667da784783a989c0e (diff)
parent7159774d52f0f28d5bd4731bba1ee65e44167dfc (diff)
Merge branch 'master' into lowermemuse
Conflicts: Mono.Cecil.PE/Image.cs Mono.Cecil/DefaultAssemblyResolver.cs Mono.Cecil/ModuleDefinition.cs Test/Mono.Cecil.Tests/Addin.cs Test/Mono.Cecil.Tests/ImageReadTests.cs Test/Mono.Cecil.Tests/ImportCecilTests.cs Test/Mono.Cecil.Tests/ImportReflectionTests.cs
Diffstat (limited to 'symbols')
-rw-r--r--symbols/mdb/.gitignore4
-rw-r--r--symbols/mdb/Mono.Cecil.Mdb.csproj77
-rw-r--r--symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs31
-rw-r--r--symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs88
-rw-r--r--symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs70
-rw-r--r--symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs184
-rw-r--r--symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs189
-rw-r--r--symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs165
-rw-r--r--symbols/mdb/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs190
-rw-r--r--symbols/mdb/Test/.gitignore4
-rw-r--r--symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj92
-rw-r--r--symbols/mdb/Test/Mono.Cecil.Tests/Addin.cs8
-rw-r--r--symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs22
-rw-r--r--symbols/pdb/.gitignore4
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs104
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs69
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs109
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs95
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs7
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs7
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs11
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs7
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs262
-rw-r--r--[-rwxr-xr-x]symbols/pdb/Microsoft.Cci.Pdb/LICENSE0
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs21
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs12
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs7
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs7
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs280
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs88
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs163
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs7
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs7
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs13
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs34
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs20
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs13
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs33
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/PdbWriter.cs129
-rw-r--r--symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs33
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb.csproj85
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs31
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs21
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs21
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs101
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs25
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs31
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs24
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs21
-rw-r--r--symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs21
-rw-r--r--symbols/pdb/Test/.gitignore4
-rw-r--r--symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj96
-rw-r--r--symbols/pdb/Test/Mono.Cecil.Tests/Addin.cs8
-rw-r--r--symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs88
-rw-r--r--symbols/pdb/Test/Resources/assemblies/FSharp.Core.dllbin0 -> 898904 bytes
-rw-r--r--symbols/pdb/Test/Resources/assemblies/VBConsApp.exebin0 -> 15360 bytes
-rw-r--r--symbols/pdb/Test/Resources/assemblies/VBConsApp.pdbbin0 -> 36352 bytes
-rw-r--r--symbols/pdb/Test/Resources/assemblies/fsapp.exebin0 -> 5120 bytes
-rw-r--r--symbols/pdb/Test/Resources/assemblies/fsapp.pdbbin0 -> 11776 bytes
59 files changed, 1533 insertions, 1710 deletions
diff --git a/symbols/mdb/.gitignore b/symbols/mdb/.gitignore
deleted file mode 100644
index 17ff348..0000000
--- a/symbols/mdb/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-bin
-obj
-*.xml
-*.user
diff --git a/symbols/mdb/Mono.Cecil.Mdb.csproj b/symbols/mdb/Mono.Cecil.Mdb.csproj
index 44c931e..776d53c 100644
--- a/symbols/mdb/Mono.Cecil.Mdb.csproj
+++ b/symbols/mdb/Mono.Cecil.Mdb.csproj
@@ -1,75 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\Mono.Cecil.settings" />
<PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">net_4_0_Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mono.Cecil.Mdb</RootNamespace>
<AssemblyName>Mono.Cecil.Mdb</AssemblyName>
- <FileAlignment>512</FileAlignment>
- <SignAssembly>true</SignAssembly>
- <AssemblyOriginatorKeyFile>..\..\mono.snk</AssemblyOriginatorKeyFile>
- </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;CECIL</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;CECIL</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;CECIL;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;CECIL;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;CECIL;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;CECIL;NET_3_5;NET_4_0</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <DefineConstants>$(DefineConstants);CECIL</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFrameworkVersion)' != 'v2.0' ">
<Reference Include="System.Core" />
@@ -84,20 +20,15 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="..\..\ProjectInfo.cs" />
<Compile Include="Mono.Cecil.Mdb\AssemblyInfo.cs" />
<Compile Include="Mono.Cecil.Mdb\MdbReader.cs" />
<Compile Include="Mono.Cecil.Mdb\MdbWriter.cs" />
<Compile Include="Mono.CompilerServices.SymbolWriter\MonoSymbolFile.cs" />
<Compile Include="Mono.CompilerServices.SymbolWriter\MonoSymbolTable.cs" />
<Compile Include="Mono.CompilerServices.SymbolWriter\MonoSymbolWriter.cs" />
+ <Compile Include="Mono.CompilerServices.SymbolWriter\SourceMethodBuilder.cs" />
<Compile Include="Mono.CompilerServices.SymbolWriter\SymbolWriterImpl.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>
- -->
</Project> \ No newline at end of file
diff --git a/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs b/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs
index 8186b50..12f9bb6 100644
--- a/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs
+++ b/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs
@@ -1,41 +1,16 @@
//
-// AssemblyInfo.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Copyright (c) 2008 - 2011 Jb Evain
-//
-// 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:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// 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.Mdb")]
-[assembly: AssemblyProduct ("Mono.Cecil")]
-[assembly: AssemblyCopyright ("Copyright © 2008 - 2011 Jb Evain")]
[assembly: CLSCompliant (false)]
-[assembly: ComVisible (false)]
-
-[assembly: AssemblyVersion ("0.9.5.0")]
-[assembly: AssemblyFileVersion ("0.9.5.0")]
diff --git a/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs b/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
index 2db0419..05ab3fb 100644
--- a/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
+++ b/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
@@ -1,29 +1,11 @@
//
-// MdbReader.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Copyright (c) 2008 - 2011 Jb Evain
-//
-// 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.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// 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;
@@ -40,29 +22,39 @@ namespace Mono.Cecil.Mdb {
public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName)
{
- return new MdbReader (MonoSymbolFile.ReadSymbolFile (module, fileName));
+ return new MdbReader (module, MonoSymbolFile.ReadSymbolFile (fileName + ".mdb", module.Mvid));
}
public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream)
{
- throw new NotImplementedException ();
+ var file = MonoSymbolFile.ReadSymbolFile (symbolStream);
+ if (module.Mvid != file.Guid) {
+ var file_stream = symbolStream as FileStream;
+ if (file_stream != null)
+ throw new MonoSymbolFileException ("Symbol file `{0}' does not match assembly", file_stream.Name);
+
+ throw new MonoSymbolFileException ("Symbol file from stream does not match assembly");
+ }
+ return new MdbReader (module, file);
}
}
public class MdbReader : ISymbolReader {
+ readonly ModuleDefinition module;
readonly MonoSymbolFile symbol_file;
readonly Dictionary<string, Document> documents;
- public MdbReader (MonoSymbolFile symFile)
+ public MdbReader (ModuleDefinition module, MonoSymbolFile symFile)
{
- symbol_file = symFile;
- documents = new Dictionary<string, Document> ();
+ this.module = module;
+ this.symbol_file = symFile;
+ this.documents = new Dictionary<string, Document> ();
}
public bool ProcessDebugHeader (ImageDebugDirectory directory, byte [] header)
{
- return true;
+ return symbol_file.Guid == module.Mvid;
}
public void Read (MethodBody body, InstructionMapper mapper)
@@ -80,7 +72,11 @@ namespace Mono.Cecil.Mdb {
static void ReadLocalVariables (MethodEntry entry, MethodBody body, Scope [] scopes)
{
var locals = entry.GetLocals ();
+
foreach (var local in locals) {
+ if (local.Index < 0 || local.Index >= body.Variables.Count) // Mono 2.6 emits wrong local infos for iterators
+ continue;
+
var variable = body.Variables [local.Index];
variable.Name = local.Name;
@@ -109,10 +105,7 @@ namespace Mono.Cecil.Mdb {
if (document == null)
document = GetDocument (entry.CompileUnit.SourceFile);
- instruction.SequencePoint = new SequencePoint (document) {
- StartLine = line.Row,
- EndLine = line.Row,
- };
+ instruction.SequencePoint = LineToSequencePoint (line, entry, document);
}
}
@@ -190,24 +183,49 @@ namespace Mono.Cecil.Mdb {
for (int i = 0; i < lines.Length; i++) {
var line = lines [i];
- instructions.Add (new InstructionSymbol (line.Offset, new SequencePoint (GetDocument (entry.CompileUnit.SourceFile)) {
- StartLine = line.Row,
- EndLine = line.Row,
- }));
+ instructions.Add (new InstructionSymbol (
+ line.Offset,
+ LineToSequencePoint (line, entry, GetDocument (entry.CompileUnit.SourceFile))));
}
}
static void ReadLocalVariables (MethodEntry entry, MethodSymbols symbols)
{
foreach (var local in entry.GetLocals ()) {
+ if (local.Index < 0 || local.Index >= symbols.Variables.Count) // Mono 2.6 emits wrong local infos for iterators
+ continue;
+
var variable = symbols.Variables [local.Index];
variable.Name = local.Name;
}
}
+ static SequencePoint LineToSequencePoint (LineNumberEntry line, MethodEntry entry, Document document)
+ {
+ return new SequencePoint (document) {
+ StartLine = line.Row,
+ EndLine = line.EndRow,
+ StartColumn = line.Column,
+ EndColumn = line.EndColumn,
+ };
+ }
+
public void Dispose ()
{
symbol_file.Dispose ();
}
}
+
+ static class MethodEntryExtensions {
+
+ public static bool HasColumnInfo (this MethodEntry entry)
+ {
+ return (entry.MethodFlags & MethodEntry.Flags.ColumnsInfoIncluded) != 0;
+ }
+
+ public static bool HasEndInfo (this MethodEntry entry)
+ {
+ return (entry.MethodFlags & MethodEntry.Flags.EndInfoIncluded) != 0;
+ }
+ }
}
diff --git a/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs b/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
index 6f4aa20..e9a4cc2 100644
--- a/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
+++ b/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
@@ -1,29 +1,11 @@
//
-// MdbWriter.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Copyright (c) 2008 - 2011 Jb Evain
-//
-// 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:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// 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;
@@ -90,7 +72,7 @@ namespace Mono.Cecil.Mdb {
}
void Populate (Collection<Instruction> instructions, int [] offsets,
- int [] startRows, int [] startCols, out SourceFile file)
+ int [] startRows, int [] endRows, int [] startCols, int [] endCols, out SourceFile file)
{
SourceFile source_file = null;
@@ -103,7 +85,9 @@ namespace Mono.Cecil.Mdb {
source_file = GetSourceFile (sequence_point.Document);
startRows [i] = sequence_point.StartLine;
+ endRows [i] = sequence_point.EndLine;
startCols [i] = sequence_point.StartColumn;
+ endCols [i] = sequence_point.EndColumn;
}
file = source_file;
@@ -120,27 +104,59 @@ namespace Mono.Cecil.Mdb {
var offsets = new int [count];
var start_rows = new int [count];
+ var end_rows = new int [count];
var start_cols = new int [count];
+ var end_cols = new int [count];
SourceFile file;
- Populate (instructions, offsets, start_rows, start_cols, out file);
+ Populate (instructions, offsets, start_rows, end_rows, start_cols, end_cols, out file);
var builder = writer.OpenMethod (file.CompilationUnit, 0, method);
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++) {
builder.MarkSequencePoint (
offsets [i],
file.CompilationUnit.SourceFile,
start_rows [i],
+ end_rows [i],
start_cols [i],
+ end_cols [i],
false);
+ }
- if (body.HasVariables)
- AddVariables (body.Variables);
+ if (body.Scope != null && body.Scope.HasScopes)
+ WriteScope (body.Scope, true);
+ else
+ if (body.HasVariables)
+ AddVariables (body.Variables);
writer.CloseMethod ();
}
+ private void WriteScope (Scope scope, bool root)
+ {
+ if (scope.Start.Offset == scope.End.Offset) return;
+ writer.OpenScope (scope.Start.Offset);
+
+
+ if (scope.HasVariables)
+ {
+ foreach (var el in scope.Variables)
+ {
+ if (!String.IsNullOrEmpty (el.Name))
+ writer.DefineLocalVariable (el.Index, el.Name);
+ }
+ }
+
+ if (scope.HasScopes)
+ {
+ foreach (var el in scope.Scopes)
+ WriteScope (el, false);
+ }
+
+ writer.CloseScope (scope.End.Offset + scope.End.GetSize());
+ }
+
readonly static byte [] empty_header = new byte [0];
public bool GetDebugHeader (out ImageDebugDirectory directory, out byte [] header)
@@ -175,6 +191,8 @@ namespace Mono.Cecil.Mdb {
GetSourceFile (sequence_point.Document).CompilationUnit.SourceFile,
sequence_point.StartLine,
sequence_point.EndLine,
+ sequence_point.StartColumn,
+ sequence_point.EndColumn,
false);
}
diff --git a/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs b/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
index 937b0a5..73e654d 100644
--- a/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
+++ b/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
@@ -1,12 +1,13 @@
//
-// Mono.CSharp.Debugger/MonoSymbolFile.cs
+// MonoSymbolFile.cs
//
-// Author:
+// Authors:
// Martin Baulig (martin@ximian.com)
+// Marek Safar (marek.safar@gmail.com)
//
// (C) 2003 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
//
-
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -30,10 +31,7 @@
using System;
using System.Reflection;
-using SRE = System.Reflection.Emit;
using System.Collections.Generic;
-using System.Text;
-using System.Threading;
using System.IO;
namespace Mono.CompilerServices.SymbolWriter
@@ -46,10 +44,16 @@ namespace Mono.CompilerServices.SymbolWriter
public MonoSymbolFileException (string message, params object[] args)
: base (String.Format (message, args))
- { }
+ {
+ }
+
+ public MonoSymbolFileException (string message, Exception innerException)
+ : base (message, innerException)
+ {
+ }
}
- internal class MyBinaryWriter : BinaryWriter
+ sealed class MyBinaryWriter : BinaryWriter
{
public MyBinaryWriter (Stream stream)
: base (stream)
@@ -109,64 +113,11 @@ namespace Mono.CompilerServices.SymbolWriter
}
}
-#if !CECIL
- internal class MonoDebuggerSupport
- {
- static GetMethodTokenFunc get_method_token;
- static GetGuidFunc get_guid;
- static GetLocalIndexFunc get_local_index;
-
- delegate int GetMethodTokenFunc (MethodBase method);
- delegate Guid GetGuidFunc (Module module);
- delegate int GetLocalIndexFunc (SRE.LocalBuilder local);
-
- static Delegate create_delegate (Type type, Type delegate_type, string name)
- {
- MethodInfo mi = type.GetMethod (name, BindingFlags.Static |
- BindingFlags.NonPublic);
- if (mi == null)
- throw new Exception ("Can't find " + name);
-
- return Delegate.CreateDelegate (delegate_type, mi);
- }
-
- static MonoDebuggerSupport ()
- {
- get_method_token = (GetMethodTokenFunc) create_delegate (
- typeof (Assembly), typeof (GetMethodTokenFunc),
- "MonoDebugger_GetMethodToken");
-
- get_guid = (GetGuidFunc) create_delegate (
- typeof (Module), typeof (GetGuidFunc), "Mono_GetGuid");
-
- get_local_index = (GetLocalIndexFunc) create_delegate (
- typeof (SRE.LocalBuilder), typeof (GetLocalIndexFunc),
- "Mono_GetLocalIndex");
- }
-
- public static int GetMethodToken (MethodBase method)
- {
- return get_method_token (method);
- }
-
- public static Guid GetGuid (Module module)
- {
- return get_guid (module);
- }
-
- public static int GetLocalIndex (SRE.LocalBuilder local)
- {
- return get_local_index (local);
- }
- }
-#endif
-
public class MonoSymbolFile : IDisposable
{
List<MethodEntry> methods = new List<MethodEntry> ();
List<SourceFileEntry> sources = new List<SourceFileEntry> ();
List<CompileUnitEntry> comp_units = new List<CompileUnitEntry> ();
- Dictionary<Type, int> type_hash = new Dictionary<Type, int> ();
Dictionary<int, AnonymousScopeEntry> anonymous_scopes;
OffsetTable ot;
@@ -174,41 +125,29 @@ namespace Mono.CompilerServices.SymbolWriter
int last_method_index;
int last_namespace_index;
- public readonly string FileName = "<dynamic>";
public readonly int MajorVersion = OffsetTable.MajorVersion;
public readonly int MinorVersion = OffsetTable.MinorVersion;
public int NumLineNumbers;
- internal MonoSymbolFile ()
+ public MonoSymbolFile ()
{
ot = new OffsetTable ();
}
- internal int AddSource (SourceFileEntry source)
+ public int AddSource (SourceFileEntry source)
{
sources.Add (source);
return sources.Count;
}
- internal int AddCompileUnit (CompileUnitEntry entry)
+ public int AddCompileUnit (CompileUnitEntry entry)
{
comp_units.Add (entry);
return comp_units.Count;
}
- internal int DefineType (Type type)
- {
- int index;
- if (type_hash.TryGetValue (type, out index))
- return index;
-
- index = ++last_type_index;
- type_hash.Add (type, index);
- return index;
- }
-
- internal void AddMethod (MethodEntry entry)
+ public void AddMethod (MethodEntry entry)
{
methods.Add (entry);
}
@@ -295,7 +234,7 @@ namespace Mono.CompilerServices.SymbolWriter
//
methods.Sort ();
for (int i = 0; i < methods.Count; i++)
- ((MethodEntry) methods [i]).Index = i + 1;
+ methods [i].Index = i + 1;
//
// Write data sections.
@@ -314,7 +253,7 @@ namespace Mono.CompilerServices.SymbolWriter
//
ot.MethodTableOffset = (int) bw.BaseStream.Position;
for (int i = 0; i < methods.Count; i++) {
- MethodEntry entry = (MethodEntry) methods [i];
+ MethodEntry entry = methods [i];
entry.Write (bw);
}
ot.MethodTableSize = (int) bw.BaseStream.Position - ot.MethodTableOffset;
@@ -324,7 +263,7 @@ namespace Mono.CompilerServices.SymbolWriter
//
ot.SourceTableOffset = (int) bw.BaseStream.Position;
for (int i = 0; i < sources.Count; i++) {
- SourceFileEntry source = (SourceFileEntry) sources [i];
+ SourceFileEntry source = sources [i];
source.Write (bw);
}
ot.SourceTableSize = (int) bw.BaseStream.Position - ot.SourceTableOffset;
@@ -334,7 +273,7 @@ namespace Mono.CompilerServices.SymbolWriter
//
ot.CompileUnitTableOffset = (int) bw.BaseStream.Position;
for (int i = 0; i < comp_units.Count; i++) {
- CompileUnitEntry unit = (CompileUnitEntry) comp_units [i];
+ CompileUnitEntry unit = comp_units [i];
unit.Write (bw);
}
ot.CompileUnitTableSize = (int) bw.BaseStream.Position - ot.CompileUnitTableOffset;
@@ -391,10 +330,8 @@ namespace Mono.CompilerServices.SymbolWriter
Guid guid;
- MonoSymbolFile (string filename)
+ MonoSymbolFile (Stream stream)
{
- this.FileName = filename;
- FileStream stream = new FileStream (filename, FileMode.Open, FileAccess.Read);
reader = new MyBinaryReader (stream);
try {
@@ -403,89 +340,56 @@ namespace Mono.CompilerServices.SymbolWriter
int minor_version = reader.ReadInt32 ();
if (magic != OffsetTable.Magic)
- throw new MonoSymbolFileException (
- "Symbol file `{0}' is not a valid " +
- "Mono symbol file", filename);
+ throw new MonoSymbolFileException ("Symbol file is not a valid");
if (major_version != OffsetTable.MajorVersion)
throw new MonoSymbolFileException (
- "Symbol file `{0}' has version {1}, " +
- "but expected {2}", filename, major_version,
- OffsetTable.MajorVersion);
+ "Symbol file has version {0} but expected {1}", major_version, OffsetTable.MajorVersion);
if (minor_version != OffsetTable.MinorVersion)
- throw new MonoSymbolFileException (
- "Symbol file `{0}' has version {1}.{2}, " +
- "but expected {3}.{4}", filename, major_version,
- minor_version, OffsetTable.MajorVersion,
- OffsetTable.MinorVersion);
+ throw new MonoSymbolFileException ("Symbol file has version {0}.{1} but expected {2}.{3}",
+ major_version, minor_version,
+ OffsetTable.MajorVersion, OffsetTable.MinorVersion);
MajorVersion = major_version;
MinorVersion = minor_version;
guid = new Guid (reader.ReadBytes (16));
ot = new OffsetTable (reader, major_version, minor_version);
- } catch {
- throw new MonoSymbolFileException (
- "Cannot read symbol file `{0}'", filename);
+ } catch (Exception e) {
+ throw new MonoSymbolFileException ("Cannot read symbol file", e);
}
source_file_hash = new Dictionary<int, SourceFileEntry> ();
compile_unit_hash = new Dictionary<int, CompileUnitEntry> ();
}
- void CheckGuidMatch (Guid other, string filename, string assembly)
+ public static MonoSymbolFile ReadSymbolFile (Assembly assembly)
{
- if (other == guid)
- return;
+ string filename = assembly.Location;
+ string name = filename + ".mdb";
- throw new MonoSymbolFileException (
- "Symbol file `{0}' does not match assembly `{1}'",
- filename, assembly);
- }
+ Module[] modules = assembly.GetModules ();
+ Guid assembly_guid = modules[0].ModuleVersionId;
-#if CECIL
- protected MonoSymbolFile (string filename, Mono.Cecil.ModuleDefinition module)
- : this (filename)
- {
- CheckGuidMatch (module.Mvid, filename, module.FullyQualifiedName);
+ return ReadSymbolFile (name, assembly_guid);
}
- public static MonoSymbolFile ReadSymbolFile (Mono.Cecil.ModuleDefinition module)
- {
- return ReadSymbolFile (module, module.FullyQualifiedName);
- }
-
- public static MonoSymbolFile ReadSymbolFile (Mono.Cecil.ModuleDefinition module, string filename)
- {
- string name = filename + ".mdb";
-
- return new MonoSymbolFile (name, module);
- }
-#else
- protected MonoSymbolFile (string filename, Assembly assembly) : this (filename)
+ public static MonoSymbolFile ReadSymbolFile (string mdbFilename)
{
- // Check that the MDB file matches the assembly, if we have been
- // passed an assembly.
- if (assembly == null)
- return;
-
- Module[] modules = assembly.GetModules ();
- Guid assembly_guid = MonoDebuggerSupport.GetGuid (modules [0]);
-
- CheckGuidMatch (assembly_guid, filename, assembly.Location);
+ return ReadSymbolFile (new FileStream (mdbFilename, FileMode.Open, FileAccess.Read));
}
- public static MonoSymbolFile ReadSymbolFile (Assembly assembly)
+ public static MonoSymbolFile ReadSymbolFile (string mdbFilename, Guid assemblyGuid)
{
- string filename = assembly.Location;
- string name = filename + ".mdb";
+ var sf = ReadSymbolFile (mdbFilename);
+ if (assemblyGuid != sf.guid)
+ throw new MonoSymbolFileException ("Symbol file `{0}' does not match assembly", mdbFilename);
- return new MonoSymbolFile (name, assembly);
+ return sf;
}
-#endif
- public static MonoSymbolFile ReadSymbolFile (string mdbFilename)
+ public static MonoSymbolFile ReadSymbolFile (Stream stream)
{
- return new MonoSymbolFile (mdbFilename, null);
+ return new MonoSymbolFile (stream);
}
public int CompileUnitCount {
@@ -643,7 +547,7 @@ namespace Mono.CompilerServices.SymbolWriter
lock (this) {
read_methods ();
- return (MethodEntry) method_list [index - 1];
+ return method_list [index - 1];
}
}
diff --git a/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs b/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
index c170150..cf5d819 100644
--- a/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
+++ b/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
@@ -183,57 +183,56 @@ namespace Mono.CompilerServices.SymbolWriter
{
#region This is actually written to the symbol file
public readonly int Row;
+ public int Column;
+ public int EndRow, EndColumn;
public readonly int File;
public readonly int Offset;
- public readonly bool IsHidden;
+ public readonly bool IsHidden; // Obsolete is never used
#endregion
- public LineNumberEntry (int file, int row, int offset)
- : this (file, row, offset, false)
- { }
-
- public LineNumberEntry (int file, int row, int offset, bool is_hidden)
+ public sealed class LocationComparer : IComparer<LineNumberEntry>
{
- this.File = file;
- this.Row = row;
- this.Offset = offset;
- this.IsHidden = is_hidden;
- }
-
- public static LineNumberEntry Null = new LineNumberEntry (0, 0, 0);
+ public static readonly LocationComparer Default = new LocationComparer ();
- private class OffsetComparerClass : IComparer<LineNumberEntry>
- {
public int Compare (LineNumberEntry l1, LineNumberEntry l2)
{
- if (l1.Offset < l2.Offset)
- return -1;
- else if (l1.Offset > l2.Offset)
- return 1;
- else
- return 0;
+ return l1.Row == l2.Row ?
+ l1.Column.CompareTo (l2.Column) :
+ l1.Row.CompareTo (l2.Row);
}
}
- private class RowComparerClass : IComparer<LineNumberEntry>
+ public static readonly LineNumberEntry Null = new LineNumberEntry (0, 0, 0, 0);
+
+ public LineNumberEntry (int file, int row, int column, int offset)
+ : this (file, row, offset, column, false)
+ {
+ }
+
+ public LineNumberEntry (int file, int row, int offset)
+ : this (file, row, -1, offset, false)
{
- public int Compare (LineNumberEntry l1, LineNumberEntry l2)
- {
- if (l1.Row < l2.Row)
- return -1;
- else if (l1.Row > l2.Row)
- return 1;
- else
- return 0;
- }
}
- public static readonly IComparer<LineNumberEntry> OffsetComparer = new OffsetComparerClass ();
- public static readonly IComparer<LineNumberEntry> RowComparer = new RowComparerClass ();
+ public LineNumberEntry (int file, int row, int column, int offset, bool is_hidden)
+ : this (file, row, column, -1, -1, offset, is_hidden)
+ {
+ }
+
+ public LineNumberEntry (int file, int row, int column, int end_row, int end_column, int offset, bool is_hidden)
+ {
+ this.File = file;
+ this.Row = row;
+ this.Column = column;
+ this.EndRow = end_row;
+ this.EndColumn = end_column;
+ this.Offset = offset;
+ this.IsHidden = is_hidden;
+ }
public override string ToString ()
{
- return String.Format ("[Line {0}:{1}:{2}]", File, Row, Offset);
+ return String.Format ("[Line {0}:{1,2}-{3,4}:{5}]", File, Row, Column, EndRow, EndColumn, Offset);
}
}
@@ -610,6 +609,11 @@ namespace Mono.CompilerServices.SymbolWriter
DataOffset = reader.ReadInt32 ();
}
+ public void ReadAll ()
+ {
+ ReadData ();
+ }
+
void ReadData ()
{
if (creating)
@@ -692,26 +696,33 @@ namespace Mono.CompilerServices.SymbolWriter
creating = true;
}
- public SourceFileEntry (MonoSymbolFile file, string file_name,
- byte[] guid, byte[] checksum)
+ public SourceFileEntry (MonoSymbolFile file, string file_name, byte[] guid, byte[] checksum)
: this (file, file_name)
{
this.guid = guid;
this.hash = checksum;
}
+ public byte[] Checksum {
+ get {
+ return hash;
+ }
+ }
+
internal void WriteData (MyBinaryWriter bw)
{
DataOffset = (int) bw.BaseStream.Position;
bw.Write (file_name);
- if (guid == null) {
- guid = Guid.NewGuid ().ToByteArray ();
+ if (guid == null)
+ guid = new byte[16];
+
+ if (hash == null) {
try {
- using (FileStream fs = new FileStream (file_name, FileMode.Open, FileAccess.Read)) {
- MD5 md5 = MD5.Create ();
- hash = md5.ComputeHash (fs);
- }
+ using (FileStream fs = new FileStream (file_name, FileMode.Open, FileAccess.Read)) {
+ MD5 md5 = MD5.Create ();
+ hash = md5.ComputeHash (fs);
+ }
} catch {
hash = new byte [16];
}
@@ -748,6 +759,7 @@ namespace Mono.CompilerServices.SymbolWriter
public string FileName {
get { return file_name; }
+ set { file_name = value; }
}
public bool AutoGenerated {
@@ -802,7 +814,6 @@ namespace Mono.CompilerServices.SymbolWriter
public const int Default_LineRange = 8;
public const byte Default_OpcodeBase = 9;
- public const bool SuppressDuplicates = true;
#endregion
public const byte DW_LNS_copy = 1;
@@ -833,7 +844,7 @@ namespace Mono.CompilerServices.SymbolWriter
this._line_numbers = lines;
}
- internal void Write (MonoSymbolFile file, MyBinaryWriter bw)
+ internal void Write (MonoSymbolFile file, MyBinaryWriter bw, bool hasColumnsInfo, bool hasEndInfo)
{
int start = (int) bw.BaseStream.Position;
@@ -843,11 +854,6 @@ namespace Mono.CompilerServices.SymbolWriter
int line_inc = LineNumbers [i].Row - last_line;
int offset_inc = LineNumbers [i].Offset - last_offset;
- if (SuppressDuplicates && (i+1 < LineNumbers.Length)) {
- if (LineNumbers [i+1].Equals (LineNumbers [i]))
- continue;
- }
-
if (LineNumbers [i].File != last_file) {
bw.Write (DW_LNS_set_file);
bw.WriteLeb128 (LineNumbers [i].File);
@@ -895,17 +901,37 @@ namespace Mono.CompilerServices.SymbolWriter
bw.Write ((byte) 1);
bw.Write (DW_LNE_end_sequence);
+ if (hasColumnsInfo) {
+ for (int i = 0; i < LineNumbers.Length; i++) {
+ var ln = LineNumbers [i];
+ if (ln.Row >= 0)
+ bw.WriteLeb128 (ln.Column);
+ }
+ }
+
+ if (hasEndInfo) {
+ for (int i = 0; i < LineNumbers.Length; i++) {
+ var ln = LineNumbers [i];
+ if (ln.EndRow == -1 || ln.EndColumn == -1 || ln.Row > ln.EndRow) {
+ bw.WriteLeb128 (0xffffff);
+ } else {
+ bw.WriteLeb128 (ln.EndRow - ln.Row);
+ bw.WriteLeb128 (ln.EndColumn);
+ }
+ }
+ }
+
file.ExtendedLineNumberSize += (int) bw.BaseStream.Position - start;
}
- internal static LineNumberTable Read (MonoSymbolFile file, MyBinaryReader br)
+ internal static LineNumberTable Read (MonoSymbolFile file, MyBinaryReader br, bool readColumnsInfo, bool readEndInfo)
{
LineNumberTable lnt = new LineNumberTable (file);
- lnt.DoRead (file, br);
+ lnt.DoRead (file, br, readColumnsInfo, readEndInfo);
return lnt;
}
- void DoRead (MonoSymbolFile file, MyBinaryReader br)
+ void DoRead (MonoSymbolFile file, MyBinaryReader br, bool includesColumns, bool includesEnds)
{
var lines = new List<LineNumberEntry> ();
@@ -922,7 +948,7 @@ namespace Mono.CompilerServices.SymbolWriter
if (opcode == DW_LNE_end_sequence) {
if (modified)
lines.Add (new LineNumberEntry (
- stm_file, stm_line, stm_offset, is_hidden));
+ stm_file, stm_line, -1, stm_offset, is_hidden));
break;
} else if (opcode == DW_LNE_MONO_negate_is_hidden) {
is_hidden = !is_hidden;
@@ -931,9 +957,7 @@ namespace Mono.CompilerServices.SymbolWriter
(opcode <= DW_LNE_MONO__extensions_end)) {
; // reserved for future extensions
} else {
- throw new MonoSymbolFileException (
- "Unknown extended opcode {0:x} in LNT ({1})",
- opcode, file.FileName);
+ throw new MonoSymbolFileException ("Unknown extended opcode {0:x}", opcode);
}
br.BaseStream.Position = end_pos;
@@ -942,7 +966,7 @@ namespace Mono.CompilerServices.SymbolWriter
switch (opcode) {
case DW_LNS_copy:
lines.Add (new LineNumberEntry (
- stm_file, stm_line, stm_offset, is_hidden));
+ stm_file, stm_line, -1, stm_offset, is_hidden));
modified = false;
break;
case DW_LNS_advance_pc:
@@ -972,13 +996,34 @@ namespace Mono.CompilerServices.SymbolWriter
stm_offset += opcode / LineRange;
stm_line += LineBase + (opcode % LineRange);
lines.Add (new LineNumberEntry (
- stm_file, stm_line, stm_offset, is_hidden));
+ stm_file, stm_line, -1, stm_offset, is_hidden));
modified = false;
}
}
- _line_numbers = new LineNumberEntry [lines.Count];
- lines.CopyTo (_line_numbers, 0);
+ _line_numbers = lines.ToArray ();
+
+ if (includesColumns) {
+ for (int i = 0; i < _line_numbers.Length; ++i) {
+ var ln = _line_numbers[i];
+ if (ln.Row >= 0)
+ ln.Column = br.ReadLeb128 ();
+ }
+ }
+ if (includesEnds) {
+ for (int i = 0; i < _line_numbers.Length; ++i) {
+ var ln = _line_numbers[i];
+
+ int row = br.ReadLeb128 ();
+ if (row == 0xffffff) {
+ ln.EndRow = -1;
+ ln.EndColumn = -1;
+ } else {
+ ln.EndRow = ln.Row + row;
+ ln.EndColumn = br.ReadLeb128 ();
+ }
+ }
+ }
}
public bool GetMethodBounds (out LineNumberEntry start, out LineNumberEntry end)
@@ -1035,7 +1080,9 @@ namespace Mono.CompilerServices.SymbolWriter
[Flags]
public enum Flags
{
- LocalNamesAmbiguous = 1
+ LocalNamesAmbiguous = 1,
+ ColumnsInfoIncluded = 1 << 1,
+ EndInfoIncluded = 1 << 2
}
public const int Size = 12;
@@ -1123,7 +1170,7 @@ namespace Mono.CompilerServices.SymbolWriter
}
}
- void CheckLineNumberTable (LineNumberEntry[] line_numbers)
+ static void CheckLineNumberTable (LineNumberEntry[] line_numbers)
{
int last_offset = -1;
int last_row = -1;
@@ -1188,8 +1235,13 @@ namespace Mono.CompilerServices.SymbolWriter
bw.Write (real_name);
}
+ foreach (var lne in lnt.LineNumbers) {
+ if (lne.EndRow != -1 || lne.EndColumn != -1)
+ flags |= Flags.EndInfoIncluded;
+ }
+
LineNumberTableOffset = (int) bw.BaseStream.Position;
- lnt.Write (file, bw);
+ lnt.Write (file, bw, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0);
DataOffset = (int) bw.BaseStream.Position;
@@ -1204,6 +1256,15 @@ namespace Mono.CompilerServices.SymbolWriter
bw.WriteLeb128 ((int) flags);
}
+ public void ReadAll ()
+ {
+ GetLineNumberTable ();
+ GetLocals ();
+ GetCodeBlocks ();
+ GetScopeVariables ();
+ GetRealName ();
+ }
+
public LineNumberTable GetLineNumberTable ()
{
lock (SymbolFile) {
@@ -1217,7 +1278,7 @@ namespace Mono.CompilerServices.SymbolWriter
long old_pos = reader.BaseStream.Position;
reader.BaseStream.Position = LineNumberTableOffset;
- lnt = LineNumberTable.Read (SymbolFile, reader);
+ lnt = LineNumberTable.Read (SymbolFile, reader, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0);
reader.BaseStream.Position = old_pos;
return lnt;
diff --git a/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs b/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
index db77c25..19e14c2 100644
--- a/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
+++ b/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
@@ -47,11 +47,7 @@ namespace Mono.CompilerServices.SymbolWriter
string filename;
private SourceMethodBuilder current_method;
-#if NET_2_1
- System.Collections.Stack current_method_stack = new System.Collections.Stack ();
-#else
Stack<SourceMethodBuilder> current_method_stack = new Stack<SourceMethodBuilder> ();
-#endif
public MonoSymbolWriter (string filename)
{
@@ -239,165 +235,4 @@ namespace Mono.CompilerServices.SymbolWriter
}
}
}
-
- public class SourceMethodBuilder
- {
- List<LocalVariableEntry> _locals;
- List<CodeBlockEntry> _blocks;
- List<ScopeVariable> _scope_vars;
-#if NET_2_1
- System.Collections.Stack _block_stack;
-#else
- Stack<CodeBlockEntry> _block_stack;
-#endif
- string _real_name;
- IMethodDef _method;
- ICompileUnit _comp_unit;
-// MethodEntry.Flags _method_flags;
- int _ns_id;
-
- public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method)
- {
- this._comp_unit = comp_unit;
- this._method = method;
- this._ns_id = ns_id;
-
- method_lines = new LineNumberEntry [32];
- }
-
- private LineNumberEntry [] method_lines;
- private int method_lines_pos = 0;
-
- public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column,
- bool is_hidden)
- {
- if (method_lines_pos == method_lines.Length) {
- LineNumberEntry [] tmp = method_lines;
- method_lines = new LineNumberEntry [method_lines.Length * 2];
- Array.Copy (tmp, method_lines, method_lines_pos);
- }
-
- int file_idx = file != null ? file.Index : 0;
- method_lines [method_lines_pos++] = new LineNumberEntry (
- file_idx, line, offset, is_hidden);
- }
-
- public void StartBlock (CodeBlockEntry.Type type, int start_offset)
- {
- if (_block_stack == null) {
-#if NET_2_1
- _block_stack = new System.Collections.Stack ();
-#else
- _block_stack = new Stack<CodeBlockEntry> ();
-#endif
- }
-
- if (_blocks == null)
- _blocks = new List<CodeBlockEntry> ();
-
- int parent = CurrentBlock != null ? CurrentBlock.Index : -1;
-
- CodeBlockEntry block = new CodeBlockEntry (
- _blocks.Count + 1, parent, type, start_offset);
-
- _block_stack.Push (block);
- _blocks.Add (block);
- }
-
- public void EndBlock (int end_offset)
- {
- CodeBlockEntry block = (CodeBlockEntry) _block_stack.Pop ();
- block.Close (end_offset);
- }
-
- public CodeBlockEntry[] Blocks {
- get {
- if (_blocks == null)
- return new CodeBlockEntry [0];
-
- CodeBlockEntry[] retval = new CodeBlockEntry [_blocks.Count];
- _blocks.CopyTo (retval, 0);
- return retval;
- }
- }
-
- public CodeBlockEntry CurrentBlock {
- get {
- if ((_block_stack != null) && (_block_stack.Count > 0))
- return (CodeBlockEntry) _block_stack.Peek ();
- else
- return null;
- }
- }
-
- public LocalVariableEntry[] Locals {
- get {
- if (_locals == null)
- return new LocalVariableEntry [0];
- else {
- LocalVariableEntry[] retval =
- new LocalVariableEntry [_locals.Count];
- _locals.CopyTo (retval, 0);
- return retval;
- }
- }
- }
-
- public void AddLocal (int index, string name)
- {
- if (_locals == null)
- _locals = new List<LocalVariableEntry> ();
- int block_idx = CurrentBlock != null ? CurrentBlock.Index : 0;
- _locals.Add (new LocalVariableEntry (index, name, block_idx));
- }
-
- public ScopeVariable[] ScopeVariables {
- get {
- if (_scope_vars == null)
- return new ScopeVariable [0];
-
- ScopeVariable[] retval = new ScopeVariable [_scope_vars.Count];
- _scope_vars.CopyTo (retval);
- return retval;
- }
- }
-
- public void AddScopeVariable (int scope, int index)
- {
- if (_scope_vars == null)
- _scope_vars = new List<ScopeVariable> ();
- _scope_vars.Add (
- new ScopeVariable (scope, index));
- }
-
- public string RealMethodName {
- get { return _real_name; }
- }
-
- public void SetRealMethodName (string name)
- {
- _real_name = name;
- }
-
- public ICompileUnit SourceFile {
- get { return _comp_unit; }
- }
-
- public IMethodDef Method {
- get { return _method; }
- }
-
- public void DefineMethod (MonoSymbolFile file)
- {
- LineNumberEntry[] lines = new LineNumberEntry [method_lines_pos];
- Array.Copy (method_lines, lines, method_lines_pos);
-
- MethodEntry entry = new MethodEntry (
- file, _comp_unit.Entry, _method.Token, ScopeVariables,
- Locals, lines, Blocks, RealMethodName, 0, //_method_flags,
- _ns_id);
-
- file.AddMethod (entry);
- }
- }
}
diff --git a/symbols/mdb/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs b/symbols/mdb/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs
new file mode 100644
index 0000000..88363e7
--- /dev/null
+++ b/symbols/mdb/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs
@@ -0,0 +1,190 @@
+//
+// SourceMethodBuilder.cs
+//
+// Authors:
+// Martin Baulig (martin@ximian.com)
+// Marek Safar (marek.safar@gmail.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
+//
+// 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.
+//
+
+using System.Collections.Generic;
+
+namespace Mono.CompilerServices.SymbolWriter
+{
+ public class SourceMethodBuilder
+ {
+ List<LocalVariableEntry> _locals;
+ List<CodeBlockEntry> _blocks;
+ List<ScopeVariable> _scope_vars;
+ Stack<CodeBlockEntry> _block_stack;
+ readonly List<LineNumberEntry> method_lines;
+
+ readonly ICompileUnit _comp_unit;
+ readonly int ns_id;
+ readonly IMethodDef method;
+
+ public SourceMethodBuilder (ICompileUnit comp_unit)
+ {
+ this._comp_unit = comp_unit;
+ method_lines = new List<LineNumberEntry> ();
+ }
+
+ public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method)
+ : this (comp_unit)
+ {
+ this.ns_id = ns_id;
+ this.method = method;
+ }
+
+ public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, bool is_hidden)
+ {
+ MarkSequencePoint (offset, file, line, column, -1, -1, is_hidden);
+ }
+
+ public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, int end_line, int end_column, bool is_hidden)
+ {
+ int file_idx = file != null ? file.Index : 0;
+ var lne = new LineNumberEntry (file_idx, line, column, end_line, end_column, offset, is_hidden);
+
+ if (method_lines.Count > 0) {
+ var prev = method_lines[method_lines.Count - 1];
+
+ //
+ // Same offset cannot be used for multiple lines
+ //
+ if (prev.Offset == offset) {
+ //
+ // Use the new location because debugger will adjust
+ // the breakpoint to next line with sequence point
+ //
+ if (LineNumberEntry.LocationComparer.Default.Compare (lne, prev) > 0)
+ method_lines[method_lines.Count - 1] = lne;
+
+ return;
+ }
+ }
+
+ method_lines.Add (lne);
+ }
+
+ public void StartBlock (CodeBlockEntry.Type type, int start_offset)
+ {
+ if (_block_stack == null) {
+ _block_stack = new Stack<CodeBlockEntry> ();
+ }
+
+ if (_blocks == null)
+ _blocks = new List<CodeBlockEntry> ();
+
+ int parent = CurrentBlock != null ? CurrentBlock.Index : -1;
+
+ CodeBlockEntry block = new CodeBlockEntry (
+ _blocks.Count + 1, parent, type, start_offset);
+
+ _block_stack.Push (block);
+ _blocks.Add (block);
+ }
+
+ public void EndBlock (int end_offset)
+ {
+ CodeBlockEntry block = (CodeBlockEntry) _block_stack.Pop ();
+ block.Close (end_offset);
+ }
+
+ public CodeBlockEntry[] Blocks {
+ get {
+ if (_blocks == null)
+ return new CodeBlockEntry [0];
+
+ CodeBlockEntry[] retval = new CodeBlockEntry [_blocks.Count];
+ _blocks.CopyTo (retval, 0);
+ return retval;
+ }
+ }
+
+ public CodeBlockEntry CurrentBlock {
+ get {
+ if ((_block_stack != null) && (_block_stack.Count > 0))
+ return (CodeBlockEntry) _block_stack.Peek ();
+ else
+ return null;
+ }
+ }
+
+ public LocalVariableEntry[] Locals {
+ get {
+ if (_locals == null)
+ return new LocalVariableEntry [0];
+ else {
+ return _locals.ToArray ();
+ }
+ }
+ }
+
+ public ICompileUnit SourceFile {
+ get {
+ return _comp_unit;
+ }
+ }
+
+ public void AddLocal (int index, string name)
+ {
+ if (_locals == null)
+ _locals = new List<LocalVariableEntry> ();
+ int block_idx = CurrentBlock != null ? CurrentBlock.Index : 0;
+ _locals.Add (new LocalVariableEntry (index, name, block_idx));
+ }
+
+ public ScopeVariable[] ScopeVariables {
+ get {
+ if (_scope_vars == null)
+ return new ScopeVariable [0];
+
+ return _scope_vars.ToArray ();
+ }
+ }
+
+ public void AddScopeVariable (int scope, int index)
+ {
+ if (_scope_vars == null)
+ _scope_vars = new List<ScopeVariable> ();
+ _scope_vars.Add (
+ new ScopeVariable (scope, index));
+ }
+
+ public void DefineMethod (MonoSymbolFile file)
+ {
+ DefineMethod (file, method.Token);
+ }
+
+ public void DefineMethod (MonoSymbolFile file, int token)
+ {
+ MethodEntry entry = new MethodEntry (
+ file, _comp_unit.Entry, token, ScopeVariables,
+ Locals, method_lines.ToArray (), Blocks, null, MethodEntry.Flags.ColumnsInfoIncluded, ns_id);
+
+ file.AddMethod (entry);
+ }
+ }
+}
diff --git a/symbols/mdb/Test/.gitignore b/symbols/mdb/Test/.gitignore
deleted file mode 100644
index 17ff348..0000000
--- a/symbols/mdb/Test/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-bin
-obj
-*.xml
-*.user
diff --git a/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj b/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
index 708f800..cbe056c 100644
--- a/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
+++ b/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
@@ -1,77 +1,11 @@
-<?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">
+ <Import Project="..\..\..\Mono.Cecil.Tests.settings" />
<PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">net_4_0_Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AC71DF9C-99FA-4A63-990A-66C8010355A6}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mono.Cecil.Mdb.Tests</RootNamespace>
<AssemblyName>Mono.Cecil.Mdb.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,33 +21,11 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <Compile Include="Mono.Cecil.Tests\Addin.cs" />
<Compile Include="Mono.Cecil.Tests\MdbTests.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\assemblies\hello.exe" />
<Content Include="Resources\assemblies\hello.exe.mdb" />
</ItemGroup>
- <ItemGroup>
- <Reference Include="nunit.core, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.core.dll</HintPath>
- </Reference>
- <Reference Include="nunit.core.interfaces, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.core.interfaces.dll</HintPath>
- </Reference>
- <Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\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>
- -->
</Project> \ No newline at end of file
diff --git a/symbols/mdb/Test/Mono.Cecil.Tests/Addin.cs b/symbols/mdb/Test/Mono.Cecil.Tests/Addin.cs
deleted file mode 100644
index 4865122..0000000
--- a/symbols/mdb/Test/Mono.Cecil.Tests/Addin.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using NUnit.Core.Extensibility;
-
-namespace Mono.Cecil.Tests {
-
- [NUnitAddin]
- public class CecilMdbAddin : CecilTestAddin {
- }
-}
diff --git a/symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs b/symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs
index 757732d..545ee31 100644
--- a/symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs
+++ b/symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs
@@ -8,25 +8,26 @@ namespace Mono.Cecil.Tests {
[TestFixture]
public class MdbTests : BaseTestFixture {
- [TestModule ("hello.exe", SymbolReaderProvider = typeof (MdbReaderProvider), SymbolWriterProvider = typeof (MdbWriterProvider))]
- public void Main (ModuleDefinition module)
+ [Test]
+ public void MdbWithJustLineInfo ()
{
- var type = module.GetType ("Program");
- var main = type.GetMethod ("Main");
+ TestModule ("hello.exe", module => {
+ var type = module.GetType ("Program");
+ var main = type.GetMethod ("Main");
- AssertCode (@"
+ AssertCode (@"
.locals init (System.Int32 i)
- .line 7,7:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
+ .line 7,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_0000: ldc.i4.0
IL_0001: stloc.0
- .line 7,7:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
+ .line 7,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_0002: br IL_0013
- .line 8,8:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
+ .line 8,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_0007: ldarg.0
IL_0008: ldloc.0
IL_0009: ldelem.ref
IL_000a: call System.Void Program::Print(System.String)
- .line 7,7:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
+ .line 7,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_000f: ldloc.0
IL_0010: ldc.i4.1
IL_0011: add
@@ -36,10 +37,11 @@ namespace Mono.Cecil.Tests {
IL_0015: ldlen
IL_0016: conv.i4
IL_0017: blt IL_0007
- .line 10,10:0,0 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
+ .line 10,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
IL_001c: ldc.i4.0
IL_001d: ret
", main);
+ }, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider));
}
static void AssertCode (string expected, MethodDefinition method)
diff --git a/symbols/pdb/.gitignore b/symbols/pdb/.gitignore
deleted file mode 100644
index 17ff348..0000000
--- a/symbols/pdb/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-bin
-obj
-*.xml
-*.user
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs b/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
index 852f797..d92a5b7 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -12,7 +17,6 @@ namespace Microsoft.Cci.Pdb {
internal BitAccess(int capacity) {
this.buffer = new byte[capacity];
- this.offset = 0;
}
internal byte[] Buffer {
@@ -26,15 +30,26 @@ namespace Microsoft.Cci.Pdb {
offset = 0;
}
+ internal void Append(Stream stream, int count) {
+ int newCapacity = offset + count;
+ if (buffer.Length < newCapacity) {
+ byte[] newBuffer = new byte[newCapacity];
+ Array.Copy(buffer, newBuffer, buffer.Length);
+ buffer = newBuffer;
+ }
+ stream.Read(buffer, offset, count);
+ offset += count;
+ }
+
internal int Position {
get { return offset; }
set { offset = value; }
}
private int offset;
- internal void WriteBuffer(Stream stream, int count) {
- stream.Write(buffer, 0, count);
- }
+ //internal void WriteBuffer(Stream stream, int count) {
+ // stream.Write(buffer, 0, count);
+ //}
internal void MinCapacity(int capacity) {
if (buffer.Length < capacity) {
@@ -49,25 +64,25 @@ namespace Microsoft.Cci.Pdb {
}
}
- internal void WriteInt32(int value) {
- buffer[offset + 0] = (byte)value;
- buffer[offset + 1] = (byte)(value >> 8);
- buffer[offset + 2] = (byte)(value >> 16);
- buffer[offset + 3] = (byte)(value >> 24);
- offset += 4;
- }
+ //internal void WriteInt32(int value) {
+ // buffer[offset + 0] = (byte)value;
+ // buffer[offset + 1] = (byte)(value >> 8);
+ // buffer[offset + 2] = (byte)(value >> 16);
+ // buffer[offset + 3] = (byte)(value >> 24);
+ // offset += 4;
+ //}
- internal void WriteInt32(int[] values) {
- for (int i = 0; i < values.Length; i++) {
- WriteInt32(values[i]);
- }
- }
+ //internal void WriteInt32(int[] values) {
+ // for (int i = 0; i < values.Length; i++) {
+ // WriteInt32(values[i]);
+ // }
+ //}
- internal void WriteBytes(byte[] bytes) {
- for (int i = 0; i < bytes.Length; i++) {
- buffer[offset++] = bytes[i];
- }
- }
+ //internal void WriteBytes(byte[] bytes) {
+ // for (int i = 0; i < bytes.Length; i++) {
+ // buffer[offset++] = bytes[i];
+ // }
+ //}
internal void ReadInt16(out short value) {
value = (short)((buffer[offset + 0] & 0xFF) |
@@ -75,6 +90,11 @@ namespace Microsoft.Cci.Pdb {
offset += 2;
}
+ internal void ReadInt8(out sbyte value) {
+ value = (sbyte)buffer[offset];
+ offset += 1;
+ }
+
internal void ReadInt32(out int value) {
value = (int)((buffer[offset + 0] & 0xFF) |
(buffer[offset + 1] << 8) |
@@ -84,14 +104,14 @@ namespace Microsoft.Cci.Pdb {
}
internal void ReadInt64(out long value) {
- value = (long)((buffer[offset + 0] & 0xFF) |
- (buffer[offset + 1] << 8) |
- (buffer[offset + 2] << 16) |
- (buffer[offset + 3] << 24) |
- (buffer[offset + 4] << 32) |
- (buffer[offset + 5] << 40) |
- (buffer[offset + 6] << 48) |
- (buffer[offset + 7] << 56));
+ value = (long)(((ulong)buffer[offset + 0] & 0xFF) |
+ ((ulong)buffer[offset + 1] << 8) |
+ ((ulong)buffer[offset + 2] << 16) |
+ ((ulong)buffer[offset + 3] << 24) |
+ ((ulong)buffer[offset + 4] << 32) |
+ ((ulong)buffer[offset + 5] << 40) |
+ ((ulong)buffer[offset + 6] << 48) |
+ ((ulong)buffer[offset + 7] << 56));
offset += 8;
}
@@ -115,14 +135,14 @@ namespace Microsoft.Cci.Pdb {
}
internal void ReadUInt64(out ulong value) {
- value = (ulong)((buffer[offset + 0] & 0xFF) |
- (buffer[offset + 1] << 8) |
- (buffer[offset + 2] << 16) |
- (buffer[offset + 3] << 24) |
- (buffer[offset + 4] << 32) |
- (buffer[offset + 5] << 40) |
- (buffer[offset + 6] << 48) |
- (buffer[offset + 7] << 56));
+ value = (ulong)(((ulong)buffer[offset + 0] & 0xFF) |
+ ((ulong)buffer[offset + 1] << 8) |
+ ((ulong)buffer[offset + 2] << 16) |
+ ((ulong)buffer[offset + 3] << 24) |
+ ((ulong)buffer[offset + 4] << 32) |
+ ((ulong)buffer[offset + 5] << 40) |
+ ((ulong)buffer[offset + 6] << 48) |
+ ((ulong)buffer[offset + 7] << 56));
offset += 8;
}
@@ -159,7 +179,7 @@ namespace Microsoft.Cci.Pdb {
internal decimal ReadDecimal() {
int[] bits = new int[4];
this.ReadInt32(bits);
- return new decimal(bits);
+ return new decimal(bits[2], bits[3], bits[1], bits[0] < 0, (byte)((bits[0] & 0x00FF0000) >> 16));
}
internal void ReadBString(out string value) {
@@ -169,6 +189,12 @@ namespace Microsoft.Cci.Pdb {
offset += len;
}
+ internal string ReadBString(int len) {
+ var result = Encoding.UTF8.GetString(buffer, offset, len);
+ offset += len;
+ return result;
+ }
+
internal void ReadCString(out string value) {
int len = 0;
while (offset + len < buffer.Length && buffer[offset + len] != 0) {
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs b/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs
index a9ed7f7..6719131 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -13,10 +18,10 @@ namespace Microsoft.Cci.Pdb {
bits.ReadUInt32(words);
}
- internal BitSet(int size) {
- this.size = size;
- words = new uint[size];
- }
+ //internal BitSet(int size) {
+ // this.size = size;
+ // words = new uint[size];
+ //}
internal bool IsSet(int index) {
int word = index / 32;
@@ -24,43 +29,43 @@ namespace Microsoft.Cci.Pdb {
return ((words[word] & GetBit(index)) != 0);
}
- internal void Set(int index) {
- int word = index / 32;
- if (word >= this.size) return;
- words[word] |= GetBit(index);
- }
+ //internal void Set(int index) {
+ // int word = index / 32;
+ // if (word >= this.size) return;
+ // words[word] |= GetBit(index);
+ //}
- internal void Clear(int index) {
- int word = index / 32;
- if (word >= this.size) return;
- words[word] &= ~GetBit(index);
- }
+ //internal void Clear(int index) {
+ // int word = index / 32;
+ // if (word >= this.size) return;
+ // words[word] &= ~GetBit(index);
+ //}
- private uint GetBit(int index) {
+ private static uint GetBit(int index) {
return ((uint)1 << (index % 32));
}
- private uint ReverseBits(uint value) {
- uint o = 0;
- for (int i = 0; i < 32; i++) {
- o = (o << 1) | (value & 1);
- value >>= 1;
- }
- return o;
- }
+ //private static uint ReverseBits(uint value) {
+ // uint o = 0;
+ // for (int i = 0; i < 32; i++) {
+ // o = (o << 1) | (value & 1);
+ // value >>= 1;
+ // }
+ // return o;
+ //}
internal bool IsEmpty {
get { return size == 0; }
}
- internal bool GetWord(int index, out uint word) {
- if (index < size) {
- word = ReverseBits(words[index]);
- return true;
- }
- word = 0;
- return false;
- }
+ //internal bool GetWord(int index, out uint word) {
+ // if (index < size) {
+ // word = ReverseBits(words[index]);
+ // return true;
+ // }
+ // word = 0;
+ // return false;
+ //}
private int size;
private uint[] words;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs b/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs
index bef3086..49c51ce 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
//
@@ -163,67 +168,67 @@ namespace Microsoft.Cci.Pdb {
// function to extract primitive mode, type and size
- internal static CV_prmode CV_MODE(TYPE_ENUM typ) {
- return (CV_prmode)((((uint)typ) & CV_MMASK) >> CV_MSHIFT);
- }
+ //internal static CV_prmode CV_MODE(TYPE_ENUM typ) {
+ // return (CV_prmode)((((uint)typ) & CV_MMASK) >> CV_MSHIFT);
+ //}
- internal static CV_type CV_TYPE(TYPE_ENUM typ) {
- return (CV_type)((((uint)typ) & CV_TMASK) >> CV_TSHIFT);
- }
+ //internal static CV_type CV_TYPE(TYPE_ENUM typ) {
+ // return (CV_type)((((uint)typ) & CV_TMASK) >> CV_TSHIFT);
+ //}
- internal static uint CV_SUBT(TYPE_ENUM typ) {
- return ((((uint)typ) & CV_SMASK) >> CV_SSHIFT);
- }
+ //internal static uint CV_SUBT(TYPE_ENUM typ) {
+ // return ((((uint)typ) & CV_SMASK) >> CV_SSHIFT);
+ //}
// functions to check the type of a primitive
- internal static bool CV_TYP_IS_DIRECT(TYPE_ENUM typ) {
- return (CV_MODE(typ) == CV_prmode.CV_TM_DIRECT);
- }
-
- internal static bool CV_TYP_IS_PTR(TYPE_ENUM typ) {
- return (CV_MODE(typ) != CV_prmode.CV_TM_DIRECT);
- }
-
- internal static bool CV_TYP_IS_SIGNED(TYPE_ENUM typ) {
- return
- (((CV_TYPE(typ) == CV_type.CV_SIGNED) && CV_TYP_IS_DIRECT(typ)) ||
- (typ == TYPE_ENUM.T_INT1) ||
- (typ == TYPE_ENUM.T_INT2) ||
- (typ == TYPE_ENUM.T_INT4) ||
- (typ == TYPE_ENUM.T_INT8) ||
- (typ == TYPE_ENUM.T_INT16) ||
- (typ == TYPE_ENUM.T_RCHAR));
- }
-
- internal static bool CV_TYP_IS_UNSIGNED(TYPE_ENUM typ) {
- return (((CV_TYPE(typ) == CV_type.CV_UNSIGNED) && CV_TYP_IS_DIRECT(typ)) ||
- (typ == TYPE_ENUM.T_UINT1) ||
- (typ == TYPE_ENUM.T_UINT2) ||
- (typ == TYPE_ENUM.T_UINT4) ||
- (typ == TYPE_ENUM.T_UINT8) ||
- (typ == TYPE_ENUM.T_UINT16));
- }
-
- internal static bool CV_TYP_IS_REAL(TYPE_ENUM typ) {
- return ((CV_TYPE(typ) == CV_type.CV_REAL) && CV_TYP_IS_DIRECT(typ));
- }
+ //internal static bool CV_TYP_IS_DIRECT(TYPE_ENUM typ) {
+ // return (CV_MODE(typ) == CV_prmode.CV_TM_DIRECT);
+ //}
+
+ //internal static bool CV_TYP_IS_PTR(TYPE_ENUM typ) {
+ // return (CV_MODE(typ) != CV_prmode.CV_TM_DIRECT);
+ //}
+
+ //internal static bool CV_TYP_IS_SIGNED(TYPE_ENUM typ) {
+ // return
+ // (((CV_TYPE(typ) == CV_type.CV_SIGNED) && CV_TYP_IS_DIRECT(typ)) ||
+ // (typ == TYPE_ENUM.T_INT1) ||
+ // (typ == TYPE_ENUM.T_INT2) ||
+ // (typ == TYPE_ENUM.T_INT4) ||
+ // (typ == TYPE_ENUM.T_INT8) ||
+ // (typ == TYPE_ENUM.T_INT16) ||
+ // (typ == TYPE_ENUM.T_RCHAR));
+ //}
+
+ //internal static bool CV_TYP_IS_UNSIGNED(TYPE_ENUM typ) {
+ // return (((CV_TYPE(typ) == CV_type.CV_UNSIGNED) && CV_TYP_IS_DIRECT(typ)) ||
+ // (typ == TYPE_ENUM.T_UINT1) ||
+ // (typ == TYPE_ENUM.T_UINT2) ||
+ // (typ == TYPE_ENUM.T_UINT4) ||
+ // (typ == TYPE_ENUM.T_UINT8) ||
+ // (typ == TYPE_ENUM.T_UINT16));
+ //}
+
+ //internal static bool CV_TYP_IS_REAL(TYPE_ENUM typ) {
+ // return ((CV_TYPE(typ) == CV_type.CV_REAL) && CV_TYP_IS_DIRECT(typ));
+ //}
const uint CV_FIRST_NONPRIM = 0x1000;
- internal static bool CV_IS_PRIMITIVE(TYPE_ENUM typ) {
- return ((uint)(typ) < CV_FIRST_NONPRIM);
- }
+ //internal static bool CV_IS_PRIMITIVE(TYPE_ENUM typ) {
+ // return ((uint)(typ) < CV_FIRST_NONPRIM);
+ //}
- internal static bool CV_TYP_IS_COMPLEX(TYPE_ENUM typ) {
- return ((CV_TYPE(typ) == CV_type.CV_COMPLEX) && CV_TYP_IS_DIRECT(typ));
- }
+ //internal static bool CV_TYP_IS_COMPLEX(TYPE_ENUM typ) {
+ // return ((CV_TYPE(typ) == CV_type.CV_COMPLEX) && CV_TYP_IS_DIRECT(typ));
+ //}
- internal static bool CV_IS_INTERNAL_PTR(TYPE_ENUM typ) {
- return (CV_IS_PRIMITIVE(typ) &&
- CV_TYPE(typ) == CV_type.CV_CVRESERVED &&
- CV_TYP_IS_PTR(typ));
- }
+ //internal static bool CV_IS_INTERNAL_PTR(TYPE_ENUM typ) {
+ // return (CV_IS_PRIMITIVE(typ) &&
+ // CV_TYPE(typ) == CV_type.CV_CVRESERVED &&
+ // CV_TYP_IS_PTR(typ));
+ //}
}
// selected values for type_index - for a more complete definition, see
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs b/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs
index 99929d9..48a1851 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -9,8 +14,6 @@ using System.IO;
namespace Microsoft.Cci.Pdb {
internal class DataStream {
internal DataStream() {
- this.contentSize = 0;
- this.pages = null;
}
internal DataStream(int contentSize, BitAccess bits, int count) {
@@ -72,73 +75,35 @@ namespace Microsoft.Cci.Pdb {
}
}
- internal void Write(PdbWriter writer, byte[] bytes) {
- Write(writer, bytes, bytes.Length);
- }
-
- internal void Write(PdbWriter writer, byte[] bytes, int data) {
- if (bytes == null || data == 0) {
- return;
- }
-
- int left = data;
- int used = 0;
- int rema = contentSize % writer.pageSize;
- if (rema != 0) {
- int todo = writer.pageSize - rema;
- if (todo > left) {
- todo = left;
- }
-
- int lastPage = pages[pages.Length - 1];
- writer.Seek(lastPage, rema);
- writer.Write(bytes, used, todo);
- used += todo;
- left -= todo;
- }
-
- if (left > 0) {
- int count = (left + writer.pageSize - 1) / writer.pageSize;
- int page0 = writer.AllocatePages(count);
-
- writer.Seek(page0, 0);
- writer.Write(bytes, used, left);
-
- AddPages(page0, count);
- }
-
- contentSize += data;
- }
-
- private void AddPages(int page0, int count) {
- if (pages == null) {
- pages = new int[count];
- for (int i = 0; i < count; i++) {
- pages[i] = page0 + i;
- }
- } else {
- int[] old = pages;
- int used = old.Length;
-
- pages = new int[used + count];
- Array.Copy(old, pages, used);
- for (int i = 0; i < count; i++) {
- pages[used + i] = page0 + i;
- }
- }
- }
-
- internal int Pages {
- get { return pages == null ? 0 : pages.Length; }
- }
+ //private void AddPages(int page0, int count) {
+ // if (pages == null) {
+ // pages = new int[count];
+ // for (int i = 0; i < count; i++) {
+ // pages[i] = page0 + i;
+ // }
+ // } else {
+ // int[] old = pages;
+ // int used = old.Length;
+
+ // pages = new int[used + count];
+ // Array.Copy(old, pages, used);
+ // for (int i = 0; i < count; i++) {
+ // pages[used + i] = page0 + i;
+ // }
+ // }
+ //}
+
+ //internal int Pages {
+ // get { return pages == null ? 0 : pages.Length; }
+ //}
internal int Length {
get { return contentSize; }
}
- internal int GetPage(int index) {
- return pages[index];
- }
+ //internal int GetPage(int index) {
+ // return pages[index];
+ //}
internal int contentSize;
internal int[] pages;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs b/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs
index b6159ab..588f3c1 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs b/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs
index 29fb9fd..0ca7915 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs b/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs
index a9a5b2a..8ab3717 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -9,7 +14,7 @@ namespace Microsoft.Cci.Pdb {
internal class DbiModuleInfo {
internal DbiModuleInfo(BitAccess bits, bool readStrings) {
bits.ReadInt32(out opened);
- section = new DbiSecCon(bits);
+ new DbiSecCon(bits);
bits.ReadUInt16(out flags);
bits.ReadInt16(out stream);
bits.ReadInt32(out cbSyms);
@@ -35,7 +40,7 @@ namespace Microsoft.Cci.Pdb {
}
internal int opened; // 0..3
- internal DbiSecCon section; // 4..31
+ //internal DbiSecCon section; // 4..31
internal ushort flags; // 32..33
internal short stream; // 34..35
internal int cbSyms; // 36..39
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs b/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs
index 1e2b60d..de9fde9 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs b/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs
index a092b1c..db0e41b 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -54,7 +59,7 @@ namespace Microsoft.Cci.Pdb {
// By Brian Grunkemeyer, algorithm by Patrick Dussud.
// Version 1.30 2/20/2000
//| <include path='docs/doc[@for="IntHashTable"]/*' />
- internal class IntHashTable : IEnumerable {
+ internal class IntHashTable {//: IEnumerable {
/*
Implementation Notes:
@@ -125,7 +130,7 @@ namespace Microsoft.Cci.Pdb {
187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263,
1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369};
- private int GetPrime(int minSize) {
+ private static int GetPrime(int minSize) {
if (minSize < 0) {
throw new ArgumentException("Arg_HTCapacityOverflow");
}
@@ -168,17 +173,17 @@ namespace Microsoft.Cci.Pdb {
: this(0, 100) {
}
- // Constructs a new hashtable with the given initial capacity and a load
- // factor of 1.0. The capacity argument serves as an indication of
- // the number of entries the hashtable will contain. When this number (or
- // an approximation) is known, specifying it in the constructor can
- // eliminate a number of resizing operations that would otherwise be
- // performed when elements are added to the hashtable.
- //
- //| <include path='docs/doc[@for="IntHashTable.IntHashTable1"]/*' />
- internal IntHashTable(int capacity)
- : this(capacity, 100) {
- }
+ //// Constructs a new hashtable with the given initial capacity and a load
+ //// factor of 1.0. The capacity argument serves as an indication of
+ //// the number of entries the hashtable will contain. When this number (or
+ //// an approximation) is known, specifying it in the constructor can
+ //// eliminate a number of resizing operations that would otherwise be
+ //// performed when elements are added to the hashtable.
+ ////
+ ////| <include path='docs/doc[@for="IntHashTable.IntHashTable1"]/*' />
+ //internal IntHashTable(int capacity)
+ // : this(capacity, 100) {
+ //}
// Constructs a new hashtable with the given initial capacity and load
// factor. The capacity argument serves as an indication of the
@@ -213,7 +218,7 @@ namespace Microsoft.Cci.Pdb {
// The out parameter seed is h1(key), while the out parameter
// incr is h2(key, hashSize). Callers of this function should
// add incr each time through a loop.
- private uint InitHash(int key, int hashsize, out uint seed, out uint incr) {
+ private static uint InitHash(int key, int hashsize, out uint seed, out uint incr) {
// Hashcode must be positive. Also, we must not use the sign bit, since
// that is used for the collision bit.
uint hashcode = (uint)key & 0x7FFFFFFF;
@@ -236,52 +241,52 @@ namespace Microsoft.Cci.Pdb {
Insert(key, value, true);
}
- // Removes all entries from this hashtable.
- //| <include path='docs/doc[@for="IntHashTable.Clear"]/*' />
- internal void Clear() {
- if (count == 0)
- return;
+ //// Removes all entries from this hashtable.
+ ////| <include path='docs/doc[@for="IntHashTable.Clear"]/*' />
+ //internal void Clear() {
+ // if (count == 0)
+ // return;
- for (int i = 0; i < buckets.Length; i++) {
- buckets[i].hash_coll = 0;
- buckets[i].key = -1;
- buckets[i].val = null;
- }
+ // for (int i = 0; i < buckets.Length; i++) {
+ // buckets[i].hash_coll = 0;
+ // buckets[i].key = -1;
+ // buckets[i].val = null;
+ // }
- count = 0;
- occupancy = 0;
- }
+ // count = 0;
+ // occupancy = 0;
+ //}
// Checks if this hashtable contains an entry with the given key. This is
// an O(1) operation.
//
//| <include path='docs/doc[@for="IntHashTable.Contains"]/*' />
- internal bool Contains(int key) {
- if (key < 0) {
- throw new ArgumentException("Argument_KeyLessThanZero");
- }
-
- uint seed;
- uint incr;
- // Take a snapshot of buckets, in case another thread resizes table
- bucket[] lbuckets = buckets;
- uint hashcode = InitHash(key, lbuckets.Length, out seed, out incr);
- int ntry = 0;
-
- bucket b;
- do {
- int bucketNumber = (int)(seed % (uint)lbuckets.Length);
- b = lbuckets[bucketNumber];
- if (b.val == null) {
- return false;
- }
- if (((b.hash_coll & 0x7FFFFFFF) == hashcode) && b.key == key) {
- return true;
- }
- seed += incr;
- } while (b.hash_coll < 0 && ++ntry < lbuckets.Length);
- return false;
- }
+ //internal bool Contains(int key) {
+ // if (key < 0) {
+ // throw new ArgumentException("Argument_KeyLessThanZero");
+ // }
+
+ // uint seed;
+ // uint incr;
+ // // Take a snapshot of buckets, in case another thread resizes table
+ // bucket[] lbuckets = buckets;
+ // uint hashcode = InitHash(key, lbuckets.Length, out seed, out incr);
+ // int ntry = 0;
+
+ // bucket b;
+ // do {
+ // int bucketNumber = (int)(seed % (uint)lbuckets.Length);
+ // b = lbuckets[bucketNumber];
+ // if (b.val == null) {
+ // return false;
+ // }
+ // if (((b.hash_coll & 0x7FFFFFFF) == hashcode) && b.key == key) {
+ // return true;
+ // }
+ // seed += incr;
+ // } while (b.hash_coll < 0 && ++ntry < lbuckets.Length);
+ // return false;
+ //}
// Returns the value associated with the given key. If an entry with the
// given key is not found, the returned value is null.
@@ -313,9 +318,9 @@ namespace Microsoft.Cci.Pdb {
} while (b.hash_coll < 0 && ++ntry < lbuckets.Length);
return null;
}
- set {
- Insert(key, value, false);
- }
+ //set {
+ // Insert(key, value, false);
+ //}
}
// Increases the bucket count of this hashtable. This method is called from
@@ -374,9 +379,9 @@ namespace Microsoft.Cci.Pdb {
// enumerator will throw an exception.
//
//| <include path='docs/doc[@for="IntHashTable.IEnumerable.GetEnumerator"]/*' />
- IEnumerator IEnumerable.GetEnumerator() {
- return new IntHashTableEnumerator(this);
- }
+ //IEnumerator IEnumerable.GetEnumerator() {
+ // return new IntHashTableEnumerator(this);
+ //}
// Internal method to compare two keys.
//
@@ -502,78 +507,77 @@ namespace Microsoft.Cci.Pdb {
// Returns the number of associations in this hashtable.
//
//| <include path='docs/doc[@for="IntHashTable.Count"]/*' />
- internal int Count {
- get { return count; }
- }
+ //internal int Count {
+ // get { return count; }
+ //}
// Implements an enumerator for a hashtable. The enumerator uses the
// internal version number of the hashtabke to ensure that no modifications
// are made to the hashtable while an enumeration is in progress.
- private class IntHashTableEnumerator : IEnumerator {
- private IntHashTable hashtable;
- private int bucket;
- private int version;
- private bool current;
- private int currentKey;
- private Object currentValue;
-
- internal IntHashTableEnumerator(IntHashTable hashtable) {
- this.hashtable = hashtable;
- bucket = hashtable.buckets.Length;
- version = hashtable.version;
- current = false;
- }
-
- public bool MoveNext() {
- if (version != hashtable.version)
- throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
- while (bucket > 0) {
- bucket--;
- Object val = hashtable.buckets[bucket].val;
- if (val != null) {
- currentKey = hashtable.buckets[bucket].key;
- currentValue = val;
- current = true;
- return true;
- }
- }
- current = false;
- return false;
- }
-
- internal int Key {
- get {
- if (current == false)
- throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
- return currentKey;
- }
- }
-
- public Object Current {
- get {
- if (current == false)
- throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
- return currentValue;
- }
- }
-
- public Object Value {
- get {
- if (version != hashtable.version)
- throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
- if (current == false)
- throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
- return currentValue;
- }
- }
-
- public void Reset() {
- if (version != hashtable.version) throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
- current = false;
- bucket = hashtable.buckets.Length;
- currentKey = -1;
- currentValue = null;
- }
- }
+ //private class IntHashTableEnumerator : IEnumerator {
+ // private IntHashTable hashtable;
+ // private int bucket;
+ // private int version;
+ // private bool current;
+ // //private int currentKey;
+ // private Object currentValue;
+
+ // internal IntHashTableEnumerator(IntHashTable hashtable) {
+ // this.hashtable = hashtable;
+ // bucket = hashtable.buckets.Length;
+ // version = hashtable.version;
+ // }
+
+ // public bool MoveNext() {
+ // if (version != hashtable.version)
+ // throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
+ // while (bucket > 0) {
+ // bucket--;
+ // Object val = hashtable.buckets[bucket].val;
+ // if (val != null) {
+ // //currentKey = hashtable.buckets[bucket].key;
+ // currentValue = val;
+ // current = true;
+ // return true;
+ // }
+ // }
+ // current = false;
+ // return false;
+ // }
+
+ // //internal int Key {
+ // // get {
+ // // if (current == false)
+ // // throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
+ // // return currentKey;
+ // // }
+ // //}
+
+ // public Object Current {
+ // get {
+ // if (current == false)
+ // throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
+ // return currentValue;
+ // }
+ // }
+
+ // //public Object Value {
+ // // get {
+ // // if (version != hashtable.version)
+ // // throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
+ // // if (current == false)
+ // // throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
+ // // return currentValue;
+ // // }
+ // //}
+
+ // public void Reset() {
+ // if (version != hashtable.version) throw new InvalidOperationException("InvalidOperation_EnumFailedVersion");
+ // current = false;
+ // bucket = hashtable.buckets.Length;
+ // //currentKey = -1;
+ // currentValue = null;
+ // }
+ //}
}
}
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/LICENSE b/symbols/pdb/Microsoft.Cci.Pdb/LICENSE
index 7bfc997..7bfc997 100755..100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/LICENSE
+++ b/symbols/pdb/Microsoft.Cci.Pdb/LICENSE
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs b/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs
index 3a7910d..a6669b5 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -8,12 +13,20 @@ using System;
namespace Microsoft.Cci.Pdb {
internal class MsfDirectory {
internal MsfDirectory(PdbReader reader, PdbFileHeader head, BitAccess bits) {
- bits.MinCapacity(head.directorySize);
int pages = reader.PagesFromSize(head.directorySize);
// 0..n in page of directory pages.
- reader.Seek(head.directoryRoot, 0);
- bits.FillBuffer(reader.reader, pages * 4);
+ bits.MinCapacity(head.directorySize);
+ int directoryRootPages = head.directoryRoot.Length;
+ int pagesPerPage = head.pageSize / 4;
+ int pagesToGo = pages;
+ for (int i = 0; i < directoryRootPages; i++) {
+ int pagesInThisPage = pagesToGo <= pagesPerPage ? pagesToGo : pagesPerPage;
+ reader.Seek(head.directoryRoot[i], 0);
+ bits.Append(reader.reader, pagesInThisPage * 4);
+ pagesToGo -= pagesInThisPage;
+ }
+ bits.Position = 0;
DataStream stream = new DataStream(head.directorySize, bits, pages);
bits.MinCapacity(head.directorySize);
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs
index 1f1aec1..434841b 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -22,6 +27,11 @@ namespace Microsoft.Cci.Pdb {
this.value = tag1;
} else if (tag2 == 0x80) {
switch (tag1) {
+ case 0x00: //sbyte
+ sbyte sb;
+ bits.ReadInt8(out sb);
+ this.value = sb;
+ break;
case 0x01: //short
short s;
bits.ReadInt16(out s);
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs
index 515dc37..d7f8f0f 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs
index 0dd7f93..38d1d56 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
index d6d493c..47191ef 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -21,7 +26,7 @@ namespace Microsoft.Cci.Pdb {
bits.ReadGuid(out doctype);
}
- static Dictionary<string,int> LoadNameIndex(BitAccess bits, out int age, out Guid guid) {
+ static Dictionary<string, int> LoadNameIndex(BitAccess bits, out int age, out Guid guid) {
Dictionary<string, int> result = new Dictionary<string, int>();
int ver;
int sig;
@@ -30,9 +35,9 @@ namespace Microsoft.Cci.Pdb {
bits.ReadInt32(out age); // 8..11 Age
bits.ReadGuid(out guid); // 12..27 GUID
- if (ver != 20000404) {
- throw new PdbDebugException("Unsupported PDB Stream version {0}", ver);
- }
+ //if (ver != 20000404) {
+ // throw new PdbDebugException("Unsupported PDB Stream version {0}", ver);
+ //}
// Read string buffer.
int buf;
@@ -70,7 +75,7 @@ namespace Microsoft.Cci.Pdb {
bits.ReadCString(out name);
bits.Position = saved;
- result.Add(name, ni);
+ result.Add(name.ToUpperInvariant(), ni);
j++;
}
}
@@ -126,17 +131,13 @@ namespace Microsoft.Cci.Pdb {
return ht;
}
- private static PdbFunction match = new PdbFunction();
-
- private static PdbFunction FindFunction(PdbFunction[] funcs, ushort sec, uint off) {
- match.segment = sec;
- match.address = off;
+ private static int FindFunction(PdbFunction[] funcs, ushort sec, uint off) {
+ var match = new PdbFunction {
+ segment = sec,
+ address = off,
+ };
- int item = Array.BinarySearch(funcs, match, PdbFunction.byAddress);
- if (item >= 0) {
- return funcs[item];
- }
- return null;
+ return Array.BinarySearch(funcs, match, PdbFunction.byAddress);
}
static void LoadManagedLines(PdbFunction[] funcs,
@@ -146,53 +147,10 @@ namespace Microsoft.Cci.Pdb {
Dictionary<string, int> nameIndex,
PdbReader reader,
uint limit) {
- Array.Sort(funcs, PdbFunction.byAddress);
- IntHashTable checks = new IntHashTable();
+ Array.Sort(funcs, PdbFunction.byAddressAndToken);
- // Read the files first
int begin = bits.Position;
- while (bits.Position < limit) {
- int sig;
- int siz;
- bits.ReadInt32(out sig);
- bits.ReadInt32(out siz);
- int place = bits.Position;
- int endSym = bits.Position + siz;
-
- switch ((DEBUG_S_SUBSECTION)sig) {
- case DEBUG_S_SUBSECTION.FILECHKSMS:
- while (bits.Position < endSym) {
- CV_FileCheckSum chk;
-
- int ni = bits.Position - place;
- bits.ReadUInt32(out chk.name);
- bits.ReadUInt8(out chk.len);
- bits.ReadUInt8(out chk.type);
-
- string name = (string)names[(int)chk.name];
- int guidStream;
- Guid doctypeGuid = SymDocumentType.Text;
- Guid languageGuid = SymLanguageType.CSharp;
- Guid vendorGuid = SymLanguageVendor.Microsoft;
- if (nameIndex.TryGetValue("/src/files/"+name, out guidStream)) {
- var guidBits = new BitAccess(0x100);
- dir.streams[guidStream].Read(reader, guidBits);
- LoadGuidStream(guidBits, out doctypeGuid, out languageGuid, out vendorGuid);
- }
-
- PdbSource src = new PdbSource((uint)ni, name, doctypeGuid, languageGuid, vendorGuid);
- checks.Add(ni, src);
- bits.Position += chk.len;
- bits.Align(4);
- }
- bits.Position = endSym;
- break;
-
- default:
- bits.Position = endSym;
- break;
- }
- }
+ IntHashTable checks = ReadSourceFileInfo(bits, limit, names, dir, nameIndex, reader);
// Read the lines next.
bits.Position = begin;
@@ -211,8 +169,25 @@ namespace Microsoft.Cci.Pdb {
bits.ReadUInt16(out sec.sec);
bits.ReadUInt16(out sec.flags);
bits.ReadUInt32(out sec.cod);
- PdbFunction func = FindFunction(funcs, sec.sec, sec.off);
- if (func == null) break;
+ int funcIndex = FindFunction(funcs, sec.sec, sec.off);
+ if (funcIndex < 0) break;
+ var func = funcs[funcIndex];
+ if (func.lines == null) {
+ while (funcIndex > 0) {
+ var f = funcs[funcIndex-1];
+ if (f.lines != null || f.segment != sec.sec || f.address != sec.off) break;
+ func = f;
+ funcIndex--;
+ }
+ } else {
+ while (funcIndex < funcs.Length-1 && func.lines != null) {
+ var f = funcs[funcIndex+1];
+ if (f.segment != sec.sec || f.address != sec.off) break;
+ func = f;
+ funcIndex++;
+ }
+ }
+ if (func.lines != null) break;
// Count the line blocks.
int begSym = bits.Position;
@@ -255,7 +230,7 @@ namespace Microsoft.Cci.Pdb {
uint lineBegin = line.flags & (uint)CV_Line_Flags.linenumStart;
uint delta = (line.flags & (uint)CV_Line_Flags.deltaLineEnd) >> 24;
- bool statement = ((line.flags & (uint)CV_Line_Flags.fStatement) == 0);
+ //bool statement = ((line.flags & (uint)CV_Line_Flags.fStatement) == 0);
if ((sec.flags & 1) != 0) {
bits.Position = pcol + 4 * i;
bits.ReadUInt16(out column.offColumnStart);
@@ -295,7 +270,7 @@ namespace Microsoft.Cci.Pdb {
bits.Position = 4;
// Console.WriteLine("{0}:", info.moduleName);
- funcs = PdbFunction.LoadManagedFunctions(info.moduleName,
+ funcs = PdbFunction.LoadManagedFunctions(/*info.moduleName,*/
bits, (uint)info.cbSyms,
readStrings);
if (funcs != null) {
@@ -316,10 +291,10 @@ namespace Microsoft.Cci.Pdb {
DbiHeader dh = new DbiHeader(bits);
header = new DbiDbgHdr();
- if (dh.sig != -1 || dh.ver != 19990903) {
- throw new PdbException("Unsupported DBI Stream version, sig={0}, ver={1}",
- dh.sig, dh.ver);
- }
+ //if (dh.sig != -1 || dh.ver != 19990903) {
+ // throw new PdbException("Unsupported DBI Stream version, sig={0}, ver={1}",
+ // dh.sig, dh.ver);
+ //}
// Read gpmod section.
ArrayList modList = new ArrayList();
@@ -362,12 +337,9 @@ namespace Microsoft.Cci.Pdb {
bits.Position = end;
}
- internal static PdbFunction[] LoadFunctions(Stream read, bool readAllStrings, out int age, out Guid guid) {
+ internal static PdbFunction[] LoadFunctions(Stream read, out Dictionary<uint, PdbTokenLine> tokenToSourceMapping, out string sourceServerData, out int age, out Guid guid) {
+ tokenToSourceMapping = new Dictionary<uint, PdbTokenLine>();
BitAccess bits = new BitAccess(512 * 1024);
- return LoadFunctions(read, bits, readAllStrings, out age, out guid);
- }
-
- internal static PdbFunction[] LoadFunctions(Stream read, BitAccess bits, bool readAllStrings, out int age, out Guid guid) {
PdbFileHeader head = new PdbFileHeader(read, bits);
PdbReader reader = new PdbReader(read, head.pageSize);
MsfDirectory dir = new MsfDirectory(reader, head, bits);
@@ -377,24 +349,37 @@ namespace Microsoft.Cci.Pdb {
dir.streams[1].Read(reader, bits);
Dictionary<string, int> nameIndex = LoadNameIndex(bits, out age, out guid);
int nameStream;
- if (!nameIndex.TryGetValue("/names", out nameStream)) {
+ if (!nameIndex.TryGetValue("/NAMES", out nameStream)) {
throw new PdbException("No `name' stream");
}
-
dir.streams[nameStream].Read(reader, bits);
IntHashTable names = LoadNameStream(bits);
+ int srcsrvStream;
+ if (!nameIndex.TryGetValue("SRCSRV", out srcsrvStream))
+ sourceServerData = string.Empty;
+ else {
+ DataStream dataStream = dir.streams[srcsrvStream];
+ byte[] bytes = new byte[dataStream.contentSize];
+ dataStream.Read(reader, bits);
+ sourceServerData = bits.ReadBString(bytes.Length);
+ }
+
dir.streams[3].Read(reader, bits);
- LoadDbiStream(bits, out modules, out header, readAllStrings);
+ LoadDbiStream(bits, out modules, out header, true);
ArrayList funcList = new ArrayList();
if (modules != null) {
for (int m = 0; m < modules.Length; m++) {
- if (modules[m].stream > 0) {
- dir.streams[modules[m].stream].Read(reader, bits);
- LoadFuncsFromDbiModule(bits, modules[m], names, funcList,
- readAllStrings, dir, nameIndex, reader);
+ var module = modules[m];
+ if (module.stream > 0) {
+ dir.streams[module.stream].Read(reader, bits);
+ if (module.moduleName == "TokenSourceLineInfo") {
+ LoadTokenToSourceInfo(bits, module, names, dir, nameIndex, reader, tokenToSourceMapping);
+ continue;
+ }
+ LoadFuncsFromDbiModule(bits, module, names, funcList, true, dir, nameIndex, reader);
}
}
}
@@ -413,9 +398,140 @@ namespace Microsoft.Cci.Pdb {
}
//
- Array.Sort(funcs, PdbFunction.byAddress);
+ Array.Sort(funcs, PdbFunction.byAddressAndToken);
//Array.Sort(funcs, PdbFunction.byToken);
return funcs;
}
+
+ private static void LoadTokenToSourceInfo(BitAccess bits, DbiModuleInfo module, IntHashTable names, MsfDirectory dir,
+ Dictionary<string, int> nameIndex, PdbReader reader, Dictionary<uint, PdbTokenLine> tokenToSourceMapping) {
+ bits.Position = 0;
+ int sig;
+ bits.ReadInt32(out sig);
+ if (sig != 4) {
+ throw new PdbDebugException("Invalid signature. (sig={0})", sig);
+ }
+
+ bits.Position = 4;
+
+ while (bits.Position < module.cbSyms) {
+ ushort siz;
+ ushort rec;
+
+ bits.ReadUInt16(out siz);
+ int star = bits.Position;
+ int stop = bits.Position + siz;
+ bits.Position = star;
+ bits.ReadUInt16(out rec);
+
+ switch ((SYM)rec) {
+ case SYM.S_OEM:
+ OemSymbol oem;
+
+ bits.ReadGuid(out oem.idOem);
+ bits.ReadUInt32(out oem.typind);
+ // internal byte[] rgl; // user data, force 4-byte alignment
+
+ if (oem.idOem == PdbFunction.msilMetaData) {
+ string name = bits.ReadString();
+ if (name == "TSLI") {
+ uint token;
+ uint file_id;
+ uint line;
+ uint column;
+ uint endLine;
+ uint endColumn;
+ bits.ReadUInt32(out token);
+ bits.ReadUInt32(out file_id);
+ bits.ReadUInt32(out line);
+ bits.ReadUInt32(out column);
+ bits.ReadUInt32(out endLine);
+ bits.ReadUInt32(out endColumn);
+ PdbTokenLine tokenLine;
+ if (!tokenToSourceMapping.TryGetValue(token, out tokenLine))
+ tokenToSourceMapping.Add(token, new PdbTokenLine(token, file_id, line, column, endLine, endColumn));
+ else {
+ while (tokenLine.nextLine != null) tokenLine = tokenLine.nextLine;
+ tokenLine.nextLine = new PdbTokenLine(token, file_id, line, column, endLine, endColumn);
+ }
+ }
+ bits.Position = stop;
+ break;
+ } else {
+ throw new PdbDebugException("OEM section: guid={0} ti={1}",
+ oem.idOem, oem.typind);
+ // bits.Position = stop;
+ }
+
+ case SYM.S_END:
+ bits.Position = stop;
+ break;
+
+ default:
+ //Console.WriteLine("{0,6}: {1:x2} {2}",
+ // bits.Position, rec, (SYM)rec);
+ bits.Position = stop;
+ break;
+ }
+ }
+
+ bits.Position = module.cbSyms + module.cbOldLines;
+ int limit = module.cbSyms + module.cbOldLines + module.cbLines;
+ IntHashTable sourceFiles = ReadSourceFileInfo(bits, (uint)limit, names, dir, nameIndex, reader);
+ foreach (var tokenLine in tokenToSourceMapping.Values) {
+ tokenLine.sourceFile = (PdbSource)sourceFiles[(int)tokenLine.file_id];
+ }
+
+ }
+
+ private static IntHashTable ReadSourceFileInfo(BitAccess bits, uint limit, IntHashTable names, MsfDirectory dir,
+ Dictionary<string, int> nameIndex, PdbReader reader) {
+ IntHashTable checks = new IntHashTable();
+
+ int begin = bits.Position;
+ while (bits.Position < limit) {
+ int sig;
+ int siz;
+ bits.ReadInt32(out sig);
+ bits.ReadInt32(out siz);
+ int place = bits.Position;
+ int endSym = bits.Position + siz;
+
+ switch ((DEBUG_S_SUBSECTION)sig) {
+ case DEBUG_S_SUBSECTION.FILECHKSMS:
+ while (bits.Position < endSym) {
+ CV_FileCheckSum chk;
+
+ int ni = bits.Position - place;
+ bits.ReadUInt32(out chk.name);
+ bits.ReadUInt8(out chk.len);
+ bits.ReadUInt8(out chk.type);
+
+ string name = (string)names[(int)chk.name];
+ int guidStream;
+ Guid doctypeGuid = SymDocumentType.Text;
+ Guid languageGuid = Guid.Empty;
+ Guid vendorGuid = Guid.Empty;
+ if (nameIndex.TryGetValue("/SRC/FILES/"+name.ToUpperInvariant(), out guidStream)) {
+ var guidBits = new BitAccess(0x100);
+ dir.streams[guidStream].Read(reader, guidBits);
+ LoadGuidStream(guidBits, out doctypeGuid, out languageGuid, out vendorGuid);
+ }
+
+ PdbSource src = new PdbSource(/*(uint)ni,*/ name, doctypeGuid, languageGuid, vendorGuid);
+ checks.Add(ni, src);
+ bits.Position += chk.len;
+ bits.Align(4);
+ }
+ bits.Position = endSym;
+ break;
+
+ default:
+ bits.Position = endSym;
+ break;
+ }
+ }
+ return checks;
+ }
}
}
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs
index c351076..e1f56db 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -9,21 +14,20 @@ using System.Text;
namespace Microsoft.Cci.Pdb {
internal class PdbFileHeader {
- internal PdbFileHeader(int pageSize) {
- this.magic = new byte[32] {
- 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, // "Microsof"
- 0x74, 0x20, 0x43, 0x2F, 0x43, 0x2B, 0x2B, 0x20, // "t C/C++ "
- 0x4D, 0x53, 0x46, 0x20, 0x37, 0x2E, 0x30, 0x30, // "MSF 7.00"
- 0x0D, 0x0A, 0x1A, 0x44, 0x53, 0x00, 0x00, 0x00 // "^^^DS^^^"
- };
- this.pageSize = pageSize;
- this.zero = 0;
- }
+ //internal PdbFileHeader(int pageSize) {
+ // this.magic = new byte[32] {
+ // 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, // "Microsof"
+ // 0x74, 0x20, 0x43, 0x2F, 0x43, 0x2B, 0x2B, 0x20, // "t C/C++ "
+ // 0x4D, 0x53, 0x46, 0x20, 0x37, 0x2E, 0x30, 0x30, // "MSF 7.00"
+ // 0x0D, 0x0A, 0x1A, 0x44, 0x53, 0x00, 0x00, 0x00 // "^^^DS^^^"
+ // };
+ // this.pageSize = pageSize;
+ //}
internal PdbFileHeader(Stream reader, BitAccess bits) {
bits.MinCapacity(56);
reader.Seek(0, SeekOrigin.Begin);
- bits.FillBuffer(reader, 56);
+ bits.FillBuffer(reader, 52);
this.magic = new byte[32];
bits.ReadBytes(this.magic); // 0..31
@@ -32,41 +36,45 @@ namespace Microsoft.Cci.Pdb {
bits.ReadInt32(out this.pagesUsed); // 40..43
bits.ReadInt32(out this.directorySize); // 44..47
bits.ReadInt32(out this.zero); // 48..51
- bits.ReadInt32(out this.directoryRoot); // 52..55
- }
- internal string Magic {
- get { return StringFromBytesUTF8(magic); }
+ 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 void Write(Stream writer, BitAccess bits) {
- bits.MinCapacity(56);
- bits.WriteBytes(magic); // 0..31
- bits.WriteInt32(pageSize); // 32..35
- bits.WriteInt32(freePageMap); // 36..39
- bits.WriteInt32(pagesUsed); // 40..43
- bits.WriteInt32(directorySize); // 44..47
- bits.WriteInt32(zero); // 48..51
- bits.WriteInt32(directoryRoot); // 52..55
+ //internal string Magic {
+ // get { return StringFromBytesUTF8(magic); }
+ //}
- writer.Seek(0, SeekOrigin.Begin);
- bits.WriteBuffer(writer, 56);
- }
+ //internal void Write(Stream writer, BitAccess bits) {
+ // bits.MinCapacity(pageSize);
+ // bits.WriteBytes(magic); // 0..31
+ // bits.WriteInt32(pageSize); // 32..35
+ // bits.WriteInt32(freePageMap); // 36..39
+ // bits.WriteInt32(pagesUsed); // 40..43
+ // bits.WriteInt32(directorySize); // 44..47
+ // bits.WriteInt32(zero); // 48..51
+ // bits.WriteInt32(directoryRoot); // 52..55
+
+ // writer.Seek(0, SeekOrigin.Begin);
+ // bits.WriteBuffer(writer, pageSize);
+ //}
//////////////////////////////////////////////////// Helper Functions.
//
- internal string StringFromBytesUTF8(byte[] bytes) {
- return StringFromBytesUTF8(bytes, 0, bytes.Length);
- }
+ //internal static string StringFromBytesUTF8(byte[] bytes) {
+ // return StringFromBytesUTF8(bytes, 0, bytes.Length);
+ //}
- internal 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);
- }
+ //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);
+ //}
////////////////////////////////////////////////////////////// Fields.
//
@@ -76,7 +84,7 @@ namespace Microsoft.Cci.Pdb {
internal int pagesUsed;
internal int directorySize;
internal readonly int zero;
- internal int directoryRoot;
+ internal int[] directoryRoot;
}
}
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs
index be28420..2ef733f 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -12,25 +17,31 @@ namespace Microsoft.Cci.Pdb {
static internal readonly Guid msilMetaData = new Guid(0xc6ea3fc9, 0x59b3, 0x49d6, 0xbc, 0x25,
0x09, 0x02, 0xbb, 0xab, 0xb4, 0x60);
static internal readonly IComparer byAddress = new PdbFunctionsByAddress();
- static internal readonly IComparer byToken = new PdbFunctionsByToken();
+ static internal readonly IComparer byAddressAndToken = new PdbFunctionsByAddressAndToken();
+ //static internal readonly IComparer byToken = new PdbFunctionsByToken();
internal uint token;
internal uint slotToken;
- internal string name;
- internal string module;
- internal ushort flags;
+ internal uint tokenOfMethodWhoseUsingInfoAppliesToThisMethod;
+ //internal string name;
+ //internal string module;
+ //internal ushort flags;
internal uint segment;
internal uint address;
- internal uint length;
+ //internal uint length;
//internal byte[] metadata;
internal PdbScope[] scopes;
+ internal PdbSlot[] slots;
+ internal PdbConstant[] constants;
+ internal string[] usedNamespaces;
internal PdbLines[] lines;
internal ushort[]/*?*/ usingCounts;
internal IEnumerable<INamespaceScope>/*?*/ namespaceScopes;
internal string/*?*/ iteratorClass;
internal List<ILocalScope>/*?*/ iteratorScopes;
+ internal PdbSynchronizationInformation/*?*/ synchronizationInformation;
private static string StripNamespace(string module) {
int li = module.LastIndexOf('.');
@@ -41,10 +52,10 @@ namespace Microsoft.Cci.Pdb {
}
- internal static PdbFunction[] LoadManagedFunctions(string module,
+ internal static PdbFunction[] LoadManagedFunctions(/*string module,*/
BitAccess bits, uint limit,
bool readStrings) {
- string mod = StripNamespace(module);
+ //string mod = StripNamespace(module);
int begin = bits.Position;
int count = 0;
@@ -101,7 +112,7 @@ namespace Microsoft.Cci.Pdb {
case SYM.S_GMANPROC:
case SYM.S_LMANPROC:
ManProcSym proc;
- int offset = bits.Position;
+ //int offset = bits.Position;
bits.ReadUInt32(out proc.parent);
bits.ReadUInt32(out proc.end);
@@ -122,7 +133,7 @@ namespace Microsoft.Cci.Pdb {
//Console.WriteLine("token={0:X8} [{1}::{2}]", proc.token, module, proc.name);
bits.Position = stop;
- funcs[func++] = new PdbFunction(module, proc, bits);
+ funcs[func++] = new PdbFunction(/*module,*/ proc, bits);
break;
default: {
@@ -190,15 +201,14 @@ namespace Microsoft.Cci.Pdb {
internal PdbFunction() {
}
- internal PdbFunction(string module, ManProcSym proc, BitAccess bits) {
+ internal PdbFunction(/*string module, */ManProcSym proc, BitAccess bits) {
this.token = proc.token;
- this.module = module;
- this.name = proc.name;
- this.flags = proc.flags;
+ //this.module = module;
+ //this.name = proc.name;
+ //this.flags = proc.flags;
this.segment = proc.seg;
this.address = proc.off;
- this.length = proc.len;
- this.slotToken = 0;
+ //this.length = proc.len;
if (proc.seg != 1) {
throw new PdbDebugException("Segment is {0}, not 1.", proc.seg);
@@ -207,18 +217,27 @@ namespace Microsoft.Cci.Pdb {
throw new PdbDebugException("Warning parent={0}, next={1}",
proc.parent, proc.next);
}
- if (proc.dbgStart != 0 || proc.dbgEnd != 0) {
- throw new PdbDebugException("Warning DBG start={0}, end={1}",
- proc.dbgStart, proc.dbgEnd);
- }
+ //if (proc.dbgStart != 0 || proc.dbgEnd != 0) {
+ // throw new PdbDebugException("Warning DBG start={0}, end={1}",
+ // proc.dbgStart, proc.dbgEnd);
+ //}
int constantCount;
int scopeCount;
int slotCount;
int usedNamespacesCount;
CountScopesAndSlots(bits, proc.end, out constantCount, out scopeCount, out slotCount, out usedNamespacesCount);
- scopes = new PdbScope[scopeCount];
- int scope = 0;
+ int scope = constantCount > 0 || slotCount > 0 || usedNamespacesCount > 0 ? 1 : 0;
+ int slot = 0;
+ int constant = 0;
+ int usedNs = 0;
+ scopes = new PdbScope[scopeCount+scope];
+ slots = new PdbSlot[slotCount];
+ constants = new PdbConstant[constantCount];
+ usedNamespaces = new string[usedNamespacesCount];
+
+ if (scope > 0)
+ scopes[0] = new PdbScope(this.address, proc.len, slots, constants, usedNamespaces);
while (bits.Position < proc.end) {
ushort siz;
@@ -250,6 +269,8 @@ namespace Microsoft.Cci.Pdb {
while (count-- > 0)
this.ReadCustomMetadata(bits);
}
+ } else if (name == "asyncMethodInfo") {
+ this.synchronizationInformation = new PdbSynchronizationInformation(bits);
}
bits.Position = stop;
break;
@@ -266,17 +287,28 @@ namespace Microsoft.Cci.Pdb {
bits.ReadUInt32(out block.parent);
bits.ReadUInt32(out block.end);
bits.ReadUInt32(out block.len);
- bits.ReadUInt32(out this.address);
+ bits.ReadUInt32(out block.off);
bits.ReadUInt16(out block.seg);
bits.SkipCString(out block.name);
bits.Position = stop;
- scopes[scope] = new PdbScope(block, bits, out slotToken);
+ scopes[scope++] = new PdbScope(this.address, block, bits, out slotToken);
bits.Position = (int)block.end;
break;
}
+ case SYM.S_MANSLOT:
+ slots[slot++] = new PdbSlot(bits);
+ bits.Position = stop;
+ break;
+
+ case SYM.S_MANCONSTANT:
+ constants[constant++] = new PdbConstant(bits);
+ bits.Position = stop;
+ break;
+
case SYM.S_UNAMESPACE:
+ bits.ReadCString(out usedNamespaces[usedNs++]);
bits.Position = stop;
break;
@@ -321,10 +353,10 @@ namespace Microsoft.Cci.Pdb {
switch (kind) {
case 0: this.ReadUsingInfo(bits); break;
case 1: this.ReadForwardInfo(bits); break;
- case 2: this.ReadForwardedToModuleInfo(bits); break;
+ 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;
}
@@ -346,10 +378,11 @@ namespace Microsoft.Cci.Pdb {
}
}
- private void ReadForwardedToModuleInfo(BitAccess bits) {
- }
+ //private void ReadForwardedToModuleInfo(BitAccess bits) {
+ //}
private void ReadForwardInfo(BitAccess bits) {
+ bits.ReadUInt32(out this.tokenOfMethodWhoseUsingInfoAppliesToThisMethod);
}
private void ReadUsingInfo(BitAccess bits) {
@@ -380,20 +413,86 @@ namespace Microsoft.Cci.Pdb {
}
}
- internal class PdbFunctionsByToken : IComparer {
+ internal class PdbFunctionsByAddressAndToken : IComparer {
public int Compare(Object x, Object y) {
PdbFunction fx = (PdbFunction)x;
PdbFunction fy = (PdbFunction)y;
- if (fx.token < fy.token) {
+ if (fx.segment < fy.segment) {
+ return -1;
+ } else if (fx.segment > fy.segment) {
+ return 1;
+ } else if (fx.address < fy.address) {
return -1;
- } else if (fx.token > fy.token) {
+ } else if (fx.address > fy.address) {
return 1;
} else {
- return 0;
+ if (fx.token < fy.token)
+ return -1;
+ else if (fx.token > fy.token)
+ return 1;
+ else
+ return 0;
}
}
+ }
+
+ //internal class PdbFunctionsByToken : IComparer {
+ // public int Compare(Object x, Object y) {
+ // PdbFunction fx = (PdbFunction)x;
+ // PdbFunction fy = (PdbFunction)y;
+
+ // if (fx.token < fy.token) {
+ // return -1;
+ // } else if (fx.token > fy.token) {
+ // return 1;
+ // } else {
+ // return 0;
+ // }
+ // }
+
+ //}
+ }
+
+ internal class PdbSynchronizationInformation {
+ internal uint kickoffMethodToken;
+ internal uint generatedCatchHandlerIlOffset;
+ internal PdbSynchronizationPoint[] synchronizationPoints;
+
+ internal PdbSynchronizationInformation(BitAccess bits) {
+ uint asyncStepInfoCount;
+ bits.ReadUInt32(out this.kickoffMethodToken);
+ bits.ReadUInt32(out this.generatedCatchHandlerIlOffset);
+ bits.ReadUInt32(out asyncStepInfoCount);
+ this.synchronizationPoints = new PdbSynchronizationPoint[asyncStepInfoCount];
+ for (uint i = 0; i < asyncStepInfoCount; i += 1) {
+ this.synchronizationPoints[i] = new PdbSynchronizationPoint(bits);
+ }
+ }
+
+ public uint GeneratedCatchHandlerOffset {
+ get { return this.generatedCatchHandlerIlOffset; }
+ }
+ }
+
+ internal class PdbSynchronizationPoint {
+ internal uint synchronizeOffset;
+ internal uint continuationMethodToken;
+ internal uint continuationOffset;
+
+ internal PdbSynchronizationPoint(BitAccess bits) {
+ bits.ReadUInt32(out this.synchronizeOffset);
+ bits.ReadUInt32(out this.continuationMethodToken);
+ bits.ReadUInt32(out this.continuationOffset);
+ }
+
+ public uint SynchronizeOffset {
+ get { return this.synchronizeOffset; }
+ }
+ public uint ContinuationOffset {
+ get { return this.continuationOffset; }
}
}
+
}
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs
index 78eb9d6..f6fe3a9 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs
index 9e989cd..382638b 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs
index 52a8f2a..edfd926 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -25,9 +30,9 @@ namespace Microsoft.Cci.Pdb {
return (size + pageSize - 1) / (pageSize);
}
- internal int PageSize {
- get { return pageSize; }
- }
+ //internal int PageSize {
+ // get { return pageSize; }
+ //}
internal readonly int pageSize;
internal readonly Stream reader;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs
index 72a68d7..92ac385 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -12,13 +17,25 @@ namespace Microsoft.Cci.Pdb {
internal PdbScope[] scopes;
internal string[] usedNamespaces;
- internal uint segment;
+ //internal uint segment;
internal uint address;
+ internal uint offset;
internal uint length;
- internal PdbScope(BlockSym32 block, BitAccess bits, out uint typind) {
- this.segment = block.seg;
+ internal PdbScope(uint address, uint length, PdbSlot[] slots, PdbConstant[] constants, string[] usedNamespaces) {
+ this.constants = constants;
+ this.slots = slots;
+ this.scopes = new PdbScope[0];
+ this.usedNamespaces = usedNamespaces;
+ this.address = address;
+ this.offset = 0;
+ this.length = length;
+ }
+
+ internal PdbScope(uint funcOffset, BlockSym32 block, BitAccess bits, out uint typind) {
+ //this.segment = block.seg;
this.address = block.off;
+ this.offset = block.off - funcOffset;
this.length = block.len;
typind = 0;
@@ -58,12 +75,12 @@ namespace Microsoft.Cci.Pdb {
bits.SkipCString(out sub.name);
bits.Position = stop;
- scopes[scope++] = new PdbScope(sub, bits, out typind);
+ scopes[scope++] = new PdbScope(funcOffset, sub, bits, out typind);
break;
}
case SYM.S_MANSLOT:
- slots[slot++] = new PdbSlot(bits, out typind);
+ slots[slot++] = new PdbSlot(bits);
bits.Position = stop;
break;
@@ -82,8 +99,9 @@ namespace Microsoft.Cci.Pdb {
break;
default:
- throw new PdbException("Unknown SYM in scope {0}", (SYM)rec);
- // bits.Position = stop;
+ //throw new PdbException("Unknown SYM in scope {0}", (SYM)rec);
+ bits.Position = stop;
+ break;
}
}
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs
index b2cebbe..e2b76d5 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs
@@ -1,6 +1,11 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
@@ -8,12 +13,13 @@ using System;
namespace Microsoft.Cci.Pdb {
internal class PdbSlot {
internal uint slot;
+ internal uint typeToken;
internal string name;
internal ushort flags;
- internal uint segment;
- internal uint address;
+ //internal uint segment;
+ //internal uint address;
- internal PdbSlot(BitAccess bits, out uint typind) {
+ internal PdbSlot(BitAccess bits) {
AttrSlotSym slot;
bits.ReadUInt32(out slot.index);
@@ -24,12 +30,12 @@ namespace Microsoft.Cci.Pdb {
bits.ReadCString(out slot.name);
this.slot = slot.index;
+ this.typeToken = slot.typind;
this.name = slot.name;
this.flags = slot.flags;
- this.segment = slot.segCod;
- this.address = slot.offCod;
+ //this.segment = slot.segCod;
+ //this.address = slot.offCod;
- typind = slot.typind;
}
}
}
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs
index e7b0e34..ac40f85 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs
@@ -1,20 +1,25 @@
//-----------------------------------------------------------------------------
//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
namespace Microsoft.Cci.Pdb {
internal class PdbSource {
- internal uint index;
+ //internal uint index;
internal string name;
internal Guid doctype;
internal Guid language;
internal Guid vendor;
- internal PdbSource(uint index, string name, Guid doctype, Guid language, Guid vendor) {
- this.index = index;
+ internal PdbSource(/*uint index, */string name, Guid doctype, Guid language, Guid vendor) {
+ //this.index = index;
this.name = name;
this.doctype = doctype;
this.language = language;
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs
new file mode 100644
index 0000000..879339b
--- /dev/null
+++ b/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs
@@ -0,0 +1,33 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the Microsoft Public License.
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+//
+//-----------------------------------------------------------------------------
+using System;
+
+namespace Microsoft.Cci.Pdb {
+ internal class PdbTokenLine {
+ internal uint token;
+ internal uint file_id;
+ internal uint line;
+ internal uint column;
+ internal uint endLine;
+ internal uint endColumn;
+ internal PdbSource sourceFile;
+ internal PdbTokenLine/*?*/ nextLine;
+
+ internal PdbTokenLine(uint token, uint file_id, uint line, uint column, uint endLine, uint endColumn) {
+ this.token = token;
+ this.file_id = file_id;
+ this.line = line;
+ this.column = column;
+ this.endLine = endLine;
+ this.endColumn = endColumn;
+ }
+ }
+}
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/PdbWriter.cs b/symbols/pdb/Microsoft.Cci.Pdb/PdbWriter.cs
deleted file mode 100644
index ca4992e..0000000
--- a/symbols/pdb/Microsoft.Cci.Pdb/PdbWriter.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-//-----------------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
-//
-//-----------------------------------------------------------------------------
-using System;
-using System.IO;
-
-namespace Microsoft.Cci.Pdb {
- internal class PdbWriter {
- internal PdbWriter(Stream writer, int pageSize) {
- this.pageSize = pageSize;
- this.usedBytes = pageSize * 3;
- this.writer = writer;
-
- writer.SetLength(usedBytes);
- }
-
- internal void WriteMeta(DataStream[] streams, BitAccess bits) {
- PdbFileHeader head = new PdbFileHeader(pageSize);
-
- WriteDirectory(streams,
- out head.directoryRoot,
- out head.directorySize,
- bits);
- WriteFreeMap();
-
- head.freePageMap = 2;
- head.pagesUsed = usedBytes / pageSize;
-
- writer.Seek(0, SeekOrigin.Begin);
- head.Write(writer, bits);
- }
-
- private void WriteDirectory(DataStream[] streams,
- out int directoryRoot,
- out int directorySize,
- BitAccess bits) {
- DataStream directory = new DataStream();
-
- int pages = 0;
- for (int s = 0; s < streams.Length; s++) {
- if (streams[s].Length > 0) {
- pages += streams[s].Pages;
- }
- }
-
- int use = 4 * (1 + streams.Length + pages);
- bits.MinCapacity(use);
- bits.WriteInt32(streams.Length);
- for (int s = 0; s < streams.Length; s++) {
- bits.WriteInt32(streams[s].Length);
- }
- for (int s = 0; s < streams.Length; s++) {
- if (streams[s].Length > 0) {
- bits.WriteInt32(streams[s].pages);
- }
- }
- directory.Write(this, bits.Buffer, use);
- directorySize = directory.Length;
-
- use = 4 * directory.Pages;
- bits.MinCapacity(use);
- bits.WriteInt32(directory.pages);
-
- DataStream ddir = new DataStream();
- ddir.Write(this, bits.Buffer, use);
-
- directoryRoot = ddir.pages[0];
- }
-
- private void WriteFreeMap() {
- byte[] buffer = new byte[pageSize];
-
- // We configure the old free map with only the first 3 pages allocated.
- buffer[0] = 0xf8;
- for (int i = 1; i < pageSize; i++) {
- buffer[i] = 0xff;
- }
- Seek(1, 0);
- Write(buffer, 0, pageSize);
-
- // We configure the new free map with all of the used pages gone.
- int count = usedBytes / pageSize;
- int full = count / 8;
- for (int i = 0; i < full; i++) {
- buffer[i] = 0;
- }
- int rema = count % 8;
- buffer[full] = (byte)(0xff << rema);
-
- Seek(2, 0);
- Write(buffer, 0, pageSize);
- }
-
- internal int AllocatePages(int count) {
- int begin = usedBytes;
-
- usedBytes += count * pageSize;
- writer.SetLength(usedBytes);
-
- if (usedBytes > pageSize * pageSize * 8) {
- throw new Exception("PdbWriter does not support multiple free maps.");
- }
- return begin / pageSize;
- }
-
- internal void Seek(int page, int offset) {
- writer.Seek(page * pageSize + offset, SeekOrigin.Begin);
- }
-
- internal void Write(byte[] bytes, int offset, int count) {
- writer.Write(bytes, offset, count);
- }
-
- //////////////////////////////////////////////////////////////////////
- //
- internal int PageSize {
- get { return pageSize; }
- }
-
- //////////////////////////////////////////////////////////////////////
- //
- internal readonly int pageSize;
- private Stream writer;
- private int usedBytes;
- }
-
-}
diff --git a/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs b/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs
index 2b28971..db3f291 100644
--- a/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs
+++ b/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs
@@ -13,38 +13,6 @@ using System.Diagnostics.SymbolStore;
namespace Microsoft.Cci {
- internal sealed class UsedNamespace : IUsedNamespace {
-
- internal UsedNamespace(IName alias, IName namespaceName) {
- this.alias = alias;
- this.namespaceName = namespaceName;
- }
-
- public IName Alias {
- get { return this.alias; }
- }
- readonly IName alias;
-
- public IName NamespaceName {
- get { return this.namespaceName; }
- }
- readonly IName namespaceName;
-
- }
-
- internal class NamespaceScope : INamespaceScope {
-
- internal NamespaceScope(IEnumerable<IUsedNamespace> usedNamespaces) {
- this.usedNamespaces = usedNamespaces;
- }
-
- public IEnumerable<IUsedNamespace> UsedNamespaces {
- get { return this.usedNamespaces; }
- }
- readonly IEnumerable<IUsedNamespace> usedNamespaces;
-
- }
-
internal sealed class PdbIteratorScope : ILocalScope {
internal PdbIteratorScope(uint offset, uint length) {
@@ -61,6 +29,5 @@ namespace Microsoft.Cci {
get { return this.length; }
}
uint length;
-
}
} \ No newline at end of file
diff --git a/symbols/pdb/Mono.Cecil.Pdb.csproj b/symbols/pdb/Mono.Cecil.Pdb.csproj
index 6c9e599..ff33736 100644
--- a/symbols/pdb/Mono.Cecil.Pdb.csproj
+++ b/symbols/pdb/Mono.Cecil.Pdb.csproj
@@ -1,83 +1,12 @@
-<?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">
+ <Import Project="..\..\Mono.Cecil.settings" />
<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,6 +14,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="..\..\ProjectInfo.cs" />
<Compile Include="Microsoft.Cci.Pdb\BitAccess.cs" />
<Compile Include="Microsoft.Cci.Pdb\BitSet.cs" />
<Compile Include="Microsoft.Cci.Pdb\CvInfo.cs" />
@@ -108,7 +38,7 @@
<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\PdbWriter.cs" />
+ <Compile Include="Microsoft.Cci.Pdb\PdbTokenLine.cs" />
<Compile Include="Microsoft.Cci.Pdb\SourceLocationProvider.cs" />
<Compile Include="Mono.Cecil.Pdb\AssemblyInfo.cs" />
<Compile Include="Mono.Cecil.Pdb\ISymUnmanagedDocumentWriter.cs" />
@@ -121,11 +51,4 @@
<Compile Include="Mono.Cecil.Pdb\SymWriter.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>
- -->
</Project> \ No newline at end of file
diff --git a/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs b/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs
index 14d2679..c4b4e2e 100644
--- a/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs
+++ b/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs
@@ -1,41 +1,16 @@
//
-// AssemblyInfo.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Copyright (c) 2008 - 2011 Jb Evain
-//
-// 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:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// 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 © 2008 - 2011 Jb Evain")]
[assembly: CLSCompliant (false)]
-[assembly: ComVisible (false)]
-
-[assembly: AssemblyVersion ("0.9.5.0")]
-[assembly: AssemblyFileVersion ("0.9.5.0")]
diff --git a/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs b/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs
index 8f47b2c..f694e27 100644
--- a/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs
+++ b/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs
@@ -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;
diff --git a/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs b/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs
index 11466dc..c8d1340 100644
--- a/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs
+++ b/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs
@@ -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;
diff --git a/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs b/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs
index 6509f07..b175c06 100644
--- a/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs
+++ b/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
@@ -75,7 +76,7 @@ namespace Mono.Cecil.Pdb {
uint FindTypeDefByName (string szTypeDef, uint tkEnclosingClass);
Guid GetScopeProps (StringBuilder szName, uint cchName, out uint pchName);
uint GetModuleFromScope ();
- uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, ref uint pdwTypeDefFlags);
+ uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, IntPtr pdwTypeDefFlags);
uint GetInterfaceImplProps (uint iiImpl, out uint pClass);
uint GetTypeRefProps (uint tr, out uint ptkResolutionScope, StringBuilder szName, uint cchName);
uint ResolveTypeRef (uint tr, [In] ref Guid riid, [MarshalAs (UnmanagedType.Interface)] out object ppIScope);
@@ -95,8 +96,7 @@ namespace Mono.Cecil.Pdb {
uint FindMethod (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob);
uint FindField (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob);
uint FindMemberRef (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob);
- uint GetMethodProps (uint mb, out uint pClass, IntPtr szMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr,
- IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA);
+ uint GetMethodProps (uint mb, out uint pClass, IntPtr szMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr, IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA);
uint GetMemberRefProps (uint mr, ref uint ptk, StringBuilder szMember, uint cchMember, out uint pchMember, out IntPtr /* byte* */ ppvSigBlob);
uint EnumProperties (ref uint phEnum, uint td, IntPtr /* uint* */ rProperties, uint cMax);
uint EnumEvents (ref uint phEnum, uint td, IntPtr /* uint* */ rEvents, uint cMax);
@@ -147,11 +147,47 @@ namespace Mono.Cecil.Pdb {
readonly ModuleDefinition module;
+ Dictionary<uint, TypeDefinition> types;
+ Dictionary<uint, MethodDefinition> methods;
+
public ModuleMetadata (ModuleDefinition module)
{
this.module = module;
}
+ bool TryGetType (uint token, out TypeDefinition type)
+ {
+ if (types == null)
+ InitializeMetadata (module);
+
+ return types.TryGetValue (token, out type);
+ }
+
+ bool TryGetMethod (uint token, out MethodDefinition method)
+ {
+ if (methods == null)
+ InitializeMetadata (module);
+
+ return methods.TryGetValue (token, out method);
+ }
+
+ void InitializeMetadata (ModuleDefinition module)
+ {
+ types = new Dictionary<uint, TypeDefinition> ();
+ methods = new Dictionary<uint, MethodDefinition> ();
+
+ foreach (var type in module.GetTypes ()) {
+ types.Add (type.MetadataToken.ToUInt32 (), type);
+ InitializeMethods (type);
+ }
+ }
+
+ void InitializeMethods (TypeDefinition type)
+ {
+ foreach (var method in type.Methods)
+ methods.Add (method.MetadataToken.ToUInt32 (), method);
+ }
+
public void SetModuleProps (string szName)
{
throw new NotImplementedException ();
@@ -442,10 +478,40 @@ namespace Mono.Cecil.Pdb {
throw new NotImplementedException ();
}
- public uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, ref uint pdwTypeDefFlags)
+ public uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, IntPtr pdwTypeDefFlags)
+ {
+ TypeDefinition type;
+ if (!TryGetType (td, out type)) {
+ Marshal.WriteInt16 (szTypeDef, 0);
+ pchTypeDef = 1;
+ return 0;
+ }
+
+ 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;
+ }
+
+ static void WriteIntPtr (IntPtr ptr, uint value)
{
- pchTypeDef = 0;
- return td;
+ if (ptr == IntPtr.Zero)
+ return;
+
+ Marshal.WriteInt32 (ptr, (int) value);
+ }
+
+ static void WriteString (string str, IntPtr buffer, uint bufferSize, out uint chars)
+ {
+ var length = str.Length + 1 >= bufferSize ? bufferSize - 1 : (uint) str.Length;
+ chars = length + 1;
+ var offset = 0;
+
+ for (int i = 0; i < length; i++) {
+ Marshal.WriteInt16 (buffer, offset, str [i]);
+ offset += 2;
+ }
+
+ Marshal.WriteInt16 (buffer, offset, 0);
}
public uint GetInterfaceImplProps (uint iiImpl, out uint pClass)
@@ -535,9 +601,20 @@ namespace Mono.Cecil.Pdb {
public uint GetMethodProps (uint mb, out uint pClass, IntPtr szMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr, IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA)
{
- pClass = 0;
- pchMethod = 0;
- return mb;
+ MethodDefinition method;
+ if (!TryGetMethod (mb, out method)) {
+ Marshal.WriteInt16 (szMethod, 0);
+ pchMethod = 1;
+ pClass = 0;
+ return 0;
+ }
+
+ pClass = method.DeclaringType.MetadataToken.ToUInt32 ();
+ WriteString (method.Name, szMethod, cchMethod, out pchMethod);
+ WriteIntPtr (pdwAttr, (uint) method.Attributes);
+ WriteIntPtr (pulCodeRVA, (uint) method.RVA);
+
+ return (uint) method.ImplAttributes;
}
public uint GetMemberRefProps (uint mr, ref uint ptk, StringBuilder szMember, uint cchMember, out uint pchMember, out IntPtr ppvSigBlob)
@@ -697,7 +774,11 @@ namespace Mono.Cecil.Pdb {
public uint GetNestedClassProps (uint tdNestedClass)
{
- throw new NotImplementedException ();
+ TypeDefinition type;
+ if (!TryGetType (tdNestedClass, out type))
+ return 0;
+
+ return type.IsNested ? type.DeclaringType.MetadataToken.ToUInt32 () : 0;
}
public uint GetNativeCallConvFromSig (IntPtr pvSig, uint cbSig)
diff --git a/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs b/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs
index 79e82db..bf57931 100644
--- a/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs
+++ b/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs
@@ -1,29 +1,11 @@
//
-// PdbHelper.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Copyright (c) 2008 - 2011 Jb Evain
-//
-// 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.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// 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;
@@ -104,6 +86,7 @@ namespace Mono.Cecil.Pdb {
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));
}
static void AddMapping (DocumentLanguage language, Guid guid)
diff --git a/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs b/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs
index 9d71666..d56ead0 100644
--- a/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs
+++ b/symbols/pdb/Mono.Cecil.Pdb/PdbReader.cs
@@ -1,29 +1,11 @@
//
-// PdbReader.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Copyright (c) 2008 - 2011 Jb Evain
-//
-// 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:
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// 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;
@@ -86,11 +68,14 @@ namespace Mono.Cecil.Pdb {
bool PopulateFunctions ()
{
using (pdb_file) {
+ Dictionary<uint, PdbTokenLine> tokenToSourceMapping;
+ string sourceServerData;
int age;
Guid guid;
- var funcs = PdbFile.LoadFunctions (pdb_file, true, out age, out guid);
- if (this.age != 0 && this.guid != guid)
+ var funcs = PdbFile.LoadFunctions (pdb_file, out tokenToSourceMapping, out sourceServerData, out age, out guid);
+
+ if (this.guid != guid)
return false;
foreach (PdbFunction function in funcs)
diff --git a/symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs b/symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs
index d07b698..ab35870 100644
--- a/symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs
+++ b/symbols/pdb/Mono.Cecil.Pdb/PdbWriter.cs
@@ -1,29 +1,11 @@
//
-// PdbWriter.cs
-//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Copyright (c) 2008 - 2011 Jb Evain
-//
-// 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.
+// Copyright (c) 2008 - 2015 Jb Evain
+// Copyright (c) 2008 - 2011 Novell, Inc.
//
-// 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;
diff --git a/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs b/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs
index 34918dc..a2bd1a2 100644
--- a/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs
+++ b/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs
@@ -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;
diff --git a/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs b/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs
index 678942a..6a36236 100644
--- a/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs
+++ b/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs
@@ -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;
diff --git a/symbols/pdb/Test/.gitignore b/symbols/pdb/Test/.gitignore
deleted file mode 100644
index 17ff348..0000000
--- a/symbols/pdb/Test/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-bin
-obj
-*.xml
-*.user
diff --git a/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj b/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
index 80e0ec0..d571cb7 100644
--- a/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
+++ b/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
@@ -1,77 +1,11 @@
-<?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">
+ <Import Project="..\..\..\Mono.Cecil.Tests.settings" />
<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,34 +21,16 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <Compile Include="Mono.Cecil.Tests\Addin.cs" />
<Compile Include="Mono.Cecil.Tests\Linq.cs" />
<Compile Include="Mono.Cecil.Tests\PdbTests.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" />
- </ItemGroup>
- <ItemGroup>
- <Reference Include="nunit.core, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.core.dll</HintPath>
- </Reference>
- <Reference Include="nunit.core.interfaces, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.core.interfaces.dll</HintPath>
- </Reference>
- <Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\Test\libs\nunit-2.5.10\nunit.framework.dll</HintPath>
- </Reference>
+ <Content Include="Resources\assemblies\VBConsApp.exe" />
+ <Content Include="Resources\assemblies\VBConsApp.pdb" />
</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>
- -->
</Project> \ No newline at end of file
diff --git a/symbols/pdb/Test/Mono.Cecil.Tests/Addin.cs b/symbols/pdb/Test/Mono.Cecil.Tests/Addin.cs
deleted file mode 100644
index 080f45e..0000000
--- a/symbols/pdb/Test/Mono.Cecil.Tests/Addin.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using NUnit.Core.Extensibility;
-
-namespace Mono.Cecil.Tests {
-
- [NUnitAddin]
- public class CecilPdbAddin : CecilTestAddin {
- }
-}
diff --git a/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs b/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs
index 60d93a4..f068458 100644
--- a/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs
+++ b/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs
@@ -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,34 +57,79 @@ namespace Mono.Cecil.Tests {
IL_0020: ldloc.1
IL_0021: ret
", main);
+ }, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
+ }
+
+ [Test]
+ public void Document ()
+ {
+ 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;
+
+ Assert.IsNotNull (document);
+
+ 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));
+ }
+
+ [Test]
+ public void BasicDocument ()
+ {
+ 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;
+
+ 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);
+ }, 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 FSharpDocument ()
{
- var type = module.GetType ("Program");
- var method = type.GetMethod ("Main");
+ TestModule ("fsapp.exe", module => {
+ var type = module.GetType ("Program");
+ var method = type.GetMethod ("fact");
- var sequence_point = method.Body.Instructions.Where (i => i.SequencePoint != null).First ().SequencePoint;
- var document = sequence_point.Document;
+ var sequence_point = method.Body.Instructions.Where (i => i.SequencePoint != null).First ().SequencePoint;
+ var document = sequence_point.Document;
- Assert.IsNotNull (document);
+ Assert.IsNotNull (document);
- 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 (@"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;
@@ -91,7 +137,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 ("temp", module.ImportReference (typeof (string)));
body.Variables.Add (temp);
il.Emit (OpCodes.Nop);
@@ -126,8 +172,6 @@ namespace Mono.Cecil.Tests {
Assert.IsTrue (method.HasBody);
Assert.IsNotNull (method.Body);
- System.Console.WriteLine (Formatter.FormatMethodBody (method));
-
Assert.AreEqual (Normalize (expected), Normalize (Formatter.FormatMethodBody (method)));
}
diff --git a/symbols/pdb/Test/Resources/assemblies/FSharp.Core.dll b/symbols/pdb/Test/Resources/assemblies/FSharp.Core.dll
new file mode 100644
index 0000000..1b9afb6
--- /dev/null
+++ b/symbols/pdb/Test/Resources/assemblies/FSharp.Core.dll
Binary files differ
diff --git a/symbols/pdb/Test/Resources/assemblies/VBConsApp.exe b/symbols/pdb/Test/Resources/assemblies/VBConsApp.exe
new file mode 100644
index 0000000..c86b64b
--- /dev/null
+++ b/symbols/pdb/Test/Resources/assemblies/VBConsApp.exe
Binary files differ
diff --git a/symbols/pdb/Test/Resources/assemblies/VBConsApp.pdb b/symbols/pdb/Test/Resources/assemblies/VBConsApp.pdb
new file mode 100644
index 0000000..2625666
--- /dev/null
+++ b/symbols/pdb/Test/Resources/assemblies/VBConsApp.pdb
Binary files differ
diff --git a/symbols/pdb/Test/Resources/assemblies/fsapp.exe b/symbols/pdb/Test/Resources/assemblies/fsapp.exe
new file mode 100644
index 0000000..7cdd236
--- /dev/null
+++ b/symbols/pdb/Test/Resources/assemblies/fsapp.exe
Binary files differ
diff --git a/symbols/pdb/Test/Resources/assemblies/fsapp.pdb b/symbols/pdb/Test/Resources/assemblies/fsapp.pdb
new file mode 100644
index 0000000..3743d24
--- /dev/null
+++ b/symbols/pdb/Test/Resources/assemblies/fsapp.pdb
Binary files differ