Skip to content

Commit

Permalink
Merge pull request #282 from mono/jstedfast-vsts804257
Browse files Browse the repository at this point in the history
[Mono.Debugging.Soft] Don't queue a user thread for stepping
  • Loading branch information
sgmunn authored Jan 23, 2020
2 parents 9e257ce + 938be96 commit 15047ca
Showing 1 changed file with 34 additions and 38 deletions.
72 changes: 34 additions & 38 deletions Mono.Debugging.Soft/SoftDebuggerSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 15047ca

Please sign in to comment.