Skip to content

Commit 5be3b5b

Browse files
committed
Invocation is awaited infinitely as it was before.
Better handling of exeptions in Soft invocations
1 parent ad8187f commit 5be3b5b

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

Mono.Debugging.Soft/SoftDebuggerAdaptor.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2212,8 +2212,29 @@ protected override Task<OperationResult<Value>> InvokeAsyncImpl (CancellationTok
22122212
tcs.SetException (new EvaluatorException ("Target method has thrown an exception but the exception object is inaccessible"));
22132213
}
22142214
}
2215+
catch (CommandException e) {
2216+
if (e.ErrorCode == ErrorCode.INVOKE_ABORTED) {
2217+
tcs.TrySetCanceled ();
2218+
token.ThrowIfCancellationRequested ();
2219+
}
2220+
else {
2221+
tcs.SetException (new EvaluatorException (e.Message));
2222+
}
2223+
}
22152224
catch (Exception e) {
2216-
tcs.SetException (e);
2225+
if (e is ObjectCollectedException ||
2226+
e is InvalidStackFrameException ||
2227+
e is VMNotSuspendedException ||
2228+
e is NotSupportedException ||
2229+
e is AbsentInformationException ||
2230+
e is ArgumentException) {
2231+
// user meaningfull evaluation exception -> wrap with EvaluatorException that will be properly shown in value viewer
2232+
tcs.SetException (new EvaluatorException (e.Message));
2233+
}
2234+
else {
2235+
DebuggerLoggingService.LogError ("Unexpected exception has thrown in Invocation", e);
2236+
tcs.SetException (e);
2237+
}
22172238
}
22182239
finally {
22192240
UpdateSessionState ();

Mono.Debugging/Mono.Debugging.Evaluation/AsyncOperationManager.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public OperationData (IAsyncOperationBase operation, CancellationTokenSource tok
5151
readonly HashSet<OperationData> currentOperations = new HashSet<OperationData> ();
5252
bool disposed = false;
5353
const int ShortCancelTimeout = 100;
54-
const int LongCancelTimeout = 1000;
5554

5655
static bool IsOperationCancelledException (Exception e, int depth = 4)
5756
{
@@ -125,24 +124,34 @@ public OperationResult<TValue> Invoke<TValue> (AsyncOperationBase<TValue> mc, in
125124

126125
public event EventHandler<BusyStateEventArgs> BusyStateChanged = delegate { };
127126

127+
void ChangeBusyState (bool busy, string description)
128+
{
129+
try {
130+
BusyStateChanged (this, new BusyStateEventArgs {IsBusy = true, Description = description});
131+
}
132+
catch (Exception e) {
133+
DebuggerLoggingService.LogError ("Exception during ChangeBusyState", e);
134+
}
135+
}
136+
128137
void WaitAfterCancel (IAsyncOperationBase op)
129138
{
130139
var desc = op.Description;
131140
DebuggerLoggingService.LogMessage (string.Format ("Waiting for cancel of invoke {0}", desc));
132141
try {
133142
if (!op.RawTask.Wait (ShortCancelTimeout)) {
134143
try {
135-
BusyStateChanged (this, new BusyStateEventArgs {IsBusy = true, Description = desc});
136-
op.RawTask.Wait (LongCancelTimeout);
144+
ChangeBusyState (true, desc);
145+
op.RawTask.Wait (Timeout.Infinite);
137146
}
138147
finally {
139-
BusyStateChanged (this, new BusyStateEventArgs {IsBusy = false, Description = desc});
148+
ChangeBusyState (false, desc);
140149
}
141150
}
142151
}
143152
finally {
144153
DebuggerLoggingService.LogMessage (string.Format ("Calling AfterCancelled() for {0}", desc));
145-
op.AfterCancelled (ShortCancelTimeout + LongCancelTimeout);
154+
op.AfterCancelled (ShortCancelTimeout);
146155
}
147156
}
148157

0 commit comments

Comments
 (0)