From 44afc191736ab6a31bce591ed30b5879b40b8c93 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 1 Oct 2019 15:55:24 +0900 Subject: [PATCH] Handle debugger stop event with SoftDebuggerSession.TargetEvent The debugger does not listen to some events fired by SoftDebuggerSession, and may miss a stop event, which resumes command line processing, and lead to hangup. SoftDebuggerSession.TargetEvent handles all events and eliminates possibility to introduce a hangup also in the future. --- src/Debugger.cs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/Debugger.cs b/src/Debugger.cs index 6440286..4a7b8a1 100644 --- a/src/Debugger.cs +++ b/src/Debugger.cs @@ -264,6 +264,14 @@ static void EnsureCreated() _session.TargetEvent += (sender, e) => { Log.Debug("Event: '{0}'", e.Type); + + if (e.IsStopEvent) + { + if (ActiveFrame != null) + Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true)); + + CommandLine.ResumeEvent.Set(); + } }; _session.TargetStarted += (sender, e) => @@ -293,18 +301,12 @@ static void EnsureCreated() { Log.Notice("Inferior process '{0}' ('{1}') suspended", ActiveProcess.Id, StringizeTarget()); - Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true)); - - CommandLine.ResumeEvent.Set(); }; _session.TargetInterrupted += (sender, e) => { Log.Notice("Inferior process '{0}' ('{1}') interrupted", ActiveProcess.Id, StringizeTarget()); - Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true)); - - CommandLine.ResumeEvent.Set(); }; _session.TargetHitBreakpoint += (sender, e) => @@ -322,10 +324,6 @@ static void EnsureCreated() Log.Notice("Hit breakpoint at '{0}:{1}'{2}", bp.FileName, bp.Line, cond); } - - Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true)); - - CommandLine.ResumeEvent.Set(); }; _session.TargetExited += (sender, e) => @@ -354,8 +352,6 @@ static void EnsureCreated() _debuggeeKilled = true; _kind = SessionKind.Disconnected; - - CommandLine.ResumeEvent.Set(); }; _session.TargetExceptionThrown += (sender, e) => @@ -363,11 +359,7 @@ static void EnsureCreated() var ex = ActiveException; Log.Notice("Trapped first-chance exception of type '{0}'", ex.Type); - Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true)); - PrintException(ex); - - CommandLine.ResumeEvent.Set(); }; _session.TargetUnhandledException += (sender, e) => @@ -375,11 +367,7 @@ static void EnsureCreated() var ex = ActiveException; Log.Notice("Trapped unhandled exception of type '{0}'", ex.Type); - Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true)); - PrintException(ex); - - CommandLine.ResumeEvent.Set(); }; _session.TargetThreadStarted += (sender, e) =>