You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
42
external/cecil/Mono.Cecil/AssemblyReader.cs
vendored
42
external/cecil/Mono.Cecil/AssemblyReader.cs
vendored
@@ -11,6 +11,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
@@ -2856,12 +2857,22 @@ namespace Mono.Cecil {
|
||||
if (signature == 0)
|
||||
return new Collection<SequencePoint> (0);
|
||||
|
||||
var document = metadata.GetDocument (document_index);
|
||||
var document = GetDocument (document_index);
|
||||
var reader = ReadSignature (signature);
|
||||
|
||||
return reader.ReadSequencePoints (document);
|
||||
}
|
||||
|
||||
public Document GetDocument (uint rid)
|
||||
{
|
||||
var document = metadata.GetDocument (rid);
|
||||
if (document == null)
|
||||
return null;
|
||||
|
||||
document.custom_infos = GetCustomDebugInformation (document);
|
||||
return document;
|
||||
}
|
||||
|
||||
void InitializeLocalScopes ()
|
||||
{
|
||||
if (metadata.LocalScopes != null)
|
||||
@@ -3187,6 +3198,31 @@ namespace Mono.Cecil {
|
||||
async_body.move_next = GetMethodDefinition (move_next_rid);
|
||||
|
||||
infos.Add (async_body);
|
||||
} else if (rows [i].Col1 == EmbeddedSourceDebugInformation.KindIdentifier) {
|
||||
var signature = ReadSignature (rows [i].Col2);
|
||||
var format = signature.ReadInt32 ();
|
||||
var length = signature.sig_length - 4;
|
||||
|
||||
var info = null as CustomDebugInformation;
|
||||
|
||||
if (format == 0) {
|
||||
info = new EmbeddedSourceDebugInformation (signature.ReadBytes ((int) length), compress: false);
|
||||
} else if (format > 0) {
|
||||
var compressed_stream = new MemoryStream (signature.ReadBytes ((int) length));
|
||||
var decompressed_document = new byte [format]; // if positive, format is the decompressed length of the document
|
||||
var decompressed_stream = new MemoryStream (decompressed_document);
|
||||
|
||||
using (var deflate_stream = new DeflateStream (compressed_stream, CompressionMode.Decompress, leaveOpen: true))
|
||||
deflate_stream.CopyTo (decompressed_stream);
|
||||
|
||||
info = new EmbeddedSourceDebugInformation (decompressed_document, compress: true);
|
||||
} else if (format < 0) {
|
||||
info = new BinaryCustomDebugInformation (rows [i].Col1, ReadBlob (rows [i].Col2));
|
||||
}
|
||||
|
||||
infos.Add (info);
|
||||
} else if (rows [i].Col1 == SourceLinkDebugInformation.KindIdentifier) {
|
||||
infos.Add (new SourceLinkDebugInformation (Encoding.UTF8.GetString (ReadBlob (rows [i].Col2))));
|
||||
} else {
|
||||
infos.Add (new BinaryCustomDebugInformation (rows [i].Col1, ReadBlob (rows [i].Col2)));
|
||||
}
|
||||
@@ -3759,7 +3795,7 @@ namespace Mono.Cecil {
|
||||
ReadCompressedUInt32 (); // local_sig_token
|
||||
|
||||
if (document == null)
|
||||
document = reader.metadata.GetDocument (ReadCompressedUInt32 ());
|
||||
document = reader.GetDocument (ReadCompressedUInt32 ());
|
||||
|
||||
var offset = 0;
|
||||
var start_line = 0;
|
||||
@@ -3769,7 +3805,7 @@ namespace Mono.Cecil {
|
||||
for (var i = 0; CanReadMore (); i++) {
|
||||
var delta_il = (int) ReadCompressedUInt32 ();
|
||||
if (i > 0 && delta_il == 0) {
|
||||
document = reader.metadata.GetDocument (ReadCompressedUInt32 ());
|
||||
document = reader.GetDocument (ReadCompressedUInt32 ());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
45
external/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
45
external/cecil/Mono.Cecil/AssemblyWriter.cs
vendored
@@ -11,6 +11,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
|
||||
using Mono;
|
||||
@@ -1044,6 +1045,10 @@ namespace Mono.Cecil {
|
||||
|
||||
if (module.EntryPoint != null)
|
||||
entry_point = LookupToken (module.EntryPoint);
|
||||
|
||||
var pdb_writer = symbol_writer as IMetadataSymbolWriter;
|
||||
if (pdb_writer != null)
|
||||
pdb_writer.WriteModule ();
|
||||
}
|
||||
|
||||
void BuildAssembly ()
|
||||
@@ -2345,7 +2350,7 @@ namespace Mono.Cecil {
|
||||
return signature;
|
||||
}
|
||||
|
||||
void AddCustomDebugInformations (ICustomDebugInformationProvider provider)
|
||||
public void AddCustomDebugInformations (ICustomDebugInformationProvider provider)
|
||||
{
|
||||
if (!provider.HasCustomDebugInformations)
|
||||
return;
|
||||
@@ -2365,6 +2370,12 @@ namespace Mono.Cecil {
|
||||
case CustomDebugInformationKind.StateMachineScope:
|
||||
AddStateMachineScopeDebugInformation (provider, (StateMachineScopeDebugInformation) custom_info);
|
||||
break;
|
||||
case CustomDebugInformationKind.EmbeddedSource:
|
||||
AddEmbeddedSourceDebugInformation (provider, (EmbeddedSourceDebugInformation) custom_info);
|
||||
break;
|
||||
case CustomDebugInformationKind.SourceLink:
|
||||
AddSourceLinkDebugInformation (provider, (SourceLinkDebugInformation) custom_info);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
@@ -2401,6 +2412,36 @@ namespace Mono.Cecil {
|
||||
AddCustomDebugInformation (provider, async_method, signature);
|
||||
}
|
||||
|
||||
void AddEmbeddedSourceDebugInformation (ICustomDebugInformationProvider provider, EmbeddedSourceDebugInformation embedded_source)
|
||||
{
|
||||
var signature = CreateSignatureWriter ();
|
||||
var content = embedded_source.content ?? Empty<byte>.Array;
|
||||
if (embedded_source.compress) {
|
||||
signature.WriteInt32 (content.Length);
|
||||
|
||||
var decompressed_stream = new MemoryStream (content);
|
||||
var content_stream = new MemoryStream ();
|
||||
|
||||
using (var compress_stream = new DeflateStream (content_stream, CompressionMode.Compress, leaveOpen: true))
|
||||
decompressed_stream.CopyTo (compress_stream);
|
||||
|
||||
signature.WriteBytes (content_stream.ToArray ());
|
||||
} else {
|
||||
signature.WriteInt32 (0);
|
||||
signature.WriteBytes (content);
|
||||
}
|
||||
|
||||
AddCustomDebugInformation (provider, embedded_source, signature);
|
||||
}
|
||||
|
||||
void AddSourceLinkDebugInformation (ICustomDebugInformationProvider provider, SourceLinkDebugInformation source_link)
|
||||
{
|
||||
var signature = CreateSignatureWriter ();
|
||||
signature.WriteBytes (Encoding.UTF8.GetBytes (source_link.content));
|
||||
|
||||
AddCustomDebugInformation (provider, source_link, signature);
|
||||
}
|
||||
|
||||
void AddCustomDebugInformation (ICustomDebugInformationProvider provider, CustomDebugInformation custom_info, SignatureWriter signature)
|
||||
{
|
||||
AddCustomDebugInformation (provider, custom_info, GetBlobIndex (signature));
|
||||
@@ -2505,6 +2546,8 @@ namespace Mono.Cecil {
|
||||
|
||||
document.token = token;
|
||||
|
||||
AddCustomDebugInformations (document);
|
||||
|
||||
document_map.Add (document.Url, token);
|
||||
|
||||
return token;
|
||||
|
||||
20
external/cecil/Mono.Cecil/ModuleDefinition.cs
vendored
20
external/cecil/Mono.Cecil/ModuleDefinition.cs
vendored
@@ -254,7 +254,7 @@ namespace Mono.Cecil {
|
||||
|
||||
#endif
|
||||
|
||||
public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider, IDisposable {
|
||||
public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider, ICustomDebugInformationProvider, IDisposable {
|
||||
|
||||
internal Image Image;
|
||||
internal MetadataSystem MetadataSystem;
|
||||
@@ -294,6 +294,8 @@ namespace Mono.Cecil {
|
||||
Collection<ExportedType> exported_types;
|
||||
TypeDefinitionCollection types;
|
||||
|
||||
internal Collection<CustomDebugInformation> custom_infos;
|
||||
|
||||
public bool IsMain {
|
||||
get { return kind != ModuleKind.NetModule; }
|
||||
}
|
||||
@@ -580,6 +582,18 @@ namespace Mono.Cecil {
|
||||
set { entry_point = value; }
|
||||
}
|
||||
|
||||
public bool HasCustomDebugInformations {
|
||||
get {
|
||||
return custom_infos != null && custom_infos.Count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<CustomDebugInformation> CustomDebugInformations {
|
||||
get {
|
||||
return custom_infos ?? (custom_infos = new Collection<CustomDebugInformation> ());
|
||||
}
|
||||
}
|
||||
|
||||
internal ModuleDefinition ()
|
||||
{
|
||||
this.MetadataSystem = new MetadataSystem ();
|
||||
@@ -1237,13 +1251,13 @@ namespace Mono.Cecil {
|
||||
public static void CheckWriteSeek (Stream stream)
|
||||
{
|
||||
if (!stream.CanWrite || !stream.CanSeek)
|
||||
throw new ArgumentException ();
|
||||
throw new ArgumentException ("Stream must be writable and seekable.");
|
||||
}
|
||||
|
||||
public static void CheckReadSeek (Stream stream)
|
||||
{
|
||||
if (!stream.CanRead || !stream.CanSeek)
|
||||
throw new ArgumentException ();
|
||||
throw new ArgumentException ("Stream must be readable and seekable.");
|
||||
}
|
||||
|
||||
public static void CheckType (object type)
|
||||
|
||||
Reference in New Issue
Block a user