Browse Source

WindowsDebugger cleaned up

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@217 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
0b09ba7c5c
  1. 5
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs
  3. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
  4. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ExceptionHistoryPad.cs
  5. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LoadedModulesPad.cs
  6. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  7. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs
  8. 71
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/RemotingConfigurationHelpper.cs
  9. 165
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

5
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.41115</ProductVersion> <ProductVersion>8.0.50215</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C}</ProjectGuid> <ProjectGuid>{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
@ -50,6 +50,7 @@
<Compile Include="Src\Service\ExceptionForm.cs"> <Compile Include="Src\Service\ExceptionForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Src\Service\RemotingConfigurationHelpper.cs" />
<Compile Include="Src\Service\WindowsDebugger.cs" /> <Compile Include="Src\Service\WindowsDebugger.cs" />
<EmbeddedResource Include="Src\Service\ExceptionForm.resx"> <EmbeddedResource Include="Src\Service\ExceptionForm.resx">
<DependentUpon>ExceptionForm.cs</DependentUpon> <DependentUpon>ExceptionForm.cs</DependentUpon>
@ -84,4 +85,4 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project> </Project>

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

@ -11,11 +11,8 @@ using System.Collections;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.Core; using ICSharpCode.Core;
//using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
//using ICSharpCode.Core.Properties;
using DebuggerLibrary; using DebuggerLibrary;
namespace ICSharpCode.SharpDevelop.Gui.Pads namespace ICSharpCode.SharpDevelop.Gui.Pads

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

@ -11,11 +11,8 @@ using System.Collections;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.Core; using ICSharpCode.Core;
//using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
//using ICSharpCode.Core.Properties;
using DebuggerLibrary; using DebuggerLibrary;
namespace ICSharpCode.SharpDevelop.Gui.Pads namespace ICSharpCode.SharpDevelop.Gui.Pads

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

@ -11,11 +11,8 @@ using System.Collections;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.Core; using ICSharpCode.Core;
//using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
//using ICSharpCode.Core.Properties;
using DebuggerLibrary; using DebuggerLibrary;
namespace ICSharpCode.SharpDevelop.Gui.Pads namespace ICSharpCode.SharpDevelop.Gui.Pads

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LoadedModulesPad.cs

@ -10,10 +10,8 @@ using System.CodeDom.Compiler;
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
//using ICSharpCode.Core.Services;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
//using ICSharpCode.Core.Properties;
using DebuggerLibrary; using DebuggerLibrary;

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

@ -10,12 +10,9 @@ using System.CodeDom.Compiler;
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
//using ICSharpCode.Core.Services;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
//using ICSharpCode.Core.Properties;
using DebuggerLibrary; using DebuggerLibrary;
namespace ICSharpCode.SharpDevelop.Gui.Pads namespace ICSharpCode.SharpDevelop.Gui.Pads

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

@ -11,11 +11,8 @@ using System.Collections;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.Core; using ICSharpCode.Core;
//using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
//using ICSharpCode.Core.Properties;
using DebuggerLibrary; using DebuggerLibrary;
namespace ICSharpCode.SharpDevelop.Gui.Pads namespace ICSharpCode.SharpDevelop.Gui.Pads

71
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;
}
}
}

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

@ -12,87 +12,30 @@ using System.Windows.Forms;
using DebuggerLibrary; using DebuggerLibrary;
using ICSharpCode.Core; 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 System.CodeDom.Compiler;
using ICSharpCode.TextEditor; using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Document;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
//using ICSharpCode.SharpDevelop.Gui.Components;
//using ICSharpCode.SharpDevelop.Gui.Pads;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
//using ICSharpCode.SharpDevelop.Internal.Project;
//using ICSharpCode.SharpDevelop.Gui.Dialogs;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
using System.Runtime.Remoting; using System.Runtime.Remoting;
using System.Reflection; using System.Reflection;
using System.Security.Policy; using System.Security.Policy;
using System.Diagnostics; using System.Diagnostics;
//using Reflector.UserInterface;
namespace ICSharpCode.SharpDevelop.Services 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; bool useRemotingForThreadInterop = false;
NDebugger debugger; NDebugger debugger;
bool isDebuggingCache = false; bool isDebuggingCache = false;
bool isProcessRunningCache = false; bool isProcessRunningCache = false;
bool serviceInitialized = false; bool serviceInitialized = false;
List<DebuggerLibrary.Exception> exceptionHistory = new List<DebuggerLibrary.Exception>(); List<DebuggerLibrary.Exception> exceptionHistory = new List<DebuggerLibrary.Exception>();
public NDebugger DebuggerCore { public NDebugger DebuggerCore {
@ -100,9 +43,6 @@ namespace ICSharpCode.SharpDevelop.Services
return debugger; return debugger;
} }
} }
MessageViewCategory messageViewCategoryDebug;
MessageViewCategory messageViewCategoryDebuggerLog;
public bool ServiceInitialized { public bool ServiceInitialized {
get { get {
@ -281,40 +221,26 @@ namespace ICSharpCode.SharpDevelop.Services
#endregion #endregion
#region ICSharpCode.Core.Services.IService interface implementation
public event System.EventHandler Initialize; public event System.EventHandler Initialize;
public event System.EventHandler Unload;
public void InitializeService() public void InitializeService()
{ {
if (useRemotingForThreadInterop) { if (useRemotingForThreadInterop) {
// This needs to be called before instance of NDebugger is created // This needs to be called before instance of NDebugger is created
string path = null; string path = RemotingConfigurationHelpper.GetLoadedAssemblyPath("Debugger.Core.dll");
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");
}
new RemotingConfigurationHelpper(path).Configure(); new RemotingConfigurationHelpper(path).Configure();
} }
debugger = new NDebugger(); debugger = new NDebugger();
debugger.DebuggerTraceMessage += new EventHandler<MessageEventArgs>(DebuggerTraceMessage);
debugger.LogMessage += new EventHandler<MessageEventArgs>(LogMessage); debugger.LogMessage += new EventHandler<MessageEventArgs>(LogMessage);
debugger.ProcessStarted += new EventHandler<ProcessEventArgs>(ProcessStarted); debugger.ProcessStarted += new EventHandler<ProcessEventArgs>(ProcessStarted);
debugger.DebuggingPaused += new EventHandler<DebuggingPausedEventArgs>(DebuggingPaused); debugger.DebuggingPaused += new EventHandler<DebuggingPausedEventArgs>(DebuggingPaused);
debugger.DebuggingResumed += new EventHandler<DebuggerEventArgs>(DebuggingResumed); debugger.DebuggingResumed += new EventHandler<DebuggerEventArgs>(DebuggingResumed);
debugger.ProcessExited += new EventHandler<ProcessEventArgs>(ProcessExited); debugger.ProcessExited += new EventHandler<ProcessEventArgs>(ProcessExited);
debugger.IsDebuggingChanged += new EventHandler<DebuggerEventArgs>(OnIsDebuggingChanged); debugger.IsDebuggingChanged += new EventHandler<DebuggerEventArgs>(OnIsDebuggingChanged);
debugger.IsProcessRunningChanged += new EventHandler<DebuggerEventArgs>(DebuggerStateChanged); debugger.IsProcessRunningChanged += new EventHandler<DebuggerEventArgs>(OnIsProcessRunningChanged);
debugger.BreakpointStateChanged += delegate (object sender, BreakpointEventArgs e) { debugger.BreakpointStateChanged += delegate (object sender, BreakpointEventArgs e) {
RestoreSharpdevelopBreakpoint(e.Breakpoint); RestoreSharpdevelopBreakpoint(e.Breakpoint);
}; };
@ -341,23 +267,6 @@ namespace ICSharpCode.SharpDevelop.Services
serviceInitialized = true; serviceInitialized = true;
} }
public void UnloadService()
{
debugger.DebuggerTraceMessage -= new EventHandler<MessageEventArgs>(DebuggerTraceMessage);
debugger.LogMessage -= new EventHandler<MessageEventArgs>(LogMessage);
debugger.ProcessStarted -= new EventHandler<ProcessEventArgs>(ProcessStarted);
debugger.DebuggingPaused -= new EventHandler<DebuggingPausedEventArgs>(DebuggingPaused);
debugger.DebuggingResumed -= new EventHandler<DebuggerEventArgs>(DebuggingResumed);
debugger.ProcessExited -= new EventHandler<ProcessEventArgs>(ProcessExited);
debugger.IsDebuggingChanged -= new EventHandler<DebuggerEventArgs>(OnIsDebuggingChanged);
debugger.IsProcessRunningChanged -= new EventHandler<DebuggerEventArgs>(DebuggerStateChanged);
if (Unload != null) {
Unload(this, null);
}
}
#endregion
void AddBreakpoint(BreakpointBookmark breakpointBookmark) void AddBreakpoint(BreakpointBookmark breakpointBookmark)
{ {
SourcecodeSegment seg = new SourcecodeSegment(breakpointBookmark.FileName, breakpointBookmark.LineNumber + 1); 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) void LogMessage(object sender, MessageEventArgs e)
{ {
DebuggerTraceMessage(this, e); DebuggerService.PrintDebugMessage(e.Message);
if (messageViewCategoryDebug != null) {
messageViewCategoryDebug.AppendText(e.Message + "\n");
}
} }
void ProcessStarted(object sender, ProcessEventArgs e) void ProcessStarted(object sender, ProcessEventArgs e)
@ -415,17 +311,14 @@ namespace ICSharpCode.SharpDevelop.Services
if (debugger.Processes.Count == 1) { if (debugger.Processes.Count == 1) {
OnDebugStarted(EventArgs.Empty); OnDebugStarted(EventArgs.Empty);
} }
// Initialize }
/*PadDescriptor cmv = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView));
if (messageViewCategoryDebug == null) { void ProcessExited(object sender, ProcessEventArgs e)
messageViewCategoryDebug = cmv.GetCategory("Debug"); {
} if (debugger.Processes.Count == 0) {
messageViewCategoryDebug.ClearText(); exceptionHistory.Clear();
if (messageViewCategoryDebuggerLog == null) { OnDebugStopped(EventArgs.Empty);
messageViewCategoryDebuggerLog = new MessageViewCategory("DebuggerLog", "Debugger log");
//cmv.AddCategory(messageViewCategoryDebuggerLog);
} }
messageViewCategoryDebuggerLog.ClearText();*/
} }
void DebuggingPaused(object sender, DebuggingPausedEventArgs e) void DebuggingPaused(object sender, DebuggingPausedEventArgs e)
@ -441,9 +334,7 @@ namespace ICSharpCode.SharpDevelop.Services
e.ResumeDebuggingAfterEvent(); e.ResumeDebuggingAfterEvent();
return; return;
} }
//MessageBox.Show("Exception was thrown in debugee:\n" + debugger.CurrentThread.CurrentException.ToString());
ExceptionForm form = new ExceptionForm(); ExceptionForm form = new ExceptionForm();
form.label.Text = "Exception " + form.label.Text = "Exception " +
debugger.CurrentThread.CurrentException.Type + debugger.CurrentThread.CurrentException.Type +
@ -467,29 +358,14 @@ namespace ICSharpCode.SharpDevelop.Services
{ {
DebuggerService.RemoveCurrentLineMarker(); DebuggerService.RemoveCurrentLineMarker();
} }
void ProcessExited(object sender, ProcessEventArgs e)
{
if (debugger.Processes.Count == 0) {
exceptionHistory.Clear();
OnDebugStopped(EventArgs.Empty);
}
}
public void JumpToCurrentLine() public void JumpToCurrentLine()
{ {
SourcecodeSegment nextStatement = debugger.NextStatement; SourcecodeSegment nextStatement = debugger.NextStatement;
if (nextStatement == null) { if (nextStatement == null) {
//StatusBarService.SetMessage("Source code not aviable!");
return; return;
} }
DebuggerService.JumpToCurrentLine(nextStatement.SourceFullFilename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn); 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) void OnIsDebuggingChanged(object sender, DebuggerEventArgs e)
@ -498,19 +374,12 @@ namespace ICSharpCode.SharpDevelop.Services
isProcessRunningCache = debugger.IsProcessRunning; isProcessRunningCache = debugger.IsProcessRunning;
} }
public void DebuggerStateChanged(object sender, DebuggerEventArgs e) public void OnIsProcessRunningChanged(object sender, DebuggerEventArgs e)
{ {
isDebuggingCache = debugger.IsDebugging; isDebuggingCache = debugger.IsDebugging;
isProcessRunningCache = debugger.IsProcessRunning; isProcessRunningCache = debugger.IsProcessRunning;
UpdateToolbars();
}
void UpdateToolbars()
{
((DefaultWorkbench)WorkbenchSingleton.Workbench).Update(); ((DefaultWorkbench)WorkbenchSingleton.Workbench).Update();
//if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
// WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent.RedrawContent();
//}
} }
} }
} }

Loading…
Cancel
Save