Imported Upstream version 5.4.0.199

Former-commit-id: f4d318e4b2f128fa9f4d31b37bb3839a3fc0dfb2
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-09-25 16:57:44 +00:00
parent 536cd135cc
commit 5924117973
223 changed files with 3826 additions and 487 deletions

View File

@@ -161,11 +161,12 @@ namespace Mono.Cecil.Cil {
{
var start_instruction = GetInstruction (scope.Start.Offset);
if (start_instruction != null)
scope.Start = new InstructionOffset (start_instruction);
scope.Start = new InstructionOffset (start_instruction);
var end_instruction = GetInstruction (scope.End.Offset);
if (end_instruction != null)
scope.End = new InstructionOffset (end_instruction);
scope.End = end_instruction != null
? new InstructionOffset (end_instruction)
: new InstructionOffset ();
if (!scope.variables.IsNullOrEmpty ()) {
for (int i = 0; i < scope.variables.Count; i++) {

View File

@@ -60,10 +60,12 @@ namespace Mono.Cecil.Cil {
this.debug_reader = new MetadataReader (image, module, this.reader);
}
#if !READ_ONLY
public ISymbolWriterProvider GetWriterProvider ()
{
return new PortablePdbWriterProvider ();
}
#endif
public bool ProcessDebugHeader (ImageDebugHeader header)
{
@@ -92,7 +94,11 @@ namespace Mono.Cecil.Cil {
var pdb_guid = new Guid (buffer);
return module_guid == pdb_guid;
if (module_guid != pdb_guid)
return false;
ReadModule ();
return true;
}
static int ReadInt32 (byte [] bytes, int start)
@@ -103,6 +109,11 @@ namespace Mono.Cecil.Cil {
| (bytes [start + 3] << 24));
}
void ReadModule ()
{
module.custom_infos = debug_reader.GetCustomDebugInformation (module);
}
public MethodDebugInformation Read (MethodDefinition method)
{
var info = new MethodDebugInformation (method);
@@ -190,11 +201,12 @@ namespace Mono.Cecil.Cil {
this.reader = reader;
}
#if !READ_ONLY
public ISymbolWriterProvider GetWriterProvider ()
{
return new EmbeddedPortablePdbWriterProvider ();
}
#endif
public bool ProcessDebugHeader (ImageDebugHeader header)
{
return reader.ProcessDebugHeader (header);
@@ -244,6 +256,7 @@ namespace Mono.Cecil.Cil {
interface IMetadataSymbolWriter : ISymbolWriter {
void SetMetadata (MetadataBuilder metadata);
void WriteModule ();
}
public sealed class PortablePdbWriter : ISymbolWriter, IMetadataSymbolWriter {
@@ -276,6 +289,11 @@ namespace Mono.Cecil.Cil {
this.pdb_metadata.metadata_builder = metadata;
}
void IMetadataSymbolWriter.WriteModule ()
{
pdb_metadata.AddCustomDebugInformations (module);
}
public ISymbolReaderProvider GetReaderProvider ()
{
return new PortablePdbReaderProvider ();
@@ -471,6 +489,11 @@ namespace Mono.Cecil.Cil {
{
((IMetadataSymbolWriter) writer).SetMetadata (metadata);
}
void IMetadataSymbolWriter.WriteModule ()
{
((IMetadataSymbolWriter) writer).WriteModule ();
}
}
#endif

View File

@@ -433,6 +433,8 @@ namespace Mono.Cecil.Cil {
DynamicVariable,
DefaultNamespace,
AsyncMethodBody,
EmbeddedSource,
SourceLink,
}
public abstract class CustomDebugInformation : DebugInformation {
@@ -558,6 +560,57 @@ namespace Mono.Cecil.Cil {
}
}
public sealed class EmbeddedSourceDebugInformation : CustomDebugInformation {
internal byte [] content;
internal bool compress;
public byte [] Content {
get { return content; }
set { content = value; }
}
public bool Compress {
get { return compress; }
set { compress = value; }
}
public override CustomDebugInformationKind Kind {
get { return CustomDebugInformationKind.EmbeddedSource; }
}
public static Guid KindIdentifier = new Guid ("{0E8A571B-6926-466E-B4AD-8AB04611F5FE}");
public EmbeddedSourceDebugInformation (byte [] content, bool compress)
: base (KindIdentifier)
{
this.content = content;
this.compress = compress;
}
}
public sealed class SourceLinkDebugInformation : CustomDebugInformation {
internal string content;
public string Content {
get { return content; }
set { content = value; }
}
public override CustomDebugInformationKind Kind {
get { return CustomDebugInformationKind.SourceLink; }
}
public static Guid KindIdentifier = new Guid ("{CC110556-A091-4D38-9FEC-25AB9A351A6A}");
public SourceLinkDebugInformation (string content)
: base (KindIdentifier)
{
this.content = content;
}
}
public sealed class MethodDebugInformation : DebugInformation {
internal MethodDefinition method;
@@ -683,8 +736,9 @@ namespace Mono.Cecil.Cil {
}
public interface ISymbolReader : IDisposable {
#if !READ_ONLY
ISymbolWriterProvider GetWriterProvider ();
#endif
bool ProcessDebugHeader (ImageDebugHeader header);
MethodDebugInformation Read (MethodDefinition method);
}
@@ -722,14 +776,25 @@ namespace Mono.Cecil.Cil {
var pdb_file_name = Mixin.GetPdbFileName (fileName);
if (File.Exists (pdb_file_name))
return Mixin.IsPortablePdb (Mixin.GetPdbFileName (fileName))
? new PortablePdbReaderProvider ().GetSymbolReader (module, fileName)
: SymbolProvider.GetReaderProvider (SymbolKind.NativePdb).GetSymbolReader (module, fileName);
if (File.Exists (pdb_file_name)) {
if (Mixin.IsPortablePdb (Mixin.GetPdbFileName (fileName)))
return new PortablePdbReaderProvider ().GetSymbolReader (module, fileName);
try {
return SymbolProvider.GetReaderProvider (SymbolKind.NativePdb).GetSymbolReader (module, fileName);
} catch (TypeLoadException) {
// We might not include support for native pdbs.
}
}
var mdb_file_name = Mixin.GetMdbFileName (fileName);
if (File.Exists (mdb_file_name))
return SymbolProvider.GetReaderProvider (SymbolKind.Mdb).GetSymbolReader (module, fileName);
if (File.Exists (mdb_file_name)) {
try {
return SymbolProvider.GetReaderProvider (SymbolKind.Mdb).GetSymbolReader (module, fileName);
} catch (TypeLoadException) {
// We might not include support for mdbs.
}
}
if (throw_if_no_symbol)
throw new FileNotFoundException (string.Format ("No symbol found for file: {0}", fileName));
@@ -930,6 +995,7 @@ namespace Mono.Cecil {
{
const uint ppdb_signature = 0x424a5342;
if (stream.Length < 4) return false;
var position = stream.Position;
try {
var reader = new BinaryReader (stream);