diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
index 65b618ce9a..dcc3b7d3df 100644
--- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
@@ -86,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void CallStackListItemActivate(object sender, EventArgs e)
{
- if (debuggerCore.IsCurrentThreadSafeForInspection) {
+ if (debuggerCore.IsPaused) {
Function f = (Function)(callStackList.SelectedItems[0].Tag);
if (f.HasSymbols) {
debuggerCore.CurrentFunction = f;
@@ -108,7 +108,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{
callStackList.BeginUpdate();
callStackList.Items.Clear();
- if (debuggerCore.IsCurrentThreadSafeForInspection) {
+ if (debuggerCore.CurrentThread != null) {
foreach (Function f in debuggerCore.CurrentThread.Callstack) {
ListViewItem item = new ListViewItem(new string[] { f.Name, "" });
item.Tag = f;
diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
index e84e8a90b9..a25f671833 100644
--- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
@@ -107,14 +107,12 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void RefreshList()
{
- if (debuggerCore.IsCurrentProcessSafeForInspection) {
- UpdateVariables(localVarList.Items, debuggerCore.LocalVariables);
- }
+ UpdateVariables(localVarList.Items, debuggerCore.LocalVariables);
}
private void localVarList_BeforeExpand(object sender, TreeListViewCancelEventArgs e)
{
- if (debuggerCore.IsCurrentProcessSafeForInspection) {
+ if (debuggerCore.IsPaused) {
((VariableListItem)e.Item).PrepareForExpansion();
} else {
// TODO: Some message telling user that he can not explore variable since
diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs
index ebfc97e249..65dbb64b9c 100644
--- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs
@@ -97,7 +97,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void RunningThreadsListItemActivate(object sender, EventArgs e)
{
- if (debuggerCore.IsCurrentProcessSafeForInspection) {
+ if (debuggerCore.IsPaused) {
debuggerCore.CurrentThread = (Thread)(runningThreadsList.SelectedItems[0].Tag);
}
}
diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
index ec8b05c028..955470873a 100644
--- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
@@ -208,7 +208,7 @@ namespace ICSharpCode.SharpDevelop.Services
///
public string GetValueAsString(string variableName)
{
- if (debugger == null || !debugger.IsCurrentProcessSafeForInspection) return null;
+ if (debugger == null || debugger.IsRunning) return null;
VariableCollection collection = debugger.LocalVariables;
if (collection == null)
return null;
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
index bc2bae3b9b..e533a024e2 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
@@ -100,6 +100,7 @@
+
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
index 331951db9f..2de2867188 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
@@ -24,6 +24,9 @@ namespace DebuggerLibrary
NDebugger debugger;
bool handlingCallback = false;
+
+ Process callingProcess;
+ Thread callingThread;
public event EventHandler CorDebugEvalCompleted;
@@ -32,7 +35,7 @@ namespace DebuggerLibrary
this.debugger = debugger;
}
- public bool HandlingCallback {
+ bool HandlingCallback {
get {
return handlingCallback;
}
@@ -43,12 +46,8 @@ namespace DebuggerLibrary
{
EnterCallback(name);
- Process process = debugger.GetProcess(pProcess);
- process.IsProcessRunning = false;
- debugger.CurrentProcess = process;
- foreach(Thread t in process.Threads) {
- t.CurrentFunction = null;
- }
+ callingProcess = debugger.GetProcess(pProcess);
+ callingProcess.IsRunning = false;
}
// Sets CurrentProcess
@@ -58,12 +57,9 @@ namespace DebuggerLibrary
ICorDebugProcess pProcess;
pAppDomain.GetProcess(out pProcess);
- Process process = debugger.GetProcess(pProcess);
- process.IsProcessRunning = false;
- debugger.CurrentProcess = process;
- foreach(Thread t in process.Threads) {
- t.CurrentFunction = null;
- }
+
+ callingProcess = debugger.GetProcess(pProcess);
+ callingProcess.IsRunning = false;
}
// Sets CurrentProcess, CurrentThread and CurrentFunction
@@ -72,15 +68,10 @@ namespace DebuggerLibrary
{
EnterCallback(name);
- Thread thread = debugger.GetThread(pThread);
- Process process = thread.Process;
- process.IsProcessRunning = false;
- debugger.CurrentProcess = process;
- process.CurrentThread = thread;
- foreach(Thread t in process.Threads) {
- t.CurrentFunction = null;
- }
- thread.CurrentFunction = thread.LastFunctionWithLoadedSymbols;
+ callingThread = debugger.GetThread(pThread);
+
+ callingProcess = callingThread.Process;
+ callingProcess.IsRunning = false;
}
void EnterCallback(string name)
@@ -91,20 +82,25 @@ namespace DebuggerLibrary
void ExitCallback_Continue()
{
- debugger.Continue();
+ callingProcess.ContinueCallback();
+
+ callingThread = null;
+ callingProcess = null;
handlingCallback = false;
}
void ExitCallback_Paused(PausedReason reason)
{
- if (debugger.CurrentThread == null) {
- throw new DebuggerException("You are not allowed to pause since CurrentThread is not set");
+ if (callingThread != null) {
+ callingThread.DeactivateAllSteppers();
}
- debugger.CurrentThread.DeactivateAllSteppers();
handlingCallback = false;
- debugger.OnDebuggingPaused(reason);
+ debugger.Pause(reason, callingProcess, callingThread);
+
+ callingThread = null;
+ callingProcess = null;
}
@@ -114,7 +110,7 @@ namespace DebuggerLibrary
{
EnterCallback("StepComplete (" + reason.ToString() + ")", pThread);
- if (debugger.CurrentThread.LastFunction.Module.SymbolsLoaded == false) {
+ if (callingThread.LastFunction.Module.SymbolsLoaded == false) {
debugger.TraceMessage(" - leaving code without symbols");
ExitCallback_Continue();
@@ -341,7 +337,7 @@ namespace DebuggerLibrary
debugger.RemoveThread(thread);
if (thread.Process.CurrentThread == thread) {
- thread.Process.CurrentThread = null;
+ thread.Process.SetCurrentThread(null);
}
ExitCallback_Continue();
@@ -400,7 +396,7 @@ namespace DebuggerLibrary
{
EnterCallback("Exception2", pThread);
- debugger.CurrentThread.CurrentExceptionType = (ExceptionType)dwEventType;
+ callingThread.CurrentExceptionType = (ExceptionType)dwEventType;
if (ExceptionType.DEBUG_EXCEPTION_UNHANDLED != (ExceptionType)dwEventType) {
// Handled exception
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs
new file mode 100644
index 0000000000..44a0566435
--- /dev/null
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs
@@ -0,0 +1,236 @@
+//
+// 2002-2005 AlphaSierraPapa
+// GNU General Public License
+//
+// $Revision: 257 $
+//
+
+using System;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+
+using DebuggerInterop.Core;
+using DebuggerInterop.MetaData;
+using System.Collections.Generic;
+
+namespace DebuggerLibrary
+{
+ public partial class NDebugger
+ {
+ bool isPaused;
+ bool pauseOnHandledException = false;
+
+ public event EventHandler DebuggingPaused;
+ public event EventHandler DebuggingResumed;
+
+ public bool PauseOnHandledException {
+ get {
+ return pauseOnHandledException;
+ }
+ set {
+ pauseOnHandledException = value;
+ }
+ }
+
+ protected virtual void OnDebuggingPaused(PausedReason reason)
+ {
+ TraceMessage ("Debugger event: OnDebuggingPaused(" + reason.ToString() + ")");
+ if (DebuggingPaused != null) {
+ DebuggingPausedEventArgs args = new DebuggingPausedEventArgs(this, reason);
+ DebuggingPaused(this, args);
+ if (args.ResumeDebugging) {
+ Continue();
+ }
+ }
+ }
+
+ protected virtual void OnDebuggingResumed()
+ {
+ TraceMessage ("Debugger event: OnDebuggingResumed()");
+ if (DebuggingResumed != null) {
+ DebuggingResumed(this, new DebuggerEventArgs(this));
+ }
+ }
+
+ public Process CurrentProcess {
+ get {
+ if (IsRunning) return null;
+ if (currentProcess == null) {
+ return null;
+ } else {
+ if (currentProcess.IsRunning) return null;
+ return currentProcess;
+ }
+ }
+ set {
+ currentProcess = value;
+ }
+ }
+
+ public Thread CurrentThread {
+ get {
+ if (IsRunning) return null;
+ if (CurrentProcess == null) return null;
+ return CurrentProcess.CurrentThread;
+ }
+ set {
+ if (CurrentProcess != null) {
+ CurrentProcess.CurrentThread = value;
+ }
+ }
+ }
+
+ public Function CurrentFunction {
+ get {
+ if (IsRunning) return null;
+ if (CurrentThread == null) {
+ return null;
+ } else {
+ return CurrentThread.CurrentFunction;
+ }
+ }
+ set {
+ if (CurrentThread != null) {
+ CurrentThread.CurrentFunction = value;
+ }
+ }
+ }
+
+ public void AssertPaused()
+ {
+ if (!IsPaused) {
+ throw new DebuggerException("Debugger is not paused.");
+ }
+ }
+
+ public void AssertRunning()
+ {
+ if (IsPaused) {
+ throw new DebuggerException("Debugger is not running.");
+ }
+ }
+
+ public bool IsPaused {
+ get {
+ return isPaused;
+ }
+ }
+
+ public bool IsRunning {
+ get {
+ return !isPaused;
+ }
+ }
+
+ internal void Pause(PausedReason reason, Process process, Thread thread)
+ {
+ if (IsPaused) {
+ throw new DebuggerException("Already paused");
+ }
+ isPaused = true;
+ SetUpEnvironment(process, thread);
+ OnDebuggingPaused(reason);
+ }
+
+ internal void FakePause(PausedReason reason)
+ {
+ Process process = CurrentProcess;
+ Thread thread = CurrentThread;
+ Resume();
+ Pause(reason, process, thread);
+ }
+
+ internal void Resume()
+ {
+ if (!IsPaused) {
+ throw new DebuggerException("Already resumed");
+ }
+ OnDebuggingResumed();
+ isPaused = false;
+ }
+
+ void SetUpEnvironment(Process process, Thread thread)
+ {
+ CleanEnvironment();
+
+ // Set the CurrentProcess
+ if (process == null) {
+ if (thread != null) {
+ process = thread.Process;
+ }
+ }
+ currentProcess = process;
+
+ // Set the CurrentThread
+ if (process != null) {
+ if (thread != null) {
+ process.SetCurrentThread(thread);
+ } else {
+ IList threads = process.Threads;
+ if (threads.Count > 0) {
+ process.SetCurrentThread(threads[0]);
+ } else {
+ process.SetCurrentThread(null);
+ }
+ }
+ }
+
+ // CurrentFunctions in threads are fetched on request
+ }
+
+ void CleanEnvironment()
+ {
+ // Remove all stored functions,
+ // they are disponsed between callbacks and
+ // they need to be regenerated
+ foreach(Thread t in Threads) {
+ t.ClearCurrentFunction();
+ }
+
+ // Clear current thread
+ if (currentProcess != null) {
+ currentProcess.SetCurrentThread(null);
+ }
+ // Clear current process
+ currentProcess = null;
+ }
+
+ public void Break()
+ {
+ foreach(Process p in Processes) {
+ if (p.IsRunning) {
+ p.Break();
+ }
+ }
+ }
+
+ public void StepInto()
+ {
+ CurrentFunction.StepInto();
+ }
+
+ public void StepOver()
+ {
+ CurrentFunction.StepOver();
+ }
+
+ public void StepOut()
+ {
+ CurrentFunction.StepOut();
+ }
+
+ public void Continue()
+ {
+ CurrentProcess.Continue();
+ }
+
+ public void Terminate()
+ {
+ foreach(Process p in Processes) {
+ p.Terminate();
+ }
+ }
+ }
+}
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
index ec6342adfa..ac0e37c7d5 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
@@ -26,8 +26,6 @@ namespace DebuggerLibrary
ApartmentState requiredApartmentState;
EvalQueue evalQueue;
-
- bool pauseOnHandledException = false;
internal EvalQueue EvalQueue {
get {
@@ -47,15 +45,6 @@ namespace DebuggerLibrary
}
}
- public bool PauseOnHandledException {
- get {
- return pauseOnHandledException;
- }
- set {
- pauseOnHandledException = value;
- }
- }
-
internal ManagedCallback ManagedCallback {
get {
return managedCallback;
@@ -110,32 +99,6 @@ namespace DebuggerLibrary
TraceMessage("Reset done");
}
- #region Public events
-
- public event EventHandler DebuggingPaused;
-
- protected internal virtual void OnDebuggingPaused(PausedReason reason)
- {
- TraceMessage ("Debugger event: OnDebuggingPaused(" + reason.ToString() + ")");
- if (DebuggingPaused != null) {
- DebuggingPausedEventArgs args = new DebuggingPausedEventArgs(this, reason);
- DebuggingPaused(this, args);
- if (args.ResumeDebugging) {
- Continue();
- }
- }
- }
-
-
- public event EventHandler DebuggingResumed;
-
- protected internal virtual void OnDebuggingResumed()
- {
- TraceMessage ("Debugger event: OnDebuggingResumed()");
- if (DebuggingResumed != null) {
- DebuggingResumed(this, new DebuggerEventArgs(this));
- }
- }
///
/// Fired when System.Diagnostics.Trace.WriteLine() is called in debuged process
@@ -169,8 +132,6 @@ namespace DebuggerLibrary
}
- #endregion
-
public void StartWithoutDebugging(System.Diagnostics.ProcessStartInfo psi)
{
System.Diagnostics.Process process;
@@ -184,76 +145,25 @@ namespace DebuggerLibrary
Process process = Process.CreateProcess(this, filename, workingDirectory, arguments);
AddProcess(process);
}
-
- public Function CurrentFunction {
- get {
- if (IsCurrentThreadSafeForInspection) {
- return CurrentThread.CurrentFunction;
- } else {
- return null;
- }
- }
- set {
- if (IsCurrentThreadSafeForInspection) {
- CurrentThread.CurrentFunction = value;
- }
- }
- }
-
- public bool IsCurrentFunctionSafeForInspection {
- get {
- if (IsCurrentThreadSafeForInspection &&
- CurrentThread.CurrentFunction != null &&
- CurrentThread.CurrentFunction.HasSymbols) {
- return true;
- } else {
- return false;
- }
- }
- }
public SourcecodeSegment NextStatement {
get {
- if (!IsCurrentFunctionSafeForInspection) return null;
- return CurrentProcess.CurrentThread.CurrentFunction.NextStatement;
+ if (CurrentFunction == null) {
+ return null;
+ } else {
+ return CurrentFunction.NextStatement;
+ }
}
}
public VariableCollection LocalVariables {
get {
- if (!IsCurrentFunctionSafeForInspection) return VariableCollection.Empty;
- return CurrentProcess.CurrentThread.CurrentFunction.GetVariables();
+ if (CurrentFunction == null) {
+ return VariableCollection.Empty;
+ } else {
+ return CurrentFunction.GetVariables();
+ }
}
}
-
- public void Break()
- {
- CurrentProcess.Break();
- }
-
- public void StepInto()
- {
- CurrentProcess.CurrentThread.CurrentFunction.StepInto();
- }
-
- public void StepOver()
- {
- CurrentProcess.CurrentThread.CurrentFunction.StepOver();
- }
-
- public void StepOut()
- {
- CurrentProcess.CurrentThread.CurrentFunction.StepOut();
- }
-
- public void Continue()
- {
- CurrentProcess.Continue();
- }
-
- public void Terminate()
- {
- CurrentProcess.Terminate();
- }
}
}
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
index c3d80d7921..49931eec26 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
@@ -317,6 +317,8 @@ namespace DebuggerLibrary
SourcecodeSegment SetIP(bool simulate, string filename, int line, int column)
{
+ debugger.AssertPaused();
+
SourcecodeSegment suggestion = new SourcecodeSegment(filename, line, column, column);
ICorDebugFunction corFunction;
int ilOffset;
@@ -333,10 +335,7 @@ namespace DebuggerLibrary
corILFrame.CanSetIP((uint)ilOffset);
} else {
corILFrame.SetIP((uint)ilOffset);
- Thread thread = debugger.CurrentThread;
- debugger.OnDebuggingResumed();
- thread.CurrentFunction = thread.LastFunctionWithLoadedSymbols;
- debugger.OnDebuggingPaused(PausedReason.SetIP);
+ debugger.FakePause(PausedReason.SetIP);
}
} catch {
return null;
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs
index ab06732bd6..047583d884 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs
@@ -27,37 +27,6 @@ namespace DebuggerLibrary
}
}
- public Process CurrentProcess {
- get {
- if (currentProcess == null && Processes.Count > 0) {
- currentProcess = Processes[0];
- }
- return currentProcess;
- }
- set {
- currentProcess = value;
- }
- }
-
- public bool IsCurrentProcessSafeForInspection {
- get {
- if (CurrentProcess == null) {
- return false;
- } else {
- return CurrentProcess.IsProcessSafeForInspection;
- }
- }
- }
-
- internal void CheckThatCurrentProcessIsSafeForInspection()
- {
- if (CurrentProcess == null) {
- throw new DebuggerException("There is no process being debugged.");
- } else {
- CurrentProcess.CheckThatProcessIsSafeForInspection();
- }
- }
-
internal Process GetProcess(ICorDebugProcess corProcess)
{
foreach (Process process in Processes) {
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs
index 26188b73c7..a107c42b64 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs
@@ -46,22 +46,6 @@ namespace DebuggerLibrary
return threadCollection.AsReadOnly();
}
}
-
- public Thread CurrentThread {
- get {
- if (CurrentProcess == null) return null;
- return CurrentProcess.CurrentThread;
- }
- set {
- CurrentProcess.CurrentThread = value;
- }
- }
-
- public bool IsCurrentThreadSafeForInspection {
- get {
- return IsCurrentProcessSafeForInspection;
- }
- }
internal Thread GetThread(ICorDebugThread corThread)
{
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
index 9b37179555..3f40e1d7da 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
@@ -38,21 +38,18 @@ namespace DebuggerLibrary
public Thread CurrentThread {
get {
- if (currentThread != null) return currentThread;
- IList threads = Threads;
- if (currentThread == null && threads.Count > 0) {
- currentThread = threads[0];
- return currentThread;
- }
- return null;
+ return currentThread;
}
set {
currentThread = value;
- if (debugger.ManagedCallback.HandlingCallback == false) {
- debugger.OnDebuggingPaused(PausedReason.CurrentThreadChanged);
- }
+ debugger.FakePause(PausedReason.CurrentThreadChanged);
}
}
+
+ internal void SetCurrentThread(Thread thread)
+ {
+ currentThread = thread;
+ }
public IList Threads {
get {
@@ -117,7 +114,7 @@ namespace DebuggerLibrary
return new Process(debugger, outProcess);
}
- public void Break()
+ internal void Break()
{
if (!isProcessRunning) {
throw new DebuggerException("Invalid operation");
@@ -126,7 +123,7 @@ namespace DebuggerLibrary
corProcess.Stop(5000); // TODO: Hardcoded value
isProcessRunning = false;
- debugger.OnDebuggingPaused(PausedReason.Break);
+ debugger.Pause(PausedReason.Break, this, null);
}
public void Continue()
@@ -135,11 +132,18 @@ namespace DebuggerLibrary
throw new DebuggerException("Invalid operation");
}
+ debugger.Resume();
isProcessRunning = true;
- if (debugger.ManagedCallback.HandlingCallback == false) {
- debugger.OnDebuggingResumed();
+ corProcess.Continue(0);
+ }
+
+ internal void ContinueCallback()
+ {
+ if (isProcessRunning) {
+ throw new DebuggerException("Invalid operation");
}
+ isProcessRunning = true;
corProcess.Continue(0);
}
@@ -156,7 +160,7 @@ namespace DebuggerLibrary
corProcess.Terminate(0);
}
- public bool IsProcessRunning {
+ public bool IsRunning {
get {
return isProcessRunning;
}
@@ -164,26 +168,17 @@ namespace DebuggerLibrary
isProcessRunning = value;
}
}
-
- public bool IsProcessSafeForInspection {
+
+ public bool IsPaused {
get {
- if (isProcessRunning) return false;
- if (CurrentThread == null) return false;
-
- return true;
+ return !isProcessRunning;
}
}
-
- internal void CheckThatProcessIsSafeForInspection()
+
+ public void AssertPaused()
{
- if (!IsProcessSafeForInspection) {
- if (isProcessRunning) {
- throw new DebuggerException("Process is not safe for inspection because it is running.");
- } else if (CurrentThread == null){
- throw new DebuggerException("Process is not safe for inspection because it has no thread.");
- } else {
- throw new DebuggerException("Process is not safe for inspection.");
- }
+ if (!IsPaused) {
+ throw new DebuggerException("Process is not paused.");
}
}
}
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
index bbc65ae13c..978dd4a143 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
@@ -84,7 +84,7 @@ namespace DebuggerLibrary
public bool Suspended {
get {
- if (!process.IsProcessSafeForInspection) return lastSuspendedState;
+ if (process.IsRunning) return lastSuspendedState;
CorDebugThreadState state;
corThread.GetDebugState(out state);
@@ -99,7 +99,7 @@ namespace DebuggerLibrary
public ThreadPriority Priority {
get {
if (!HasBeenLoaded) return lastPriority;
- if (!process.IsProcessSafeForInspection) return lastPriority;
+ if (process.IsRunning) return lastPriority;
Variable runTimeVar = RuntimeVariable;
if (runTimeVar is NullRefVariable) return ThreadPriority.Normal;
@@ -111,7 +111,7 @@ namespace DebuggerLibrary
public Variable RuntimeVariable {
get {
if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet");
- process.CheckThatProcessIsSafeForInspection();
+ process.AssertPaused();
ICorDebugValue corValue;
corThread.GetObject(out corValue);
@@ -122,7 +122,7 @@ namespace DebuggerLibrary
public string Name {
get {
if (!HasBeenLoaded) return lastName;
- if (!process.IsProcessSafeForInspection) return lastName;
+ if (process.IsRunning) return lastName;
Variable runtimeVar = RuntimeVariable;
if (runtimeVar is NullRefVariable) return lastName;
Variable runtimeName = runtimeVar.SubVariables["m_Name"];
@@ -187,7 +187,7 @@ namespace DebuggerLibrary
get {
List callstack = new List();
- if (!process.IsProcessSafeForInspection) return callstack;
+ if (process.IsRunning) return callstack;
ICorDebugChainEnum corChainEnum;
corThread.EnumerateChains(out corChainEnum);
@@ -227,13 +227,17 @@ namespace DebuggerLibrary
public Function CurrentFunction {
get {
- process.CheckThatProcessIsSafeForInspection();
+ process.AssertPaused();
if (currentFunction == null) {
currentFunction = LastFunctionWithLoadedSymbols;
}
-
- return currentFunction;
+
+ if (currentFunction != null && currentFunction.HasSymbols) {
+ return currentFunction;
+ } else {
+ return null;
+ }
}
set {
if (value != null && !value.HasSymbols) {
@@ -242,11 +246,14 @@ namespace DebuggerLibrary
currentFunction = value;
- if (debugger.ManagedCallback.HandlingCallback == false) {
- debugger.OnDebuggingPaused(PausedReason.CurrentFunctionChanged);
- }
+ debugger.FakePause(PausedReason.CurrentFunctionChanged);
}
}
+
+ internal void ClearCurrentFunction()
+ {
+ currentFunction = null;
+ }
public Function LastFunctionWithLoadedSymbols {
get {
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
index da769e6378..10b52e39dd 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
@@ -58,7 +58,7 @@ namespace DebuggerLibrary
///
public void AsyncPerformEval()
{
- debugger.CheckThatCurrentProcessIsSafeForInspection();
+ debugger.AssertPaused();
debugger.CurrentThread.CorThread.CreateEval(out corEval);