Skip to content

Commit 25d0748

Browse files
ArseniiCherniaevnerzhulart
authored andcommitted
implemented OnException handler
(cherry picked from commit c5583ba)
1 parent c4c1738 commit 25d0748

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Mono.Debugging.Win32/CorDebuggerSession.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ void SetupProcess (CorProcess corProcess)
270270
corProcess.OnEvalException += OnEvalException;
271271
corProcess.OnLogMessage += OnLogMessage;
272272
corProcess.OnException2 += OnException2;
273+
corProcess.OnException += OnException;
273274
corProcess.RegisterStdOutput (OnStdOutput);
274275
}
275276

@@ -821,6 +822,32 @@ void OnException2 (object sender, CorException2EventArgs e)
821822
}
822823
}
823824

825+
private void OnException (object sender, CorExceptionEventArgs e)
826+
{
827+
lock (debugLock) {
828+
if (evaluating) {
829+
e.Continue = true;
830+
return;
831+
}
832+
}
833+
834+
TargetEventArgs args = new TargetEventArgs (
835+
e.Unhandled? TargetEventType.UnhandledException: TargetEventType.ExceptionThrown);
836+
837+
OnStopped ();
838+
e.Continue = false;
839+
// If an exception is thrown while stepping, cancel the stepping operation
840+
if (stepper != null && stepper.IsActive ())
841+
stepper.Deactivate ();
842+
autoStepInto = false;
843+
SetActiveThread (e.Thread);
844+
845+
args.Process = GetProcess (process);
846+
args.Thread = GetThread (e.Thread);
847+
args.Backtrace = new Backtrace (new CorBacktrace (e.Thread, this));
848+
OnTargetEvent (args);
849+
}
850+
824851
public bool IsExternalCode (string fileName)
825852
{
826853
if (string.IsNullOrWhiteSpace (fileName))

0 commit comments

Comments
 (0)