Browse Source

Apply thread-suspend rules for threads created during the stepping

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5176 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 16 years ago
parent
commit
36a37b020a
  1. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Eval.cs
  2. 13
      src/AddIns/Misc/Debugger/Debugger.Core/ManagedCallback.cs
  3. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Options.cs
  4. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Process.cs
  5. 4
      src/AddIns/Misc/Debugger/Debugger.Core/StackFrame.cs
  6. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Thread.cs
  7. 19
      src/AddIns/Misc/Debugger/Debugger.Tests/Tests/ExpressionEvaluator_Tests.cs

4
src/AddIns/Misc/Debugger/Debugger.Core/Eval.cs

@ -119,9 +119,9 @@ namespace Debugger
appDomain.Process.ActiveEvals.Add(this); appDomain.Process.ActiveEvals.Add(this);
if (appDomain.Process.Options.SuspendOtherThreads) { if (appDomain.Process.Options.SuspendOtherThreads) {
appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] { thread }); appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] { thread }, CorDebugThreadState.THREAD_SUSPEND);
} else { } else {
appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, this.Process.UnsuspendedThreads); appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, this.Process.UnsuspendedThreads, CorDebugThreadState.THREAD_RUN);
} }
} }

13
src/AddIns/Misc/Debugger/Debugger.Core/ManagedCallback.cs

@ -53,7 +53,7 @@ namespace Debugger
if (process.IsPaused && process.PauseSession.PausedReason == PausedReason.ForcedBreak) { if (process.IsPaused && process.PauseSession.PausedReason == PausedReason.ForcedBreak) {
process.TraceMessage("Processing post-break callback"); process.TraceMessage("Processing post-break callback");
// This compensates for the break call and we are in normal callback handling mode // This compensates for the break call and we are in normal callback handling mode
process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] {}); process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] {}, null);
// Start of call back - create new pause session (as usual) // Start of call back - create new pause session (as usual)
process.NotifyPaused(pausedReason); process.NotifyPaused(pausedReason);
// Make sure we stay pause after the callback is handled // Make sure we stay pause after the callback is handled
@ -88,17 +88,17 @@ namespace Debugger
if (hasQueuedCallbacks) { if (hasQueuedCallbacks) {
// Exception has Exception2 queued after it // Exception has Exception2 queued after it
process.AsyncContinue(DebuggeeStateAction.Keep, null); process.AsyncContinue(DebuggeeStateAction.Keep, null, null);
} else if (process.Evaluating) { } else if (process.Evaluating) {
// Ignore events during property evaluation // Ignore events during property evaluation
process.AsyncContinue(DebuggeeStateAction.Keep, null); process.AsyncContinue(DebuggeeStateAction.Keep, null, null);
} else if (pauseOnNextExit) { } else if (pauseOnNextExit) {
if (process.Options.Verbose) if (process.Options.Verbose)
process.TraceMessage("Callback exit: Paused"); process.TraceMessage("Callback exit: Paused");
pauseOnNextExit = false; pauseOnNextExit = false;
Pause(); Pause();
} else { } else {
process.AsyncContinue(DebuggeeStateAction.Keep, null); process.AsyncContinue(DebuggeeStateAction.Keep, null, null);
} }
isInCallback = false; isInCallback = false;
@ -374,7 +374,10 @@ namespace Debugger
// and we continue from this callback anyway // and we continue from this callback anyway
EnterCallback(PausedReason.Other, "CreateThread " + pThread.GetID(), pAppDomain); EnterCallback(PausedReason.Other, "CreateThread " + pThread.GetID(), pAppDomain);
process.Threads.Add(new Thread(process, pThread)); Thread thread = new Thread(process, pThread);
process.Threads.Add(thread);
thread.CorThread.SetDebugState(process.NewThreadState);
ExitCallback(); ExitCallback();
} }

2
src/AddIns/Misc/Debugger/Debugger.Core/Options.cs

@ -17,6 +17,6 @@ namespace Debugger
public bool StepOverFieldAccessProperties = true; public bool StepOverFieldAccessProperties = true;
public bool Verbose = false; public bool Verbose = false;
public string[] SymbolsSearchPaths = new string[0]; public string[] SymbolsSearchPaths = new string[0];
public bool SuspendOtherThreads = false; public bool SuspendOtherThreads = true;
} }
} }

10
src/AddIns/Misc/Debugger/Debugger.Core/Process.cs

@ -416,10 +416,12 @@ namespace Debugger
/// </summary> /// </summary>
public void AsyncContinue() public void AsyncContinue()
{ {
AsyncContinue(DebuggeeStateAction.Clear, this.UnsuspendedThreads); AsyncContinue(DebuggeeStateAction.Clear, this.UnsuspendedThreads, CorDebugThreadState.THREAD_RUN);
} }
internal void AsyncContinue(DebuggeeStateAction action, Thread[] threadsToRun) internal CorDebugThreadState NewThreadState = CorDebugThreadState.THREAD_RUN;
internal void AsyncContinue(DebuggeeStateAction action, Thread[] threadsToRun, CorDebugThreadState? newThreadState)
{ {
AssertPaused(); AssertPaused();
@ -447,6 +449,10 @@ namespace Debugger
} }
} }
if (newThreadState != null) {
this.NewThreadState = newThreadState.Value;
}
NotifyResumed(action); NotifyResumed(action);
corProcess.Continue(0); corProcess.Continue(0);
if (this.Options.Verbose) { if (this.Options.Verbose) {

4
src/AddIns/Misc/Debugger/Debugger.Core/StackFrame.cs

@ -219,9 +219,9 @@ namespace Debugger
void AsyncContinue() void AsyncContinue()
{ {
if (process.Options.SuspendOtherThreads) { if (process.Options.SuspendOtherThreads) {
process.AsyncContinue(DebuggeeStateAction.Clear, new Thread[] { this.Thread }); process.AsyncContinue(DebuggeeStateAction.Clear, new Thread[] { this.Thread }, CorDebugThreadState.THREAD_SUSPEND);
} else { } else {
process.AsyncContinue(DebuggeeStateAction.Clear, this.Process.UnsuspendedThreads); process.AsyncContinue(DebuggeeStateAction.Clear, this.Process.UnsuspendedThreads, CorDebugThreadState.THREAD_RUN);
} }
} }

2
src/AddIns/Misc/Debugger/Debugger.Core/Thread.cs

@ -227,7 +227,7 @@ namespace Debugger
// May happen in release code with does not have any symbols // May happen in release code with does not have any symbols
return false; return false;
} }
process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] { this /* needed */ }); process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] { this /* needed */ }, null);
process.WaitForPause(); process.WaitForPause();
return true; return true;
} }

19
src/AddIns/Misc/Debugger/Debugger.Tests/Tests/ExpressionEvaluator_Tests.cs

@ -145,6 +145,7 @@ namespace Debugger.Tests
System.Diagnostics.Debugger.Break(); System.Diagnostics.Debugger.Break();
bgWork.Start(); bgWork.Start();
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
System.Diagnostics.Debugger.Break();
} }
} }
} }
@ -259,7 +260,7 @@ namespace Debugger.Tests {
ObjectDump("TypesEqual", locType == valType); ObjectDump("TypesEqual", locType == valType);
ObjectDump("WorkerThreadMoved", process.SelectedStackFrame.GetThisValue().GetMemberValue("WorkerThreadMoved").AsString); ObjectDump("WorkerThreadMoved", process.SelectedStackFrame.GetThisValue().GetMemberValue("WorkerThreadMoved").AsString);
process.SelectedStackFrame.StepOver(); process.Continue();
ObjectDump("WorkerThreadMoved", process.SelectedStackFrame.GetThisValue().GetMemberValue("WorkerThreadMoved").AsString); ObjectDump("WorkerThreadMoved", process.SelectedStackFrame.GetThisValue().GetMemberValue("WorkerThreadMoved").AsString);
EndTest(); EndTest();
@ -437,19 +438,9 @@ namespace Debugger.Tests {
<TypeResulution> typeof(Debugger.Tests.ExpressionEvaluator_Tests.A&lt;System.Int32&gt;.B.C&lt;System.Char&gt;[][,]) = Debugger.Tests.ExpressionEvaluator_Tests+A`1+B+C`1[System.Int32,System.Char][,][] (ok)</TypeResulution> <TypeResulution> typeof(Debugger.Tests.ExpressionEvaluator_Tests.A&lt;System.Int32&gt;.B.C&lt;System.Char&gt;[][,]) = Debugger.Tests.ExpressionEvaluator_Tests+A`1+B+C`1[System.Int32,System.Char][,][] (ok)</TypeResulution>
<TypesIdentitcal>True</TypesIdentitcal> <TypesIdentitcal>True</TypesIdentitcal>
<TypesEqual>True</TypesEqual> <TypesEqual>True</TypesEqual>
<WorkerThreadMoved> <WorkerThreadMoved>False</WorkerThreadMoved>
<Value <DebuggingPaused>Break ExpressionEvaluator_Tests.cs:148,4-148,40</DebuggingPaused>
AsString="True" <WorkerThreadMoved>True</WorkerThreadMoved>
PrimitiveValue="True"
Type="System.Boolean" />
</WorkerThreadMoved>
<DebuggingPaused>StepComplete ExpressionEvaluator_Tests.cs:148,3-148,4</DebuggingPaused>
<WorkerThreadMoved>
<Value
AsString="True"
PrimitiveValue="True"
Type="System.Boolean" />
</WorkerThreadMoved>
<ProcessExited /> <ProcessExited />
</Test> </Test>
</DebuggerTests> </DebuggerTests>

Loading…
Cancel
Save