Skip to content

Commit 15047ca

Browse files
authored
Merge pull request #282 from mono/jstedfast-vsts804257
[Mono.Debugging.Soft] Don't queue a user thread for stepping
2 parents 9e257ce + 938be96 commit 15047ca

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed

Mono.Debugging.Soft/SoftDebuggerSession.cs

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,47 +1577,43 @@ protected override void OnNextLine ()
15771577

15781578
void Step (StepDepth depth, StepSize size)
15791579
{
1580-
1581-
ThreadPool.QueueUserWorkItem (delegate {
1580+
try {
1581+
Adaptor.CancelAsyncOperations (); // This call can block, so it has to run in background thread to avoid keeping the main session lock
1582+
var req = vm.CreateStepRequest (current_thread);
1583+
req.Depth = depth;
1584+
req.Size = size;
1585+
req.Filter = ShouldFilterStaticCtor () | StepFilter.DebuggerHidden | StepFilter.DebuggerStepThrough;
1586+
if (Options.ProjectAssembliesOnly)
1587+
req.Filter |= StepFilter.DebuggerNonUserCode;
1588+
if (assemblyFilters != null && assemblyFilters.Count > 0)
1589+
req.AssemblyFilter = assemblyFilters;
15821590
try {
1583-
Adaptor.CancelAsyncOperations (); // This call can block, so it has to run in background thread to avoid keeping the main session lock
1584-
var req = vm.CreateStepRequest (current_thread);
1585-
req.Depth = depth;
1586-
req.Size = size;
1587-
req.Filter = ShouldFilterStaticCtor() | StepFilter.DebuggerHidden | StepFilter.DebuggerStepThrough;
1588-
if (Options.ProjectAssembliesOnly)
1589-
req.Filter |= StepFilter.DebuggerNonUserCode;
1590-
if (assemblyFilters != null && assemblyFilters.Count > 0)
1591-
req.AssemblyFilter = assemblyFilters;
1592-
try {
1593-
req.Enabled = true;
1594-
}
1595-
catch (NotSupportedException e) {
1596-
if (vm.Version.AtLeast (2, 19)) //catch NotSupportedException thrown by old version of protocol
1597-
throw e;
1598-
}
1599-
currentStepRequest = req;
1600-
OnResumed ();
1601-
vm.Resume ();
1602-
DequeueEventsForFirstThread ();
1603-
} catch (CommandException ex) {
1604-
string reason;
1605-
1606-
switch (ex.ErrorCode) {
1607-
case ErrorCode.INVALID_FRAMEID: reason = "invalid frame id"; break;
1608-
case ErrorCode.NOT_SUSPENDED: reason = "VM not suspended"; break;
1609-
case ErrorCode.ERR_UNLOADED: reason = "AppDomain has been unloaded"; break;
1610-
case ErrorCode.NO_SEQ_POINT_AT_IL_OFFSET: reason = "no sequence point at the specified IL offset"; break;
1611-
default: reason = ex.ErrorCode.ToString (); break;
1612-
}
1591+
req.Enabled = true;
1592+
} catch (NotSupportedException e) {
1593+
if (vm.Version.AtLeast (2, 19)) //catch NotSupportedException thrown by old version of protocol
1594+
throw e;
1595+
}
1596+
currentStepRequest = req;
1597+
OnResumed ();
1598+
vm.Resume ();
1599+
DequeueEventsForFirstThread ();
1600+
} catch (CommandException ex) {
1601+
string reason;
16131602

1614-
OnDebuggerOutput (true, string.Format ("Step request failed: {0}.", reason));
1615-
DebuggerLoggingService.LogError ("Step request failed", ex);
1616-
} catch (Exception ex) {
1617-
OnDebuggerOutput (true, string.Format ("Step request failed: {0}", ex.Message));
1618-
DebuggerLoggingService.LogError ("Step request failed", ex);
1603+
switch (ex.ErrorCode) {
1604+
case ErrorCode.INVALID_FRAMEID: reason = "invalid frame id"; break;
1605+
case ErrorCode.NOT_SUSPENDED: reason = "VM not suspended"; break;
1606+
case ErrorCode.ERR_UNLOADED: reason = "AppDomain has been unloaded"; break;
1607+
case ErrorCode.NO_SEQ_POINT_AT_IL_OFFSET: reason = "no sequence point at the specified IL offset"; break;
1608+
default: reason = ex.ErrorCode.ToString (); break;
16191609
}
1620-
});
1610+
1611+
OnDebuggerOutput (true, string.Format ("Step request failed: {0}.", reason));
1612+
DebuggerLoggingService.LogError ("Step request failed", ex);
1613+
} catch (Exception ex) {
1614+
OnDebuggerOutput (true, string.Format ("Step request failed: {0}", ex.Message));
1615+
DebuggerLoggingService.LogError ("Step request failed", ex);
1616+
}
16211617
}
16221618

16231619
private StepFilter ShouldFilterStaticCtor()

0 commit comments

Comments
 (0)