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 58f367aa84..65b618ce9a 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,8 +86,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads void CallStackListItemActivate(object sender, EventArgs e) { - if (debuggerCore.IsCurrentProcessSafeForInspection) { - debuggerCore.CurrentThread.CurrentFunction = (Function)(callStackList.SelectedItems[0].Tag); + if (debuggerCore.IsCurrentThreadSafeForInspection) { + Function f = (Function)(callStackList.SelectedItems[0].Tag); + if (f.HasSymbols) { + debuggerCore.CurrentFunction = f; + } } } @@ -105,7 +108,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads { callStackList.BeginUpdate(); callStackList.Items.Clear(); - if (debuggerCore.IsCurrentProcessSafeForInspection) { + if (debuggerCore.IsCurrentThreadSafeForInspection) { 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/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs index 6ce6766451..ec8b05c028 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 @@ -384,6 +384,7 @@ namespace ICSharpCode.SharpDevelop.Services { SourcecodeSegment nextStatement = debugger.NextStatement; if (nextStatement == null) { + DebuggerService.RemoveCurrentLineMarker(); return; } DebuggerService.JumpToCurrentLine(nextStatement.SourceFullFilename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn); 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 abc5657e4b..ec6342adfa 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 @@ -184,50 +184,44 @@ namespace DebuggerLibrary Process process = Process.CreateProcess(this, filename, workingDirectory, arguments); AddProcess(process); } - - public bool IsCurrentProcessSafeForInspection { + + public Function CurrentFunction { get { - if (CurrentProcess == null) { - return false; + if (IsCurrentThreadSafeForInspection) { + return CurrentThread.CurrentFunction; } else { - return CurrentProcess.IsProcessSafeForInspection; + return null; } } - } - - internal void CheckThatCurrentProcessIsSafeForInspection() - { - if (CurrentProcess == null) { - throw new DebuggerException("There is no process being debugged."); - } else { - CurrentProcess.CheckThatProcessIsSafeForInspection(); + set { + if (IsCurrentThreadSafeForInspection) { + CurrentThread.CurrentFunction = value; + } } } - - public Thread CurrentThread { + + public bool IsCurrentFunctionSafeForInspection { get { - if (CurrentProcess == null) return null; - return CurrentProcess.CurrentThread; - } - set { - CurrentProcess.CurrentThread = value; + if (IsCurrentThreadSafeForInspection && + CurrentThread.CurrentFunction != null && + CurrentThread.CurrentFunction.HasSymbols) { + return true; + } else { + return false; + } } } public SourcecodeSegment NextStatement { get { - if (!IsCurrentProcessSafeForInspection) return null; - if (CurrentProcess.CurrentThread.CurrentFunction == null) { - return null; - } else { - return CurrentProcess.CurrentThread.CurrentFunction.NextStatement; - } + if (!IsCurrentFunctionSafeForInspection) return null; + return CurrentProcess.CurrentThread.CurrentFunction.NextStatement; } } public VariableCollection LocalVariables { get { - if (!IsCurrentProcessSafeForInspection) return VariableCollection.Empty; + if (!IsCurrentFunctionSafeForInspection) return VariableCollection.Empty; return CurrentProcess.CurrentThread.CurrentFunction.GetVariables(); } } 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 1eb76779bf..c3d80d7921 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 @@ -44,6 +44,12 @@ namespace DebuggerLibrary return methodProps.IsStatic; } } + + public bool HasSymbols { + get { + return module.SymbolsLoaded; + } + } internal ICorDebugClass ContaingClass { get { 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 b1979a1185..ab06732bd6 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 @@ -20,6 +20,12 @@ namespace DebuggerLibrary public event EventHandler ProcessStarted; public event EventHandler ProcessExited; + + public IList Processes { + get { + return processCollection.AsReadOnly(); + } + } public Process CurrentProcess { get { @@ -32,10 +38,23 @@ namespace DebuggerLibrary currentProcess = value; } } - - public IList Processes { + + public bool IsCurrentProcessSafeForInspection { get { - return processCollection.AsReadOnly(); + 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(); } } 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 a107c42b64..26188b73c7 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,6 +46,22 @@ 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/Thread.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs index f1796f39a9..bbc65ae13c 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 @@ -232,14 +232,16 @@ namespace DebuggerLibrary if (currentFunction == null) { currentFunction = LastFunctionWithLoadedSymbols; } - if (currentFunction == null) { - currentFunction = LastFunction; - } return currentFunction; } set { + if (value != null && !value.HasSymbols) { + throw new DebuggerException("CurrentFunction must have symbols"); + } + currentFunction = value; + if (debugger.ManagedCallback.HandlingCallback == false) { debugger.OnDebuggingPaused(PausedReason.CurrentFunctionChanged); } @@ -249,7 +251,7 @@ namespace DebuggerLibrary public Function LastFunctionWithLoadedSymbols { get { foreach (Function function in Callstack) { - if (function.Module.SymbolsLoaded) { + if (function.HasSymbols) { return function; } }