Browse Source

IsProcessRunningd and IsDebugging replaced with IsCurrentProcessSafeForInspection

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@242 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 21 years ago
parent
commit
19ff0d6ece
  1. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
  2. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  3. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs
  4. 6
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  5. 65
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  6. 29
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
  7. 15
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  8. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs

@ -86,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -86,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void CallStackListItemActivate(object sender, EventArgs e)
{
if (!debuggerCore.IsProcessRunning) {
if (!debuggerCore.IsCurrentProcessSafeForInspection) {
debuggerCore.CurrentThread.CurrentFunction = (Function)(callStackList.SelectedItems[0].Tag);
}
}
@ -105,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -105,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{
callStackList.BeginUpdate();
callStackList.Items.Clear();
if (debugger.IsProcessRunning == false && debuggerCore.CurrentThread != null) {
if (debuggerCore.IsCurrentProcessSafeForInspection) {
foreach (Function f in debuggerCore.CurrentThread.Callstack) {
ListViewItem item = new ListViewItem(new string[] { f.Name, "" });
item.Tag = f;

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs

@ -107,14 +107,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -107,14 +107,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void RefreshList()
{
if (debugger.IsDebugging && debugger.IsProcessRunning == false) {
if (debuggerCore.IsCurrentProcessSafeForInspection) {
UpdateVariables(localVarList.Items, debuggerCore.LocalVariables);
}
}
private void localVarList_BeforeExpand(object sender, TreeListViewCancelEventArgs e)
{
if (debugger.IsDebugging && debugger.IsProcessRunning == false) {
if (debuggerCore.IsCurrentProcessSafeForInspection) {
((VariableListItem)e.Item).PrepareForExpansion();
} else {
// TODO: Some message telling user that he can not explore variable since

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs

@ -97,7 +97,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -97,7 +97,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void RunningThreadsListItemActivate(object sender, EventArgs e)
{
if (!debugger.IsProcessRunning) {
if (debuggerCore.IsCurrentProcessSafeForInspection) {
debuggerCore.CurrentThread = (Thread)(runningThreadsList.SelectedItems[0].Tag);
}
}

6
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -208,7 +208,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -208,7 +208,7 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary>
public string GetValueAsString(string variableName)
{
if (debugger == null || !debugger.IsDebugging || debugger.IsProcessRunning) return null;
if (debugger == null || !debugger.IsCurrentProcessSafeForInspection) return null;
VariableCollection collection = debugger.LocalVariables;
if (collection == null)
return null;
@ -267,8 +267,8 @@ namespace ICSharpCode.SharpDevelop.Services @@ -267,8 +267,8 @@ namespace ICSharpCode.SharpDevelop.Services
RestoreNDebuggerBreakpoints();
isDebuggingCache = debugger.IsDebugging;
isProcessRunningCache = debugger.IsProcessRunning;
isDebuggingCache = false;
isProcessRunningCache = true;
if (Initialize != null) {
Initialize(this, null);

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

@ -53,8 +53,6 @@ namespace DebuggerLibrary @@ -53,8 +53,6 @@ namespace DebuggerLibrary
}
}
#region Basic functions
public NDebugger()
{
requiredApartmentState = System.Threading.Thread.CurrentThread.GetApartmentState();
@ -79,7 +77,6 @@ namespace DebuggerLibrary @@ -79,7 +77,6 @@ namespace DebuggerLibrary
NativeMethods.CreateDebuggingInterfaceFromVersion(3, sb.ToString(), out corDebug);
//corDebug = new CorDebugClass();
managedCallback = new ManagedCallback(this);
managedCallbackProxy = new ManagedCallbackProxy(this, managedCallback);
@ -104,8 +101,6 @@ namespace DebuggerLibrary @@ -104,8 +101,6 @@ namespace DebuggerLibrary
TraceMessage("Reset done");
}
#endregion
#region Public events
public event EventHandler<DebuggingPausedEventArgs> DebuggingPaused;
@ -167,8 +162,6 @@ namespace DebuggerLibrary @@ -167,8 +162,6 @@ namespace DebuggerLibrary
#endregion
#region Execution control
public void StartWithoutDebugging(System.Diagnostics.ProcessStartInfo psi)
{
System.Diagnostics.Process process;
@ -183,56 +176,28 @@ namespace DebuggerLibrary @@ -183,56 +176,28 @@ namespace DebuggerLibrary
AddProcess(process);
}
#endregion
public void ToggleBreakpointAt(string fileName, int line, int column)
{
// Check if there is breakpoint on that line
foreach (Breakpoint breakpoint in Breakpoints) {
// TODO check filename too
if (breakpoint.SourcecodeSegment.StartLine == line) {
RemoveBreakpoint(breakpoint);
return;
}
}
// Add the breakpoint
Breakpoint addedBreakpoint = AddBreakpoint(new SourcecodeSegment(fileName, line), true);
// Check if it wasn't forced to move to different line with breakpoint
foreach (Breakpoint breakpoint in Breakpoints) {
if (breakpoint != addedBreakpoint) { // Only the old ones
if (breakpoint.SourcecodeSegment.StartLine == addedBreakpoint.SourcecodeSegment.StartLine) {
// Whops! We have two breakpoint on signle line, delete one
RemoveBreakpoint(addedBreakpoint);
return;
}
}
}
}
public bool IsProcessRunning {
public bool IsCurrentProcessSafeForInspection {
get {
if (!IsDebugging) return false;
return CurrentProcess.IsProcessRunning;
}
set {
if (CurrentProcess == null) return;
CurrentProcess.IsProcessRunning = value;
if (CurrentProcess == null) {
return false;
} else {
return CurrentProcess.IsProcessSafeForInspection;
}
}
}
public bool IsDebugging {
get {
return (CurrentProcess != null);
internal void CheckThatCurrentProcessIsSafeForInspection()
{
if (CurrentProcess == null) {
throw new DebuggerException("There is no process being debugged.");
} else {
CurrentProcess.CheckThatProcessIsSafeForInspection();
}
}
public Thread CurrentThread {
get {
if (!IsDebugging) return null;
if (CurrentProcess == null) return null;
return CurrentProcess.CurrentThread;
}
set {
@ -242,7 +207,7 @@ namespace DebuggerLibrary @@ -242,7 +207,7 @@ namespace DebuggerLibrary
public SourcecodeSegment NextStatement {
get {
if (!IsDebugging) return null;
if (!IsCurrentProcessSafeForInspection) return null;
if (CurrentProcess.CurrentThread.CurrentFunction == null) {
return null;
} else {
@ -253,7 +218,7 @@ namespace DebuggerLibrary @@ -253,7 +218,7 @@ namespace DebuggerLibrary
public VariableCollection LocalVariables {
get {
if (!IsDebugging) return VariableCollection.Empty;
if (!IsCurrentProcessSafeForInspection) return VariableCollection.Empty;
return CurrentProcess.CurrentThread.CurrentFunction.GetVariables();
}
}

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

@ -38,14 +38,13 @@ namespace DebuggerLibrary @@ -38,14 +38,13 @@ namespace DebuggerLibrary
public Thread CurrentThread {
get {
if (IsProcessRunning) throw new DebuggerException("Process must not be running");
if (currentThread != null) return currentThread;
IList<Thread> threads = Threads;
if (currentThread == null && threads.Count > 0) {
currentThread = threads[0];
return currentThread;
}
throw new DebuggerException("No current thread");
return null;
}
set {
currentThread = value;
@ -120,7 +119,7 @@ namespace DebuggerLibrary @@ -120,7 +119,7 @@ namespace DebuggerLibrary
public void Break()
{
if (!IsProcessRunning) {
if (!isProcessRunning) {
throw new DebuggerException("Invalid operation");
}
@ -132,7 +131,7 @@ namespace DebuggerLibrary @@ -132,7 +131,7 @@ namespace DebuggerLibrary
public void Continue()
{
if (IsProcessRunning) {
if (isProcessRunning) {
throw new DebuggerException("Invalid operation");
}
@ -165,5 +164,27 @@ namespace DebuggerLibrary @@ -165,5 +164,27 @@ namespace DebuggerLibrary
isProcessRunning = value;
}
}
public bool IsProcessSafeForInspection {
get {
if (isProcessRunning) return false;
if (CurrentThread == null) return false;
return true;
}
}
internal void CheckThatProcessIsSafeForInspection()
{
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.");
}
}
}
}
}

15
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs

@ -84,7 +84,7 @@ namespace DebuggerLibrary @@ -84,7 +84,7 @@ namespace DebuggerLibrary
public bool Suspended {
get {
if (debugger.IsProcessRunning) return lastSuspendedState;
if (!process.IsProcessSafeForInspection) return lastSuspendedState;
CorDebugThreadState state;
corThread.GetDebugState(out state);
@ -99,7 +99,7 @@ namespace DebuggerLibrary @@ -99,7 +99,7 @@ namespace DebuggerLibrary
public ThreadPriority Priority {
get {
if (!HasBeenLoaded) return lastPriority;
if (debugger.IsProcessRunning) return lastPriority;
if (!process.IsProcessSafeForInspection) return lastPriority;
Variable runTimeVar = RuntimeVariable;
if (runTimeVar is NullRefVariable) return ThreadPriority.Normal;
@ -111,7 +111,8 @@ namespace DebuggerLibrary @@ -111,7 +111,8 @@ namespace DebuggerLibrary
public Variable RuntimeVariable {
get {
if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet");
if (debugger.IsProcessRunning) throw new DebuggerException("Process is running");
process.CheckThatProcessIsSafeForInspection();
ICorDebugValue corValue;
corThread.GetObject(out corValue);
return VariableFactory.CreateVariable(debugger, corValue, "Thread" + ID);
@ -121,7 +122,7 @@ namespace DebuggerLibrary @@ -121,7 +122,7 @@ namespace DebuggerLibrary
public string Name {
get {
if (!HasBeenLoaded) return lastName;
if (debugger.IsProcessRunning) return lastName;
if (!process.IsProcessSafeForInspection) return lastName;
Variable runtimeVar = RuntimeVariable;
if (runtimeVar is NullRefVariable) return lastName;
Variable runtimeName = runtimeVar.SubVariables["m_Name"];
@ -180,8 +181,7 @@ namespace DebuggerLibrary @@ -180,8 +181,7 @@ namespace DebuggerLibrary
get {
List<Function> callstack = new List<Function>();
if (!debugger.IsDebugging) return callstack;
if (debugger.IsProcessRunning) return callstack;
if (!process.IsProcessSafeForInspection) return callstack;
ICorDebugChainEnum corChainEnum;
corThread.EnumerateChains(out corChainEnum);
@ -219,7 +219,8 @@ namespace DebuggerLibrary @@ -219,7 +219,8 @@ namespace DebuggerLibrary
public Function CurrentFunction {
get {
if (debugger.IsProcessRunning) throw new DebuggerException("Process must not be running");
process.CheckThatProcessIsSafeForInspection();
return currentFunction;
}
set {

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

@ -58,9 +58,7 @@ namespace DebuggerLibrary @@ -58,9 +58,7 @@ namespace DebuggerLibrary
/// </summary>
public void AsyncPerformEval()
{
if (debugger.IsProcessRunning) {
throw new DebuggerException("Debugger must be paused");
}
debugger.CheckThatCurrentProcessIsSafeForInspection();
debugger.CurrentThread.CorThread.CreateEval(out corEval);

Loading…
Cancel
Save