diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj index cb7462949e..130b1933fa 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj @@ -2,7 +2,7 @@ Debug AnyCPU - 8.0.41115 + 8.0.50215 2.0 {EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} Library @@ -50,6 +50,7 @@ Form + ExceptionForm.cs @@ -84,4 +85,4 @@ - + \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs index 04f21c2c82..5305e15ec1 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs @@ -11,11 +11,8 @@ using System.Collections; using System.IO; using System.Diagnostics; using ICSharpCode.Core; -//using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Services; -//using ICSharpCode.Core.Properties; - using DebuggerLibrary; namespace ICSharpCode.SharpDevelop.Gui.Pads 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 671f4af724..f3f1981fe6 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 @@ -11,11 +11,8 @@ using System.Collections; using System.IO; using System.Diagnostics; using ICSharpCode.Core; -//using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Services; -//using ICSharpCode.Core.Properties; - using DebuggerLibrary; namespace ICSharpCode.SharpDevelop.Gui.Pads diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ExceptionHistoryPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ExceptionHistoryPad.cs index f271f2dd00..d8aadc974d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ExceptionHistoryPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ExceptionHistoryPad.cs @@ -11,11 +11,8 @@ using System.Collections; using System.IO; using System.Diagnostics; using ICSharpCode.Core; -//using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Services; -//using ICSharpCode.Core.Properties; - using DebuggerLibrary; namespace ICSharpCode.SharpDevelop.Gui.Pads diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LoadedModulesPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LoadedModulesPad.cs index 65fd148fb7..61ff8c3fc4 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LoadedModulesPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LoadedModulesPad.cs @@ -10,10 +10,8 @@ using System.CodeDom.Compiler; using System.Collections; using System.IO; using System.Diagnostics; -//using ICSharpCode.Core.Services; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Services; -//using ICSharpCode.Core.Properties; using DebuggerLibrary; diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs index 2fe7759ddb..7615856ffb 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs @@ -10,12 +10,9 @@ using System.CodeDom.Compiler; using System.Collections; using System.IO; using System.Diagnostics; -//using ICSharpCode.Core.Services; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Services; -//using ICSharpCode.Core.Properties; - using DebuggerLibrary; namespace ICSharpCode.SharpDevelop.Gui.Pads diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs index 6755b0be4a..1bb8d60602 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs @@ -11,11 +11,8 @@ using System.Collections; using System.IO; using System.Diagnostics; using ICSharpCode.Core; -//using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Services; -//using ICSharpCode.Core.Properties; - using DebuggerLibrary; namespace ICSharpCode.SharpDevelop.Gui.Pads diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/RemotingConfigurationHelpper.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/RemotingConfigurationHelpper.cs new file mode 100644 index 0000000000..05b90714e6 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/RemotingConfigurationHelpper.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Reflection; +using System.IO; +using System.Runtime.Remoting; +using System.Security.Policy; + +namespace ICSharpCode.SharpDevelop.Services +{ + [Serializable] + class RemotingConfigurationHelpper + { + public string path; + + public RemotingConfigurationHelpper(string path) + { + this.path = path; + } + + public static string GetLoadedAssemblyPath(string assemblyName) + { + string path = null; + foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { + string fullFilename = assembly.Location; + if (Path.GetFileName(fullFilename).ToLower() == assemblyName.ToLower()) { + path = Path.GetDirectoryName(fullFilename); + break; + } + } + if (path == null) { + throw new System.Exception("Assembly " + assemblyName + " is not loaded"); + } + return path; + } + + public void Configure() + { + AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; + + RemotingConfiguration.Configure(Path.Combine(path, "Client.config")); + + string baseDir = Directory.GetDirectoryRoot(AppDomain.CurrentDomain.BaseDirectory); + string relDirs = AppDomain.CurrentDomain.BaseDirectory + ";" + path; + AppDomain serverAppDomain = AppDomain.CreateDomain("Debugging server", + new Evidence(AppDomain.CurrentDomain.Evidence), + baseDir, + relDirs, + AppDomain.CurrentDomain.ShadowCopyFiles); + serverAppDomain.DoCallBack(new CrossAppDomainDelegate(ConfigureServer)); + } + + private void ConfigureServer() + { + AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; + RemotingConfiguration.Configure(Path.Combine(path, "Server.config")); + } + + Assembly AssemblyResolve(object sender, ResolveEventArgs args) + { + foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { + string fullFilename = assembly.Location; + if (Path.GetFileNameWithoutExtension(fullFilename).ToLower() == args.Name.ToLower() || + assembly.FullName == args.Name) { + return assembly; + } + } + return null; + } + } +} 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 90e754ede2..8958c18e20 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 @@ -12,87 +12,30 @@ using System.Windows.Forms; using DebuggerLibrary; using ICSharpCode.Core; -//using ICSharpCode.Core.Services; -//using ICSharpCode.Core.AddIns; - -//using ICSharpCode.Core.Properties; -//using ICSharpCode.Core.AddIns.Codons; -//using ICSharpCode.Core.AddIns.Conditions; using System.CodeDom.Compiler; using ICSharpCode.TextEditor; using ICSharpCode.TextEditor.Document; using ICSharpCode.SharpDevelop.Gui; -//using ICSharpCode.SharpDevelop.Gui.Components; -//using ICSharpCode.SharpDevelop.Gui.Pads; using ICSharpCode.SharpDevelop.Project; -//using ICSharpCode.SharpDevelop.Internal.Project; -//using ICSharpCode.SharpDevelop.Gui.Dialogs; using ICSharpCode.SharpDevelop.Services; using System.Runtime.Remoting; using System.Reflection; using System.Security.Policy; using System.Diagnostics; -//using Reflector.UserInterface; - namespace ICSharpCode.SharpDevelop.Services { - public class WindowsDebugger:IDebugger //, IService + public class WindowsDebugger:IDebugger { - [Serializable] - public class RemotingConfigurationHelpper - { - public string path; - - public RemotingConfigurationHelpper(string path) - { - this.path = path; - } - - public void Configure() - { - AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; - - RemotingConfiguration.Configure(Path.Combine(path, "Client.config")); - - string baseDir = Directory.GetDirectoryRoot(AppDomain.CurrentDomain.BaseDirectory); - string relDirs = AppDomain.CurrentDomain.BaseDirectory + ";" + path; - AppDomain serverAppDomain = AppDomain.CreateDomain("Debugging server", - new Evidence(AppDomain.CurrentDomain.Evidence), - baseDir, - relDirs, - AppDomain.CurrentDomain.ShadowCopyFiles); - serverAppDomain.DoCallBack(new CrossAppDomainDelegate(ConfigureServer)); - } - - private void ConfigureServer() - { - AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; - RemotingConfiguration.Configure(Path.Combine(path, "Server.config")); - } - - Assembly AssemblyResolve(object sender, ResolveEventArgs args) - { - foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { - string fullFilename = assembly.Location; - if (Path.GetFileNameWithoutExtension(fullFilename).ToLower() == args.Name.ToLower() || - assembly.FullName == args.Name) { - return assembly; - } - } - return null; - } - } - bool useRemotingForThreadInterop = false; NDebugger debugger; + bool isDebuggingCache = false; bool isProcessRunningCache = false; bool serviceInitialized = false; - List exceptionHistory = new List(); public NDebugger DebuggerCore { @@ -100,9 +43,6 @@ namespace ICSharpCode.SharpDevelop.Services return debugger; } } - - MessageViewCategory messageViewCategoryDebug; - MessageViewCategory messageViewCategoryDebuggerLog; public bool ServiceInitialized { get { @@ -281,40 +221,26 @@ namespace ICSharpCode.SharpDevelop.Services #endregion - #region ICSharpCode.Core.Services.IService interface implementation public event System.EventHandler Initialize; - - public event System.EventHandler Unload; public void InitializeService() { if (useRemotingForThreadInterop) { // This needs to be called before instance of NDebugger is created - string path = null; - foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { - string fullFilename = assembly.Location; - if (Path.GetFileName(fullFilename).ToLower() == "debugger.core.dll") { - path = Path.GetDirectoryName(fullFilename); - break; - } - } - - if (path == null) { - throw new System.Exception("Debugger.Core.dll is not loaded"); - } + string path = RemotingConfigurationHelpper.GetLoadedAssemblyPath("Debugger.Core.dll"); new RemotingConfigurationHelpper(path).Configure(); } debugger = new NDebugger(); - debugger.DebuggerTraceMessage += new EventHandler(DebuggerTraceMessage); debugger.LogMessage += new EventHandler(LogMessage); debugger.ProcessStarted += new EventHandler(ProcessStarted); debugger.DebuggingPaused += new EventHandler(DebuggingPaused); debugger.DebuggingResumed += new EventHandler(DebuggingResumed); debugger.ProcessExited += new EventHandler(ProcessExited); debugger.IsDebuggingChanged += new EventHandler(OnIsDebuggingChanged); - debugger.IsProcessRunningChanged += new EventHandler(DebuggerStateChanged); + debugger.IsProcessRunningChanged += new EventHandler(OnIsProcessRunningChanged); + debugger.BreakpointStateChanged += delegate (object sender, BreakpointEventArgs e) { RestoreSharpdevelopBreakpoint(e.Breakpoint); }; @@ -341,23 +267,6 @@ namespace ICSharpCode.SharpDevelop.Services serviceInitialized = true; } - public void UnloadService() - { - debugger.DebuggerTraceMessage -= new EventHandler(DebuggerTraceMessage); - debugger.LogMessage -= new EventHandler(LogMessage); - debugger.ProcessStarted -= new EventHandler(ProcessStarted); - debugger.DebuggingPaused -= new EventHandler(DebuggingPaused); - debugger.DebuggingResumed -= new EventHandler(DebuggingResumed); - debugger.ProcessExited -= new EventHandler(ProcessExited); - debugger.IsDebuggingChanged -= new EventHandler(OnIsDebuggingChanged); - debugger.IsProcessRunningChanged -= new EventHandler(DebuggerStateChanged); - - if (Unload != null) { - Unload(this, null); - } - } - #endregion - void AddBreakpoint(BreakpointBookmark breakpointBookmark) { SourcecodeSegment seg = new SourcecodeSegment(breakpointBookmark.FileName, breakpointBookmark.LineNumber + 1); @@ -391,23 +300,10 @@ namespace ICSharpCode.SharpDevelop.Services } } } - - // Output messages that report status of debugger - void DebuggerTraceMessage(object sender, MessageEventArgs e) - { - if (messageViewCategoryDebuggerLog != null) { - messageViewCategoryDebuggerLog.AppendText(e.Message + "\n"); - System.Console.WriteLine(e.Message); - } - } - - // Output messages form debuged program that are caused by System.Diagnostics.Trace.WriteLine(), etc... + void LogMessage(object sender, MessageEventArgs e) { - DebuggerTraceMessage(this, e); - if (messageViewCategoryDebug != null) { - messageViewCategoryDebug.AppendText(e.Message + "\n"); - } + DebuggerService.PrintDebugMessage(e.Message); } void ProcessStarted(object sender, ProcessEventArgs e) @@ -415,17 +311,14 @@ namespace ICSharpCode.SharpDevelop.Services if (debugger.Processes.Count == 1) { OnDebugStarted(EventArgs.Empty); } - // Initialize - /*PadDescriptor cmv = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)); - if (messageViewCategoryDebug == null) { - messageViewCategoryDebug = cmv.GetCategory("Debug"); - } - messageViewCategoryDebug.ClearText(); - if (messageViewCategoryDebuggerLog == null) { - messageViewCategoryDebuggerLog = new MessageViewCategory("DebuggerLog", "Debugger log"); - //cmv.AddCategory(messageViewCategoryDebuggerLog); + } + + void ProcessExited(object sender, ProcessEventArgs e) + { + if (debugger.Processes.Count == 0) { + exceptionHistory.Clear(); + OnDebugStopped(EventArgs.Empty); } - messageViewCategoryDebuggerLog.ClearText();*/ } void DebuggingPaused(object sender, DebuggingPausedEventArgs e) @@ -441,9 +334,7 @@ namespace ICSharpCode.SharpDevelop.Services e.ResumeDebuggingAfterEvent(); return; } - - - //MessageBox.Show("Exception was thrown in debugee:\n" + debugger.CurrentThread.CurrentException.ToString()); + ExceptionForm form = new ExceptionForm(); form.label.Text = "Exception " + debugger.CurrentThread.CurrentException.Type + @@ -467,29 +358,14 @@ namespace ICSharpCode.SharpDevelop.Services { DebuggerService.RemoveCurrentLineMarker(); } - - void ProcessExited(object sender, ProcessEventArgs e) - { - if (debugger.Processes.Count == 0) { - exceptionHistory.Clear(); - OnDebugStopped(EventArgs.Empty); - } - } public void JumpToCurrentLine() { SourcecodeSegment nextStatement = debugger.NextStatement; if (nextStatement == null) { - //StatusBarService.SetMessage("Source code not aviable!"); return; } DebuggerService.JumpToCurrentLine(nextStatement.SourceFullFilename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn); - - string stepRanges = ""; - foreach (int i in nextStatement.StepRanges) { - stepRanges += i.ToString("X") + " "; - } - //StatusBarService.SetMessage("IL:" + nextStatement.ILOffset.ToString("X") + " StepRange:" + stepRanges + " "); } void OnIsDebuggingChanged(object sender, DebuggerEventArgs e) @@ -498,19 +374,12 @@ namespace ICSharpCode.SharpDevelop.Services isProcessRunningCache = debugger.IsProcessRunning; } - public void DebuggerStateChanged(object sender, DebuggerEventArgs e) + public void OnIsProcessRunningChanged(object sender, DebuggerEventArgs e) { isDebuggingCache = debugger.IsDebugging; isProcessRunningCache = debugger.IsProcessRunning; - UpdateToolbars(); - } - - void UpdateToolbars() - { + ((DefaultWorkbench)WorkbenchSingleton.Workbench).Update(); - //if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) { - // WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent.RedrawContent(); - //} } } }