|
1 |
| -using System.Threading.Tasks; |
| 1 | +using System; |
| 2 | +using System.Runtime.InteropServices; |
| 3 | +using System.Threading.Tasks; |
2 | 4 | using Microsoft.Samples.Debugging.CorDebug;
|
3 | 5 | using Microsoft.Samples.Debugging.CorDebug.NativeApi;
|
4 | 6 | using Mono.Debugging.Client;
|
@@ -100,24 +102,41 @@ protected override Task<OperationResult<CorValue>> InvokeAsyncImpl ()
|
100 | 102 |
|
101 | 103 | protected override void AbortImpl (int abortCallTimes)
|
102 | 104 | {
|
103 |
| - if (abortCallTimes < 10) { |
104 |
| - DebuggerLoggingService.LogMessage ("Calling Abort() for {0} time", abortCallTimes); |
105 |
| - eval.Abort (); |
106 |
| - } |
107 |
| - else { |
108 |
| - if (abortCallTimes == 20) { |
109 |
| - // if Abort() and RudeAbort() didn't bring any result let's try to resume all the threads to free possible deadlocks in target process |
110 |
| - // maybe this can help to abort hanging evaluations |
111 |
| - DebuggerLoggingService.LogMessage ("RudeAbort() didn't stop eval after {0} times", abortCallTimes - 1); |
112 |
| - DebuggerLoggingService.LogMessage ("Calling Stop()"); |
113 |
| - context.Session.Process.Stop (0); |
114 |
| - DebuggerLoggingService.LogMessage ("Calling SetAllThreadsDebugState(THREAD_RUN)"); |
115 |
| - context.Session.Process.SetAllThreadsDebugState (CorDebugThreadState.THREAD_RUN, null); |
116 |
| - DebuggerLoggingService.LogMessage ("Calling Continue()"); |
117 |
| - context.Session.Process.Continue (false); |
| 105 | + try { |
| 106 | + if (abortCallTimes < 10) { |
| 107 | + DebuggerLoggingService.LogMessage ("Calling Abort() for {0} time", abortCallTimes); |
| 108 | + eval.Abort (); |
| 109 | + } |
| 110 | + else { |
| 111 | + if (abortCallTimes == 20) { |
| 112 | + // if Abort() and RudeAbort() didn't bring any result let's try to resume all the threads to free possible deadlocks in target process |
| 113 | + // maybe this can help to abort hanging evaluations |
| 114 | + DebuggerLoggingService.LogMessage ("RudeAbort() didn't stop eval after {0} times", abortCallTimes - 1); |
| 115 | + DebuggerLoggingService.LogMessage ("Calling Stop()"); |
| 116 | + context.Session.Process.Stop (0); |
| 117 | + DebuggerLoggingService.LogMessage ("Calling SetAllThreadsDebugState(THREAD_RUN)"); |
| 118 | + context.Session.Process.SetAllThreadsDebugState (CorDebugThreadState.THREAD_RUN, null); |
| 119 | + DebuggerLoggingService.LogMessage ("Calling Continue()"); |
| 120 | + context.Session.Process.Continue (false); |
| 121 | + } |
| 122 | + DebuggerLoggingService.LogMessage ("Calling RudeAbort() for {0} time", abortCallTimes); |
| 123 | + eval.RudeAbort(); |
| 124 | + } |
| 125 | + |
| 126 | + } catch (COMException e) { |
| 127 | + var hResult = e.ToHResult<HResult> (); |
| 128 | + switch (hResult) { |
| 129 | + case HResult.CORDBG_E_PROCESS_TERMINATED: |
| 130 | + DebuggerLoggingService.LogMessage ("Process was terminated. Set cancelled for eval"); |
| 131 | + tcs.TrySetCanceled (); |
| 132 | + return; |
| 133 | + case HResult.CORDBG_E_OBJECT_NEUTERED: |
| 134 | + DebuggerLoggingService.LogMessage ("Eval object was neutered. Set cancelled for eval"); |
| 135 | + tcs.TrySetCanceled (); |
| 136 | + return; |
118 | 137 | }
|
119 |
| - DebuggerLoggingService.LogMessage ("Calling RudeAbort() for {0} time", abortCallTimes); |
120 |
| - eval.RudeAbort(); |
| 138 | + tcs.SetException (e); |
| 139 | + throw; |
121 | 140 | }
|
122 | 141 | }
|
123 | 142 | }
|
|
0 commit comments