Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mono.Debugging.Soft] Don't queue a user thread for stepping #282

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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