Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invocations refactoring #85

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
90a1f51
Special evaluator exception type (EvaluatorExceptionThrownException) …
nerzhulart Aug 13, 2015
b72dfaf
EvaluatorExceptionThrownException handling in ValueReference. This al…
nerzhulart Dec 19, 2016
cac578c
Evaluation exception wrapping in CreateObjectValue.
nerzhulart May 13, 2016
54a8ed0
Separate lock object. Get rid of useful Monitor.Pulse()
nerzhulart Sep 13, 2016
f3e1fee
Async operations rewritten to Tasks
nerzhulart Nov 8, 2016
ad8187f
Proper logging: before the exception body was lost, now it's logged.
nerzhulart Nov 22, 2016
5be3b5b
Invocation is awaited infinitely as it was before.
nerzhulart Jan 17, 2017
1d4a9c4
Restore GetInfo() and detailed logging on invocation
nerzhulart Jan 17, 2017
d8ef7b8
More proper evaluation aborting.
nerzhulart Jan 23, 2017
3226be3
Get rid of OperationData
nerzhulart Jan 23, 2017
e9ee3d0
Move checking for cancelled token into try-catch to guarantee that Up…
nerzhulart Feb 1, 2017
5db72cd
CorDebug Invocations rewritten to .Net Task API (commit moved from …
nerzhulart Mar 16, 2017
0aec667
CorDebug Checking for aborted state in CorMethodCall
nerzhulart Mar 16, 2017
e1f7852
More proper evaluation aborting
nerzhulart Mar 16, 2017
ae0eb0f
Trying to continue all threads if eval Abort() and RudeAbort() failed…
nerzhulart Mar 16, 2017
29b6a90
Handle exceptions in AbortImpl() (Moved from MD repo)
nerzhulart Mar 16, 2017
c594ffc
Restore RemoteFrameObject for AsyncEvaluationTracker
nerzhulart Mar 17, 2017
45b3c96
Remove unused file IAsyncOperation.cs
nerzhulart Mar 17, 2017
3f9b165
Break loop if disposed.
nerzhulart Mar 17, 2017
c6f1148
Line endings fix
nerzhulart Mar 17, 2017
e2cf427
Don't call Abort() if operation is alredy in aborting state
nerzhulart Mar 17, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 92 additions & 96 deletions Mono.Debugging.Soft/SoftDebuggerAdaptor.cs
Original file line number Diff line number Diff line change
@@ -32,8 +32,7 @@
using System.Reflection.Emit;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;

using System.Threading.Tasks;
using Mono.Debugger.Soft;
using Mono.Debugging.Backend;
using Mono.Debugging.Evaluation;
@@ -2145,100 +2144,112 @@ static string MirrorStringToString (EvaluationContext ctx, StringMirror mirror)
}
}

class MethodCall: AsyncOperation
internal class SoftOperationResult : OperationResult<Value>
{
readonly InvokeOptions options = InvokeOptions.DisableBreakpoints | InvokeOptions.SingleThreaded;
public SoftOperationResult (Value result, bool resultIsException, Value[] outArgs) : base (result, resultIsException)
{
OutArgs = outArgs;
}

readonly ManualResetEvent shutdownEvent = new ManualResetEvent (false);
public Value[] OutArgs { get; private set; }
}

internal class SoftMethodCall: AsyncOperationBase<Value>
{
readonly InvokeOptions options = InvokeOptions.DisableBreakpoints | InvokeOptions.SingleThreaded;
readonly SoftEvaluationContext ctx;
readonly MethodMirror function;
readonly Value[] args;
readonly object obj;
IAsyncResult handle;
Exception exception;
IInvokeResult result;

public MethodCall (SoftEvaluationContext ctx, MethodMirror function, object obj, Value[] args, bool enableOutArgs)
readonly IInvocableMethodOwnerMirror obj;
IInvokeAsyncResult invokeAsyncResult;

public SoftMethodCall (SoftEvaluationContext ctx, MethodMirror function, IInvocableMethodOwnerMirror obj, Value[] args, bool enableOutArgs)
{
this.ctx = ctx;
this.function = function;
this.obj = obj;
this.args = args;
if (enableOutArgs) {
this.options |= InvokeOptions.ReturnOutArgs;
options |= InvokeOptions.ReturnOutArgs;
}
if (function.VirtualMachine.Version.AtLeast (2, 40)) {
this.options |= InvokeOptions.Virtual;
options |= InvokeOptions.Virtual;
}
}

public override string Description {
get {
return function.DeclaringType.FullName + "." + function.Name;
}
}

public override void Invoke ()
{
try {
var invocableMirror = obj as IInvocableMethodOwnerMirror;
if (invocableMirror != null) {
var optionsToInvoke = options;
if (obj is StructMirror) {
optionsToInvoke |= InvokeOptions.ReturnOutThis;
}
handle = invocableMirror.BeginInvokeMethod (ctx.Thread, function, args, optionsToInvoke, null, null);
get
{
try {
return function.DeclaringType.FullName + "." + function.Name;
}
catch (Exception e) {
DebuggerLoggingService.LogError ("Exception during getting description of method", e);
return "[Unknown method]";
}
else
throw new ArgumentException ("Soft debugger method calls cannot be invoked on objects of type " + obj.GetType ().Name);
} catch (InvocationException ex) {
ctx.Session.StackVersion++;
exception = ex;
} catch (Exception ex) {
ctx.Session.StackVersion++;
DebuggerLoggingService.LogError ("Error in soft debugger method call thread on " + GetInfo (), ex);
exception = ex;
}
}

public override void Abort ()
{
if (handle is IInvokeAsyncResult) {
var info = GetInfo ();
DebuggerLoggingService.LogMessage ("Aborting invocation of " + info);
((IInvokeAsyncResult) handle).Abort ();
// Don't wait for the abort to finish. The engine will do it.
} else {
throw new NotSupportedException ();
}
}

public override void Shutdown ()
{
shutdownEvent.Set ();
}

void EndInvoke ()
protected override Task<OperationResult<Value>> InvokeAsyncImpl ()
{
try {
result = ((IInvocableMethodOwnerMirror) obj).EndInvokeMethodWithResult (handle);
} catch (InvocationException ex) {
if (!Aborting && ex.Exception != null) {
string ename = ctx.Adapter.GetValueTypeName (ctx, ex.Exception);
var vref = ctx.Adapter.GetMember (ctx, null, ex.Exception, "Message");

exception = vref != null ? new Exception (ename + ": " + (string) vref.ObjectValue) : new Exception (ename);
return;
var optionsToInvoke = options;
if (obj is StructMirror) {
optionsToInvoke |= InvokeOptions.ReturnOutThis;
}
exception = ex;
} catch (Exception ex) {
DebuggerLoggingService.LogError ("Error in soft debugger method call thread on " + GetInfo (), ex);
exception = ex;
} finally {
ctx.Session.StackVersion++;
var tcs = new TaskCompletionSource<OperationResult<Value>> ();
invokeAsyncResult = (IInvokeAsyncResult)obj.BeginInvokeMethod (ctx.Thread, function, args, optionsToInvoke, ar => {
try {
if (Token.IsCancellationRequested) {
tcs.SetCanceled ();
return;
}
var endInvokeResult = obj.EndInvokeMethodWithResult (ar);
tcs.SetResult (new SoftOperationResult (endInvokeResult.Result, false, endInvokeResult.OutArgs));
}
catch (InvocationException ex) {
if (ex.Exception != null) {
tcs.SetResult (new SoftOperationResult (ex.Exception, true, null));
}
else {
tcs.SetException (new EvaluatorException ("Target method has thrown an exception but the exception object is inaccessible"));
}
}
catch (CommandException e) {
if (e.ErrorCode == ErrorCode.INVOKE_ABORTED) {
tcs.TrySetCanceled ();
}
else {
tcs.SetException (new EvaluatorException (e.Message));
}
}
catch (Exception e) {
if (e is ObjectCollectedException ||
e is InvalidStackFrameException ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this logic gone?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced simple Exception message to full exception object. So now you can walk through it, but before you can see only exception message

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is that object shown to the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an ObjectValue with its children that has IsException flag. It's shown in watchpad as ordinary object

e is VMNotSuspendedException ||
e is NotSupportedException ||
e is AbsentInformationException ||
e is ArgumentException) {
// user meaningfull evaluation exception -> wrap with EvaluatorException that will be properly shown in value viewer
tcs.SetException (new EvaluatorException (e.Message));
}
else {
DebuggerLoggingService.LogError (string.Format ("Unexpected exception has thrown when ending invocation of {0}", GetInfo ()), e);
tcs.SetException (e);
}
}
finally {
UpdateSessionState ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More logic that has been removed for no apparent good reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean logic of getting exception message so look at line 2230. SoftOperationResult wraps exception object to show it like ordinary object for user

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean GetInfo(), which is used to log the method and type name when there is an invocation error.

Copy link
Contributor Author

@nerzhulart nerzhulart Jan 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that GetInfo used only for logging. Isnt't it enough to use Description for this? Now I log all this states using this property

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is enough or not, it needs to be checked. I just don't want code to be removed if there isn't a good reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reasons to remove are simplifying and avoiding duplications.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's bring it back then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

}
}, null);
return tcs.Task;
} catch (Exception e) {
UpdateSessionState ();
DebuggerLoggingService.LogError (string.Format ("Unexpected exception has thrown when invoking {0}", GetInfo ()), e);
throw;
}
}

string GetInfo ()
{
try {
@@ -2250,41 +2261,26 @@ string GetInfo ()
else if (obj is StructMirror)
type = ((StructMirror)obj).Type;
return string.Format ("method {0} on object {1}",
function == null? "[null]" : function.FullName,
type == null? "[null]" : type.FullName);
function.FullName,
type == null? "[null]" : type.FullName);
} catch (Exception ex) {
DebuggerLoggingService.LogError ("Error getting info for SDB MethodCall", ex);
return "";
return "[Unknown method]";
}
}

public override bool WaitForCompleted (int timeout)
void UpdateSessionState ()
{
if (handle == null)
return true;
int res = WaitHandle.WaitAny (new WaitHandle[] { handle.AsyncWaitHandle, shutdownEvent }, timeout);
if (res == 0) {
EndInvoke ();
return true;
}
// Return true if shut down.
return res == 1;
}

public Value ReturnValue {
get {
if (exception != null)
throw new EvaluatorException (exception.Message);
return result.Result;
}
ctx.Session.StackVersion++;
}

public Value[] OutArgs {
get {
if (exception != null)
throw new EvaluatorException (exception.Message);
return result.OutArgs;
protected override void AbortImpl (int abortCallTimes)
{
if (invokeAsyncResult == null) {
DebuggerLoggingService.LogError ("invokeAsyncResult is null", new ArgumentNullException ("invokeAsyncResult"));
return;
}
invokeAsyncResult.Abort ();
}
}
}
15 changes: 9 additions & 6 deletions Mono.Debugging.Soft/SoftEvaluationContext.cs
Original file line number Diff line number Diff line change
@@ -190,16 +190,19 @@ Value RuntimeInvoke (MethodMirror method, object target, Value[] values, bool en
DC.DebuggerLoggingService.LogMessage ("Thread state before evaluation is {0}", threadState);
throw new EvaluatorException ("Evaluation is not allowed when the thread is in 'Wait' state");
}
var mc = new MethodCall (this, method, target, values, enableOutArgs);
var invocableMirror = target as IInvocableMethodOwnerMirror;
if (invocableMirror == null)
throw new ArgumentException ("Soft debugger method calls cannot be invoked on objects of type " + target.GetType ().Name);
var mc = new SoftMethodCall (this, method, invocableMirror, values, enableOutArgs);
//Since runtime is returning NOT_SUSPENDED error if two methods invokes are executed
//at same time we have to lock invoking to prevent this...
lock (method.VirtualMachine) {
Adapter.AsyncExecute (mc, Options.EvaluationTimeout);
}
if (enableOutArgs) {
outArgs = mc.OutArgs;
var result = (SoftOperationResult)Adapter.InvokeSync (mc, Options.EvaluationTimeout).ThrowIfException (this);
if (enableOutArgs) {
outArgs = result.OutArgs;
}
return result.Result;
}
return mc.ReturnValue;
}
}

83 changes: 19 additions & 64 deletions Mono.Debugging.Win32/CorDebuggerSession.cs
Original file line number Diff line number Diff line change
@@ -111,6 +111,13 @@ public static int EvaluationTimestamp {
get { return evaluationTimestamp; }
}

internal CorProcess Process
{
get
{
return process;
}
}

public override void Dispose ( )
{
@@ -1417,49 +1424,16 @@ public CorValue RuntimeInvoke (CorEvaluationContext ctx, CorFunction function, C
arguments.CopyTo (args, 1);
}

CorMethodCall mc = new CorMethodCall ();
CorValue exception = null;
CorEval eval = ctx.Eval;

DebugEventHandler<CorEvalEventArgs> completeHandler = delegate (object o, CorEvalEventArgs eargs) {
OnEndEvaluating ();
mc.DoneEvent.Set ();
eargs.Continue = false;
};

DebugEventHandler<CorEvalEventArgs> exceptionHandler = delegate(object o, CorEvalEventArgs eargs) {
OnEndEvaluating ();
exception = eargs.Eval.Result;
mc.DoneEvent.Set ();
eargs.Continue = false;
};

process.OnEvalComplete += completeHandler;
process.OnEvalException += exceptionHandler;

mc.OnInvoke = delegate {
if (function.GetMethodInfo (this).Name == ".ctor")
eval.NewParameterizedObject (function, typeArgs, args);
else
eval.CallParameterizedFunction (function, typeArgs, args);
process.SetAllThreadsDebugState (CorDebugThreadState.THREAD_SUSPEND, ctx.Thread);
ClearEvalStatus ();
OnStartEvaluating ();
process.Continue (false);
};
mc.OnAbort = delegate {
eval.Abort ();
};
mc.OnGetDescription = delegate {
MethodInfo met = function.GetMethodInfo (ctx.Session);
if (met != null)
return met.DeclaringType.FullName + "." + met.Name;
else
return "<Unknown>";
};

var methodCall = new CorMethodCall (ctx, function, typeArgs, args);
try {
ObjectAdapter.AsyncExecute (mc, ctx.Options.EvaluationTimeout);
var result = ObjectAdapter.InvokeSync (methodCall, ctx.Options.EvaluationTimeout);
if (result.ResultIsException) {
var vref = new CorValRef (result.Result);
throw new EvaluatorExceptionThrownException (vref, ObjectAdapter.GetValueTypeName (ctx, vref));
}

WaitUntilStopped ();
return result.Result;
}
catch (COMException ex) {
// eval exception is a 'good' exception that should be shown in value box
@@ -1469,35 +1443,16 @@ public CorValue RuntimeInvoke (CorEvaluationContext ctx, CorFunction function, C
throw evalException;
throw;
}
finally {
process.OnEvalComplete -= completeHandler;
process.OnEvalException -= exceptionHandler;
}

WaitUntilStopped ();
if (exception != null) {
/* ValueReference<CorValue, CorType> msg = ctx.Adapter.GetMember (ctx, val, "Message");
if (msg != null) {
string s = msg.ObjectValue as string;
mc.ExceptionMessage = s;
}
else
mc.ExceptionMessage = "Evaluation failed.";*/
CorValRef vref = new CorValRef (exception);
throw new EvaluatorException ("Evaluation failed: " + ObjectAdapter.GetValueTypeName (ctx, vref));
}

return eval.Result;
}

void OnStartEvaluating ( )
internal void OnStartEvaluating ( )
{
lock (debugLock) {
evaluating = true;
}
}

void OnEndEvaluating ( )
internal void OnEndEvaluating ( )
{
lock (debugLock) {
evaluating = false;
@@ -1603,7 +1558,7 @@ public void WaitUntilStopped ()
}
}

void ClearEvalStatus ( )
internal void ClearEvalStatus ( )
{
foreach (CorProcess p in dbg.Processes) {
if (p.Id == processId) {
140 changes: 118 additions & 22 deletions Mono.Debugging.Win32/CorMethodCall.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,143 @@
using System.Threading;
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.Samples.Debugging.CorDebug;
using Microsoft.Samples.Debugging.CorDebug.NativeApi;
using Mono.Debugging.Client;
using Mono.Debugging.Evaluation;

namespace Mono.Debugging.Win32
{
class CorMethodCall: AsyncOperation
class CorMethodCall: AsyncOperationBase<CorValue>
{
public delegate void CallCallback ( );
public delegate string DescriptionCallback ( );
readonly CorEvaluationContext context;
readonly CorFunction function;
readonly CorType[] typeArgs;
readonly CorValue[] args;

public CallCallback OnInvoke;
public CallCallback OnAbort;
public DescriptionCallback OnGetDescription;
readonly CorEval eval;

public ManualResetEvent DoneEvent = new ManualResetEvent (false);

public override string Description
public CorMethodCall (CorEvaluationContext context, CorFunction function, CorType[] typeArgs, CorValue[] args)
{
get { return OnGetDescription (); }
this.context = context;
this.function = function;
this.typeArgs = typeArgs;
this.args = args;
eval = context.Eval;
}

public override void Invoke ( )
void ProcessOnEvalComplete (object sender, CorEvalEventArgs evalArgs)
{
OnInvoke ();
DoProcessEvalFinished (evalArgs, false);
}

public override void Abort ( )
void ProcessOnEvalException (object sender, CorEvalEventArgs evalArgs)
{
OnAbort ();
DoProcessEvalFinished (evalArgs, true);
}

public override void Shutdown ( )
void DoProcessEvalFinished (CorEvalEventArgs evalArgs, bool isException)
{
try {
Abort ();
if (evalArgs.Eval != eval)
return;
context.Session.OnEndEvaluating ();
evalArgs.Continue = false;
if (Token.IsCancellationRequested) {
DebuggerLoggingService.LogMessage ("EvalFinished() but evaluation was cancelled");
tcs.TrySetCanceled ();
}
catch {
else {
DebuggerLoggingService.LogMessage ("EvalFinished(). Setting the result");
tcs.TrySetResult(new OperationResult<CorValue> (evalArgs.Eval.Result, isException));
}
DoneEvent.Set ();
}

public override bool WaitForCompleted (int timeout)
void SubscribeOnEvals ()
{
context.Session.Process.OnEvalComplete += ProcessOnEvalComplete;
context.Session.Process.OnEvalException += ProcessOnEvalException;
}

void UnSubcribeOnEvals ()
{
return DoneEvent.WaitOne (timeout, false);
context.Session.Process.OnEvalComplete -= ProcessOnEvalComplete;
context.Session.Process.OnEvalException -= ProcessOnEvalException;
}

public override string Description
{
get
{
var met = function.GetMethodInfo (context.Session);
if (met == null)
return "[Unknown method]";
if (met.DeclaringType == null)
return met.Name;
return met.DeclaringType.FullName + "." + met.Name;
}
}

readonly TaskCompletionSource<OperationResult<CorValue>> tcs = new TaskCompletionSource<OperationResult<CorValue>> ();

protected override Task<OperationResult<CorValue>> InvokeAsyncImpl ()
{
SubscribeOnEvals ();

if (function.GetMethodInfo (context.Session).Name == ".ctor")
eval.NewParameterizedObject (function, typeArgs, args);
else
eval.CallParameterizedFunction (function, typeArgs, args);
context.Session.Process.SetAllThreadsDebugState (CorDebugThreadState.THREAD_SUSPEND, context.Thread);
context.Session.ClearEvalStatus ();
context.Session.OnStartEvaluating ();
context.Session.Process.Continue (false);
Task = tcs.Task;
// Don't pass token here, because it causes immediately task cancellation which must be performed by debugger event or real timeout
return Task.ContinueWith (task => {
UnSubcribeOnEvals ();
return task.Result;
});
}


protected override void AbortImpl (int abortCallTimes)
{
try {
if (abortCallTimes < 10) {
DebuggerLoggingService.LogMessage ("Calling Abort() for {0} time", abortCallTimes);
eval.Abort ();
}
else {
if (abortCallTimes == 20) {
// if Abort() and RudeAbort() didn't bring any result let's try to resume all the threads to free possible deadlocks in target process
// maybe this can help to abort hanging evaluations
DebuggerLoggingService.LogMessage ("RudeAbort() didn't stop eval after {0} times", abortCallTimes - 1);
DebuggerLoggingService.LogMessage ("Calling Stop()");
context.Session.Process.Stop (0);
DebuggerLoggingService.LogMessage ("Calling SetAllThreadsDebugState(THREAD_RUN)");
context.Session.Process.SetAllThreadsDebugState (CorDebugThreadState.THREAD_RUN, null);
DebuggerLoggingService.LogMessage ("Calling Continue()");
context.Session.Process.Continue (false);
}
DebuggerLoggingService.LogMessage ("Calling RudeAbort() for {0} time", abortCallTimes);
eval.RudeAbort();
}

} catch (COMException e) {
var hResult = e.ToHResult<HResult> ();
switch (hResult) {
case HResult.CORDBG_E_PROCESS_TERMINATED:
DebuggerLoggingService.LogMessage ("Process was terminated. Set cancelled for eval");
tcs.TrySetCanceled ();
return;
case HResult.CORDBG_E_OBJECT_NEUTERED:
DebuggerLoggingService.LogMessage ("Eval object was neutered. Set cancelled for eval");
tcs.TrySetCanceled ();
return;
}
tcs.SetException (e);
throw;
}
}
}
}
18 changes: 14 additions & 4 deletions Mono.Debugging/Mono.Debugging.Client/ObjectValue.cs
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
using System.Linq;

using Mono.Debugging.Backend;
using Mono.Debugging.Evaluation;

namespace Mono.Debugging.Client
{
@@ -151,8 +152,18 @@ public static ObjectValue CreateError (IObjectValueSource source, ObjectPath pat
val.value = value;
return val;
}

public static ObjectValue CreateImplicitNotSupported (IObjectValueSource source, ObjectPath path, string typeName, ObjectValueFlags flags)

public static ObjectValue CreateEvaluationException (EvaluationContext ctx, IObjectValueSource source, ObjectPath path, EvaluatorExceptionThrownException exception,
ObjectValueFlags flags = ObjectValueFlags.None)
{
var error = CreateError (source, path, exception.ExceptionTypeName, "Exception was thrown", flags);
var exceptionReference = LiteralValueReference.CreateTargetObjectLiteral (ctx, "Exception", exception.Exception);
var exceptionValue = exceptionReference.CreateObjectValue (ctx.Options);
error.children = new List<ObjectValue> {exceptionValue};
return error;
}

public static ObjectValue CreateImplicitNotSupported (IObjectValueSource source, ObjectPath path, string typeName, ObjectValueFlags flags)
{
var val = Create (source, path, typeName);
val.flags = flags | ObjectValueFlags.ImplicitNotSupported;
@@ -530,8 +541,7 @@ public ObjectValue[] GetAllChildren (EvaluationOptions options)
ConnectCallbacks (parentFrame, cs);
children.AddRange (cs);
} catch (Exception ex) {
if (parentFrame != null)
parentFrame.DebuggerSession.OnDebuggerOutput (true, ex.ToString ());
DebuggerLoggingService.LogError ("Exception in GetAllChildren()", ex);
children.Add (CreateFatalError ("", ex.Message, ObjectValueFlags.ReadOnly));
}
}
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ namespace Mono.Debugging.Evaluation
/// will then be made asynchronous and the Run method will immediately return an ObjectValue
/// with the Evaluating state.
/// </summary>
public class AsyncEvaluationTracker: RemoteFrameObject, IObjectValueUpdater, IDisposable
public class AsyncEvaluationTracker: IObjectValueUpdater, IDisposable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were no usages of AsyncEvaluationTracker by this interface.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you used by some dynamic way I can revert this change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important bit is that RemoteFrameObject is a MarshalByRefObject, and AsyncEvaluationTracker needs to be remotable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain how is this working? where to look at the remoting?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library is designed so that the debugging engine can run in a remote process, which communicates with the client using remoting. That's really up to the debugger engine implementation. In such scenario, the AsyncEvaluationTracker could be executing in the remote process and generating ObjectValue instances that are serialized into the client process and which may need to hold a reference to that remote object (

return ObjectValue.CreateEvaluating (this, new ObjectPath (id, name), flags);
). This model was necessary with the old Mono debugger, but it is not with the soft debugger. However, the infrastructure is still there, in case a specific debugger implementation needs it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore the RemoteFrameObject base class.

{
Dictionary<string, UpdateCallback> asyncCallbacks = new Dictionary<string, UpdateCallback> ();
Dictionary<string, ObjectValue> asyncResults = new Dictionary<string, ObjectValue> ();
94 changes: 94 additions & 0 deletions Mono.Debugging/Mono.Debugging.Evaluation/AsyncOperationBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Mono.Debugging.Client;

namespace Mono.Debugging.Evaluation
{
public class OperationResult<TValue>
{
public TValue Result { get; private set; }
public bool ResultIsException { get; private set; }

public OperationResult (TValue result, bool resultIsException)
{
Result = result;
ResultIsException = resultIsException;
}
}

public static class OperationResultEx
{
public static OperationResult<TValue> ThrowIfException<TValue> (this OperationResult<TValue> result, EvaluationContext ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just make it a member of OperationResult?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this approach makes the code more simple. OperationResult is just a data class without any internal logic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks unnecessary to me. In any case, up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case ThrowIfException is more helper method rather than required to be in the class. It's IMHO

{
if (!result.ResultIsException)
return result;
var exceptionTypeName = ctx.Adapter.GetValueTypeName (ctx, result.Result);
throw new EvaluatorExceptionThrownException (result.Result, exceptionTypeName);
}
}

public interface IAsyncOperationBase
{
Task RawTask { get; }
string Description { get; }
void Abort ();
}

public abstract class AsyncOperationBase<TValue> : IAsyncOperationBase
{
public Task<OperationResult<TValue>> Task { get; protected set; }

public Task RawTask
{
get
{
return Task;
}
}

public abstract string Description { get; }

int abortCalls = 0;

readonly CancellationTokenSource tokenSource = new CancellationTokenSource ();

/// <summary>
/// When evaluation is aborted and debugger callback is invoked the implementation has to check
/// for Token.IsCancellationRequested and call Task.SetCancelled() instead of setting the result
/// </summary>
protected CancellationToken Token { get { return tokenSource.Token; } }

public void Abort ()
{
try {
tokenSource.Cancel();
AbortImpl (Interlocked.Increment (ref abortCalls) - 1);
}
catch (OperationCanceledException) {
// if CancelImpl throw OCE we shouldn't mute it
throw;
}
catch (Exception e) {
DebuggerLoggingService.LogMessage ("Exception in CancelImpl(): {0}", e.Message);
}
}

public Task<OperationResult<TValue>> InvokeAsync ()
{
if (Task != null) throw new Exception("Task must be null");
Task = InvokeAsyncImpl ();
return Task;
}

protected abstract Task<OperationResult<TValue>> InvokeAsyncImpl ();

/// <summary>
/// The implementation has to tell the debugger to abort the evaluation. This method must bot block.
/// </summary>
/// <param name="abortCallTimes">indicates how many times this method has been already called for this evaluation.
/// E.g. the implementation can perform some 'rude abort' after several previous ordinary 'aborts' were failed. For the first call this parameter == 0</param>
protected abstract void AbortImpl (int abortCallTimes);

}
}
290 changes: 119 additions & 171 deletions Mono.Debugging/Mono.Debugging.Evaluation/AsyncOperationManager.cs
Original file line number Diff line number Diff line change
@@ -27,215 +27,163 @@

using System;
using System.Collections.Generic;
using ST = System.Threading;
using System.Linq;
using System.Threading.Tasks;
using Mono.Debugging.Client;

namespace Mono.Debugging.Evaluation
{
public class AsyncOperationManager: IDisposable
public class AsyncOperationManager : IDisposable
{
List<AsyncOperation> operationsToCancel = new List<AsyncOperation> ();
internal bool Disposing;
readonly HashSet<IAsyncOperationBase> currentOperations = new HashSet<IAsyncOperationBase> ();
bool disposed = false;
const int ShortCancelTimeout = 100;

public void Invoke (AsyncOperation methodCall, int timeout)
static bool IsOperationCancelledException (Exception e, int depth = 4)
{
methodCall.Aborted = false;
methodCall.Manager = this;
if (e is OperationCanceledException)
return true;
var aggregateException = e as AggregateException;

lock (operationsToCancel) {
operationsToCancel.Add (methodCall);
methodCall.Invoke ();
if (depth > 0 && aggregateException != null) {
foreach (var innerException in aggregateException.InnerExceptions) {
if (IsOperationCancelledException (innerException, depth - 1))
return true;
}
}
return false;
}

public OperationResult<TValue> Invoke<TValue> (AsyncOperationBase<TValue> mc, int timeout)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no Aborted property on AsyncOperation now, Cancellation is controlled by Task API

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

if (timeout <= 0)
throw new ArgumentOutOfRangeException("timeout", timeout, "timeout must be greater than 0");

Task<OperationResult<TValue>> task;
var description = mc.Description;
lock (currentOperations) {
if (disposed)
throw new ObjectDisposedException ("Already disposed");
DebuggerLoggingService.LogMessage (string.Format("Starting invoke for {0}", description));
task = mc.InvokeAsync ();
currentOperations.Add (mc);
}

if (timeout > 0) {
if (!methodCall.WaitForCompleted (timeout)) {
bool wasAborted = methodCall.Aborted;
methodCall.InternalAbort ();
lock (operationsToCancel) {
operationsToCancel.Remove (methodCall);
ST.Monitor.PulseAll (operationsToCancel);
bool cancelledAfterTimeout = false;
try {
if (task.Wait (timeout)) {
DebuggerLoggingService.LogMessage (string.Format ("Invoke {0} succeeded in {1} ms", description, timeout));
return task.Result;
}
DebuggerLoggingService.LogMessage (string.Format ("Invoke {0} timed out after {1} ms. Cancelling.", description, timeout));
mc.Abort ();
try {
WaitAfterCancel (mc);
}
catch (Exception e) {
if (IsOperationCancelledException (e)) {
DebuggerLoggingService.LogMessage (string.Format ("Invoke {0} was cancelled after timeout", description));
cancelledAfterTimeout = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the Shutdown logic is gone, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shutdown had nearly the same logic as the Cancel. I've unified them into Cancel.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly the same logic, but not the same. Let's say an invocation is made. While the caller is waiting for the invocation to end, the manager is disposed, so the call is canceled. But if the call can't really be cancelled, the caller will wait forever.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think so? After Dispose is called the Invoke method on another thread will throw EvaluationAbortedException

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the .Abort() call on the invocation fails, or can't be completed (it can happen, that's why there is all that abort retry and debugger busy mode infrastructure), then the invocation will never end, and EvaluationAbortedException will never be thrown.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. See below

}
if (wasAborted)
throw new EvaluatorAbortedException ();
else
throw new TimeOutException ();
throw;
}
DebuggerLoggingService.LogMessage (string.Format ("{0} cancelling timed out", description));
throw new TimeOutException ();
}
else {
methodCall.WaitForCompleted (System.Threading.Timeout.Infinite);
}

lock (operationsToCancel) {
operationsToCancel.Remove (methodCall);
ST.Monitor.PulseAll (operationsToCancel);
if (methodCall.Aborted) {
catch (Exception e) {
if (IsOperationCancelledException (e)) {
if (cancelledAfterTimeout)
throw new TimeOutException ();
DebuggerLoggingService.LogMessage (string.Format ("Invoke {0} was cancelled outside before timeout", description));
throw new EvaluatorAbortedException ();
}
throw;
}
finally {
lock (currentOperations) {
currentOperations.Remove (mc);
}
}
}


if (!string.IsNullOrEmpty (methodCall.ExceptionMessage)) {
throw new Exception (methodCall.ExceptionMessage);
public event EventHandler<BusyStateEventArgs> BusyStateChanged = delegate { };

void ChangeBusyState (bool busy, string description)
{
try {
BusyStateChanged (this, new BusyStateEventArgs {IsBusy = busy, Description = description});
}
catch (Exception e) {
DebuggerLoggingService.LogError ("Exception during ChangeBusyState", e);
}
}
public void Dispose ()

void WaitAfterCancel (IAsyncOperationBase op)
{
Disposing = true;
lock (operationsToCancel) {
foreach (AsyncOperation op in operationsToCancel) {
op.InternalShutdown ();
var desc = op.Description;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't take into account that the method may already be being aborted, like the old implementation did.

DebuggerLoggingService.LogMessage (string.Format ("Waiting for cancel of invoke {0}", desc));
if (!op.RawTask.Wait (ShortCancelTimeout)) {
try {
ChangeBusyState (true, desc);
while (true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop should gracefully exit if AsyncOperationManager is disposed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic for switching to busy state is now different. Please use old logic.

Copy link
Contributor Author

@nerzhulart nerzhulart Mar 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop should gracefully exit if AsyncOperationManager is disposed.

Done

Copy link
Contributor Author

@nerzhulart nerzhulart Mar 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic for switching to busy state is now different. Please use old logic.

Can you please explain more detailed?
For me the current logic is quite the same:

  1. StartInvoke
  2. Wait normally for given timeout
  3. If timed out -> Abort()
  4. Wait for Short timeout
  5. If timed out -> Enter busy
  6. Repeat from 4
  7. If awaited -> Exit busy

Seems something like that was before and implemented on magic counters. And the code was very confusing

op.Abort ();
if (op.RawTask.Wait (ShortCancelTimeout))
break;
}
}
finally {
ChangeBusyState (false, desc);
}
operationsToCancel.Clear ();
}
}

public void AbortAll ()
{
lock (operationsToCancel) {
foreach (AsyncOperation op in operationsToCancel)
op.InternalAbort ();
DebuggerLoggingService.LogMessage ("Aborting all the current invocations");
List<IAsyncOperationBase> copy;
lock (currentOperations) {
if (disposed) throw new ObjectDisposedException ("Already disposed");
copy = currentOperations.ToList ();
currentOperations.Clear ();
}

CancelOperations (copy, true);
}

public void EnterBusyState (AsyncOperation oper)
{
BusyStateEventArgs args = new BusyStateEventArgs ();
args.IsBusy = true;
args.Description = oper.Description;
if (BusyStateChanged != null)
BusyStateChanged (this, args);
}

public void LeaveBusyState (AsyncOperation oper)
{
BusyStateEventArgs args = new BusyStateEventArgs ();
args.IsBusy = false;
args.Description = oper.Description;
if (BusyStateChanged != null)
BusyStateChanged (this, args);
}

public event EventHandler<BusyStateEventArgs> BusyStateChanged;
}

public abstract class AsyncOperation
{
internal bool Aborted;
internal AsyncOperationManager Manager;

public bool Aborting { get; internal set; }

internal void InternalAbort ()
void CancelOperations (List<IAsyncOperationBase> operations, bool wait)
{
ST.Monitor.Enter (this);
if (Aborted) {
ST.Monitor.Exit (this);
return;
}

if (Aborting) {
// Somebody else is aborting this. Just wait for it to finish.
ST.Monitor.Exit (this);
WaitForCompleted (ST.Timeout.Infinite);
return;
}

Aborting = true;

int abortState = 0;
int abortRetryWait = 100;
bool abortRequested = false;

do {
if (abortState > 0)
ST.Monitor.Enter (this);

foreach (var operation in operations) {
var taskDescription = operation.Description;
try {
if (!Aborted && !abortRequested) {
// The Abort() call doesn't block. WaitForCompleted is used below to wait for the abort to succeed
Abort ();
abortRequested = true;
}
// Short wait for the Abort to finish. If this wait is not enough, it will wait again in the next loop
if (WaitForCompleted (100)) {
ST.Monitor.Exit (this);
break;
operation.Abort ();
if (wait) {
WaitAfterCancel (operation);
}
} catch {
// If abort fails, try again after a short wait
}
abortState++;
if (abortState == 6) {
// Several abort calls have failed. Inform the user that the debugger is busy
abortRetryWait = 500;
try {
Manager.EnterBusyState (this);
} catch (Exception ex) {
Console.WriteLine (ex);
catch (Exception e) {
if (IsOperationCancelledException (e)) {
DebuggerLoggingService.LogMessage (string.Format ("Invocation of {0} cancelled in CancelOperations()", taskDescription));
}
else {
DebuggerLoggingService.LogError (string.Format ("Invocation of {0} thrown an exception in CancelOperations()", taskDescription), e);
}
}
ST.Monitor.Exit (this);
} while (!Aborted && !WaitForCompleted (abortRetryWait) && !Manager.Disposing);

if (Manager.Disposing) {
InternalShutdown ();
}
else {
lock (this) {
Aborted = true;
if (abortState >= 6)
Manager.LeaveBusyState (this);
}
}
}

internal void InternalShutdown ()


public void Dispose ()
{
lock (this) {
if (Aborted)
return;
try {
Aborted = true;
Shutdown ();
} catch {
// Ignore
}
List<IAsyncOperationBase> copy;
lock (currentOperations) {
if (disposed) throw new ObjectDisposedException ("Already disposed");
disposed = true;
copy = currentOperations.ToList ();
currentOperations.Clear ();
}
// don't wait on dispose
CancelOperations (copy, wait: false);
}

/// <summary>
/// Message of the exception, if the execution failed.
/// </summary>
public string ExceptionMessage { get; set; }

/// <summary>
/// Returns a short description of the operation, to be shown in the Debugger Busy Dialog
/// when it blocks the execution of the debugger.
/// </summary>
public abstract string Description { get; }

/// <summary>
/// Called to invoke the operation. The execution must be asynchronous (it must return immediatelly).
/// </summary>
public abstract void Invoke ( );

/// <summary>
/// Called to abort the execution of the operation. It has to throw an exception
/// if the operation can't be aborted. This operation must not block. The engine
/// will wait for the operation to be aborted by calling WaitForCompleted.
/// </summary>
public abstract void Abort ();

/// <summary>
/// Waits until the operation has been completed or aborted.
/// </summary>
public abstract bool WaitForCompleted (int timeout);

/// <summary>
/// Called when the debugging session has been disposed.
/// I must cause any call to WaitForCompleted to exit, even if the operation
/// has not been completed or can't be aborted.
/// </summary>
public abstract void Shutdown ();
}
}
}
16 changes: 15 additions & 1 deletion Mono.Debugging/Mono.Debugging.Evaluation/ExpressionEvaluator.cs
Original file line number Diff line number Diff line change
@@ -199,14 +199,28 @@ public virtual ValueReference GetCurrentException (EvaluationContext ctx)
[Serializable]
public class EvaluatorException: Exception
{

protected EvaluatorException (SerializationInfo info, StreamingContext context)
: base (info, context)
{
}

public EvaluatorException (string msg, params object[] args): base (string.Format (msg, args))
public EvaluatorException (string msg, params object[] args): base (string.Format(msg, args))
{
}
}

[Serializable]
public class EvaluatorExceptionThrownException : EvaluatorException
{
public EvaluatorExceptionThrownException (object exception, string exceptionTypeName) : base ("Exception is thrown")
{
Exception = exception;
ExceptionTypeName = exceptionTypeName;
}

public object Exception { get; private set; }
public string ExceptionTypeName { get; private set; }
}

[Serializable]
22 changes: 22 additions & 0 deletions Mono.Debugging/Mono.Debugging.Evaluation/IAsyncOperation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Mono.Debugging.Evaluation
{
public interface IAsyncOperation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right! Thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still unused...

{
/// <summary>
/// Called to invoke the operation. The execution must be asynchronous (it must return immediatelly).
/// </summary>
void BeginInvoke ();

/// <summary>
/// Called to abort the execution of the operation. It has to throw an exception
/// if the operation can't be aborted. This operation must not block. The engine
/// will wait for the operation to be aborted by calling WaitForCompleted.
/// </summary>
void Abort ();

/// <summary>
/// Waits until the operation has been completed or aborted.
/// </summary>
bool WaitForCompleted (int timeout);
}
}
14 changes: 10 additions & 4 deletions Mono.Debugging/Mono.Debugging.Evaluation/ObjectValueAdaptor.cs
Original file line number Diff line number Diff line change
@@ -91,6 +91,8 @@ public ObjectValue CreateObjectValue (EvaluationContext ctx, IObjectValueSource
return CreateObjectValueImpl (ctx, source, path, obj, flags);
} catch (EvaluatorAbortedException ex) {
return ObjectValue.CreateFatalError (path.LastName, ex.Message, flags);
} catch (EvaluatorExceptionThrownException ex) {
return ObjectValue.CreateEvaluationException (ctx, source, path, ex);
} catch (EvaluatorException ex) {
return ObjectValue.CreateFatalError (path.LastName, ex.Message, flags);
} catch (Exception ex) {
@@ -588,7 +590,7 @@ public virtual ObjectValue[] GetObjectValueChildren (EvaluationContext ctx, IObj
values.Add (oval);
}
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
DebuggerLoggingService.LogError ("Exception in GetObjectValueChildren()", ex);
values.Add (ObjectValue.CreateError (null, new ObjectPath (val.Name), GetDisplayTypeName (GetTypeName (ctx, val.Type)), ex.Message, val.Flags));
}
}
@@ -1111,6 +1113,8 @@ public virtual object TargetObjectToObject (EvaluationContext ctx, object obj)
return new EvaluationResult ("{" + CallToString (ctx, obj) + "}");
} catch (TimeOutException) {
// ToString() timed out, fall back to default behavior.
} catch (EvaluatorExceptionThrownException e) {
// ToString() call thrown exception, fall back to default behavior.
}
}

@@ -1324,9 +1328,9 @@ public string EvaluateDisplayString (EvaluationContext ctx, object obj, string e
return display.ToString ();
}

public void AsyncExecute (AsyncOperation operation, int timeout)
public OperationResult<TValue> InvokeSync<TValue> (AsyncOperationBase<TValue> operation, int timeout)
{
asyncOperationManager.Invoke (operation, timeout);
return asyncOperationManager.Invoke (operation, timeout);
}

public ObjectValue CreateObjectValueAsync (string name, ObjectValueFlags flags, ObjectEvaluatorDelegate evaluator)
@@ -1355,10 +1359,12 @@ public ObjectValue GetExpressionValue (EvaluationContext ctx, string exp)
return ObjectValue.CreateImplicitNotSupported (ctx.ExpressionValueSource, new ObjectPath (exp), "", ObjectValueFlags.None);
} catch (NotSupportedExpressionException ex) {
return ObjectValue.CreateNotSupported (ctx.ExpressionValueSource, new ObjectPath (exp), "", ex.Message, ObjectValueFlags.None);
} catch (EvaluatorExceptionThrownException ex) {
return ObjectValue.CreateEvaluationException (ctx, ctx.ExpressionValueSource, new ObjectPath (exp), ex);
} catch (EvaluatorException ex) {
return ObjectValue.CreateError (ctx.ExpressionValueSource, new ObjectPath (exp), "", ex.Message, ObjectValueFlags.None);
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
DebuggerLoggingService.LogError ("Exception in GetExpressionValue()", ex);
return ObjectValue.CreateUnknown (exp);
}
}
7 changes: 5 additions & 2 deletions Mono.Debugging/Mono.Debugging.Evaluation/ValueReference.cs
Original file line number Diff line number Diff line change
@@ -106,10 +106,13 @@ public ObjectValue CreateObjectValue (EvaluationOptions options)
return DC.ObjectValue.CreateImplicitNotSupported (this, new ObjectPath (Name), Context.Adapter.GetDisplayTypeName (GetContext (options), Type), Flags);
} catch (NotSupportedExpressionException ex) {
return DC.ObjectValue.CreateNotSupported (this, new ObjectPath (Name), Context.Adapter.GetDisplayTypeName (GetContext (options), Type), ex.Message, Flags);
} catch (EvaluatorExceptionThrownException ex) {
return DC.ObjectValue.CreateEvaluationException (Context, Context.ExpressionValueSource, new ObjectPath (Name), ex);
} catch (EvaluatorException ex) {
return DC.ObjectValue.CreateError (this, new ObjectPath (Name), "", ex.Message, Flags);
} catch (Exception ex) {
Context.WriteDebuggerError (ex);
}
catch (Exception ex) {
DebuggerLoggingService.LogError ("Exception in CreateObjectValue()", ex);
return DC.ObjectValue.CreateUnknown (Name);
}
}
2 changes: 2 additions & 0 deletions Mono.Debugging/Mono.Debugging.csproj
Original file line number Diff line number Diff line change
@@ -82,10 +82,12 @@
<Compile Include="Mono.Debugging.Evaluation\ArrayElementGroup.cs" />
<Compile Include="Mono.Debugging.Evaluation\ArrayValueReference.cs" />
<Compile Include="Mono.Debugging.Evaluation\AsyncEvaluationTracker.cs" />
<Compile Include="Mono.Debugging.Evaluation\AsyncOperationBase.cs" />
<Compile Include="Mono.Debugging.Evaluation\AsyncOperationManager.cs" />
<Compile Include="Mono.Debugging.Evaluation\EvaluationContext.cs" />
<Compile Include="Mono.Debugging.Evaluation\ExpressionEvaluator.cs" />
<Compile Include="Mono.Debugging.Evaluation\FilteredMembersSource.cs" />
<Compile Include="Mono.Debugging.Evaluation\IAsyncOperation.cs" />
<Compile Include="Mono.Debugging.Evaluation\ICollectionAdaptor.cs" />
<Compile Include="Mono.Debugging.Evaluation\LiteralValueReference.cs" />
<Compile Include="Mono.Debugging.Evaluation\NamespaceValueReference.cs" />