Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -5,7 +5,7 @@ LIBRARY = Mono.Debugger.Soft.dll
LIBRARY_SNK = ../mono.snk
LIB_REFS = System Mono.Cecil System.Core
LIB_MCS_FLAGS = /unsafe -D:MONO_DATACONVERTER_STATIC_METHODS /publicsign
LIB_MCS_FLAGS = /unsafe -D:MONO_DATACONVERTER_STATIC_METHODS -D:ENABLE_CECIL /publicsign
KEYFILE = $(LIBRARY_SNK)
TEST_LIB_REFS = Mono.Cecil System System.Core
@@ -34,7 +34,7 @@ $(test_output_dir)/dtest-excfilter.exe: Test/dtest-excfilter.il | $(test_output_
$(ILASM) -out:$@ /exe /debug Test/dtest-excfilter.il
$(test_output_dir)/dtest-app.exe: Test/dtest-app.cs $(TEST_HELPERS_SOURCES) | $(test_output_dir)
$(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Core.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -out:$@ -unsafe $(PLATFORM_DEBUG_FLAGS) -optimize- Test/dtest-app.cs $(TEST_HELPERS_SOURCES)
$(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Core.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Runtime.CompilerServices.Unsafe.dll -sourcelink:Test/sourcelink.json -out:$@ -unsafe $(PLATFORM_DEBUG_FLAGS) -optimize- Test/dtest-app.cs $(TEST_HELPERS_SOURCES)
TEST_HELPERS_SOURCES = \
../test-helpers/NetworkHelpers.cs \
@@ -44,6 +44,7 @@ EXTRA_DISTFILES = \
Test/dtest-app.cs \
Test/dtest.cs \
Test/dtest-excfilter.il \
Test/sourcelink.json \
$(TEST_HELPERS_SOURCES)
CLEAN_FILES = $(addprefix $(test_output_dir)/, dtest-app.exe dtest-app.exe.mdb dtest-app.pdb dtest-excfilter.exe dtest-excfilter.exe.mdb dtest-excfilter.pdb)

View File

@@ -74,4 +74,5 @@ Mono.Debugger.Soft/ITargetProcess.cs
Mono.Debugger.Soft/AbsentInformationException.cs
Mono.Debugger.Soft/UserBreakEvent.cs
Mono.Debugger.Soft/UserLogEvent.cs
Mono.Debugger.Soft/CrashEvent.cs
Mono.Debugger.Soft/ILInterpreter.cs

View File

@@ -1,10 +1,13 @@
using System;
using System.Reflection;
using Mono.Debugger;
using Mono.Cecil;
using System.Collections.Generic;
using System.IO;
#if ENABLE_CECIL
using Mono.Cecil;
#endif
namespace Mono.Debugger.Soft
{
public class AssemblyMirror : Mirror
@@ -14,7 +17,6 @@ namespace Mono.Debugger.Soft
bool entry_point_set;
ModuleMirror main_module;
AssemblyName aname;
AssemblyDefinition meta;
AppDomainMirror domain;
byte[] metadata_blob;
bool? isDynamic;
@@ -24,6 +26,10 @@ namespace Mono.Debugger.Soft
Dictionary<uint, long> tokenTypeCache = new Dictionary<uint, long> ();
Dictionary<uint, long> tokenMethodCache = new Dictionary<uint, long> ();
#if ENABLE_CECIL
AssemblyDefinition meta;
#endif
internal AssemblyMirror (VirtualMachine vm, long id) : base (vm, id) {
}
@@ -118,6 +124,7 @@ namespace Mono.Debugger.Soft
return GetType (name, false, false);
}
#if ENABLE_CECIL
/*
* An optional Cecil assembly which could be used to access metadata instead
* of reading it from the debuggee.
@@ -146,6 +153,7 @@ namespace Mono.Debugger.Soft
using (var ms = new MemoryStream (GetMetadataBlob ()))
return meta = AssemblyDefinition.ReadAssembly (ms);
}
#endif
public byte[] GetMetadataBlob () {
if (metadata_blob != null)

View File

@@ -6,7 +6,6 @@ using System.Threading;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Mono.Cecil.Metadata;
namespace Mono.Debugger.Soft
{
@@ -219,7 +218,7 @@ namespace Mono.Debugger.Soft
}
class ModuleInfo {
public string Name, ScopeName, FQName, Guid;
public string Name, ScopeName, FQName, Guid, SourceLink;
public long Assembly;
}
@@ -367,6 +366,14 @@ namespace Mono.Debugger.Soft
get; set;
}
public string Dump {
get; set;
}
public ulong Hash {
get; set;
}
public EventInfo (EventType type, int req_id) {
EventType = type;
ReqId = req_id;
@@ -420,7 +427,7 @@ namespace Mono.Debugger.Soft
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
internal const int MINOR_VERSION = 48;
internal const int MINOR_VERSION = 50;
enum WPSuspendPolicy {
NONE = 0,
@@ -463,7 +470,8 @@ namespace Mono.Debugger.Soft
EXCEPTION = 13,
KEEPALIVE = 14,
USER_BREAK = 15,
USER_LOG = 16
USER_LOG = 16,
CRASH = 17
}
enum ModifierKind {
@@ -508,7 +516,8 @@ namespace Mono.Debugger.Soft
GET_ID = 5,
/* Ditto */
GET_TID = 6,
SET_IP = 7
SET_IP = 7,
GET_ELAPSED_TIME = 8
}
enum CmdEventRequest {
@@ -1272,6 +1281,7 @@ namespace Mono.Debugger.Soft
}
bool disconnected;
VMCrashException crashed;
internal ManualResetEvent DisconnectedEvent = new ManualResetEvent (false);
@@ -1279,10 +1289,14 @@ namespace Mono.Debugger.Soft
while (!closed) {
try {
bool res = ReceivePacket ();
if (!res)
if (!res) {
break;
}
} catch (ThreadAbortException) {
break;
} catch (VMCrashException ex) {
crashed = ex;
break;
} catch (Exception ex) {
if (!closed) {
Console.WriteLine (ex);
@@ -1300,6 +1314,15 @@ namespace Mono.Debugger.Soft
EventHandler.VMDisconnect (0, 0, null);
}
void disconnected_check () {
if (!disconnected)
return;
else if (crashed != null)
throw crashed;
else
throw new VMDisconnectedException ();
}
bool ReceivePacket () {
byte[] packet = ReadPacket ();
@@ -1354,6 +1377,11 @@ namespace Mono.Debugger.Soft
exit_code = r.ReadInt ();
//EventHandler.VMDeath (req_id, 0, null);
events [i] = new EventInfo (etype, req_id) { ExitCode = exit_code };
} else if (kind == EventKind.CRASH) {
ulong hash = (ulong) r.ReadLong ();
string dump = r.ReadString ();
events [i] = new EventInfo (etype, req_id) { Dump = dump, Hash = hash};
} else if (kind == EventKind.THREAD_START) {
events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = thread_id };
//EventHandler.ThreadStart (req_id, thread_id, thread_id);
@@ -1571,8 +1599,7 @@ namespace Mono.Debugger.Soft
int id = IdGenerator;
Stopwatch watch = null;
if (disconnected)
throw new VMDisconnectedException ();
disconnected_check ();
if (EnableConnectionLogging)
watch = Stopwatch.StartNew ();
@@ -1606,8 +1633,7 @@ namespace Mono.Debugger.Soft
return r;
}
} else {
if (disconnected)
throw new VMDisconnectedException ();
disconnected_check ();
Monitor.Wait (reply_packets_monitor);
}
}
@@ -1640,7 +1666,15 @@ namespace Mono.Debugger.Soft
CattrNamedArgInfo arg = new CattrNamedArgInfo ();
int arg_type = r.ReadByte ();
arg.is_property = arg_type == 0x54;
arg.id = r.ReadId ();
// 2.12 is the only version we can guarantee the server will send a field id
// It was added in https://github.com/mono/mono/commit/db0b932cd6c3c93976479ae3f6b5b2a885f681de
// In between 2.11 and 2.12
if (arg.is_property)
arg.id = r.ReadId ();
else if (Version.AtLeast (2, 12))
arg.id = r.ReadId ();
arg.value = r.ReadValue ();
info.named_args [j] = arg;
}
@@ -2084,6 +2118,10 @@ namespace Mono.Debugger.Soft
return SendReceive (CommandSet.THREAD, (int)CmdThread.GET_NAME, new PacketWriter ().WriteId (id)).ReadString ();
}
internal long Thread_GetElapsedTime (long id) {
return SendReceive (CommandSet.THREAD, (int)CmdThread.GET_ELAPSED_TIME, new PacketWriter ().WriteId (id)).ReadLong ();
}
internal void Thread_GetFrameInfo (long id, int start_frame, int length, Action<FrameInfo[]> resultCallaback) {
Send (CommandSet.THREAD, (int)CmdThread.GET_FRAME_INFO, new PacketWriter ().WriteId (id).WriteInt (start_frame).WriteInt (length), (res) => {
int count = res.ReadInt ();
@@ -2131,6 +2169,8 @@ namespace Mono.Debugger.Soft
internal ModuleInfo Module_GetInfo (long id) {
PacketReader r = SendReceive (CommandSet.MODULE, (int)CmdModule.GET_INFO, new PacketWriter ().WriteId (id));
ModuleInfo info = new ModuleInfo { Name = r.ReadString (), ScopeName = r.ReadString (), FQName = r.ReadString (), Guid = r.ReadString (), Assembly = r.ReadId () };
if (Version.AtLeast (2, 48))
info.SourceLink = r.ReadString ();
return info;
}

View File

@@ -0,0 +1,25 @@
namespace Mono.Debugger.Soft
{
public class CrashEvent : Event {
ulong hash;
string dump;
internal CrashEvent (VirtualMachine vm, int req_id, long thread_id, string dump, ulong hash) : base (EventType.Crash, vm, req_id, thread_id) {
this.dump = dump;
this.hash = hash;
}
public ulong Hash {
get {
return hash;
}
}
public string Dump {
get {
return dump;
}
}
}
}

View File

@@ -4,7 +4,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Text;
using Mono.Cecil.Metadata;
namespace Mono.Debugger.Soft {
@@ -112,32 +111,34 @@ namespace Mono.Debugger.Soft {
var ctor_args = new object [attr.ctor_args.Length];
for (int j = 0; j < ctor_args.Length; ++j)
ctor_args [j] = CreateArg (vm, attr.ctor_args [j]);
var named_args = new object [attr.named_args.Length];
for (int j = 0; j < named_args.Length; ++j) {
var named_args = new List<object> (attr.named_args.Length);
for (int j = 0; j < attr.named_args.Length; ++j) {
CattrNamedArgInfo arg = attr.named_args [j];
CustomAttributeTypedArgumentMirror val;
CustomAttributeNamedArgumentMirror? named_arg = null;
val = CreateArg (vm, arg.value);
TypeMirror t = ctor.DeclaringType;
while (named_args [j] == null && t != null) {
while (named_arg == null && t != null) {
if (arg.is_property) {
foreach (var prop in t.GetProperties ()) {
if (prop.Id == arg.id)
named_args [j] = new CustomAttributeNamedArgumentMirror (prop, null, val);
named_arg = new CustomAttributeNamedArgumentMirror (prop, null, val);
}
} else {
} else if (vm.Version.AtLeast (2, 12)) { // we don't have the field ID before 2.12
foreach (var field in t.GetFields ()) {
if (field.Id == arg.id)
named_args [j] = new CustomAttributeNamedArgumentMirror (null, field, val);
named_arg = new CustomAttributeNamedArgumentMirror (null, field, val);
}
}
t = t.BaseType;
}
if (named_args [j] == null)
throw new NotImplementedException ();
if (named_arg.HasValue)
named_args.Add (named_arg.Value);
}
res [i] = new CustomAttributeDataMirror (ctor, ctor_args, named_args);
res [i] = new CustomAttributeDataMirror (ctor, ctor_args, named_args.ToArray ());
}
return res;

View File

@@ -26,6 +26,8 @@ namespace Mono.Debugger.Soft
// System.Diagnostics.Debugger.Log ()
//
UserLog = 16,
// Fatal error handling
Crash = 17,
// Not part of the wire protocol
VMDisconnect = 99
}

View File

@@ -2,8 +2,10 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
#if ENABLE_CECIL
using C = Mono.Cecil;
using Mono.Cecil.Metadata;
#endif
namespace Mono.Debugger.Soft
{
@@ -14,9 +16,12 @@ namespace Mono.Debugger.Soft
TypeMirror type;
FieldAttributes attrs;
CustomAttributeDataMirror[] cattrs;
C.FieldDefinition meta;
bool inited;
#if ENABLE_CECIL
C.FieldDefinition meta;
#endif
public FieldInfoMirror (TypeMirror parent, long id, string name, TypeMirror type, FieldAttributes attrs) : base (parent.VirtualMachine, id) {
this.parent = parent;
this.name = name;
@@ -167,6 +172,7 @@ namespace Mono.Debugger.Soft
return GetCAttrs (attributeType, inherit);
}
#if ENABLE_CECIL
public C.FieldDefinition Metadata {
get {
if (parent.Metadata == null)
@@ -184,10 +190,14 @@ namespace Mono.Debugger.Soft
return meta;
}
}
#endif
CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
#if ENABLE_CECIL
if (cattrs == null && Metadata != null && !Metadata.HasCustomAttributes)
cattrs = new CustomAttributeDataMirror [0];
#endif
// FIXME: Handle inherit
if (cattrs == null) {

View File

@@ -1,11 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using Mono.Cecil.Cil;
using Mono.Cecil.Metadata;
using System.IO;
using System.Reflection;
#if ENABLE_CECIL
using Mono.Cecil.Cil;
#else
using System.Reflection.Emit;
#endif
namespace Mono.Debugger.Soft
{
/*

View File

@@ -1,6 +1,10 @@
using System;
#if ENABLE_CECIL
using Mono.Cecil.Cil;
using Mono.Cecil.Metadata;
#else
using System.Reflection.Emit;
#endif
namespace Mono.Debugger.Soft
{

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using C = Mono.Cecil;
using Mono.Cecil.Metadata;
namespace Mono.Debugger.Soft
{

View File

@@ -2,12 +2,16 @@ using System;
using System.Globalization;
using System.Collections.Generic;
using System.Text;
using Mono.Cecil.Cil;
using Mono.Cecil.Metadata;
using System.IO;
using System.Linq;
using System.Reflection;
#if ENABLE_CECIL
using Mono.Cecil.Cil;
#else
using System.Reflection.Emit;
#endif
namespace Mono.Debugger.Soft
{
public class MethodBodyMirror : Mirror
@@ -84,11 +88,21 @@ namespace Mono.Debugger.Soft
if (!opcodes_inited) {
foreach (FieldInfo fi in typeof (OpCodes).GetFields (BindingFlags.Static|BindingFlags.Public)) {
var val = (OpCode)fi.GetValue (null);
bool isOneByteOpCode;
uint index;
if (val.Op1 == 0xff)
OneByteOpCode [val.Op2] = val;
#if ENABLE_CECIL
isOneByteOpCode = val.Op1 == 0xff;
index = val.Op2;
#else
uint value = (uint)val.Value;
isOneByteOpCode = value <= 0xff;
index = isOneByteOpCode ? value : value & 0xff;
#endif
if (isOneByteOpCode)
OneByteOpCode [index] = val;
else
TwoBytesOpCode [val.Op2] = val;
TwoBytesOpCode [index] = val;
}
opcodes_inited = true;
}
@@ -139,9 +153,11 @@ namespace Mono.Debugger.Soft
case OperandType.ShortInlineVar :
instr.Operand = br.ReadByte ();
break;
#if ENABLE_CECIL
case OperandType.ShortInlineArg :
instr.Operand = br.ReadByte ();
break;
#endif
case OperandType.InlineSig :
br.ReadInt32 ();
//instr.Operand = GetCallSiteAt (br.ReadInt32 (), context);
@@ -152,9 +168,11 @@ namespace Mono.Debugger.Soft
case OperandType.InlineVar :
instr.Operand = br.ReadInt16 ();
break;
#if ENABLE_CECIL
case OperandType.InlineArg :
instr.Operand = br.ReadInt16 ();
break;
#endif
case OperandType.InlineI8 :
instr.Operand = br.ReadInt64 ();
break;

View File

@@ -3,8 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
#if ENABLE_CECIL
using C = Mono.Cecil;
using Mono.Cecil.Metadata;
#endif
namespace Mono.Debugger.Soft
{
@@ -14,7 +16,6 @@ namespace Mono.Debugger.Soft
MethodInfo info;
TypeMirror declaring_type;
DebugInfo debug_info;
C.MethodDefinition meta;
CustomAttributeDataMirror[] cattrs;
ParameterInfoMirror[] param_info;
ParameterInfoMirror ret_param;
@@ -25,6 +26,10 @@ namespace Mono.Debugger.Soft
MethodMirror gmd;
TypeMirror[] type_args;
#if ENABLE_CECIL
C.MethodDefinition meta;
#endif
internal MethodMirror (VirtualMachine vm, long id) : base (vm, id) {
}
@@ -93,8 +98,10 @@ namespace Mono.Debugger.Soft
}
CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
#if ENABLE_CECIL
if (cattrs == null && meta != null && !Metadata.HasCustomAttributes)
cattrs = new CustomAttributeDataMirror [0];
#endif
// FIXME: Handle inherit
if (cattrs == null) {
@@ -417,6 +424,7 @@ namespace Mono.Debugger.Soft
return null;
}
#if ENABLE_CECIL
public C.MethodDefinition Metadata {
get {
if (meta == null)
@@ -424,6 +432,7 @@ namespace Mono.Debugger.Soft
return meta;
}
}
#endif
//
// Evaluate the method on the client using an IL interpreter.

View File

@@ -1,6 +1,5 @@
using System;
using Mono.Debugger;
using Mono.Cecil;
namespace Mono.Debugger.Soft
{
@@ -62,5 +61,14 @@ namespace Mono.Debugger.Soft
}
// FIXME: Add function to query the guid, check in Metadata
// Since protocol version 2.48
public string SourceLink {
get {
vm.CheckProtocolVersion (2, 48);
ReadInfo ();
return info.SourceLink;
}
}
}
}

View File

@@ -22,7 +22,17 @@ namespace Mono.Debugger.Soft
public Value[] OutArgs { get; set; }
}
public class ObjectMirror : Value {
public interface IInvokable {
Value InvokeMethod (ThreadMirror thread, MethodMirror method, IList<Value> arguments);
Value InvokeMethod (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options);
IAsyncResult BeginInvokeMethod (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options, AsyncCallback callback, object state);
Value EndInvokeMethod (IAsyncResult asyncResult);
InvokeResult EndInvokeMethodWithResult (IAsyncResult asyncResult);
Task<Value> InvokeMethodAsync (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None);
Task<InvokeResult> InvokeMethodAsyncWithResult (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None);
}
public class ObjectMirror : Value, IInvokable {
TypeMirror type;
AppDomainMirror domain;
@@ -164,36 +174,37 @@ namespace Mono.Debugger.Soft
}
public InvokeResult EndInvokeMethodWithResult (IAsyncResult asyncResult) {
return ObjectMirror.EndInvokeMethodInternalWithResult (asyncResult);
return ObjectMirror.EndInvokeMethodInternalWithResult (asyncResult);
}
public Task<Value> InvokeMethodAsync (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None) {
var tcs = new TaskCompletionSource<Value> ();
BeginInvokeMethod (thread, method, arguments, options, iar =>
{
try {
tcs.SetResult (EndInvokeMethod (iar));
} catch (OperationCanceledException) {
tcs.TrySetCanceled ();
} catch (Exception ex) {
tcs.TrySetException (ex);
}
}, null);
return tcs.Task;
return InvokeMethodAsync (vm, thread, method, this, arguments, options);
}
internal static Task<Value> InvokeMethodAsync (VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList<Value> arguments, InvokeOptions options) {
return InvokeMethodAsync (vm, thread, method, this_obj, arguments, options, EndInvokeMethodInternal);
}
public Task<InvokeResult> InvokeMethodAsyncWithResult (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None) {
var tcs = new TaskCompletionSource<InvokeResult> ();
BeginInvokeMethod (thread, method, arguments, options, iar =>
{
try {
tcs.SetResult (EndInvokeMethodInternalWithResult (iar));
} catch (OperationCanceledException) {
tcs.TrySetCanceled ();
} catch (Exception ex) {
tcs.TrySetException (ex);
}
}, null);
return InvokeMethodAsyncWithResult (vm, thread, method, this, arguments, options);
}
internal static Task<InvokeResult> InvokeMethodAsyncWithResult (VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList<Value> arguments, InvokeOptions options) {
return InvokeMethodAsync (vm, thread, method, this_obj, arguments, options, EndInvokeMethodInternalWithResult);
}
internal static Task<TResult> InvokeMethodAsync<TResult> (VirtualMachine vm, ThreadMirror thread, MethodMirror method, Value this_obj, IList<Value> arguments, InvokeOptions options, Func<IAsyncResult, TResult> callback) {
var tcs = new TaskCompletionSource<TResult> ();
BeginInvokeMethod (vm, thread, method, this_obj, arguments, options, iar =>
{
try {
tcs.SetResult (callback (iar));
} catch (OperationCanceledException) {
tcs.TrySetCanceled ();
} catch (Exception ex) {
tcs.TrySetException (ex);
}
}, null);
return tcs.Task;
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Mono.Debugger.Soft
{
@@ -57,7 +58,15 @@ namespace Mono.Debugger.Soft
}
public InvokeResult EndInvokeMethodWithResult (IAsyncResult asyncResult) {
return ObjectMirror.EndInvokeMethodInternalWithResult (asyncResult);
return ObjectMirror.EndInvokeMethodInternalWithResult (asyncResult);
}
public Task<Value> InvokeMethodAsync (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None) {
return ObjectMirror.InvokeMethodAsync (vm, thread, method, this, arguments, options);
}
public Task<InvokeResult> InvokeMethodAsyncWithResult (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None) {
return ObjectMirror.InvokeMethodAsyncWithResult (vm, thread, method, this, arguments, options);
}
}
}

View File

@@ -2,8 +2,10 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
#if ENABLE_CECIL
using C = Mono.Cecil;
using Mono.Cecil.Metadata;
#endif
namespace Mono.Debugger.Soft
{
@@ -14,7 +16,10 @@ namespace Mono.Debugger.Soft
PropertyAttributes attrs;
MethodMirror get_method, set_method;
CustomAttributeDataMirror[] cattrs;
#if ENABLE_CECIL
C.PropertyDefinition meta;
#endif
public PropertyInfoMirror (TypeMirror parent, long id, string name, MethodMirror get_method, MethodMirror set_method, PropertyAttributes attrs) : base (parent.VirtualMachine, id) {
this.parent = parent;
@@ -91,6 +96,7 @@ namespace Mono.Debugger.Soft
return new ParameterInfoMirror [0];
}
#if ENABLE_CECIL
public C.PropertyDefinition Metadata {
get {
if (parent.Metadata == null)
@@ -108,6 +114,7 @@ namespace Mono.Debugger.Soft
return meta;
}
}
#endif
public CustomAttributeDataMirror[] GetCustomAttributes (bool inherit) {
return GetCAttrs (null, inherit);
@@ -120,8 +127,11 @@ namespace Mono.Debugger.Soft
}
CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
#if ENABLE_CECIL
if (cattrs == null && Metadata != null && !Metadata.HasCustomAttributes)
cattrs = new CustomAttributeDataMirror [0];
#endif
// FIXME: Handle inherit
if (cattrs == null) {

View File

@@ -7,7 +7,7 @@ namespace Mono.Debugger.Soft
/*
* Represents a valuetype value in the debuggee
*/
public class StructMirror : Value {
public class StructMirror : Value, IInvokable {
TypeMirror type;
Value[] fields;
@@ -84,11 +84,7 @@ namespace Mono.Debugger.Soft
}
public Value EndInvokeMethod (IAsyncResult asyncResult) {
var result = ObjectMirror.EndInvokeMethodInternalWithResult (asyncResult);
var outThis = result.OutThis as StructMirror;
if (outThis != null) {
SetFields (outThis.Fields);
}
var result = EndInvokeMethodWithResult (asyncResult);
return result.Result;
}
@@ -102,33 +98,11 @@ namespace Mono.Debugger.Soft
}
public Task<Value> InvokeMethodAsync (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None) {
var tcs = new TaskCompletionSource<Value> ();
BeginInvokeMethod (thread, method, arguments, options, iar =>
{
try {
tcs.SetResult (EndInvokeMethod (iar));
} catch (OperationCanceledException) {
tcs.TrySetCanceled ();
} catch (Exception ex) {
tcs.TrySetException (ex);
}
}, null);
return tcs.Task;
return ObjectMirror.InvokeMethodAsync (vm, thread, method, this, arguments, options, EndInvokeMethod);
}
public Task<InvokeResult> InvokeMethodAsyncWithResult (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None) {
var tcs = new TaskCompletionSource<InvokeResult> ();
BeginInvokeMethod (thread, method, arguments, options, iar =>
{
try {
tcs.SetResult (ObjectMirror.EndInvokeMethodInternalWithResult (iar));
} catch (OperationCanceledException) {
tcs.TrySetCanceled ();
} catch (Exception ex) {
tcs.TrySetException (ex);
}
}, null);
return tcs.Task;
return ObjectMirror.InvokeMethodAsync (vm, thread, method, this, arguments, options, EndInvokeMethodWithResult);
}
}
}

View File

@@ -30,11 +30,21 @@ namespace Mono.Debugger.Soft
return frames;
}
public long ElapsedTime () {
vm.CheckProtocolVersion (2, 50);
long elapsedTime = GetElapsedTime ();
return elapsedTime;
}
internal void InvalidateFrames () {
cacheInvalid = true;
threadStateInvalid = true;
}
internal long GetElapsedTime () {
return vm.conn.Thread_GetElapsedTime (id);
}
internal void FetchFrames (bool mustFetch = false) {
lock (fetchingLocker) {
if (fetching || !cacheInvalid)

View File

@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using C = Mono.Cecil;
using Mono.Cecil.Metadata;
using System.Threading.Tasks;
#if ENABLE_CECIL
using C = Mono.Cecil;
#endif
namespace Mono.Debugger.Soft
{
/*
@@ -12,12 +14,11 @@ namespace Mono.Debugger.Soft
* It might be better to make this a subclass of Type, but that could be
* difficult as some of our methods like GetMethods () return Mirror objects.
*/
public class TypeMirror : Mirror
public class TypeMirror : Mirror, IInvokable
{
MethodMirror[] methods;
AssemblyMirror ass;
ModuleMirror module;
C.TypeDefinition meta;
FieldInfoMirror[] fields;
PropertyInfoMirror[] properties;
TypeInfo info;
@@ -30,6 +31,10 @@ namespace Mono.Debugger.Soft
bool cached_base_type;
bool inited;
#if ENABLE_CECIL
C.TypeDefinition meta;
#endif
internal const BindingFlags DefaultBindingFlags =
BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
@@ -613,6 +618,7 @@ namespace Mono.Debugger.Soft
return res;
}
#if ENABLE_CECIL
public C.TypeDefinition Metadata {
get {
if (meta == null) {
@@ -623,6 +629,7 @@ namespace Mono.Debugger.Soft
return meta;
}
}
#endif
TypeInfo GetInfo () {
if (info == null)
@@ -705,8 +712,10 @@ namespace Mono.Debugger.Soft
void AppendCustomAttrs (IList<CustomAttributeDataMirror> attrs, TypeMirror type, bool inherit)
{
#if ENABLE_CECIL
if (cattrs == null && Metadata != null && !Metadata.HasCustomAttributes)
cattrs = new CustomAttributeDataMirror [0];
#endif
if (cattrs == null) {
CattrInfo[] info = vm.conn.Type_GetCustomAttributes (id, 0, false);
@@ -805,22 +814,15 @@ namespace Mono.Debugger.Soft
}
public InvokeResult EndInvokeMethodWithResult (IAsyncResult asyncResult) {
return ObjectMirror.EndInvokeMethodInternalWithResult (asyncResult);
return ObjectMirror.EndInvokeMethodInternalWithResult (asyncResult);
}
public Task<Value> InvokeMethodAsync (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None) {
var tcs = new TaskCompletionSource<Value> ();
BeginInvokeMethod (thread, method, arguments, options, iar =>
{
try {
tcs.SetResult (EndInvokeMethod (iar));
} catch (OperationCanceledException) {
tcs.TrySetCanceled ();
} catch (Exception ex) {
tcs.TrySetException (ex);
}
}, null);
return tcs.Task;
return ObjectMirror.InvokeMethodAsync (vm, thread, method, null, arguments, options);
}
public Task<InvokeResult> InvokeMethodAsyncWithResult (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options = InvokeOptions.None) {
return ObjectMirror.InvokeMethodAsyncWithResult (vm, thread, method, null, arguments, options);
}
public Value NewInstance (ThreadMirror thread, MethodMirror method, IList<Value> arguments) {

Some files were not shown because too many files have changed in this diff Show More