Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit 44afc19

Browse files
committed
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.
1 parent 115b1d8 commit 44afc19

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

src/Debugger.cs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ static void EnsureCreated()
264264
_session.TargetEvent += (sender, e) =>
265265
{
266266
Log.Debug("Event: '{0}'", e.Type);
267+
268+
if (e.IsStopEvent)
269+
{
270+
if (ActiveFrame != null)
271+
Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true));
272+
273+
CommandLine.ResumeEvent.Set();
274+
}
267275
};
268276

269277
_session.TargetStarted += (sender, e) =>
@@ -293,18 +301,12 @@ static void EnsureCreated()
293301
{
294302
Log.Notice("Inferior process '{0}' ('{1}') suspended",
295303
ActiveProcess.Id, StringizeTarget());
296-
Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true));
297-
298-
CommandLine.ResumeEvent.Set();
299304
};
300305

301306
_session.TargetInterrupted += (sender, e) =>
302307
{
303308
Log.Notice("Inferior process '{0}' ('{1}') interrupted",
304309
ActiveProcess.Id, StringizeTarget());
305-
Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true));
306-
307-
CommandLine.ResumeEvent.Set();
308310
};
309311

310312
_session.TargetHitBreakpoint += (sender, e) =>
@@ -322,10 +324,6 @@ static void EnsureCreated()
322324

323325
Log.Notice("Hit breakpoint at '{0}:{1}'{2}", bp.FileName, bp.Line, cond);
324326
}
325-
326-
Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true));
327-
328-
CommandLine.ResumeEvent.Set();
329327
};
330328

331329
_session.TargetExited += (sender, e) =>
@@ -354,32 +352,22 @@ static void EnsureCreated()
354352

355353
_debuggeeKilled = true;
356354
_kind = SessionKind.Disconnected;
357-
358-
CommandLine.ResumeEvent.Set();
359355
};
360356

361357
_session.TargetExceptionThrown += (sender, e) =>
362358
{
363359
var ex = ActiveException;
364360

365361
Log.Notice("Trapped first-chance exception of type '{0}'", ex.Type);
366-
Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true));
367-
368362
PrintException(ex);
369-
370-
CommandLine.ResumeEvent.Set();
371363
};
372364

373365
_session.TargetUnhandledException += (sender, e) =>
374366
{
375367
var ex = ActiveException;
376368

377369
Log.Notice("Trapped unhandled exception of type '{0}'", ex.Type);
378-
Log.Emphasis(Utilities.StringizeFrame(ActiveFrame, true));
379-
380370
PrintException(ex);
381-
382-
CommandLine.ResumeEvent.Set();
383371
};
384372

385373
_session.TargetThreadStarted += (sender, e) =>

0 commit comments

Comments
 (0)