diff options
author | Keting Yang <ketyang@microsoft.com> | 2019-11-08 18:05:26 +0300 |
---|---|---|
committer | monojenkins <jo.shields+jenkins@xamarin.com> | 2019-12-19 21:41:03 +0300 |
commit | b77b95cf6eb5c1e7b9857f2e3be64cffe8d6a0ab (patch) | |
tree | a6868619d28a9ac3c6ecd9f47bc81da3be0996c6 /main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol | |
parent | bd4a8aeda591da3b13e382ccd3861d2b2580a987 (diff) |
[Unit Test] Show source code while debugging
1. update the version of VSCodeDebugProtocol used
2. Update the exception request during Lauch and Attach to catch the unhandled exception as a "stopped" event
3. While handling exception, throw exception regardless of whether a breakpoint exists or not
4. In `DebuggingService`, when `NotifyCallStackChanged()` is called when conditions satisfied, subsequent calls will occur: `OnStackChanged()` -> `SetSourceCodeFrame()` -> `NotifyCurrentFrameChanged()`. Therefore adding `noNeedUpdateFrame` to prevent duplicate calls to `OnFrameChanged`
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1000552
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol')
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs index 5da7eda093..f5f35302f7 100644 --- a/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs +++ b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs @@ -156,6 +156,7 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol } bool currentExceptionState = false; + bool unhandleExceptionRegistered = false; void UpdateExceptions () { //Disposed @@ -163,11 +164,13 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol return; var hasCustomExceptions = breakpoints.Select (b => b.Key).OfType<Catchpoint> ().Any (e => e.Enabled); - if (currentExceptionState != hasCustomExceptions) { + if (currentExceptionState != hasCustomExceptions || !unhandleExceptionRegistered) { currentExceptionState = hasCustomExceptions; - protocolClient.SendRequest (new SetExceptionBreakpointsRequest ( - Capabilities.ExceptionBreakpointFilters.Where (f => hasCustomExceptions || (f.Default ?? false)).Select (f => f.Filter).ToList () - ), null); + var exceptionRequest = new SetExceptionBreakpointsRequest ( + Capabilities.ExceptionBreakpointFilters.Where (f => hasCustomExceptions || (f.Default ?? false) || (f.Label == "User-Unhandled Exceptions")).Select (f => f.Filter).ToList ()); + exceptionRequest.ExceptionOptions = new List<ExceptionOptions> () { new ExceptionOptions (ExceptionBreakMode.Unhandled)}; + protocolClient.SendRequest (exceptionRequest, null); + unhandleExceptionRegistered = true; } } @@ -268,6 +271,7 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol LaunchRequest launchRequest = CreateLaunchRequest (startInfo); protocolClient.SendRequestSync (launchRequest); protocolClient.SendRequestSync (new ConfigurationDoneRequest ()); + UpdateExceptions (); } protected void Attach (long processId) @@ -277,6 +281,7 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol protocolClient.SendRequestSync (attachRequest); OnStarted (); protocolClient.SendRequestSync (new ConfigurationDoneRequest ()); + UpdateExceptions (); } protected internal DebugProtocolHost protocolClient; @@ -403,12 +408,7 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol // It's OK to evaluate expressions in external code stackFrame = (VsCodeStackFrame)backtrace.GetFrame (0); } - - if (!breakpoints.Select (b => b.Key).OfType<Catchpoint> ().Any (c => ShouldStopOnExceptionCatchpoint (c, stackFrame.frameId))) { - OnContinue (); - return; - } - args = new TargetEventArgs (TargetEventType.ExceptionThrown); + args = new TargetEventArgs (TargetEventType.UnhandledException); break; default: throw new NotImplementedException (body.Reason.ToString ()); @@ -502,13 +502,13 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol return; protocolClient.SendRequest ( - new SetBreakpointsRequest (source) {
+ new SetBreakpointsRequest (source) { Breakpoints = sourceFile.Select (b => new SourceBreakpoint { Line = b.OriginalLine, Column = b.OriginalColumn, - Condition = b.ConditionExpression,
- HitCondition = GetHitCondition(b)
- }).ToList ()
+ Condition = b.ConditionExpression, + HitCondition = GetHitCondition(b) + }).ToList () }, (obj) => { Task.Run (() => { for (int i = 0; i < obj.Breakpoints.Count; i++) { |