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ý 20 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 @@ -89,8 +89,14 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
if (debuggerCore.IsPaused) {
Function f = (Function)(callStackList.SelectedItems[0].Tag);
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 @@ -112,7 +118,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
foreach (Function f in debuggerCore.CurrentThread.Callstack) {
ListViewItem item = new ListViewItem(new string[] { f.Name, "" });
item.Tag = f;
item.ForeColor = f.Module.SymbolsLoaded ? Color.Black : Color.Gray;
item.ForeColor = f.HasSymbols ? Color.Black : Color.Gray;
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 @@ -115,8 +115,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
if (debuggerCore.IsPaused) {
((VariableListItem)e.Item).PrepareForExpansion();
} else {
// TODO: Some message telling user that he can not explore variable since
// the debugger has been resumed.
MessageBox.Show("You can not explore variables while the debuggee is running.");
e.Cancel = true;
}
}

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

@ -78,10 +78,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -78,10 +78,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{
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.ThreadStarted += new EventHandler<ThreadEventArgs>(ThreadStarted);
debuggerCore.ThreadStateChanged += new EventHandler<ThreadEventArgs>(ThreadStateChanged);
debuggerCore.ThreadExited += new EventHandler<ThreadEventArgs>(ThreadExited);
RefreshList();
}
@ -94,11 +94,22 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -94,11 +94,22 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
priority.Text = "Priority";
breaked.Text = "Breaked";
}
void RefreshList()
{
foreach (Thread t in debuggerCore.Threads) {
RefreshThread(t);
}
}
void RunningThreadsListItemActivate(object sender, EventArgs e)
{
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 @@ -107,50 +118,60 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
RefreshList();
}
private void AddThread(object sender, ThreadEventArgs e)
void ThreadStarted(object sender, ThreadEventArgs e)
{
runningThreadsList.Items.Add(new ListViewItem(e.Thread.ID.ToString()));
RefreshThread(this, e);
AddThread(e.Thread);
}
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) {
if (e.Thread.ID.ToString() == item.Text) {
if (thread.ID.ToString() == item.Text) {
item.SubItems.Clear();
item.Text = e.Thread.ID.ToString();
item.Tag = e.Thread;
item.SubItems.Add(e.Thread.Name);
item.Text = thread.ID.ToString();
item.Tag = thread;
item.SubItems.Add(thread.Name);
Function location;
location = e.Thread.LastFunctionWithLoadedSymbols;
location = thread.LastFunctionWithLoadedSymbols;
if (location == null) {
location = e.Thread.LastFunction;
location = thread.LastFunction;
}
if (location != null) {
item.SubItems.Add(location.Name);
} else {
item.SubItems.Add("N/A");
}
item.SubItems.Add(e.Thread.Priority.ToString());
item.SubItems.Add(e.Thread.Suspended.ToString());
item.SubItems.Add(thread.Priority.ToString());
item.SubItems.Add(thread.Suspended.ToString());
return;
}
}
AddThread(this, e);
AddThread(thread);
}
private void RemoveThread(object sender, ThreadEventArgs e)
void RemoveThread(Thread thread)
{
foreach (ListViewItem item in runningThreadsList.Items) {
if (e.Thread.ID.ToString() == item.Text)
if (thread.ID.ToString() == item.Text) {
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 @@ -155,17 +155,29 @@ namespace ICSharpCode.SharpDevelop.Services
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()
{
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()
{
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 {

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

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

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

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

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

@ -40,15 +40,16 @@ namespace DebuggerLibrary @@ -40,15 +40,16 @@ namespace DebuggerLibrary
get {
return currentThread;
}
set {
internal set {
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 {
@ -123,7 +124,7 @@ namespace DebuggerLibrary @@ -123,7 +124,7 @@ namespace DebuggerLibrary
corProcess.Stop(5000); // TODO: Hardcoded value
isProcessRunning = false;
debugger.Pause(PausedReason.Break, this, null);
debugger.Pause(PausedReason.Break, this, null, null);
}
public void Continue()

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

@ -239,20 +239,20 @@ namespace DebuggerLibrary @@ -239,20 +239,20 @@ namespace DebuggerLibrary
return null;
}
}
set {
internal set {
if (value != null && !value.HasSymbols) {
throw new DebuggerException("CurrentFunction must have symbols");
}
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 {

Loading…
Cancel
Save