Merge branch 'upstream'
Former-commit-id: 2b1c245bf6e8e5ca915a2500305caac21e41c7d3
This commit is contained in:
commit
2260be33dc
@ -45,6 +45,9 @@
|
||||
/* Disable support for huge assemblies */
|
||||
#undef DISABLE_LARGE_CODE
|
||||
|
||||
/* Disable support code for the LLDB plugin. */
|
||||
#undef DISABLE_LLDB
|
||||
|
||||
/* Disable support debug logging */
|
||||
#undef DISABLE_LOGGING
|
||||
|
||||
|
@ -1 +1 @@
|
||||
c1a14b2d46acd778f29ac790455f1f801e55f675
|
||||
5ee52c595af4a754ddf1cc4e287415421e543537
|
@ -1 +1 @@
|
||||
e39a33a545310609f476581bdc2ee0c419270987
|
||||
c6c1d89ecade1efd48abd44c9cb42126f11dacff
|
15
external/cecil/Mono.Cecil.Cil/CodeReader.cs
vendored
15
external/cecil/Mono.Cecil.Cil/CodeReader.cs
vendored
@ -159,17 +159,20 @@ namespace Mono.Cecil.Cil {
|
||||
|
||||
void ReadScope (ScopeDebugInformation scope)
|
||||
{
|
||||
scope.Start = new InstructionOffset (GetInstruction (scope.Start.Offset));
|
||||
var start_instruction = GetInstruction (scope.Start.Offset);
|
||||
if (start_instruction != null)
|
||||
scope.Start = new InstructionOffset (start_instruction);
|
||||
|
||||
var end_instruction = GetInstruction (scope.End.Offset);
|
||||
scope.End = end_instruction == null
|
||||
? new InstructionOffset ()
|
||||
: new InstructionOffset (end_instruction);
|
||||
if (end_instruction != null)
|
||||
scope.End = new InstructionOffset (end_instruction);
|
||||
|
||||
if (!scope.variables.IsNullOrEmpty ()) {
|
||||
for (int i = 0; i < scope.variables.Count; i++) {
|
||||
var variable = scope.variables [i];
|
||||
variable.index = new VariableIndex (GetVariable (variable.Index));
|
||||
var variable_info = scope.variables [i];
|
||||
var variable = GetVariable (variable_info.Index);
|
||||
if (variable != null)
|
||||
variable_info.index = new VariableIndex (variable);
|
||||
}
|
||||
}
|
||||
|
||||
|
3
external/cecil/Mono.Cecil.Cil/PortablePdb.cs
vendored
3
external/cecil/Mono.Cecil.Cil/PortablePdb.cs
vendored
@ -204,7 +204,7 @@ namespace Mono.Cecil.Cil {
|
||||
|
||||
directory = new ImageDebugDirectory () {
|
||||
MajorVersion = 256,
|
||||
MinorVersion = 20577,
|
||||
MinorVersion = 20557,
|
||||
Type = 2,
|
||||
};
|
||||
|
||||
@ -255,6 +255,7 @@ namespace Mono.Cecil.Cil {
|
||||
writer.WriteMetadataHeader ();
|
||||
writer.WriteMetadata ();
|
||||
|
||||
writer.Flush ();
|
||||
writer.stream.Dispose ();
|
||||
}
|
||||
|
||||
|
1
external/cecil/Mono.Cecil.PE/ImageWriter.cs
vendored
1
external/cecil/Mono.Cecil.PE/ImageWriter.cs
vendored
@ -678,6 +678,7 @@ namespace Mono.Cecil.PE {
|
||||
WriteRsrc ();
|
||||
if (reloc != null)
|
||||
WriteReloc ();
|
||||
Flush ();
|
||||
}
|
||||
|
||||
void BuildTextMap ()
|
||||
|
2
external/cecil/Mono.Cecil.nuspec
vendored
2
external/cecil/Mono.Cecil.nuspec
vendored
@ -2,7 +2,7 @@
|
||||
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<id>Mono.Cecil</id>
|
||||
<version>0.10.0.0-beta1-v2</version>
|
||||
<version>0.10.0.0-beta2</version>
|
||||
<title>Mono.Cecil</title>
|
||||
<authors>Jb Evain</authors>
|
||||
<owners>Jb Evain</owners>
|
||||
|
15
external/cecil/Mono.Cecil/AssemblyReader.cs
vendored
15
external/cecil/Mono.Cecil/AssemblyReader.cs
vendored
@ -2558,6 +2558,17 @@ namespace Mono.Cecil {
|
||||
return (int) size;
|
||||
}
|
||||
|
||||
public IEnumerable<CustomAttribute> GetCustomAttributes ()
|
||||
{
|
||||
InitializeTypeDefinitions ();
|
||||
|
||||
var length = image.TableHeap [Table.CustomAttribute].Length;
|
||||
var custom_attributes = new Collection<CustomAttribute> ((int) length);
|
||||
ReadCustomAttributeRange (new Range (1, length), custom_attributes);
|
||||
|
||||
return custom_attributes;
|
||||
}
|
||||
|
||||
public byte [] ReadCustomAttributeBlob (uint signature)
|
||||
{
|
||||
return ReadBlob (signature);
|
||||
@ -3739,7 +3750,9 @@ namespace Mono.Cecil {
|
||||
if (i > 0 && separator != 0)
|
||||
builder.Append (separator);
|
||||
|
||||
builder.Append (reader.ReadUTF8StringBlob (ReadCompressedUInt32 ()));
|
||||
uint part = ReadCompressedUInt32 ();
|
||||
if (part != 0)
|
||||
builder.Append (reader.ReadUTF8StringBlob (part));
|
||||
}
|
||||
|
||||
return builder.ToString ();
|
||||
|
22
external/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
22
external/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
@ -85,6 +85,9 @@ namespace Mono.Cecil {
|
||||
|
||||
module.MetadataSystem.Clear ();
|
||||
|
||||
if (module.symbol_reader != null)
|
||||
module.symbol_reader.Dispose ();
|
||||
|
||||
var name = module.assembly != null ? module.assembly.Name : null;
|
||||
var fq_name = stream.value.GetFileName ();
|
||||
var symbol_writer_provider = parameters.SymbolWriterProvider;
|
||||
@ -105,9 +108,6 @@ namespace Mono.Cecil {
|
||||
|
||||
BuildMetadata (module, metadata);
|
||||
|
||||
if (module.symbol_reader != null)
|
||||
module.symbol_reader.Dispose ();
|
||||
|
||||
var writer = ImageWriter.CreateWriter (module, metadata, stream);
|
||||
|
||||
writer.WriteImage ();
|
||||
@ -2257,7 +2257,7 @@ namespace Mono.Cecil {
|
||||
{
|
||||
var rid = local_scope_table.AddRow (new LocalScopeRow (
|
||||
method_info.Method.MetadataToken.RID,
|
||||
AddImportScope (scope.Import),
|
||||
scope.import != null ? AddImportScope (scope.import) : 0,
|
||||
local_variable_rid,
|
||||
local_constant_rid,
|
||||
(uint) scope.Start.Offset,
|
||||
@ -2273,9 +2273,6 @@ namespace Mono.Cecil {
|
||||
if (scope.HasConstants)
|
||||
AddLocalConstants (scope);
|
||||
|
||||
if (scope.Import != null)
|
||||
AddImportScope (scope.Import);
|
||||
|
||||
for (int i = 0; i < scope.Scopes.Count; i++)
|
||||
AddLocalScope (method_info, scope.Scopes [i]);
|
||||
}
|
||||
@ -2516,10 +2513,13 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
signature.WriteByte ((byte) separator);
|
||||
|
||||
var parts = name.Split (new [] { separator }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (parts [i]));
|
||||
var parts = name.Split (new [] { separator });
|
||||
for (int i = 0; i < parts.Length; i++) {
|
||||
if (parts [i] == String.Empty)
|
||||
signature.WriteCompressedUInt32 (0);
|
||||
else
|
||||
signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (parts [i]));
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
3
external/cecil/Mono.Cecil/MethodReference.cs
vendored
3
external/cecil/Mono.Cecil/MethodReference.cs
vendored
@ -122,6 +122,9 @@ namespace Mono.Cecil {
|
||||
if (this.ReturnType.ContainsGenericParameter || base.ContainsGenericParameter)
|
||||
return true;
|
||||
|
||||
if (!HasParameters)
|
||||
return false;
|
||||
|
||||
var parameters = this.Parameters;
|
||||
|
||||
for (int i = 0; i < parameters.Count; i++)
|
||||
|
@ -48,6 +48,11 @@ namespace Mono.Cecil {
|
||||
set { Parameter.Attributes = value; }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return Parameter.Name; }
|
||||
set { Parameter.Name = value; }
|
||||
}
|
||||
|
||||
public bool HasCustomAttributes {
|
||||
get { return parameter != null && parameter.HasCustomAttributes; }
|
||||
}
|
||||
|
@ -661,6 +661,14 @@ namespace Mono.Cecil {
|
||||
return Read (this, (_, reader) => reader.GetMemberReferences ());
|
||||
}
|
||||
|
||||
public IEnumerable<CustomAttribute> GetCustomAttributes ()
|
||||
{
|
||||
if (!HasImage)
|
||||
return Empty<CustomAttribute>.Array;
|
||||
|
||||
return Read (this, (_, reader) => reader.GetCustomAttributes ());
|
||||
}
|
||||
|
||||
public TypeReference GetType (string fullName, bool runtimeName)
|
||||
{
|
||||
return runtimeName
|
||||
|
2
external/cecil/ProjectInfo.cs
vendored
2
external/cecil/ProjectInfo.cs
vendored
@ -19,4 +19,4 @@ using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyVersion ("0.10.0.0")]
|
||||
[assembly: AssemblyFileVersion ("0.10.0.0")]
|
||||
[assembly: AssemblyInformationalVersion ("0.10.0.0-beta1")]
|
||||
[assembly: AssemblyInformationalVersion ("0.10.0.0-beta2")]
|
||||
|
21
external/cecil/README.md
vendored
21
external/cecil/README.md
vendored
@ -1,23 +1,4 @@
|
||||
Cecil
|
||||
=====
|
||||
|
||||
Mono.Cecil is a library to generate and inspect programs and libraries in the ECMA CIL form.
|
||||
|
||||
To put it simply, you can use Cecil to:
|
||||
|
||||
* Analyze .NET binaries using a simple and powerful object model, without having to load assemblies to use Reflection.
|
||||
* Modify .NET binaries, add new metadata structures and alter the IL code.
|
||||
|
||||
Cecil has been around since 2004 and is [widely used](https://github.com/jbevain/cecil/wiki/Users) in the .NET community.
|
||||
|
||||
The best way to learn how to use Cecil is to dive into the [Cecil.Samples](https://github.com/jbevain/cecil.samples) repository. It's a growing collection of samples with the goal of showing how to get things done using Cecil, as IL manipulation can sometime get tricky.
|
||||
|
||||
Read about the Cecil development on the [development log](http://cecil.pe).
|
||||
|
||||
To discuss Cecil, the best place is the [mono-cecil](https://groups.google.com/group/mono-cecil) Google Group.
|
||||
|
||||
Cecil is a project under the benevolent umbrella of the [.NET Foundation](http://www.dotnetfoundation.org/).
|
||||
|
||||
[](https://ci.appveyor.com/project/jbevain/cecil)
|
||||
[](https://travis-ci.org/jbevain/cecil)
|
||||
[](https://gitter.im/jbevain/cecil?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
This is a fork of [Cecil](https://github.com/jbevain/cecil) library. Please do any pull requests in the original repository before they are merged into Mono fork.
|
||||
|
@ -351,5 +351,21 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.IsTrue (module.HasSymbols);
|
||||
}, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PortablePdbLineInfo ()
|
||||
{
|
||||
TestModule ("line.exe", module => {
|
||||
var type = module.GetType ("Tests");
|
||||
var main = type.GetMethod ("Main");
|
||||
|
||||
AssertCode (@"
|
||||
.locals ()
|
||||
.line 4,4:42,43 '/foo/bar.cs'
|
||||
IL_0000: nop
|
||||
.line 5,5:2,3 '/foo/bar.cs'
|
||||
IL_0001: ret", main);
|
||||
}, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
external/cecil/Test/Resources/assemblies/line.pdb
vendored
Normal file
BIN
external/cecil/Test/Resources/assemblies/line.pdb
vendored
Normal file
Binary file not shown.
@ -174,6 +174,29 @@ namespace Mono.Cecil.Rocks {
|
||||
instruction.Operand = null;
|
||||
}
|
||||
|
||||
public static void Optimize (this MethodBody self)
|
||||
{
|
||||
if (self == null)
|
||||
throw new ArgumentNullException ("self");
|
||||
|
||||
OptimizeLongs (self);
|
||||
OptimizeMacros (self);
|
||||
}
|
||||
|
||||
static void OptimizeLongs (this MethodBody self)
|
||||
{
|
||||
for (var i = 0; i < self.Instructions.Count; i++) {
|
||||
var instruction = self.Instructions [i];
|
||||
if (instruction.OpCode.Code != Code.Ldc_I8)
|
||||
continue;
|
||||
var l = (long)instruction.Operand;
|
||||
if (l >= uint.MaxValue)
|
||||
continue;
|
||||
ExpandMacro (instruction, OpCodes.Ldc_I4, (uint)l);
|
||||
self.Instructions.Insert (++i, Instruction.Create (OpCodes.Conv_I8));
|
||||
}
|
||||
}
|
||||
|
||||
public static void OptimizeMacros (this MethodBody self)
|
||||
{
|
||||
if (self == null)
|
||||
|
@ -79,7 +79,6 @@ namespace Mono.Cecil.Tests {
|
||||
foreach (var sp in info.SequencePoints)
|
||||
Assert.AreEqual(@"C:\tmp\repropartial\BreakpointTest.Portable\TestService.cs", sp.Document.Url);
|
||||
|
||||
|
||||
}, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider));
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace Mono.Cecil.Pdb {
|
||||
|
||||
static bool IsPortablePdb (string fileName)
|
||||
{
|
||||
using (var file = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.None))
|
||||
using (var file = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
return IsPortablePdb (file);
|
||||
}
|
||||
|
||||
|
@ -104,11 +104,17 @@ namespace Mono.Cecil.Pdb {
|
||||
|
||||
ReadSequencePoints (function, symbol);
|
||||
|
||||
if (function.scopes.Length > 1)
|
||||
throw new NotSupportedException ();
|
||||
else if (function.scopes.Length == 1)
|
||||
if (!function.scopes.IsNullOrEmpty())
|
||||
symbol.scope = ReadScopeAndLocals (function.scopes [0], symbol);
|
||||
|
||||
if (function.scopes.Length > 1) {
|
||||
for (int i = 1; i < function.scopes.Length; i++) {
|
||||
var s = ReadScopeAndLocals (function.scopes [i], symbol);
|
||||
if (!AddScope (symbol.scope.Scopes, s))
|
||||
symbol.scope.Scopes.Add (s);
|
||||
}
|
||||
}
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
@ -133,6 +139,9 @@ namespace Mono.Cecil.Pdb {
|
||||
parent.variables = new Collection<VariableDebugInformation> (scope.slots.Length);
|
||||
|
||||
foreach (PdbSlot slot in scope.slots) {
|
||||
if (slot.flags == 1) // parameter names
|
||||
continue;
|
||||
|
||||
var index = (int) slot.slot;
|
||||
var variable = new VariableDebugInformation (index, slot.name);
|
||||
if (slot.flags == 4)
|
||||
@ -157,6 +166,21 @@ namespace Mono.Cecil.Pdb {
|
||||
return parent;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void ReadSequencePoints (PdbFunction function, MethodDebugInformation info)
|
||||
{
|
||||
if (function.lines == null)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user