Skip to content

Commit 102fa7a

Browse files
committed
Invocation is awaited infinitely as it was before.
Better handling of exeptions in Soft invocations
1 parent 9809e72 commit 102fa7a

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
@@ -2244,8 +2244,29 @@ protected override Task<OperationResult<Value>> InvokeAsyncImpl (CancellationTok
22442244
tcs.SetException (new EvaluatorException ("Target method has thrown an exception but the exception object is inaccessible"));
22452245
}
22462246
}
2247+
catch (CommandException e) {
2248+
if (e.ErrorCode == ErrorCode.INVOKE_ABORTED) {
2249+
tcs.TrySetCanceled ();
2250+
token.ThrowIfCancellationRequested ();
2251+
}
2252+
else {
2253+
tcs.SetException (new EvaluatorException (e.Message));
2254+
}
2255+
}
22472256
catch (Exception e) {
2248-
tcs.SetException (e);
2257+
if (e is ObjectCollectedException ||
2258+
e is InvalidStackFrameException ||
2259+
e is VMNotSuspendedException ||
2260+
e is NotSupportedException ||
2261+
e is AbsentInformationException ||
2262+
e is ArgumentException) {
2263+
// user meaningfull evaluation exception -> wrap with EvaluatorException that will be properly shown in value viewer
2264+
tcs.SetException (new EvaluatorException (e.Message));
2265+
}
2266+
else {
2267+
DebuggerLoggingService.LogError ("Unexpected exception has thrown in Invocation", e);
2268+
tcs.SetException (e);
2269+
}
22492270
}
22502271
finally {
22512272
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)