Browse Source

Added some error messages, worked on function and thread switching

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@259 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 21 years ago
parent
commit
15f12a2d08
  1. 10
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
  2. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  3. 75
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs
  4. 18
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  5. 9
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  6. 38
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs
  7. 11
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
  8. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs

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

@ -89,8 +89,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
if (debuggerCore.IsPaused) { if (debuggerCore.IsPaused) {
Function f = (Function)(callStackList.SelectedItems[0].Tag); Function f = (Function)(callStackList.SelectedItems[0].Tag);
if (f.HasSymbols) { if (f.HasSymbols) {
debuggerCore.CurrentFunction = f; if (debuggerCore.CurrentThread != null) {
debuggerCore.CurrentThread.SetCurrentFunction(f);
}
} else {
MessageBox.Show("You can not switch to function without symbols", "Function switch");
} }
} else {
MessageBox.Show("You can not switch functions while the debugger is running.", "Function switch");
} }
} }
@ -112,7 +118,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
foreach (Function f in debuggerCore.CurrentThread.Callstack) { foreach (Function f in debuggerCore.CurrentThread.Callstack) {
ListViewItem item = new ListViewItem(new string[] { f.Name, "" }); ListViewItem item = new ListViewItem(new string[] { f.Name, "" });
item.Tag = f; item.Tag = f;
item.ForeColor = f.Module.SymbolsLoaded ? Color.Black : Color.Gray; item.ForeColor = f.HasSymbols ? Color.Black : Color.Gray;
callStackList.Items.Add(item); callStackList.Items.Add(item);
} }
} }

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

@ -115,8 +115,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
if (debuggerCore.IsPaused) { if (debuggerCore.IsPaused) {
((VariableListItem)e.Item).PrepareForExpansion(); ((VariableListItem)e.Item).PrepareForExpansion();
} else { } else {
// TODO: Some message telling user that he can not explore variable since MessageBox.Show("You can not explore variables while the debuggee is running.");
// the debugger has been resumed.
e.Cancel = true; e.Cancel = true;
} }
} }

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

@ -78,10 +78,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
debuggerCore = debugger.DebuggerCore; debuggerCore = debugger.DebuggerCore;
debuggerCore.ThreadStarted += new EventHandler<ThreadEventArgs>(AddThread);
debuggerCore.ThreadStateChanged += new EventHandler<ThreadEventArgs>(RefreshThread);
debuggerCore.ThreadExited += new EventHandler<ThreadEventArgs>(RemoveThread);
debuggerCore.DebuggingPaused += new EventHandler<DebuggingPausedEventArgs>(OnDebuggingPaused); debuggerCore.DebuggingPaused += new EventHandler<DebuggingPausedEventArgs>(OnDebuggingPaused);
debuggerCore.ThreadStarted += new EventHandler<ThreadEventArgs>(ThreadStarted);
debuggerCore.ThreadStateChanged += new EventHandler<ThreadEventArgs>(ThreadStateChanged);
debuggerCore.ThreadExited += new EventHandler<ThreadEventArgs>(ThreadExited);
RefreshList(); RefreshList();
} }
@ -94,11 +94,22 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
priority.Text = "Priority"; priority.Text = "Priority";
breaked.Text = "Breaked"; breaked.Text = "Breaked";
} }
void RefreshList()
{
foreach (Thread t in debuggerCore.Threads) {
RefreshThread(t);
}
}
void RunningThreadsListItemActivate(object sender, EventArgs e) void RunningThreadsListItemActivate(object sender, EventArgs e)
{ {
if (debuggerCore.IsPaused) { if (debuggerCore.IsPaused) {
debuggerCore.CurrentThread = (Thread)(runningThreadsList.SelectedItems[0].Tag); if (debuggerCore.CurrentProcess != null) {
debuggerCore.CurrentProcess.SetCurrentThread((Thread)(runningThreadsList.SelectedItems[0].Tag));
}
} else {
MessageBox.Show("You can not switch threads while the debugger is running.", "Thread switch");
} }
} }
@ -107,50 +118,60 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
RefreshList(); RefreshList();
} }
private void AddThread(object sender, ThreadEventArgs e) void ThreadStarted(object sender, ThreadEventArgs e)
{ {
runningThreadsList.Items.Add(new ListViewItem(e.Thread.ID.ToString())); AddThread(e.Thread);
RefreshThread(this, e);
} }
private void RefreshThread(object sender, ThreadEventArgs e) void ThreadStateChanged(object sender, ThreadEventArgs e)
{
RefreshThread(e.Thread);
}
void ThreadExited(object sender, ThreadEventArgs e)
{
RemoveThread(e.Thread);
}
void AddThread(Thread thread)
{
runningThreadsList.Items.Add(new ListViewItem(thread.ID.ToString()));
RefreshThread(thread);
}
void RefreshThread(Thread thread)
{ {
foreach (ListViewItem item in runningThreadsList.Items) { foreach (ListViewItem item in runningThreadsList.Items) {
if (e.Thread.ID.ToString() == item.Text) { if (thread.ID.ToString() == item.Text) {
item.SubItems.Clear(); item.SubItems.Clear();
item.Text = e.Thread.ID.ToString(); item.Text = thread.ID.ToString();
item.Tag = e.Thread; item.Tag = thread;
item.SubItems.Add(e.Thread.Name); item.SubItems.Add(thread.Name);
Function location; Function location;
location = e.Thread.LastFunctionWithLoadedSymbols; location = thread.LastFunctionWithLoadedSymbols;
if (location == null) { if (location == null) {
location = e.Thread.LastFunction; location = thread.LastFunction;
} }
if (location != null) { if (location != null) {
item.SubItems.Add(location.Name); item.SubItems.Add(location.Name);
} else { } else {
item.SubItems.Add("N/A"); item.SubItems.Add("N/A");
} }
item.SubItems.Add(e.Thread.Priority.ToString()); item.SubItems.Add(thread.Priority.ToString());
item.SubItems.Add(e.Thread.Suspended.ToString()); item.SubItems.Add(thread.Suspended.ToString());
return; return;
} }
} }
AddThread(this, e); AddThread(thread);
} }
private void RemoveThread(object sender, ThreadEventArgs e) void RemoveThread(Thread thread)
{ {
foreach (ListViewItem item in runningThreadsList.Items) { foreach (ListViewItem item in runningThreadsList.Items) {
if (e.Thread.ID.ToString() == item.Text) if (thread.ID.ToString() == item.Text) {
item.Remove(); item.Remove();
} }
}
private void RefreshList()
{
foreach (Thread t in debuggerCore.Threads) {
RefreshThread(this, new ThreadEventArgs(debuggerCore, t));
} }
} }
} }

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

@ -155,17 +155,29 @@ namespace ICSharpCode.SharpDevelop.Services
public void StepInto() public void StepInto()
{ {
debugger.StepInto(); if (debugger.CurrentFunction == null) {
MessageBox.Show("You can not step because there is no function selected to be stepped","Step into");
} else {
debugger.StepInto();
}
} }
public void StepOver() public void StepOver()
{ {
debugger.StepOver(); if (debugger.CurrentFunction == null) {
MessageBox.Show("You can not step because there is no function selected to be stepped","Step over");
} else {
debugger.StepOver();
}
} }
public void StepOut() public void StepOut()
{ {
debugger.StepOut(); if (debugger.CurrentFunction == null) {
MessageBox.Show("You can not step because there is no function selected to be stepped","Step out");
} else {
debugger.StepOut();
}
} }
public bool SupportsStepping { public bool SupportsStepping {

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

@ -78,6 +78,7 @@ namespace DebuggerLibrary
{ {
handlingCallback = true; handlingCallback = true;
debugger.TraceMessage("Callback: " + name); debugger.TraceMessage("Callback: " + name);
debugger.AssertRunning();
} }
void ExitCallback_Continue() void ExitCallback_Continue()
@ -97,7 +98,7 @@ namespace DebuggerLibrary
handlingCallback = false; handlingCallback = false;
debugger.Pause(reason, callingProcess, callingThread); debugger.Pause(reason, callingProcess, callingThread, null);
callingThread = null; callingThread = null;
callingProcess = null; callingProcess = null;
@ -337,7 +338,7 @@ namespace DebuggerLibrary
debugger.RemoveThread(thread); debugger.RemoveThread(thread);
if (thread.Process.CurrentThread == thread) { if (thread.Process.CurrentThread == thread) {
thread.Process.SetCurrentThread(null); thread.Process.CurrentThread = null;
} }
ExitCallback_Continue(); ExitCallback_Continue();
@ -358,10 +359,6 @@ namespace DebuggerLibrary
debugger.RemoveProcess(process); debugger.RemoveProcess(process);
if (debugger.CurrentProcess == process) {
debugger.CurrentProcess = null;
}
if (debugger.Processes.Count == 0) { if (debugger.Processes.Count == 0) {
debugger.ResetEnvironment(); debugger.ResetEnvironment();
} }

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

@ -64,9 +64,6 @@ namespace DebuggerLibrary
return currentProcess; return currentProcess;
} }
} }
set {
currentProcess = value;
}
} }
public Thread CurrentThread { public Thread CurrentThread {
@ -75,11 +72,6 @@ namespace DebuggerLibrary
if (CurrentProcess == null) return null; if (CurrentProcess == null) return null;
return CurrentProcess.CurrentThread; return CurrentProcess.CurrentThread;
} }
set {
if (CurrentProcess != null) {
CurrentProcess.CurrentThread = value;
}
}
} }
public Function CurrentFunction { public Function CurrentFunction {
@ -91,11 +83,6 @@ namespace DebuggerLibrary
return CurrentThread.CurrentFunction; return CurrentThread.CurrentFunction;
} }
} }
set {
if (CurrentThread != null) {
CurrentThread.CurrentFunction = value;
}
}
} }
public void AssertPaused() public void AssertPaused()
@ -124,13 +111,13 @@ namespace DebuggerLibrary
} }
} }
internal void Pause(PausedReason reason, Process process, Thread thread) internal void Pause(PausedReason reason, Process process, Thread thread, Function function)
{ {
if (IsPaused) { if (IsPaused) {
throw new DebuggerException("Already paused"); throw new DebuggerException("Already paused");
} }
isPaused = true; isPaused = true;
SetUpEnvironment(process, thread); SetUpEnvironment(process, thread, function);
OnDebuggingPaused(reason); OnDebuggingPaused(reason);
} }
@ -138,8 +125,9 @@ namespace DebuggerLibrary
{ {
Process process = CurrentProcess; Process process = CurrentProcess;
Thread thread = CurrentThread; Thread thread = CurrentThread;
Function function = CurrentFunction;
Resume(); Resume();
Pause(reason, process, thread); Pause(reason, process, thread, function);
} }
internal void Resume() internal void Resume()
@ -151,7 +139,7 @@ namespace DebuggerLibrary
isPaused = false; isPaused = false;
} }
void SetUpEnvironment(Process process, Thread thread) void SetUpEnvironment(Process process, Thread thread, Function function)
{ {
CleanEnvironment(); CleanEnvironment();
@ -166,18 +154,22 @@ namespace DebuggerLibrary
// Set the CurrentThread // Set the CurrentThread
if (process != null) { if (process != null) {
if (thread != null) { if (thread != null) {
process.SetCurrentThread(thread); process.CurrentThread = thread;
} else { } else {
IList<Thread> threads = process.Threads; IList<Thread> threads = process.Threads;
if (threads.Count > 0) { if (threads.Count > 0) {
process.SetCurrentThread(threads[0]); process.CurrentThread = threads[0];
} else { } else {
process.SetCurrentThread(null); process.CurrentThread = null;
} }
} }
} }
// CurrentFunctions in threads are fetched on request // Set the CurrentFunction
// Other CurrentFunctions in threads are fetched on request
if (thread != null && function != null) {
thread.CurrentFunction = function;
}
} }
void CleanEnvironment() void CleanEnvironment()
@ -186,12 +178,12 @@ namespace DebuggerLibrary
// they are disponsed between callbacks and // they are disponsed between callbacks and
// they need to be regenerated // they need to be regenerated
foreach(Thread t in Threads) { foreach(Thread t in Threads) {
t.ClearCurrentFunction(); t.CurrentFunction = null;
} }
// Clear current thread // Clear current thread
if (currentProcess != null) { if (currentProcess != null) {
currentProcess.SetCurrentThread(null); currentProcess.CurrentThread = null;
} }
// Clear current process // Clear current process
currentProcess = null; currentProcess = null;

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

@ -40,15 +40,16 @@ namespace DebuggerLibrary
get { get {
return currentThread; return currentThread;
} }
set { internal set {
currentThread = value; currentThread = value;
debugger.FakePause(PausedReason.CurrentThreadChanged);
} }
} }
internal void SetCurrentThread(Thread thread) public void SetCurrentThread(Thread thread)
{ {
currentThread = thread; CurrentThread = thread;
debugger.FakePause(PausedReason.CurrentThreadChanged);
} }
public IList<Thread> Threads { public IList<Thread> Threads {
@ -123,7 +124,7 @@ namespace DebuggerLibrary
corProcess.Stop(5000); // TODO: Hardcoded value corProcess.Stop(5000); // TODO: Hardcoded value
isProcessRunning = false; isProcessRunning = false;
debugger.Pause(PausedReason.Break, this, null); debugger.Pause(PausedReason.Break, this, null, null);
} }
public void Continue() public void Continue()

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

@ -239,20 +239,20 @@ namespace DebuggerLibrary
return null; return null;
} }
} }
set { internal set {
if (value != null && !value.HasSymbols) { if (value != null && !value.HasSymbols) {
throw new DebuggerException("CurrentFunction must have symbols"); throw new DebuggerException("CurrentFunction must have symbols");
} }
currentFunction = value; currentFunction = value;
debugger.FakePause(PausedReason.CurrentFunctionChanged);
} }
} }
internal void ClearCurrentFunction() public void SetCurrentFunction(Function function)
{ {
currentFunction = null; CurrentFunction = function;
debugger.FakePause(PausedReason.CurrentFunctionChanged);
} }
public Function LastFunctionWithLoadedSymbols { public Function LastFunctionWithLoadedSymbols {

Loading…
Cancel
Save