Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@@ -78,6 +78,7 @@ namespace Mono.Cecil.Mdb {
return null;
var info = new MethodDebugInformation (method);
info.code_size = ReadCodeSize (method);
var scopes = ReadScopes (entry, info);
ReadLineNumbers (entry, info);
@@ -86,6 +87,11 @@ namespace Mono.Cecil.Mdb {
return info;
}
static int ReadCodeSize (MethodDefinition method)
{
return method.Module.Read (method, (m, reader) => reader.ReadCodeSize (m));
}
static void ReadLocalVariables (MethodEntry entry, ScopeDebugInformation [] scopes)
{
var locals = entry.GetLocals ();

View File

@@ -137,9 +137,15 @@ namespace Mono.Cecil.Pdb {
}
}
if (function.iteratorScopes != null)
foreach (var iterator_scope in function.iteratorScopes)
symbol.CustomDebugInformations.Add (new StateMachineScopeDebugInformation ((int) iterator_scope.Offset, (int) (iterator_scope.Offset + iterator_scope.Length + 1)));
if (function.iteratorScopes != null) {
var state_machine = new StateMachineScopeDebugInformation ();
foreach (var iterator_scope in function.iteratorScopes) {
state_machine.Scopes.Add (new StateMachineScope ((int) iterator_scope.Offset, (int) (iterator_scope.Offset + iterator_scope.Length + 1)));
}
symbol.CustomDebugInformations.Add (state_machine);
}
if (function.synchronizationInformation != null) {
var async_debug_info = new AsyncMethodBodyDebugInformation ((int) function.synchronizationInformation.GeneratedCatchHandlerOffset);
@@ -147,11 +153,11 @@ namespace Mono.Cecil.Pdb {
foreach (var synchronization_point in function.synchronizationInformation.synchronizationPoints) {
async_debug_info.Yields.Add (new InstructionOffset ((int) synchronization_point.SynchronizeOffset));
async_debug_info.Resumes.Add (new InstructionOffset ((int) synchronization_point.ContinuationOffset));
async_debug_info.ResumeMethods.Add (method);
}
symbol.CustomDebugInformations.Add (async_debug_info);
async_debug_info.MoveNextMethod = method;
symbol.StateMachineKickOffMethod = (MethodDefinition) method.Module.LookupToken ((int) function.synchronizationInformation.kickoffMethodToken);
}

View File

@@ -111,10 +111,10 @@ namespace Mono.Cecil.Pdb {
}
if (info.HasCustomDebugInformations) {
var scopes = info.CustomDebugInformations.OfType<StateMachineScopeDebugInformation> ().ToArray ();
var state_machine = info.CustomDebugInformations.FirstOrDefault (cdi => cdi.Kind == CustomDebugInformationKind.StateMachineScope) as StateMachineScopeDebugInformation;
if (scopes.Length > 0)
metadata.WriteIteratorScopes (scopes, info);
if (state_machine != null)
metadata.WriteIteratorScopes (state_machine, info);
}
metadata.WriteCustomMetadata ();
@@ -139,7 +139,7 @@ namespace Mono.Cecil.Pdb {
async_metadata.WriteUInt32 ((uint) async_debug_info.Resumes.Count);
for (int i = 0; i < async_debug_info.Resumes.Count; ++i) {
async_metadata.WriteUInt32 ((uint) async_debug_info.Yields [i].Offset);
async_metadata.WriteUInt32 (async_debug_info.MoveNextMethod != null ? async_debug_info.MoveNextMethod.MetadataToken.ToUInt32 () : 0);
async_metadata.WriteUInt32 (async_debug_info.resume_methods [i].MetadataToken.ToUInt32 ());
async_metadata.WriteUInt32 ((uint) async_debug_info.Resumes [i].Offset);
}
@@ -312,10 +312,11 @@ namespace Mono.Cecil.Pdb {
Write (CustomMetadataType.ForwardInfo, () => writer.WriteUInt32 (import_parent.ToUInt32 ()));
}
public void WriteIteratorScopes (StateMachineScopeDebugInformation [] scopes, MethodDebugInformation debug_info)
public void WriteIteratorScopes (StateMachineScopeDebugInformation state_machine, MethodDebugInformation debug_info)
{
Write (CustomMetadataType.IteratorScopes, () => {
writer.WriteInt32 (scopes.Length);
var scopes = state_machine.Scopes;
writer.WriteInt32 (scopes.Count);
foreach (var scope in scopes) {
var start = scope.Start.Offset;
var end = scope.End.IsEndOfMethod ? debug_info.code_size : scope.End.Offset;

View File

@@ -354,8 +354,9 @@ namespace Mono.Cecil.Tests {
var state_machine_scope = move_next.DebugInformation.CustomDebugInformations [0] as StateMachineScopeDebugInformation;
Assert.IsNotNull (state_machine_scope);
Assert.AreEqual (142, state_machine_scope.Start.Offset);
Assert.AreEqual (319, state_machine_scope.End.Offset);
Assert.AreEqual (1, state_machine_scope.Scopes.Count);
Assert.AreEqual (142, state_machine_scope.Scopes [0].Start.Offset);
Assert.AreEqual (319, state_machine_scope.Scopes [0].End.Offset);
var async_body = move_next.DebugInformation.CustomDebugInformations [1] as AsyncMethodBodyDebugInformation;
Assert.IsNotNull (async_body);
@@ -369,7 +370,8 @@ namespace Mono.Cecil.Tests {
Assert.AreEqual (98, async_body.Resumes [0].Offset);
Assert.AreEqual (227, async_body.Resumes [1].Offset);
Assert.AreEqual (move_next, async_body.MoveNextMethod);
Assert.AreEqual (move_next, async_body.ResumeMethods [0]);
Assert.AreEqual (move_next, async_body.ResumeMethods [1]);
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
}