You've already forked linux-packaging-mono
Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
parent
1190d13a04
commit
6bdd276d05
28
external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj
vendored
Normal file
28
external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}</ProjectGuid>
|
||||
<RootNamespace>Mono.Cecil.Mdb</RootNamespace>
|
||||
<AssemblyName>Mono.Cecil.Mdb</AssemblyName>
|
||||
<DefineConstants>$(DefineConstants);CECIL</DefineConstants>
|
||||
</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>
|
||||
<Name>Mono.Cecil</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\ProjectInfo.cs" />
|
||||
<Compile Include="Mono.Cecil.Mdb\*.cs" />
|
||||
<Compile Include="Mono.CompilerServices.SymbolWriter\*.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\Mono.Cecil.props" />
|
||||
<Import Project="$(MSBuildCSharpTargets)" />
|
||||
</Project>
|
||||
16
external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs
vendored
Normal file
16
external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle ("Mono.Cecil.Mdb")]
|
||||
|
||||
[assembly: CLSCompliant (false)]
|
||||
204
external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
vendored
Normal file
204
external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Collections.Generic;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
namespace Mono.Cecil.Mdb {
|
||||
|
||||
public sealed class MdbReaderProvider : ISymbolReaderProvider {
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckFileName (fileName);
|
||||
|
||||
return new MdbReader (module, MonoSymbolFile.ReadSymbolFile (Mixin.GetMdbFileName (fileName), module.Mvid));
|
||||
}
|
||||
|
||||
public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckStream (symbolStream);
|
||||
|
||||
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 sealed class MdbReader : ISymbolReader {
|
||||
|
||||
readonly ModuleDefinition module;
|
||||
readonly MonoSymbolFile symbol_file;
|
||||
readonly Dictionary<string, Document> documents;
|
||||
|
||||
public MdbReader (ModuleDefinition module, MonoSymbolFile symFile)
|
||||
{
|
||||
this.module = module;
|
||||
this.symbol_file = symFile;
|
||||
this.documents = new Dictionary<string, Document> ();
|
||||
}
|
||||
|
||||
public bool ProcessDebugHeader (ImageDebugDirectory directory, byte [] header)
|
||||
{
|
||||
return symbol_file.Guid == module.Mvid;
|
||||
}
|
||||
|
||||
public MethodDebugInformation Read (MethodDefinition method)
|
||||
{
|
||||
var method_token = method.MetadataToken;
|
||||
var entry = symbol_file.GetMethodByToken (method_token.ToInt32 ());
|
||||
if (entry == null)
|
||||
return null;
|
||||
|
||||
var info = new MethodDebugInformation (method);
|
||||
|
||||
var scopes = ReadScopes (entry, info);
|
||||
ReadLineNumbers (entry, info);
|
||||
ReadLocalVariables (entry, scopes);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static void ReadLocalVariables (MethodEntry entry, ScopeDebugInformation [] scopes)
|
||||
{
|
||||
var locals = entry.GetLocals ();
|
||||
|
||||
foreach (var local in locals) {
|
||||
var variable = new VariableDebugInformation (local.Index, local.Name);
|
||||
|
||||
var index = local.BlockIndex;
|
||||
if (index < 0 || index >= scopes.Length)
|
||||
continue;
|
||||
|
||||
var scope = scopes [index];
|
||||
if (scope == null)
|
||||
continue;
|
||||
|
||||
scope.Variables.Add (variable);
|
||||
}
|
||||
}
|
||||
|
||||
void ReadLineNumbers (MethodEntry entry, MethodDebugInformation info)
|
||||
{
|
||||
var table = entry.GetLineNumberTable ();
|
||||
|
||||
info.sequence_points = new Collection<SequencePoint> (table.LineNumbers.Length);
|
||||
|
||||
for (var i = 0; i < table.LineNumbers.Length; i++) {
|
||||
var line = table.LineNumbers [i];
|
||||
if (i > 0 && table.LineNumbers [i - 1].Offset == line.Offset)
|
||||
continue;
|
||||
|
||||
info.sequence_points.Add (LineToSequencePoint (line));
|
||||
}
|
||||
}
|
||||
|
||||
Document GetDocument (SourceFileEntry file)
|
||||
{
|
||||
var file_name = file.FileName;
|
||||
|
||||
Document document;
|
||||
if (documents.TryGetValue (file_name, out document))
|
||||
return document;
|
||||
|
||||
document = new Document (file_name) {
|
||||
Hash = file.Checksum,
|
||||
};
|
||||
|
||||
documents.Add (file_name, document);
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
static ScopeDebugInformation [] ReadScopes (MethodEntry entry, MethodDebugInformation info)
|
||||
{
|
||||
var blocks = entry.GetCodeBlocks ();
|
||||
var scopes = new ScopeDebugInformation [blocks.Length + 1];
|
||||
|
||||
info.scope = scopes [0] = new ScopeDebugInformation {
|
||||
Start = new InstructionOffset (0),
|
||||
End = new InstructionOffset (info.code_size),
|
||||
};
|
||||
|
||||
foreach (var block in blocks) {
|
||||
if (block.BlockType != CodeBlockEntry.Type.Lexical && block.BlockType != CodeBlockEntry.Type.CompilerGenerated)
|
||||
continue;
|
||||
|
||||
var scope = new ScopeDebugInformation ();
|
||||
scope.Start = new InstructionOffset (block.StartOffset);
|
||||
scope.End = new InstructionOffset (block.EndOffset);
|
||||
|
||||
scopes [block.Index + 1] = scope;
|
||||
|
||||
if (!AddScope (info.scope.Scopes, scope))
|
||||
info.scope.Scopes.Add (scope);
|
||||
}
|
||||
|
||||
return scopes;
|
||||
}
|
||||
|
||||
static bool AddScope (Collection<ScopeDebugInformation> scopes, ScopeDebugInformation scope)
|
||||
{
|
||||
foreach (var sub_scope in scopes) {
|
||||
if (sub_scope.HasScopes && AddScope (sub_scope.Scopes, scope))
|
||||
return true;
|
||||
|
||||
if (scope.Start.Offset >= sub_scope.Start.Offset && scope.End.Offset <= sub_scope.End.Offset) {
|
||||
sub_scope.Scopes.Add (scope);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SequencePoint LineToSequencePoint (LineNumberEntry line)
|
||||
{
|
||||
var source = symbol_file.GetSourceFile (line.File);
|
||||
return new SequencePoint (line.Offset, GetDocument (source)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
212
external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
vendored
Normal file
212
external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Collections.Generic;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
namespace Mono.Cecil.Mdb {
|
||||
|
||||
#if !READ_ONLY
|
||||
public sealed class MdbWriterProvider : ISymbolWriterProvider {
|
||||
|
||||
public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
Mixin.CheckFileName (fileName);
|
||||
|
||||
return new MdbWriter (module.Mvid, fileName);
|
||||
}
|
||||
|
||||
public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MdbWriter : ISymbolWriter {
|
||||
|
||||
readonly Guid mvid;
|
||||
readonly MonoSymbolWriter writer;
|
||||
readonly Dictionary<string, SourceFile> source_files;
|
||||
|
||||
public MdbWriter (Guid mvid, string assembly)
|
||||
{
|
||||
this.mvid = mvid;
|
||||
this.writer = new MonoSymbolWriter (assembly);
|
||||
this.source_files = new Dictionary<string, SourceFile> ();
|
||||
}
|
||||
|
||||
SourceFile GetSourceFile (Document document)
|
||||
{
|
||||
var url = document.Url;
|
||||
|
||||
SourceFile source_file;
|
||||
if (source_files.TryGetValue (url, out source_file))
|
||||
return source_file;
|
||||
|
||||
var entry = writer.DefineDocument (url, null, document.Hash != null && document.Hash.Length == 16 ? document.Hash : null);
|
||||
var compile_unit = writer.DefineCompilationUnit (entry);
|
||||
|
||||
source_file = new SourceFile (compile_unit, entry);
|
||||
source_files.Add (url, source_file);
|
||||
return source_file;
|
||||
}
|
||||
|
||||
void Populate (Collection<SequencePoint> sequencePoints, int [] offsets,
|
||||
int [] startRows, int [] endRows, int [] startCols, int [] endCols, out SourceFile file)
|
||||
{
|
||||
SourceFile source_file = null;
|
||||
|
||||
for (int i = 0; i < sequencePoints.Count; i++) {
|
||||
var sequence_point = sequencePoints [i];
|
||||
offsets [i] = sequence_point.Offset;
|
||||
|
||||
if (source_file == null)
|
||||
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;
|
||||
}
|
||||
|
||||
public void Write (MethodDebugInformation info)
|
||||
{
|
||||
var method = new SourceMethod (info.method);
|
||||
|
||||
var sequence_points = info.SequencePoints;
|
||||
int count = sequence_points.Count;
|
||||
if (count == 0)
|
||||
return;
|
||||
|
||||
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 (sequence_points, 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++) {
|
||||
builder.MarkSequencePoint (
|
||||
offsets [i],
|
||||
file.CompilationUnit.SourceFile,
|
||||
start_rows [i],
|
||||
start_cols [i],
|
||||
end_rows [i],
|
||||
end_cols [i],
|
||||
false);
|
||||
}
|
||||
|
||||
if (info.scope != null)
|
||||
WriteRootScope (info.scope, info);
|
||||
|
||||
writer.CloseMethod ();
|
||||
}
|
||||
|
||||
void WriteRootScope (ScopeDebugInformation scope, MethodDebugInformation info)
|
||||
{
|
||||
WriteScopeVariables (scope);
|
||||
|
||||
if (scope.HasScopes)
|
||||
WriteScopes (scope.Scopes, info);
|
||||
}
|
||||
|
||||
void WriteScope (ScopeDebugInformation scope, MethodDebugInformation info)
|
||||
{
|
||||
writer.OpenScope (scope.Start.Offset);
|
||||
|
||||
WriteScopeVariables (scope);
|
||||
|
||||
if (scope.HasScopes)
|
||||
WriteScopes (scope.Scopes, info);
|
||||
|
||||
writer.CloseScope (scope.End.IsEndOfMethod ? info.code_size : scope.End.Offset);
|
||||
}
|
||||
|
||||
void WriteScopes (Collection<ScopeDebugInformation> scopes, MethodDebugInformation info)
|
||||
{
|
||||
for (int i = 0; i < scopes.Count; i++)
|
||||
WriteScope (scopes [i], info);
|
||||
}
|
||||
|
||||
void WriteScopeVariables (ScopeDebugInformation scope)
|
||||
{
|
||||
if (!scope.HasVariables)
|
||||
return;
|
||||
|
||||
foreach (var variable in scope.variables)
|
||||
if (!string.IsNullOrEmpty (variable.Name))
|
||||
writer.DefineLocalVariable (variable.Index, variable.Name);
|
||||
}
|
||||
|
||||
public bool GetDebugHeader (out ImageDebugDirectory directory, out byte [] header)
|
||||
{
|
||||
directory = new ImageDebugDirectory ();
|
||||
header = Empty<byte>.Array;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
writer.WriteSymbolFile (mvid);
|
||||
}
|
||||
|
||||
class SourceFile : ISourceFile {
|
||||
|
||||
readonly CompileUnitEntry compilation_unit;
|
||||
readonly SourceFileEntry entry;
|
||||
|
||||
public SourceFileEntry Entry {
|
||||
get { return entry; }
|
||||
}
|
||||
|
||||
public CompileUnitEntry CompilationUnit {
|
||||
get { return compilation_unit; }
|
||||
}
|
||||
|
||||
public SourceFile (CompileUnitEntry comp_unit, SourceFileEntry entry)
|
||||
{
|
||||
this.compilation_unit = comp_unit;
|
||||
this.entry = entry;
|
||||
}
|
||||
}
|
||||
|
||||
class SourceMethod : IMethodDef {
|
||||
|
||||
readonly MethodDefinition method;
|
||||
|
||||
public string Name {
|
||||
get { return method.Name; }
|
||||
}
|
||||
|
||||
public int Token {
|
||||
get { return method.MetadataToken.ToInt32 (); }
|
||||
}
|
||||
|
||||
public SourceMethod (MethodDefinition method)
|
||||
{
|
||||
this.method = method;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
637
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
vendored
Normal file
637
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1444
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
vendored
Normal file
1444
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
238
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
vendored
Normal file
238
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
//
|
||||
// Mono.CSharp.Debugger/MonoSymbolWriter.cs
|
||||
//
|
||||
// Author:
|
||||
// Martin Baulig (martin@ximian.com)
|
||||
//
|
||||
// This is the default implementation of the System.Diagnostics.SymbolStore.ISymbolWriter
|
||||
// interface.
|
||||
//
|
||||
// (C) 2002 Ximian, Inc. http://www.ximian.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;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Mono.CompilerServices.SymbolWriter
|
||||
{
|
||||
public class MonoSymbolWriter
|
||||
{
|
||||
List<SourceMethodBuilder> methods;
|
||||
List<SourceFileEntry> sources;
|
||||
List<CompileUnitEntry> comp_units;
|
||||
protected readonly MonoSymbolFile file;
|
||||
string filename;
|
||||
|
||||
private SourceMethodBuilder current_method;
|
||||
Stack<SourceMethodBuilder> current_method_stack = new Stack<SourceMethodBuilder> ();
|
||||
|
||||
public MonoSymbolWriter (string filename)
|
||||
{
|
||||
this.methods = new List<SourceMethodBuilder> ();
|
||||
this.sources = new List<SourceFileEntry> ();
|
||||
this.comp_units = new List<CompileUnitEntry> ();
|
||||
this.file = new MonoSymbolFile ();
|
||||
|
||||
this.filename = filename + ".mdb";
|
||||
}
|
||||
|
||||
public MonoSymbolFile SymbolFile {
|
||||
get { return file; }
|
||||
}
|
||||
|
||||
public void CloseNamespace ()
|
||||
{ }
|
||||
|
||||
public void DefineLocalVariable (int index, string name)
|
||||
{
|
||||
if (current_method == null)
|
||||
return;
|
||||
|
||||
current_method.AddLocal (index, name);
|
||||
}
|
||||
|
||||
public void DefineCapturedLocal (int scope_id, string name, string captured_name)
|
||||
{
|
||||
file.DefineCapturedVariable (scope_id, name, captured_name,
|
||||
CapturedVariable.CapturedKind.Local);
|
||||
}
|
||||
|
||||
public void DefineCapturedParameter (int scope_id, string name, string captured_name)
|
||||
{
|
||||
file.DefineCapturedVariable (scope_id, name, captured_name,
|
||||
CapturedVariable.CapturedKind.Parameter);
|
||||
}
|
||||
|
||||
public void DefineCapturedThis (int scope_id, string captured_name)
|
||||
{
|
||||
file.DefineCapturedVariable (scope_id, "this", captured_name,
|
||||
CapturedVariable.CapturedKind.This);
|
||||
}
|
||||
|
||||
public void DefineCapturedScope (int scope_id, int id, string captured_name)
|
||||
{
|
||||
file.DefineCapturedScope (scope_id, id, captured_name);
|
||||
}
|
||||
|
||||
public void DefineScopeVariable (int scope, int index)
|
||||
{
|
||||
if (current_method == null)
|
||||
return;
|
||||
|
||||
current_method.AddScopeVariable (scope, index);
|
||||
}
|
||||
|
||||
public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column,
|
||||
bool is_hidden)
|
||||
{
|
||||
if (current_method == null)
|
||||
return;
|
||||
|
||||
current_method.MarkSequencePoint (offset, file, line, column, is_hidden);
|
||||
}
|
||||
|
||||
public SourceMethodBuilder OpenMethod (ICompileUnit file, int ns_id, IMethodDef method)
|
||||
{
|
||||
SourceMethodBuilder builder = new SourceMethodBuilder (file, ns_id, method);
|
||||
current_method_stack.Push (current_method);
|
||||
current_method = builder;
|
||||
methods.Add (current_method);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public void CloseMethod ()
|
||||
{
|
||||
current_method = (SourceMethodBuilder) current_method_stack.Pop ();
|
||||
}
|
||||
|
||||
public SourceFileEntry DefineDocument (string url)
|
||||
{
|
||||
SourceFileEntry entry = new SourceFileEntry (file, url);
|
||||
sources.Add (entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
public SourceFileEntry DefineDocument (string url, byte[] guid, byte[] checksum)
|
||||
{
|
||||
SourceFileEntry entry = new SourceFileEntry (file, url, guid, checksum);
|
||||
sources.Add (entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
public CompileUnitEntry DefineCompilationUnit (SourceFileEntry source)
|
||||
{
|
||||
CompileUnitEntry entry = new CompileUnitEntry (file, source);
|
||||
comp_units.Add (entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
public int DefineNamespace (string name, CompileUnitEntry unit,
|
||||
string[] using_clauses, int parent)
|
||||
{
|
||||
if ((unit == null) || (using_clauses == null))
|
||||
throw new NullReferenceException ();
|
||||
|
||||
return unit.DefineNamespace (name, using_clauses, parent);
|
||||
}
|
||||
|
||||
public int OpenScope (int start_offset)
|
||||
{
|
||||
if (current_method == null)
|
||||
return 0;
|
||||
|
||||
current_method.StartBlock (CodeBlockEntry.Type.Lexical, start_offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void CloseScope (int end_offset)
|
||||
{
|
||||
if (current_method == null)
|
||||
return;
|
||||
|
||||
current_method.EndBlock (end_offset);
|
||||
}
|
||||
|
||||
public void OpenCompilerGeneratedBlock (int start_offset)
|
||||
{
|
||||
if (current_method == null)
|
||||
return;
|
||||
|
||||
current_method.StartBlock (CodeBlockEntry.Type.CompilerGenerated,
|
||||
start_offset);
|
||||
}
|
||||
|
||||
public void CloseCompilerGeneratedBlock (int end_offset)
|
||||
{
|
||||
if (current_method == null)
|
||||
return;
|
||||
|
||||
current_method.EndBlock (end_offset);
|
||||
}
|
||||
|
||||
public void StartIteratorBody (int start_offset)
|
||||
{
|
||||
current_method.StartBlock (CodeBlockEntry.Type.IteratorBody,
|
||||
start_offset);
|
||||
}
|
||||
|
||||
public void EndIteratorBody (int end_offset)
|
||||
{
|
||||
current_method.EndBlock (end_offset);
|
||||
}
|
||||
|
||||
public void StartIteratorDispatcher (int start_offset)
|
||||
{
|
||||
current_method.StartBlock (CodeBlockEntry.Type.IteratorDispatcher,
|
||||
start_offset);
|
||||
}
|
||||
|
||||
public void EndIteratorDispatcher (int end_offset)
|
||||
{
|
||||
current_method.EndBlock (end_offset);
|
||||
}
|
||||
|
||||
public void DefineAnonymousScope (int id)
|
||||
{
|
||||
file.DefineAnonymousScope (id);
|
||||
}
|
||||
|
||||
public void WriteSymbolFile (Guid guid)
|
||||
{
|
||||
foreach (SourceMethodBuilder method in methods)
|
||||
method.DefineMethod (file);
|
||||
|
||||
try {
|
||||
// We mmap the file, so unlink the previous version since it may be in use
|
||||
File.Delete (filename);
|
||||
} catch {
|
||||
// We can safely ignore
|
||||
}
|
||||
using (FileStream fs = new FileStream (filename, FileMode.Create, FileAccess.Write)) {
|
||||
file.CreateSymbolFile (guid, fs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
190
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs
vendored
Normal file
190
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs
vendored
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
349
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs
vendored
Normal file
349
external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs
vendored
Normal file
@@ -0,0 +1,349 @@
|
||||
//
|
||||
// SymbolWriterImpl.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez Gual (lluis@novell.com)
|
||||
//
|
||||
// (C) 2005 Novell, Inc. http://www.novell.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;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Diagnostics.SymbolStore;
|
||||
|
||||
namespace Mono.CompilerServices.SymbolWriter
|
||||
{
|
||||
public class SymbolWriterImpl: ISymbolWriter
|
||||
{
|
||||
MonoSymbolWriter msw;
|
||||
|
||||
int nextLocalIndex;
|
||||
int currentToken;
|
||||
string methodName;
|
||||
Stack namespaceStack = new Stack ();
|
||||
bool methodOpened;
|
||||
|
||||
Hashtable documents = new Hashtable ();
|
||||
|
||||
#if !CECIL
|
||||
ModuleBuilder mb;
|
||||
delegate Guid GetGuidFunc (ModuleBuilder mb);
|
||||
GetGuidFunc get_guid_func;
|
||||
|
||||
public SymbolWriterImpl (ModuleBuilder mb)
|
||||
{
|
||||
this.mb = mb;
|
||||
}
|
||||
|
||||
public void Close ()
|
||||
{
|
||||
MethodInfo mi = typeof (ModuleBuilder).GetMethod (
|
||||
"Mono_GetGuid",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
if (mi == null)
|
||||
return;
|
||||
|
||||
get_guid_func = (GetGuidFunc) System.Delegate.CreateDelegate (
|
||||
typeof (GetGuidFunc), mi);
|
||||
|
||||
msw.WriteSymbolFile (get_guid_func (mb));
|
||||
}
|
||||
#else
|
||||
Guid guid;
|
||||
|
||||
public SymbolWriterImpl (Guid guid)
|
||||
{
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public void Close ()
|
||||
{
|
||||
msw.WriteSymbolFile (guid);
|
||||
}
|
||||
#endif
|
||||
|
||||
public void CloseMethod ()
|
||||
{
|
||||
if (methodOpened) {
|
||||
methodOpened = false;
|
||||
nextLocalIndex = 0;
|
||||
msw.CloseMethod ();
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseNamespace ()
|
||||
{
|
||||
namespaceStack.Pop ();
|
||||
msw.CloseNamespace ();
|
||||
}
|
||||
|
||||
public void CloseScope (int endOffset)
|
||||
{
|
||||
msw.CloseScope (endOffset);
|
||||
}
|
||||
|
||||
public ISymbolDocumentWriter DefineDocument (
|
||||
string url,
|
||||
Guid language,
|
||||
Guid languageVendor,
|
||||
Guid documentType)
|
||||
{
|
||||
SymbolDocumentWriterImpl doc = (SymbolDocumentWriterImpl) documents [url];
|
||||
if (doc == null) {
|
||||
SourceFileEntry entry = msw.DefineDocument (url);
|
||||
CompileUnitEntry comp_unit = msw.DefineCompilationUnit (entry);
|
||||
doc = new SymbolDocumentWriterImpl (comp_unit);
|
||||
documents [url] = doc;
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
public void DefineField (
|
||||
SymbolToken parent,
|
||||
string name,
|
||||
FieldAttributes attributes,
|
||||
byte[] signature,
|
||||
SymAddressKind addrKind,
|
||||
int addr1,
|
||||
int addr2,
|
||||
int addr3)
|
||||
{
|
||||
}
|
||||
|
||||
public void DefineGlobalVariable (
|
||||
string name,
|
||||
FieldAttributes attributes,
|
||||
byte[] signature,
|
||||
SymAddressKind addrKind,
|
||||
int addr1,
|
||||
int addr2,
|
||||
int addr3)
|
||||
{
|
||||
}
|
||||
|
||||
public void DefineLocalVariable (
|
||||
string name,
|
||||
FieldAttributes attributes,
|
||||
byte[] signature,
|
||||
SymAddressKind addrKind,
|
||||
int addr1,
|
||||
int addr2,
|
||||
int addr3,
|
||||
int startOffset,
|
||||
int endOffset)
|
||||
{
|
||||
msw.DefineLocalVariable (nextLocalIndex++, name);
|
||||
}
|
||||
|
||||
public void DefineParameter (
|
||||
string name,
|
||||
ParameterAttributes attributes,
|
||||
int sequence,
|
||||
SymAddressKind addrKind,
|
||||
int addr1,
|
||||
int addr2,
|
||||
int addr3)
|
||||
{
|
||||
}
|
||||
|
||||
public void DefineSequencePoints (
|
||||
ISymbolDocumentWriter document,
|
||||
int[] offsets,
|
||||
int[] lines,
|
||||
int[] columns,
|
||||
int[] endLines,
|
||||
int[] endColumns)
|
||||
{
|
||||
SymbolDocumentWriterImpl doc = (SymbolDocumentWriterImpl) document;
|
||||
SourceFileEntry file = doc != null ? doc.Entry.SourceFile : null;
|
||||
|
||||
for (int n=0; n<offsets.Length; n++) {
|
||||
if (n > 0 && offsets[n] == offsets[n-1] && lines[n] == lines[n-1] && columns[n] == columns[n-1])
|
||||
continue;
|
||||
msw.MarkSequencePoint (offsets[n], file, lines[n], columns[n], false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize (IntPtr emitter, string filename, bool fFullBuild)
|
||||
{
|
||||
msw = new MonoSymbolWriter (filename);
|
||||
}
|
||||
|
||||
public void OpenMethod (SymbolToken method)
|
||||
{
|
||||
currentToken = method.GetToken ();
|
||||
}
|
||||
|
||||
public void OpenNamespace (string name)
|
||||
{
|
||||
NamespaceInfo n = new NamespaceInfo ();
|
||||
n.NamespaceID = -1;
|
||||
n.Name = name;
|
||||
namespaceStack.Push (n);
|
||||
}
|
||||
|
||||
public int OpenScope (int startOffset)
|
||||
{
|
||||
return msw.OpenScope (startOffset);
|
||||
}
|
||||
|
||||
public void SetMethodSourceRange (
|
||||
ISymbolDocumentWriter startDoc,
|
||||
int startLine,
|
||||
int startColumn,
|
||||
ISymbolDocumentWriter endDoc,
|
||||
int endLine,
|
||||
int endColumn)
|
||||
{
|
||||
int nsId = GetCurrentNamespace (startDoc);
|
||||
SourceMethodImpl sm = new SourceMethodImpl (methodName, currentToken, nsId);
|
||||
msw.OpenMethod (((ICompileUnit)startDoc).Entry, nsId, sm);
|
||||
methodOpened = true;
|
||||
}
|
||||
|
||||
public void SetScopeRange (int scopeID, int startOffset, int endOffset)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetSymAttribute (SymbolToken parent, string name, byte[] data)
|
||||
{
|
||||
// This is a hack! but MonoSymbolWriter needs the method name
|
||||
// and ISymbolWriter does not have any method for providing it
|
||||
if (name == "__name")
|
||||
methodName = System.Text.Encoding.UTF8.GetString (data);
|
||||
}
|
||||
|
||||
public void SetUnderlyingWriter (IntPtr underlyingWriter)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetUserEntryPoint (SymbolToken entryMethod)
|
||||
{
|
||||
}
|
||||
|
||||
public void UsingNamespace (string fullName)
|
||||
{
|
||||
if (namespaceStack.Count == 0) {
|
||||
OpenNamespace ("");
|
||||
}
|
||||
|
||||
NamespaceInfo ni = (NamespaceInfo) namespaceStack.Peek ();
|
||||
if (ni.NamespaceID != -1) {
|
||||
NamespaceInfo old = ni;
|
||||
CloseNamespace ();
|
||||
OpenNamespace (old.Name);
|
||||
ni = (NamespaceInfo) namespaceStack.Peek ();
|
||||
ni.UsingClauses = old.UsingClauses;
|
||||
}
|
||||
ni.UsingClauses.Add (fullName);
|
||||
}
|
||||
|
||||
int GetCurrentNamespace (ISymbolDocumentWriter doc)
|
||||
{
|
||||
if (namespaceStack.Count == 0) {
|
||||
OpenNamespace ("");
|
||||
}
|
||||
|
||||
NamespaceInfo ni = (NamespaceInfo) namespaceStack.Peek ();
|
||||
if (ni.NamespaceID == -1)
|
||||
{
|
||||
string[] usings = (string[]) ni.UsingClauses.ToArray (typeof(string));
|
||||
|
||||
int parentId = 0;
|
||||
if (namespaceStack.Count > 1) {
|
||||
namespaceStack.Pop ();
|
||||
parentId = ((NamespaceInfo) namespaceStack.Peek ()).NamespaceID;
|
||||
namespaceStack.Push (ni);
|
||||
}
|
||||
|
||||
ni.NamespaceID = msw.DefineNamespace (ni.Name, ((ICompileUnit)doc).Entry, usings, parentId);
|
||||
}
|
||||
return ni.NamespaceID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SymbolDocumentWriterImpl: ISymbolDocumentWriter, ISourceFile, ICompileUnit
|
||||
{
|
||||
CompileUnitEntry comp_unit;
|
||||
|
||||
public SymbolDocumentWriterImpl (CompileUnitEntry comp_unit)
|
||||
{
|
||||
this.comp_unit = comp_unit;
|
||||
}
|
||||
|
||||
public void SetCheckSum (Guid algorithmId, byte[] checkSum)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetSource (byte[] source)
|
||||
{
|
||||
}
|
||||
|
||||
SourceFileEntry ISourceFile.Entry {
|
||||
get { return comp_unit.SourceFile; }
|
||||
}
|
||||
|
||||
public CompileUnitEntry Entry {
|
||||
get { return comp_unit; }
|
||||
}
|
||||
}
|
||||
|
||||
class SourceMethodImpl: IMethodDef
|
||||
{
|
||||
string name;
|
||||
int token;
|
||||
int namespaceID;
|
||||
|
||||
public SourceMethodImpl (string name, int token, int namespaceID)
|
||||
{
|
||||
this.name = name;
|
||||
this.token = token;
|
||||
this.namespaceID = namespaceID;
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
public int NamespaceID {
|
||||
get { return namespaceID; }
|
||||
}
|
||||
|
||||
public int Token {
|
||||
get { return token; }
|
||||
}
|
||||
}
|
||||
|
||||
class NamespaceInfo
|
||||
{
|
||||
public string Name;
|
||||
public int NamespaceID;
|
||||
public ArrayList UsingClauses = new ArrayList ();
|
||||
}
|
||||
}
|
||||
30
external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
vendored
Normal file
30
external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{AC71DF9C-99FA-4A63-990A-66C8010355A6}</ProjectGuid>
|
||||
<RootNamespace>Mono.Cecil.Mdb.Tests</RootNamespace>
|
||||
<AssemblyName>Mono.Cecil.Mdb.Tests</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Mono.Cecil.csproj">
|
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
|
||||
<Name>Mono.Cecil</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Test\Mono.Cecil.Tests.csproj">
|
||||
<Project>{A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}</Project>
|
||||
<Name>Mono.Cecil.Tests</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Mono.Cecil.Mdb.csproj">
|
||||
<Project>{8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}</Project>
|
||||
<Name>Mono.Cecil.Mdb</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Mono.Cecil.Tests\*.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\**\*" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\..\Mono.Cecil.Tests.props" />
|
||||
<Import Project="$(MSBuildCSharpTargets)" />
|
||||
</Project>
|
||||
86
external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs
vendored
Normal file
86
external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
using Mono.Cecil.Mdb;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Mono.Cecil.Tests {
|
||||
|
||||
[TestFixture]
|
||||
public class MdbTests : BaseTestFixture {
|
||||
|
||||
[Test]
|
||||
public void MdbWithJustLineInfo ()
|
||||
{
|
||||
TestModule ("hello.exe", module => {
|
||||
var type = module.GetType ("Program");
|
||||
var main = type.GetMethod ("Main");
|
||||
|
||||
AssertCode (@"
|
||||
.locals init (System.Int32 i)
|
||||
.line 6,-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,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs'
|
||||
IL_0002: br IL_0013
|
||||
.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,-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
|
||||
IL_0012: stloc.0
|
||||
IL_0013: ldloc.0
|
||||
IL_0014: ldarg.0
|
||||
IL_0015: ldlen
|
||||
IL_0016: conv.i4
|
||||
IL_0017: blt IL_0007
|
||||
.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));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RoundTripCoreLib ()
|
||||
{
|
||||
TestModule ("mscorlib.dll", module => {
|
||||
var type = module.GetType ("System.IO.__Error");
|
||||
var method = type.GetMethod ("WinIOError");
|
||||
|
||||
Assert.IsNotNull (method.Body);
|
||||
}, verify: !Platform.OnMono, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartialClass ()
|
||||
{
|
||||
TestModule ("BreakpointTest.Portable.dll", module => {
|
||||
var type = module.GetType ("BreakpointTest.Portable.TestService/<MyAsyncAction1>c__async3");
|
||||
var method = type.GetMethod ("MoveNext");
|
||||
|
||||
Assert.IsNotNull (method);
|
||||
|
||||
var info = method.DebugInformation;
|
||||
Assert.AreEqual (5, info.SequencePoints.Count);
|
||||
foreach (var sp in info.SequencePoints)
|
||||
Assert.AreEqual(@"C:\tmp\repropartial\BreakpointTest.Portable\TestService.Actions.cs", sp.Document.Url);
|
||||
|
||||
type = module.GetType("BreakpointTest.Portable.TestService/<MyAsyncAction2>c__async2");
|
||||
method = type.GetMethod("MoveNext");
|
||||
|
||||
Assert.IsNotNull(method);
|
||||
|
||||
info = method.DebugInformation;
|
||||
Assert.AreEqual(5, info.SequencePoints.Count);
|
||||
foreach (var sp in info.SequencePoints)
|
||||
Assert.AreEqual(@"C:\tmp\repropartial\BreakpointTest.Portable\TestService.cs", sp.Document.Url);
|
||||
|
||||
|
||||
}, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider));
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
external/linker/cecil/symbols/mdb/Test/Resources/assemblies/BreakpointTest.Portable.dll.mdb
vendored
Normal file
BIN
external/linker/cecil/symbols/mdb/Test/Resources/assemblies/BreakpointTest.Portable.dll.mdb
vendored
Normal file
Binary file not shown.
BIN
external/linker/cecil/symbols/mdb/Test/Resources/assemblies/hello.exe.mdb
vendored
Normal file
BIN
external/linker/cecil/symbols/mdb/Test/Resources/assemblies/hello.exe.mdb
vendored
Normal file
Binary file not shown.
1
external/linker/cecil/symbols/mdb/Test/Resources/assemblies/mscorlib.dll.mdb.REMOVED.git-id
vendored
Normal file
1
external/linker/cecil/symbols/mdb/Test/Resources/assemblies/mscorlib.dll.mdb.REMOVED.git-id
vendored
Normal file
@@ -0,0 +1 @@
|
||||
f997a8c39889b310ac6995842263f24ef6d94396
|
||||
255
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
vendored
Normal file
255
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Cci.Pdb {
|
||||
internal class BitAccess {
|
||||
|
||||
internal BitAccess(int capacity) {
|
||||
this.buffer = new byte[capacity];
|
||||
}
|
||||
|
||||
internal byte[] Buffer {
|
||||
get { return buffer; }
|
||||
}
|
||||
private byte[] buffer;
|
||||
|
||||
internal void FillBuffer(Stream stream, int capacity) {
|
||||
MinCapacity(capacity);
|
||||
stream.Read(buffer, 0, capacity);
|
||||
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 MinCapacity(int capacity) {
|
||||
if (buffer.Length < capacity) {
|
||||
buffer = new byte[capacity];
|
||||
}
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
internal void Align(int alignment) {
|
||||
while ((offset % alignment) != 0) {
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
//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 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) |
|
||||
(buffer[offset + 1] << 8));
|
||||
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) |
|
||||
(buffer[offset + 2] << 16) |
|
||||
(buffer[offset + 3] << 24));
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
internal void ReadInt64(out long value) {
|
||||
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;
|
||||
}
|
||||
|
||||
internal void ReadUInt16(out ushort value) {
|
||||
value = (ushort)((buffer[offset + 0] & 0xFF) |
|
||||
(buffer[offset + 1] << 8));
|
||||
offset += 2;
|
||||
}
|
||||
|
||||
internal void ReadUInt8(out byte value) {
|
||||
value = (byte)((buffer[offset + 0] & 0xFF));
|
||||
offset += 1;
|
||||
}
|
||||
|
||||
internal void ReadUInt32(out uint value) {
|
||||
value = (uint)((buffer[offset + 0] & 0xFF) |
|
||||
(buffer[offset + 1] << 8) |
|
||||
(buffer[offset + 2] << 16) |
|
||||
(buffer[offset + 3] << 24));
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
internal void ReadUInt64(out ulong value) {
|
||||
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;
|
||||
}
|
||||
|
||||
internal void ReadInt32(int[] values) {
|
||||
for (int i = 0; i < values.Length; i++) {
|
||||
ReadInt32(out values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ReadUInt32(uint[] values) {
|
||||
for (int i = 0; i < values.Length; i++) {
|
||||
ReadUInt32(out values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ReadBytes(byte[] bytes) {
|
||||
for (int i = 0; i < bytes.Length; i++) {
|
||||
bytes[i] = buffer[offset++];
|
||||
}
|
||||
}
|
||||
|
||||
internal float ReadFloat() {
|
||||
float result = BitConverter.ToSingle(buffer, offset);
|
||||
offset += 4;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal double ReadDouble() {
|
||||
double result = BitConverter.ToDouble(buffer, offset);
|
||||
offset += 8;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal decimal ReadDecimal() {
|
||||
int[] bits = new int[4];
|
||||
this.ReadInt32(bits);
|
||||
return new decimal(bits[2], bits[3], bits[1], bits[0] < 0, (byte)((bits[0] & 0x00FF0000) >> 16));
|
||||
}
|
||||
|
||||
internal void ReadBString(out string value) {
|
||||
ushort len;
|
||||
this.ReadUInt16(out len);
|
||||
value = Encoding.UTF8.GetString(buffer, offset, len);
|
||||
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) {
|
||||
len++;
|
||||
}
|
||||
value = Encoding.UTF8.GetString(buffer, offset, len);
|
||||
offset += len + 1;
|
||||
}
|
||||
|
||||
internal void SkipCString(out string value) {
|
||||
int len = 0;
|
||||
while (offset + len < buffer.Length && buffer[offset + len] != 0) {
|
||||
len++;
|
||||
}
|
||||
offset += len + 1;
|
||||
value= null;
|
||||
}
|
||||
|
||||
internal void ReadGuid(out Guid guid) {
|
||||
uint a;
|
||||
ushort b;
|
||||
ushort c;
|
||||
byte d;
|
||||
byte e;
|
||||
byte f;
|
||||
byte g;
|
||||
byte h;
|
||||
byte i;
|
||||
byte j;
|
||||
byte k;
|
||||
|
||||
ReadUInt32(out a);
|
||||
ReadUInt16(out b);
|
||||
ReadUInt16(out c);
|
||||
ReadUInt8(out d);
|
||||
ReadUInt8(out e);
|
||||
ReadUInt8(out f);
|
||||
ReadUInt8(out g);
|
||||
ReadUInt8(out h);
|
||||
ReadUInt8(out i);
|
||||
ReadUInt8(out j);
|
||||
ReadUInt8(out k);
|
||||
|
||||
guid = new Guid(a, b, c, d, e, f, g, h, i, j, k);
|
||||
}
|
||||
|
||||
internal string ReadString() {
|
||||
int len = 0;
|
||||
while (offset + len < buffer.Length && buffer[offset + len] != 0) {
|
||||
len+=2;
|
||||
}
|
||||
string result = Encoding.Unicode.GetString(buffer, offset, len);
|
||||
offset += len + 2;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
74
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs
vendored
Normal file
74
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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 struct BitSet {
|
||||
internal BitSet(BitAccess bits) {
|
||||
bits.ReadInt32(out size); // 0..3 : Number of words
|
||||
words = new uint[size];
|
||||
bits.ReadUInt32(words);
|
||||
}
|
||||
|
||||
//internal BitSet(int size) {
|
||||
// this.size = size;
|
||||
// words = new uint[size];
|
||||
//}
|
||||
|
||||
internal bool IsSet(int index) {
|
||||
int word = index / 32;
|
||||
if (word >= this.size) return false;
|
||||
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 Clear(int index) {
|
||||
// int word = index / 32;
|
||||
// if (word >= this.size) return;
|
||||
// words[word] &= ~GetBit(index);
|
||||
//}
|
||||
|
||||
private static uint GetBit(int index) {
|
||||
return ((uint)1 << (index % 32));
|
||||
}
|
||||
|
||||
//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;
|
||||
//}
|
||||
|
||||
private int size;
|
||||
private uint[] words;
|
||||
}
|
||||
|
||||
}
|
||||
2435
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs
vendored
Normal file
2435
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
111
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs
vendored
Normal file
111
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.Cci.Pdb {
|
||||
internal class DataStream {
|
||||
internal DataStream() {
|
||||
}
|
||||
|
||||
internal DataStream(int contentSize, BitAccess bits, int count) {
|
||||
this.contentSize = contentSize;
|
||||
if (count > 0) {
|
||||
this.pages = new int[count];
|
||||
bits.ReadInt32(this.pages);
|
||||
}
|
||||
}
|
||||
|
||||
internal void Read(PdbReader reader, BitAccess bits) {
|
||||
bits.MinCapacity(contentSize);
|
||||
Read(reader, 0, bits.Buffer, 0, contentSize);
|
||||
}
|
||||
|
||||
internal void Read(PdbReader reader, int position,
|
||||
byte[] bytes, int offset, int data) {
|
||||
if (position + data > contentSize) {
|
||||
throw new PdbException("DataStream can't read off end of stream. " +
|
||||
"(pos={0},siz={1})",
|
||||
position, data);
|
||||
}
|
||||
if (position == contentSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
int left = data;
|
||||
int page = position / reader.pageSize;
|
||||
int rema = position % reader.pageSize;
|
||||
|
||||
// First get remained of first page.
|
||||
if (rema != 0) {
|
||||
int todo = reader.pageSize - rema;
|
||||
if (todo > left) {
|
||||
todo = left;
|
||||
}
|
||||
|
||||
reader.Seek(pages[page], rema);
|
||||
reader.Read(bytes, offset, todo);
|
||||
|
||||
offset += todo;
|
||||
left -= todo;
|
||||
page++;
|
||||
}
|
||||
|
||||
// Now get the remaining pages.
|
||||
while (left > 0) {
|
||||
int todo = reader.pageSize;
|
||||
if (todo > left) {
|
||||
todo = left;
|
||||
}
|
||||
|
||||
reader.Seek(pages[page], 0);
|
||||
reader.Read(bytes, offset, todo);
|
||||
|
||||
offset += todo;
|
||||
left -= todo;
|
||||
page++;
|
||||
}
|
||||
}
|
||||
|
||||
//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 contentSize;
|
||||
internal int[] pages;
|
||||
}
|
||||
}
|
||||
41
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs
vendored
Normal file
41
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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 struct DbiDbgHdr {
|
||||
internal DbiDbgHdr(BitAccess bits) {
|
||||
bits.ReadUInt16(out snFPO);
|
||||
bits.ReadUInt16(out snException);
|
||||
bits.ReadUInt16(out snFixup);
|
||||
bits.ReadUInt16(out snOmapToSrc);
|
||||
bits.ReadUInt16(out snOmapFromSrc);
|
||||
bits.ReadUInt16(out snSectionHdr);
|
||||
bits.ReadUInt16(out snTokenRidMap);
|
||||
bits.ReadUInt16(out snXdata);
|
||||
bits.ReadUInt16(out snPdata);
|
||||
bits.ReadUInt16(out snNewFPO);
|
||||
bits.ReadUInt16(out snSectionHdrOrig);
|
||||
}
|
||||
|
||||
internal ushort snFPO; // 0..1
|
||||
internal ushort snException; // 2..3 (deprecated)
|
||||
internal ushort snFixup; // 4..5
|
||||
internal ushort snOmapToSrc; // 6..7
|
||||
internal ushort snOmapFromSrc; // 8..9
|
||||
internal ushort snSectionHdr; // 10..11
|
||||
internal ushort snTokenRidMap; // 12..13
|
||||
internal ushort snXdata; // 14..15
|
||||
internal ushort snPdata; // 16..17
|
||||
internal ushort snNewFPO; // 18..19
|
||||
internal ushort snSectionHdrOrig; // 20..21
|
||||
}
|
||||
}
|
||||
59
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs
vendored
Normal file
59
external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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 struct DbiHeader {
|
||||
internal DbiHeader(BitAccess bits) {
|
||||
bits.ReadInt32(out sig);
|
||||
bits.ReadInt32(out ver);
|
||||
bits.ReadInt32(out age);
|
||||
bits.ReadInt16(out gssymStream);
|
||||
bits.ReadUInt16(out vers);
|
||||
bits.ReadInt16(out pssymStream);
|
||||
bits.ReadUInt16(out pdbver);
|
||||
bits.ReadInt16(out symrecStream);
|
||||
bits.ReadUInt16(out pdbver2);
|
||||
bits.ReadInt32(out gpmodiSize);
|
||||
bits.ReadInt32(out secconSize);
|
||||
bits.ReadInt32(out secmapSize);
|
||||
bits.ReadInt32(out filinfSize);
|
||||
bits.ReadInt32(out tsmapSize);
|
||||
bits.ReadInt32(out mfcIndex);
|
||||
bits.ReadInt32(out dbghdrSize);
|
||||
bits.ReadInt32(out ecinfoSize);
|
||||
bits.ReadUInt16(out flags);
|
||||
bits.ReadUInt16(out machine);
|
||||
bits.ReadInt32(out reserved);
|
||||
}
|
||||
|
||||
internal int sig; // 0..3
|
||||
internal int ver; // 4..7
|
||||
internal int age; // 8..11
|
||||
internal short gssymStream; // 12..13
|
||||
internal ushort vers; // 14..15
|
||||
internal short pssymStream; // 16..17
|
||||
internal ushort pdbver; // 18..19
|
||||
internal short symrecStream; // 20..21
|
||||
internal ushort pdbver2; // 22..23
|
||||
internal int gpmodiSize; // 24..27
|
||||
internal int secconSize; // 28..31
|
||||
internal int secmapSize; // 32..35
|
||||
internal int filinfSize; // 36..39
|
||||
internal int tsmapSize; // 40..43
|
||||
internal int mfcIndex; // 44..47
|
||||
internal int dbghdrSize; // 48..51
|
||||
internal int ecinfoSize; // 52..55
|
||||
internal ushort flags; // 56..57
|
||||
internal ushort machine; // 58..59
|
||||
internal int reserved; // 60..63
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user