Browse Source

Handling of CurrentThread and CurrentFunction changed

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@201 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
b1610ce327
  1. 9
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
  2. 7
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs
  3. 31
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  4. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/DebuggerEvents/PausedReason.cs
  5. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  6. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  7. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
  8. 27
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs

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

@ -87,8 +87,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -87,8 +87,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void CallStackListItemActivate(object sender, EventArgs e)
{
debugger.selectedFunction = (Function)(callStackList.SelectedItems[0].Tag);
debugger.JumpToCurrentLine();
if (!debuggerCore.IsProcessRunning) {
debuggerCore.CurrentThread.CurrentFunction = (Function)(callStackList.SelectedItems[0].Tag);
}
}
public void DebuggerStateChanged(object sender, DebuggerEventArgs e)
@ -100,8 +101,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -100,8 +101,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{
callStackList.BeginUpdate();
callStackList.Items.Clear();
if (debugger.IsProcessRunning == false && debugger.selectedThread != null) {
foreach (Function f in debugger.selectedThread.Callstack) {
if (debugger.IsProcessRunning == false && debuggerCore.CurrentThread != null) {
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;

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

@ -98,10 +98,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -98,10 +98,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void RunningThreadsListItemActivate(object sender, EventArgs e)
{
debugger.SelectThread((Thread)(runningThreadsList.SelectedItems[0].Tag));
debugger.JumpToCurrentLine();
CallStackPad callStackPad = (CallStackPad)WorkbenchSingleton.Workbench.GetPad(typeof(CallStackPad)).PadContent;
callStackPad.RefreshList();
if (!debugger.IsProcessRunning) {
debuggerCore.CurrentThread = (Thread)(runningThreadsList.SelectedItems[0].Tag);
}
}

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

@ -115,8 +115,6 @@ namespace ICSharpCode.SharpDevelop.Services @@ -115,8 +115,6 @@ namespace ICSharpCode.SharpDevelop.Services
MessageViewCategory messageViewCategoryDebug;
MessageViewCategory messageViewCategoryDebuggerLog;
public Thread selectedThread;
public Function selectedFunction;
public bool ServiceInitialized {
get {
@ -381,16 +379,11 @@ namespace ICSharpCode.SharpDevelop.Services @@ -381,16 +379,11 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
try {
SelectThread(debugger.CurrentThread);
} catch (CurrentThreadNotAviableException) {}
JumpToCurrentLine();
}
void DebuggingResumed(object sender, DebuggerEventArgs e)
{
selectedThread = null;
selectedFunction = null;
DebuggerService.RemoveCurrentLineMarker();
}
@ -399,34 +392,12 @@ namespace ICSharpCode.SharpDevelop.Services @@ -399,34 +392,12 @@ namespace ICSharpCode.SharpDevelop.Services
exceptionHistory.Clear();
//DebuggerService.Stop();//TODO: delete
}
public void SelectThread(Thread thread)
{
selectedThread = thread;
try {
selectedFunction = thread.CurrentFunction;
// Prefer first function on callstack that has symbols (source code)
if (selectedFunction.Module.SymbolsLoaded == false) {
foreach (Function f in thread.Callstack) {
if (f.Module.SymbolsLoaded) {
selectedFunction = f;
break;
}
}
}
} catch (CurrentFunctionNotAviableException) {}
}
public void JumpToCurrentLine()
{
//StatusBarService.SetMessage("Source code not aviable!");
try {
if (selectedFunction == null) {
return;
}
SourcecodeSegment nextStatement = selectedFunction.NextStatement;
SourcecodeSegment nextStatement = debugger.NextStatement;
DebuggerService.JumpToCurrentLine(nextStatement.SourceFullFilename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn);
string stepRanges = "";

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/DebuggerEvents/PausedReason.cs

@ -13,6 +13,7 @@ namespace DebuggerLibrary @@ -13,6 +13,7 @@ namespace DebuggerLibrary
Exception,
DebuggerError,
EvalComplete,
CurrentThreadChanged
CurrentThreadChanged,
CurrentFunctionChanged
}
}

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

@ -56,6 +56,7 @@ namespace DebuggerLibrary @@ -56,6 +56,7 @@ namespace DebuggerLibrary
void ExitCallback_Paused(PausedReason reason)
{
debugger.CurrentThread.CurrentFunction = debugger.CurrentThread.LastFunctionWithLoadedSymbols;
if (reason != PausedReason.EvalComplete) {
debugger.OnDebuggingPaused(reason);
debugger.OnIsProcessRunningChanged();
@ -256,10 +257,6 @@ namespace DebuggerLibrary @@ -256,10 +257,6 @@ namespace DebuggerLibrary
debugger.AddThread(pThread);
if (debugger.MainThread == null) {
debugger.MainThread = debugger.GetThread(pThread);
}
ExitCallback_Continue(pAppDomain);
}
@ -306,9 +303,6 @@ namespace DebuggerLibrary @@ -306,9 +303,6 @@ namespace DebuggerLibrary
if (debugger.CurrentThread == thread)
debugger.CurrentThread = null;
if (debugger.MainThread == thread)
debugger.MainThread = null;
debugger.RemoveThread(thread);
ExitCallback_Continue(pAppDomain);

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

@ -328,16 +328,6 @@ namespace DebuggerLibrary @@ -328,16 +328,6 @@ namespace DebuggerLibrary
}
}
public Thread MainThread {
get {
if (!IsDebugging) return null;
return CurrentProcess.MainThread;
}
set {
CurrentProcess.MainThread = value;
}
}
public SourcecodeSegment NextStatement {
get {
if (!IsDebugging) return null;

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

@ -18,7 +18,6 @@ namespace DebuggerLibrary @@ -18,7 +18,6 @@ namespace DebuggerLibrary
ICorDebugProcess corProcess;
Thread mainThread;
Thread currentThread;
bool isProcessRunning;
@ -38,28 +37,15 @@ namespace DebuggerLibrary @@ -38,28 +37,15 @@ namespace DebuggerLibrary
get {
if (IsProcessRunning) throw new CurrentThreadNotAviableException();
if (currentThread != null) return currentThread;
if (mainThread != null) return mainThread;
throw new CurrentThreadNotAviableException();
}
set {
currentThread = value;
if (mainThread == null) {
mainThread = value;
}
if (debugger.ManagedCallback.HandlingCallback == false) {
debugger.OnDebuggingPaused(PausedReason.CurrentThreadChanged);
}
}
}
public Thread MainThread {
get {
return mainThread;
}
set {
mainThread = value;
}
}
static public Process CreateProcess(NDebugger debugger, string filename, string workingDirectory, string arguments)
{

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

@ -26,6 +26,8 @@ namespace DebuggerLibrary @@ -26,6 +26,8 @@ namespace DebuggerLibrary
string lastName = string.Empty;
bool hasBeenLoaded = false;
Function currentFunction;
internal bool HasBeenLoaded {
get {
return hasBeenLoaded;
@ -181,17 +183,24 @@ namespace DebuggerLibrary @@ -181,17 +183,24 @@ namespace DebuggerLibrary
public Function CurrentFunction {
get {
if (debugger.IsProcessRunning) throw new CurrentFunctionNotAviableException();
ICorDebugFrame corFrame;
corThread.GetActiveFrame(out corFrame);
if (corFrame == null) {
List<Function> callstack = Callstack;
if (callstack.Count > 0) {
return callstack[0];
} else {
throw new CurrentFunctionNotAviableException();
return currentFunction;
}
set {
currentFunction = value;
if (debugger.ManagedCallback.HandlingCallback == false) {
debugger.OnDebuggingPaused(PausedReason.CurrentFunctionChanged);
}
}
}
public Function LastFunctionWithLoadedSymbols {
get {
foreach (Function function in Callstack) {
if (function.Module.SymbolsLoaded) {
return function;
}
}
return new Function(debugger, corFrame);
return null;
}
}
}

Loading…
Cancel
Save