Browse Source

Store PauseSession per process

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1685 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 19 years ago
parent
commit
c3bb2fae23
  1. 4
      src/AddIns/Misc/Debugger/Debugger.BooInterpreter/Project/Src/DebugeeInterpreterContext.cs
  2. 17
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  3. 37
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs
  4. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  5. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  6. 51
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs

4
src/AddIns/Misc/Debugger/Debugger.BooInterpreter/Project/Src/DebugeeInterpreterContext.cs

@ -137,16 +137,14 @@ namespace Debugger
PrintLine("Getting local variable " + name); PrintLine("Getting local variable " + name);
// First, get out of GC unsafe point // First, get out of GC unsafe point
Stepper stepOut = new Stepper(debugger.SelectedThread.LastFunction, "Boo interperter"); Stepper stepOut = new Stepper(debugger.SelectedThread.LastFunction, "Boo interperter");
stepOut.PauseWhenComplete = true;
stepOut.StepComplete += delegate { stepOut.StepComplete += delegate {
debugger.MTA2STA.AsyncCall(delegate { debugger.MTA2STA.AsyncCall(delegate {
if (!interpreter_localVariable.SetValue(localVar)) { if (!interpreter_localVariable.SetValue(localVar)) {
PrintLine("Getting of local variable " + name + " failed"); PrintLine("Getting of local variable " + name + " failed");
} }
debugger.SkipEventsDuringEvaluation = true; debugger.Continue();
}); });
}; };
debugger.SkipEventsDuringEvaluation = false;
stepOut.StepOut(); stepOut.StepOut();
} }

17
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs

@ -24,7 +24,6 @@ namespace Debugger
{ {
NDebugger debugger; NDebugger debugger;
bool pauseProcessInsteadOfContinue; bool pauseProcessInsteadOfContinue;
bool skipEventsDuringEvaluation;
public NDebugger Debugger { public NDebugger Debugger {
get { get {
@ -32,15 +31,6 @@ namespace Debugger
} }
} }
public bool SkipEventsDuringEvaluation {
get {
return skipEventsDuringEvaluation;
}
set {
skipEventsDuringEvaluation = value;
}
}
public ManagedCallback(NDebugger debugger) public ManagedCallback(NDebugger debugger)
{ {
this.debugger = debugger; this.debugger = debugger;
@ -65,8 +55,7 @@ namespace Debugger
} else { } else {
pauseProcessInsteadOfContinue = false; pauseProcessInsteadOfContinue = false;
} }
debugger.SelectedProcess.IsRunning = false; debugger.SelectedProcess.NotifyPaused(new PauseSession(pausedReason));
debugger.PauseSession = new PauseSession(pausedReason);
} else { } else {
throw new DebuggerException("Invalid state at the start of callback"); throw new DebuggerException("Invalid state at the start of callback");
} }
@ -96,11 +85,11 @@ namespace Debugger
void ExitCallback_Paused() void ExitCallback_Paused()
{ {
if (debugger.Evaluating && skipEventsDuringEvaluation) { if (debugger.Evaluating) {
// Ignore events during property evaluation // Ignore events during property evaluation
ExitCallback_Continue(); ExitCallback_Continue();
} else { } else {
debugger.Pause(); debugger.Pause(debugger.PauseSession.PausedReason != PausedReason.EvalComplete);
} }
} }

37
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs

@ -19,9 +19,8 @@ namespace Debugger
public partial class NDebugger public partial class NDebugger
{ {
bool pauseOnHandledException = false; bool pauseOnHandledException = false;
ManualResetEvent pausedHandle = new ManualResetEvent(false); internal ManualResetEvent pausedHandle = new ManualResetEvent(false);
PauseSession pauseSession;
DebugeeState debugeeState; DebugeeState debugeeState;
Process selectedProcess; Process selectedProcess;
@ -47,7 +46,7 @@ namespace Debugger
} }
} }
protected virtual void OnDebuggingResumed() internal virtual void OnDebuggingResumed()
{ {
TraceMessage ("Debugger event: OnDebuggingResumed()"); TraceMessage ("Debugger event: OnDebuggingResumed()");
if (DebuggingResumed != null) { if (DebuggingResumed != null) {
@ -101,15 +100,13 @@ namespace Debugger
} }
} }
/// <summary>
/// Indentification of the current debugger session. This value changes whenever debugger is continued
/// </summary>
public PauseSession PauseSession { public PauseSession PauseSession {
get { get {
return pauseSession; if (SelectedProcess == null) {
return null;
} else {
return SelectedProcess.PauseSession;
} }
internal set {
pauseSession = value;
} }
} }
@ -138,13 +135,13 @@ namespace Debugger
public bool IsPaused { public bool IsPaused {
get { get {
return (pauseSession != null); return (PauseSession != null);
} }
} }
public bool IsRunning { public bool IsRunning {
get { get {
return (pauseSession == null); return !IsPaused;
} }
} }
@ -155,11 +152,11 @@ namespace Debugger
public PausedReason PausedReason { public PausedReason PausedReason {
get { get {
AssertPaused(); AssertPaused();
return pauseSession.PausedReason; return PauseSession.PausedReason;
} }
} }
internal void Pause() internal void Pause(bool debuggeeStateChanged)
{ {
if (this.SelectedThread == null && this.Threads.Count > 0) { if (this.SelectedThread == null && this.Threads.Count > 0) {
this.SelectedProcess.SelectedThread = this.Threads[0]; this.SelectedProcess.SelectedThread = this.Threads[0];
@ -174,7 +171,7 @@ namespace Debugger
this.SelectedThread.SelectedFunction = this.SelectedThread.LastFunctionWithLoadedSymbols; this.SelectedThread.SelectedFunction = this.SelectedThread.LastFunctionWithLoadedSymbols;
} }
if (PausedReason != PausedReason.EvalComplete) { if (debuggeeStateChanged) {
DebugeeState oldDebugeeState = debugeeState; DebugeeState oldDebugeeState = debugeeState;
debugeeState = new DebugeeState(this); debugeeState = new DebugeeState(this);
OnDebuggeeStateChanged(); OnDebuggeeStateChanged();
@ -196,18 +193,6 @@ namespace Debugger
} }
} }
internal void Resume()
{
if (IsRunning) {
throw new DebuggerException("Already resumed");
}
pauseSession.NotifyHasExpired();
pauseSession = null;
OnDebuggingResumed();
pausedHandle.Reset();
}
/// <summary> /// <summary>
/// Waits until the debugger pauses unless it is already paused. /// Waits until the debugger pauses unless it is already paused.
/// Use PausedReason to find out why it paused. /// Use PausedReason to find out why it paused.

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs

@ -50,15 +50,6 @@ namespace Debugger
} }
} }
public bool SkipEventsDuringEvaluation {
get {
return managedCallback.SkipEventsDuringEvaluation;
}
set {
managedCallback.SkipEventsDuringEvaluation = value;
}
}
public NDebugger() public NDebugger()
{ {
if (ApartmentState.STA == System.Threading.Thread.CurrentThread.GetApartmentState()) { if (ApartmentState.STA == System.Threading.Thread.CurrentThread.GetApartmentState()) {
@ -133,7 +124,6 @@ namespace Debugger
selectedProcess = null; selectedProcess = null;
pausedHandle.Reset(); pausedHandle.Reset();
pauseSession = null;
pendingEvalsCollection.Clear(); pendingEvalsCollection.Clear();

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

@ -343,8 +343,8 @@ namespace Debugger
} else { } else {
// invalidates all frames and chains for the current thread // invalidates all frames and chains for the current thread
CorILFrame.SetIP((uint)ilOffset); CorILFrame.SetIP((uint)ilOffset);
debugger.PauseSession = new PauseSession(PausedReason.SetIP); debugger.SelectedProcess.NotifyPaused(new PauseSession(PausedReason.SetIP));
debugger.Pause(); debugger.Pause(false);
} }
} catch { } catch {
return null; return null;

51
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs

@ -21,7 +21,7 @@ namespace Debugger
ICorDebugProcess corProcess; ICorDebugProcess corProcess;
Thread selectedThread; Thread selectedThread;
bool isProcessRunning = true; PauseSession pauseSession;
bool hasExpired = false; bool hasExpired = false;
@ -43,6 +43,19 @@ namespace Debugger
} }
} }
/// <summary>
/// Indentification of the current debugger session. This value changes whenever debugger is continued
/// </summary>
public PauseSession PauseSession {
get {
return pauseSession;
}
}
internal void NotifyPaused(PauseSession pauseSession)
{
this.pauseSession = pauseSession;
}
public NDebugger Debugger { public NDebugger Debugger {
get { get {
@ -127,27 +140,25 @@ namespace Debugger
internal void Break() internal void Break()
{ {
if (!isProcessRunning) { AssertRunning();
throw new DebuggerException("Invalid operation");
}
corProcess.Stop(5000); // TODO: Hardcoded value corProcess.Stop(5000); // TODO: Hardcoded value
isProcessRunning = false; pauseSession = new PauseSession(PausedReason.ForcedBreak);
debugger.PauseSession = new PauseSession(PausedReason.ForcedBreak);
debugger.SelectedProcess = this; debugger.SelectedProcess = this;
debugger.Pause(); debugger.Pause(true);
} }
public void Continue() public void Continue()
{ {
if (isProcessRunning) { AssertPaused();
throw new DebuggerException("Invalid operation");
} pauseSession.NotifyHasExpired();
pauseSession = null;
debugger.OnDebuggingResumed();
debugger.pausedHandle.Reset();
debugger.Resume();
isProcessRunning = true;
corProcess.Continue(0); corProcess.Continue(0);
} }
@ -164,24 +175,28 @@ namespace Debugger
public bool IsRunning { public bool IsRunning {
get { get {
return isProcessRunning; return pauseSession == null;
}
internal set {
isProcessRunning = value;
} }
} }
public bool IsPaused { public bool IsPaused {
get { get {
return !isProcessRunning; return !IsRunning;
} }
} }
public void AssertPaused() public void AssertPaused()
{ {
if (!IsPaused) { if (IsRunning) {
throw new DebuggerException("Process is not paused."); throw new DebuggerException("Process is not paused.");
} }
} }
public void AssertRunning()
{
if (IsPaused) {
throw new DebuggerException("Process is not running.");
}
}
} }
} }

Loading…
Cancel
Save