From 938be96415a9a2725d6d10df2130e9715cd85c79 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 22 Jan 2020 13:07:40 -0500 Subject: [PATCH] [Mono.Debugging.Soft] Don't queue a user thread for stepping Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/804257/ --- Mono.Debugging.Soft/SoftDebuggerSession.cs | 72 ++++++++++------------ 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/Mono.Debugging.Soft/SoftDebuggerSession.cs b/Mono.Debugging.Soft/SoftDebuggerSession.cs index 293e8fd8a..02f0ac837 100644 --- a/Mono.Debugging.Soft/SoftDebuggerSession.cs +++ b/Mono.Debugging.Soft/SoftDebuggerSession.cs @@ -1577,47 +1577,43 @@ protected override void OnNextLine () void Step (StepDepth depth, StepSize size) { - - ThreadPool.QueueUserWorkItem (delegate { + try { + Adaptor.CancelAsyncOperations (); // This call can block, so it has to run in background thread to avoid keeping the main session lock + var req = vm.CreateStepRequest (current_thread); + req.Depth = depth; + req.Size = size; + req.Filter = ShouldFilterStaticCtor () | StepFilter.DebuggerHidden | StepFilter.DebuggerStepThrough; + if (Options.ProjectAssembliesOnly) + req.Filter |= StepFilter.DebuggerNonUserCode; + if (assemblyFilters != null && assemblyFilters.Count > 0) + req.AssemblyFilter = assemblyFilters; try { - Adaptor.CancelAsyncOperations (); // This call can block, so it has to run in background thread to avoid keeping the main session lock - var req = vm.CreateStepRequest (current_thread); - req.Depth = depth; - req.Size = size; - req.Filter = ShouldFilterStaticCtor() | StepFilter.DebuggerHidden | StepFilter.DebuggerStepThrough; - if (Options.ProjectAssembliesOnly) - req.Filter |= StepFilter.DebuggerNonUserCode; - if (assemblyFilters != null && assemblyFilters.Count > 0) - req.AssemblyFilter = assemblyFilters; - try { - req.Enabled = true; - } - catch (NotSupportedException e) { - if (vm.Version.AtLeast (2, 19)) //catch NotSupportedException thrown by old version of protocol - throw e; - } - currentStepRequest = req; - OnResumed (); - vm.Resume (); - DequeueEventsForFirstThread (); - } catch (CommandException ex) { - string reason; - - switch (ex.ErrorCode) { - case ErrorCode.INVALID_FRAMEID: reason = "invalid frame id"; break; - case ErrorCode.NOT_SUSPENDED: reason = "VM not suspended"; break; - case ErrorCode.ERR_UNLOADED: reason = "AppDomain has been unloaded"; break; - case ErrorCode.NO_SEQ_POINT_AT_IL_OFFSET: reason = "no sequence point at the specified IL offset"; break; - default: reason = ex.ErrorCode.ToString (); break; - } + req.Enabled = true; + } catch (NotSupportedException e) { + if (vm.Version.AtLeast (2, 19)) //catch NotSupportedException thrown by old version of protocol + throw e; + } + currentStepRequest = req; + OnResumed (); + vm.Resume (); + DequeueEventsForFirstThread (); + } catch (CommandException ex) { + string reason; - OnDebuggerOutput (true, string.Format ("Step request failed: {0}.", reason)); - DebuggerLoggingService.LogError ("Step request failed", ex); - } catch (Exception ex) { - OnDebuggerOutput (true, string.Format ("Step request failed: {0}", ex.Message)); - DebuggerLoggingService.LogError ("Step request failed", ex); + switch (ex.ErrorCode) { + case ErrorCode.INVALID_FRAMEID: reason = "invalid frame id"; break; + case ErrorCode.NOT_SUSPENDED: reason = "VM not suspended"; break; + case ErrorCode.ERR_UNLOADED: reason = "AppDomain has been unloaded"; break; + case ErrorCode.NO_SEQ_POINT_AT_IL_OFFSET: reason = "no sequence point at the specified IL offset"; break; + default: reason = ex.ErrorCode.ToString (); break; } - }); + + OnDebuggerOutput (true, string.Format ("Step request failed: {0}.", reason)); + DebuggerLoggingService.LogError ("Step request failed", ex); + } catch (Exception ex) { + OnDebuggerOutput (true, string.Format ("Step request failed: {0}", ex.Message)); + DebuggerLoggingService.LogError ("Step request failed", ex); + } } private StepFilter ShouldFilterStaticCtor()