Browse Source

Reworked DebuggerService, IDebugger, DefaultDebugger and Debugger menu

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@214 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
5c7a9b3264
  1. 89
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
  3. 13
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpLanguageBinding.cs
  4. 13
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetLanguageBinding.cs
  5. 280
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  6. 12
      src/Main/Base/Project/Src/Commands/DebugCommands.cs
  7. 8
      src/Main/Base/Project/Src/Internal/Auswerter/DebuggerSupportsAuswerter.cs
  8. 17
      src/Main/Base/Project/Src/Internal/Auswerter/IsProcessRunningAuswerter.cs
  9. 14
      src/Main/Base/Project/Src/Project/MSBuildProject.cs
  10. 220
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  11. 122
      src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs
  12. 62
      src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

89
AddIns/ICSharpCode.SharpDevelop.addin

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<AddIn name = "SharpDevelop Core"
<AddIn name = "SharpDevelop Core"
author = "Mike Krueger"
copyright = "GPL"
url = "http://www.icsharpcode.net"
@ -709,32 +709,34 @@ @@ -709,32 +709,34 @@
icon = "Icons.16x16.BuildCurrentSelectedProject"
tooltip = "${res:XML.MainMenu.RunMenu.BuildProject.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.Rebuild"/>
<Condition name="IsProcessRunning" isprocessrunning="False" isdebugging = "False" action="Disable">
<Condition name="DebuggerSupports" debuggersupports = "ExecutionControl">
<ToolbarItem id = "DebuggerSeparator" type = "Separator" />
<Condition name="DebuggerSupports" debuggersupports = "Start">
<Condition name="IsProcessRunning" isdebugging="False" action="Disable">
<ToolbarItem id = "Run"
icon = "Icons.16x16.RunProgramIcon"
tooltip = "${res:XML.MainMenu.RunMenu.Run.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.Execute"/>
</Condition>
<ComplexCondition>
<Not>
<Condition name="DebuggerSupports" debuggersupports = "ExecutionControl"/>
</Not>
</Condition>
<Condition name="DebuggerSupports" debuggersupports = "StartWithoutDebugging">
<Condition name="IsProcessRunning" isdebugging="False" action="Disable">
<ToolbarItem id = "RunWithoutDebugger"
icon = "Icons.16x16.RunProgramIcon"
icon = "Icons.16x16.Debug.StartWithoutDebugging"
tooltip = "${res:XML.MainMenu.RunMenu.Run.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.ExecuteWithoutDebugger"/>
</ComplexCondition>
</Condition>
</Condition>
<Condition name="IsProcessRunning" isprocessrunning="True" action="Disable">
<ToolbarItem id = "Stop"
<Condition name="DebuggerSupports" debuggersupports = "Stop">
<Condition name="IsProcessRunning" isdebugging="True" action="Disable">
<ToolbarItem id = "Stop"
icon = "Icons.16x16.StopProcess"
tooltip = "${res:XML.MainMenu.DebugMenu.Stop.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand"/>
</Condition>
</Condition>
<Condition name="DebuggerSupports" debuggersupports = "ExecutionControl">
@ -750,6 +752,12 @@ @@ -750,6 +752,12 @@
icon = "Icons.16x16.Debug.Continue"
tooltip = "${res:XML.MainMenu.DebugMenu.Continue.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.ContinueDebuggingCommand"/>
</Condition>
</Condition>
<Condition name="DebuggerSupports" debuggersupports = "Stepping">
<Condition name="IsProcessRunning" isprocessrunning = "False" isdebugging = "True" action = "Disable">
<ToolbarItem id = "SteppingSeparator" type = "Separator" />
<ToolbarItem id = "Step over"
icon = "Icons.16x16.Debug.StepOver"
tooltip = "Step over"
@ -764,6 +772,7 @@ @@ -764,6 +772,7 @@
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/>
</Condition>
</Condition>
<ToolbarItem id = "ChooseConfigurationSeparator" type = "Separator"/>
</ComplexCondition>
<ToolbarItem id = "ChooseLayout"
@ -1204,35 +1213,38 @@ @@ -1204,35 +1213,38 @@
</And>
<Condition name = "CombineOpen" iscombineopen="True"/>
</Or>
<ComplexCondition>
<Not>
<Condition name="DebuggerSupports" debuggersupports = "ExecutionControl"/>
</Not>
<MenuItem id = "RunWithoutDebugger"
label = "${res:XML.MainMenu.RunMenu.Run}"
icon = "Icons.16x16.RunProgramIcon"
shortcut = "F5"
class = "ICSharpCode.SharpDevelop.Project.Commands.ExecuteWithoutDebugger"/>
</ComplexCondition>
<Condition name="DebuggerSupports" debuggersupports = "ExecutionControl">
<Condition name="IsProcessRunning" isprocessrunning="False" isdebugging="False" action="Disable">
<Condition name="DebuggerSupports" debuggersupports = "Start">
<Condition name="IsProcessRunning" isdebugging="False" action="Disable">
<MenuItem id = "Run"
label = "${res:XML.MainMenu.RunMenu.Run}"
icon = "Icons.16x16.RunProgramIcon"
shortcut = "F5"
class = "ICSharpCode.SharpDevelop.Project.Commands.Execute"/>
<MenuItem id = "RunWithout debug"
</Condition>
</Condition>
<Condition name="DebuggerSupports" debuggersupports = "StartWithoutDebugging">
<Condition name="IsProcessRunning" isdebugging="False" action="Disable">
<MenuItem id = "RunWithoutDebugger"
label = "${res:XML.MainMenu.DebugMenu.RunWithoutDebug}"
icon = "Icons.16x16.Debug.StartWithoutDebugging"
shortcut = "Control|F5"
class = "ICSharpCode.SharpDevelop.Project.Commands.ExecuteWithoutDebugger"/>
</Condition>
<MenuItem id = "RunSeparator" type = "Separator" />
</Condition>
<Condition name="DebuggerSupports" debuggersupports = "Stop">
<Condition name="IsProcessRunning" isdebugging="True" action="Disable">
<MenuItem id = "Stop"
label = "${res:XML.MainMenu.DebugMenu.Stop}"
icon="Icons.16x16.StopProcess"
class = "ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand"/>
</Condition>
</Condition>
<Condition name="DebuggerSupports" debuggersupports = "ExecutionControl">
<MenuItem id = "ExecutionControlSeparator" type = "Separator" />
<Condition name="IsProcessRunning" isprocessrunning = "True" isdebugging = "True" action = "Disable">
<MenuItem id = "Break"
label = "Break"
@ -1248,17 +1260,10 @@ @@ -1248,17 +1260,10 @@
class = "ICSharpCode.SharpDevelop.Project.Commands.ContinueDebuggingCommand"/>
</Condition>
</Condition>
<Condition name="IsProcessRunning" isprocessrunning="True" action="Disable">
<MenuItem id = "Stop"
label = "${res:XML.MainMenu.DebugMenu.Stop}"
icon="Icons.16x16.StopProcess"
class = "ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand"/>
</Condition>
<Condition name="DebuggerSupports" debuggersupports = "Stepping">
<MenuItem id = "BeforeSteppingSeparator" type = "Separator" />
<Condition name="IsProcessRunning" isprocessrunning = "False" isdebugging = "True" action = "Disable">
<Condition name="IsProcessRunning" isprocessrunning = "False" isdebugging = "True" action = "Disable">
<MenuItem id = "BeforeSteppingSeparator" type = "Separator" />
<MenuItem id = "Step"
label = "Step"
icon="Icons.16x16.Debug.StepOver"
@ -1862,4 +1867,4 @@ @@ -1862,4 +1867,4 @@
extensions = ".css"
resource = "Icons.16x16.CSSIcon"/>
</Path>
</AddIn>
</AddIn>

4
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj

@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
<Compile Include="Src\FormattingStrategy\DocumentAccessor.cs" />
<Compile Include="Src\FormattingStrategy\Indentation.cs" />
<Compile Include="Src\OptionPanels\BuildOptions.cs">
<SubType>Form</SubType>
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Parser\ExpressionFinder.cs" />
<Compile Include="Src\Parser\Parser.cs" />
@ -73,6 +73,8 @@ @@ -73,6 +73,8 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Src\PrettyPrinter\Gui\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />

13
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpLanguageBinding.cs

@ -66,13 +66,20 @@ namespace CSharpBinding @@ -66,13 +66,20 @@ namespace CSharpBinding
if (debug) {
DebuggerService.Start(exe, Path.GetDirectoryName(exe), "");
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = exe;
psi.WorkingDirectory = Path.GetDirectoryName(exe);
psi.Arguments = "";
DebuggerService.CurrentDebugger.Start(psi);
} else {
ProcessStartInfo psi = new ProcessStartInfo(Environment.GetEnvironmentVariable("ComSpec"), "/c " + "\"" + exe + "\"" + " & pause");
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Environment.GetEnvironmentVariable("ComSpec");
psi.WorkingDirectory = Path.GetDirectoryName(exe);
psi.Arguments = "/c " + "\"" + exe + "\"" + " & pause";
psi.UseShellExecute = false;
DebuggerService.StartWithoutDebugging(psi);
DebuggerService.CurrentDebugger.StartWithoutDebugging(psi);
}
}
#endregion

13
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetLanguageBinding.cs

@ -66,13 +66,20 @@ namespace VBNetBinding @@ -66,13 +66,20 @@ namespace VBNetBinding
if (debug) {
DebuggerService.Start(exe, Path.GetDirectoryName(exe), "");
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = exe;
psi.WorkingDirectory = Path.GetDirectoryName(exe);
psi.Arguments = "";
DebuggerService.CurrentDebugger.Start(psi);
} else {
ProcessStartInfo psi = new ProcessStartInfo(Environment.GetEnvironmentVariable("ComSpec"), "/c " + "\"" + exe + "\"" + " & pause");
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Environment.GetEnvironmentVariable("ComSpec");
psi.WorkingDirectory = Path.GetDirectoryName(exe);
psi.Arguments = "/c " + "\"" + exe + "\"" + " & pause";
psi.UseShellExecute = false;
DebuggerService.StartWithoutDebugging(psi);
DebuggerService.CurrentDebugger.StartWithoutDebugging(psi);
}
}
#endregion

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

@ -32,12 +32,13 @@ using ICSharpCode.SharpDevelop.Services; @@ -32,12 +32,13 @@ 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 //, IService
{
[Serializable]
public class RemotingConfigurationHelpper
@ -91,22 +92,9 @@ namespace ICSharpCode.SharpDevelop.Services @@ -91,22 +92,9 @@ namespace ICSharpCode.SharpDevelop.Services
bool isProcessRunningCache = false;
bool serviceInitialized = false;
public event EventHandler DebugStopped; // FIX: unused
List<DebuggerLibrary.Exception> exceptionHistory = new List<DebuggerLibrary.Exception>();
protected virtual void OnDebugStopped(EventArgs e)
{
if (DebugStopped != null) {
DebugStopped(this, e);
}
}
public void Dispose()// FIX: unused
{
}
public NDebugger DebuggerCore {
get {
return debugger;
@ -121,28 +109,177 @@ namespace ICSharpCode.SharpDevelop.Services @@ -121,28 +109,177 @@ namespace ICSharpCode.SharpDevelop.Services
return serviceInitialized;
}
}
public IList<DebuggerLibrary.Exception> ExceptionHistory {
get {
return exceptionHistory.AsReadOnly();
}
}
public WindowsDebugger()
{
}
#region IDebugger Members
public bool IsDebugging {
get {
return isDebuggingCache;
}
}
public bool IsProcessRunning {
get {
return isProcessRunningCache;
}
}
public bool CanDebug(IProject project)
{
return true;
}
public bool SupportsStepping {
public void Start(ProcessStartInfo processStartInfo)
{
if (!serviceInitialized) {
InitializeService();
}
debugger.Start(processStartInfo.FileName,
processStartInfo.WorkingDirectory,
processStartInfo.Arguments);
}
public bool SupportsStart {
get {
return true;
}
}
public IList<DebuggerLibrary.Exception> ExceptionHistory {
public void StartWithoutDebugging(ProcessStartInfo processStartInfo)
{
System.Diagnostics.Process process;
process = new System.Diagnostics.Process();
process.StartInfo = processStartInfo;
process.Start();
}
public bool SupportsStartWithoutDebugging {
get {
return exceptionHistory.AsReadOnly();
return true;
}
}
public void Stop()
{
debugger.Terminate();
}
public bool SupportsStop {
get {
return true;
}
}
public WindowsDebugger()
// ExecutionControl:
public void Break()
{
debugger.Break();
}
public void Continue()
{
debugger.Continue();
}
public bool SupportsExecutionControl {
get {
return true;
}
}
// Stepping:
public void StepInto()
{
debugger.StepInto();
}
public void StepOver()
{
debugger.StepOver();
}
public void StepOut()
{
debugger.StepOut();
}
public bool SupportsStepping {
get {
return true;
}
}
public event EventHandler DebugStarted;
protected virtual void OnDebugStarted(EventArgs e)
{
if (DebugStarted != null) {
DebugStarted(this, e);
}
}
public event EventHandler IsProcessRunningChanged;
protected virtual void OnIsProcessRunningChanged(EventArgs e)
{
if (IsProcessRunningChanged != null) {
IsProcessRunningChanged(this, e);
}
}
public event EventHandler DebugStopped;
protected virtual void OnDebugStopped(EventArgs e)
{
if (DebugStopped != null) {
DebugStopped(this, e);
}
}
/// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// </summary>
public string GetValueAsString(string variableName)
{
if (!debugger.IsDebugging || debugger.IsProcessRunning) return null;
VariableCollection collection = debugger.LocalVariables;
if (collection == null)
return null;
foreach (Variable v in collection) {
if (v.Name == variableName) {
object val = v.Value;
if (val == null)
return "<null>";
else if (val is string)
return "\"" + val.ToString() + "\"";
else
return val.ToString();
}
}
return null;
}
public void Dispose()
{
Stop();
}
#endregion
#region ICSharpCode.Core.Services.IService interface implementation
public event System.EventHandler Initialize;
@ -218,80 +355,6 @@ namespace ICSharpCode.SharpDevelop.Services @@ -218,80 +355,6 @@ namespace ICSharpCode.SharpDevelop.Services
}
#endregion
#region ICSharpCode.SharpDevelop.Services.IDebugger interface implementation
public bool IsDebugging {
get {
return isDebuggingCache;
}
}
public bool IsProcessRunning {
get {
return isProcessRunningCache;
}
}
public bool SupportsStartStop {
get {
return true;
}
}
public bool SupportsExecutionControl {
get {
return true;
}
}
public void StartWithoutDebugging(System.Diagnostics.ProcessStartInfo psi)
{
System.Diagnostics.Process process;
process = new System.Diagnostics.Process();
process.StartInfo = psi;
process.Start();
}
public void Start(string fileName, string workingDirectory, string arguments)
{
if (!serviceInitialized) {
InitializeService();
}
debugger.Start(fileName, workingDirectory, arguments);
}
public void Stop()
{
debugger.Terminate();
}
public void Break()
{
debugger.Break();
}
public void StepInto()
{
debugger.StepInto();
}
public void StepOver()
{
debugger.StepOver();
}
public void StepOut()
{
debugger.StepOut();
}
public void Continue()
{
debugger.Continue();
}
#endregion
public void RestoreNDebuggerBreakpoints(object sender, EventArgs e)
{
debugger.ClearBreakpoints();
@ -334,6 +397,9 @@ namespace ICSharpCode.SharpDevelop.Services @@ -334,6 +397,9 @@ namespace ICSharpCode.SharpDevelop.Services
void ProcessStarted(object sender, ProcessEventArgs e)
{
if (debugger.Processes.Count == 1) {
OnDebugStarted(EventArgs.Empty);
}
// Initialize
/*PadDescriptor cmv = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView));
if (messageViewCategoryDebug == null) {
@ -349,6 +415,10 @@ namespace ICSharpCode.SharpDevelop.Services @@ -349,6 +415,10 @@ namespace ICSharpCode.SharpDevelop.Services
void DebuggingPaused(object sender, DebuggingPausedEventArgs e)
{
OnIsProcessRunningChanged(EventArgs.Empty);
JumpToCurrentLine();
if (e.Reason == PausedReason.Exception) {
exceptionHistory.Add(debugger.CurrentThread.CurrentException);
if (debugger.CurrentThread.CurrentException.ExceptionType != ExceptionType.DEBUG_EXCEPTION_UNHANDLED && (debugger.CatchHandledExceptions == false)) {
@ -376,8 +446,6 @@ namespace ICSharpCode.SharpDevelop.Services @@ -376,8 +446,6 @@ namespace ICSharpCode.SharpDevelop.Services
throw new NotImplementedException();
}
}
JumpToCurrentLine();
}
void DebuggingResumed(object sender, DebuggerEventArgs e)
@ -389,6 +457,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -389,6 +457,7 @@ namespace ICSharpCode.SharpDevelop.Services
{
if (debugger.Processes.Count == 0) {
exceptionHistory.Clear();
OnDebugStopped(EventArgs.Empty);
}
}
@ -428,28 +497,5 @@ namespace ICSharpCode.SharpDevelop.Services @@ -428,28 +497,5 @@ namespace ICSharpCode.SharpDevelop.Services
// WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent.RedrawContent();
//}
}
/// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// </summary>
public string GetValueAsString(string variableName)
{
if (!debugger.IsDebugging || debugger.IsProcessRunning) return null;
VariableCollection collection = debugger.LocalVariables;
if (collection == null)
return null;
foreach (Variable v in collection) {
if (v.Name == variableName) {
object val = v.Value;
if (val == null)
return "<null>";
else if (val is string)
return "\"" + val.ToString() + "\"";
else
return val.ToString();
}
}
return null;
}
}
}

12
src/Main/Base/Project/Src/Commands/DebugCommands.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -47,7 +47,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
DebuggerService.Continue();
DebuggerService.CurrentDebugger.Continue();
}
}
@ -55,7 +55,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -55,7 +55,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
DebuggerService.Break();
DebuggerService.CurrentDebugger.Break();
}
}
@ -63,7 +63,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -63,7 +63,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
DebuggerService.Stop();
DebuggerService.CurrentDebugger.Stop();
}
}
@ -71,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -71,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
DebuggerService.Step(false);
DebuggerService.CurrentDebugger.StepOver();
}
}
@ -79,7 +79,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -79,7 +79,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
DebuggerService.Step(true);
DebuggerService.CurrentDebugger.StepInto();
}
}
@ -87,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -87,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
DebuggerService.StepOut();
DebuggerService.CurrentDebugger.StepOut();
}
}
}

8
src/Main/Base/Project/Src/Internal/Auswerter/DebuggerSupportsAuswerter.cs

@ -12,8 +12,12 @@ namespace ICSharpCode.Core @@ -12,8 +12,12 @@ namespace ICSharpCode.Core
IDebugger debugger = DebuggerService.CurrentDebugger as IDebugger;
if (debugger != null) {
switch (condition.Properties["debuggersupports"]) {
case "StartStop":
return debugger.SupportsStartStop;
case "Start":
return debugger.SupportsStart;
case "StartWithoutDebugging":
return debugger.SupportsStartWithoutDebugging;
case "Stop":
return debugger.SupportsStop;
case "ExecutionControl":
return debugger.SupportsExecutionControl;
case "Stepping":

17
src/Main/Base/Project/Src/Internal/Auswerter/IsProcessRunningAuswerter.cs

@ -16,13 +16,16 @@ namespace ICSharpCode.Core @@ -16,13 +16,16 @@ namespace ICSharpCode.Core
{
public bool IsValid(object caller, Condition condition)
{
bool isprocessrunning = Boolean.Parse(condition.Properties["isprocessrunning"]);
string isDebugging = condition.Properties.Get("isdebugging", String.Empty);
IDebugger debugger = DebuggerService.CurrentDebugger;
return isprocessrunning == DebuggerService.IsProcessRunning &&
(isDebugging == String.Empty ||
DebuggerService.IsDebugging == Boolean.Parse(isDebugging)
);
string isdebugging = condition.Properties.Get("isdebugging", String.Empty);
string isprocessrunning = condition.Properties.Get("isprocessrunning", String.Empty);
bool isdebuggingPassed = (isdebugging == String.Empty) ||
(DebuggerService.CurrentDebugger.IsDebugging == Boolean.Parse(isdebugging));
bool isprocessrunningPassed = (isprocessrunning == String.Empty) ||
(DebuggerService.CurrentDebugger.IsProcessRunning == Boolean.Parse(isprocessrunning));
return isdebuggingPassed && isprocessrunningPassed;
}
}
}

14
src/Main/Base/Project/Src/Project/MSBuildProject.cs

@ -233,16 +233,16 @@ namespace ICSharpCode.SharpDevelop.Project @@ -233,16 +233,16 @@ namespace ICSharpCode.SharpDevelop.Project
public override void Start(bool withDebugging)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = OutputAssemblyFullPath;
psi.WorkingDirectory = Path.GetDirectoryName(OutputAssemblyFullPath);
psi.Arguments = "";
if (withDebugging) {
DebuggerService.Start(OutputAssemblyFullPath,
Path.GetDirectoryName(OutputAssemblyFullPath),
"");
DebuggerService.CurrentDebugger.Start(psi);
} else {
DebuggerService.StartWithoutDebugging(OutputAssemblyFullPath,
Path.GetDirectoryName(OutputAssemblyFullPath),
"");
DebuggerService.CurrentDebugger.StartWithoutDebugging(psi);
}
}
// static void BeforeBuild()

220
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -26,66 +26,52 @@ namespace ICSharpCode.Core @@ -26,66 +26,52 @@ namespace ICSharpCode.Core
{
public static class DebuggerService
{
static System.Diagnostics.Process standardProcess = null;
static bool isRunning = false;
static IDebugger defaultDebugger = null;
static IDebugger currentDebugger = null;
static ArrayList debugger = null;
public static IDebugger CurrentDebugger {
get {
if (currentDebugger != null) {
return currentDebugger;
}
if (debugger == null) {
InitializeService();
}
if (debugger != null) {
IProject project = null;
if (ProjectService.OpenSolution != null) {
project = ProjectService.OpenSolution.StartupProject;
}
foreach (IDebugger d in debugger) {
if (d.CanDebug(project)) {
currentDebugger = d;
return d;
}
}
}
if (defaultDebugger == null) {
defaultDebugger = new DefaultDebugger();
}
currentDebugger = defaultDebugger;
return defaultDebugger;
}
static IDebugger currentDebugger;
static ArrayList debuggers;
static string oldLayoutConfiguration = "Default";
static DebuggerService()
{
InitializeService();
InitializeService2();
}
public static bool IsProcessRunning {
get {
if (standardProcess != null) {
return isRunning;
}
if (currentDebugger != null) {
return currentDebugger.IsProcessRunning;
static IDebugger GetCompatibleDebugger()
{
IProject project = null;
if (ProjectService.OpenSolution != null) {
project = ProjectService.OpenSolution.StartupProject;
}
foreach (IDebugger d in debuggers) {
if (d.CanDebug(project)) {
return d;
}
return false;
}
return new DefaultDebugger();
}
public static bool IsDebugging {
public static IDebugger CurrentDebugger {
get {
if (currentDebugger == null) {
return false;
currentDebugger = GetCompatibleDebugger();
currentDebugger.DebugStarted += new EventHandler(DebugStarted);
currentDebugger.DebugStopped += new EventHandler(DebugStopped);
}
return currentDebugger.IsDebugging;
return currentDebugger;
}
}
static DebuggerService()
static void DebugStarted(object sender, EventArgs e)
{
InitializeService();
InitializeService2();
//oldLayoutConfiguration = LayoutConfiguration.CurrentLayoutName;
//LayoutConfiguration.CurrentLayoutName = "Debug";
}
static void DebugStopped(object sender, EventArgs e)
{
//LayoutConfiguration.CurrentLayoutName = oldLayoutConfiguration;
}
static MessageViewCategory debugCategory = null;
@ -110,27 +96,6 @@ namespace ICSharpCode.Core @@ -110,27 +96,6 @@ namespace ICSharpCode.Core
} catch (Exception) {}
}
static string oldLayoutConfiguration = "Default";
static void HandleDebugStopped(object sender, EventArgs e)
{
// LayoutConfiguration.CurrentLayoutName = oldLayoutConfiguration;
//// Alex: if stopped - kill process which might be running or stuck
if (standardProcess != null) {
standardProcess.Kill();
standardProcess.Close();
standardProcess = null;
}
IDebugger debugger = CurrentDebugger;
if (debugger != null) {
debugger.Stop();
}
debugger.DebugStopped -= new EventHandler(HandleDebugStopped);
debugger.Dispose();
isRunning = false;
}
#region ICSharpCode.Core.IService interface implementation
public static void InitializeService()
{
@ -140,7 +105,10 @@ namespace ICSharpCode.Core @@ -140,7 +105,10 @@ namespace ICSharpCode.Core
} catch (Exception) {
}
if (treeNode != null) {
debugger = treeNode.BuildChildItems(null);
debuggers = treeNode.BuildChildItems(null);
}
if (debuggers == null) {
debuggers = new ArrayList();
}
ProjectService.SolutionLoaded += new SolutionEventHandler(ClearOnCombineEvent);
@ -160,119 +128,7 @@ namespace ICSharpCode.Core @@ -160,119 +128,7 @@ namespace ICSharpCode.Core
debugCategory.ClearText();
}
#endregion
public static void GotoSourceFile(string fileName, int lineNumber, int column)
{
FileService.JumpToFilePosition(fileName, lineNumber, column);
}
public static void StartWithoutDebugging(System.Diagnostics.ProcessStartInfo psi)
{
if (IsProcessRunning) {
return;
}
try {
standardProcess = new System.Diagnostics.Process();
standardProcess.StartInfo = psi;
standardProcess.Exited += new EventHandler(StandardProcessExited);
standardProcess.EnableRaisingEvents = true;
standardProcess.Start();
isRunning = true;
} catch (Exception e) {
MessageService.ShowError(e, "Can't execute " + "\"" + psi.FileName + "\"\n");
}
}
public static void StartWithoutDebugging(string fileName, string workingDirectory, string arguments)
{
ProcessStartInfo startInfo = new ProcessStartInfo(fileName, arguments);
startInfo.WorkingDirectory = workingDirectory;
startInfo.UseShellExecute = false;
StartWithoutDebugging(startInfo);
}
public static void Start(string fileName, string workingDirectory, string arguments)
{
if (IsProcessRunning) {
return;
}
oldLayoutConfiguration = LayoutConfiguration.CurrentLayoutName;
// LayoutConfiguration.CurrentLayoutName = "Debug";
IDebugger debugger = CurrentDebugger;
if (debugger != null) {
debugger.Start(fileName, workingDirectory, arguments);
debugger.DebugStopped += new EventHandler(HandleDebugStopped);
}
isRunning = true;
}
public static void Break()
{
IDebugger debugger = CurrentDebugger;
if (debugger != null && debugger.SupportsExecutionControl) {
debugger.Break();
}
}
public static void Continue()
{
IDebugger debugger = CurrentDebugger;
if (debugger != null && debugger.SupportsExecutionControl) {
debugger.Continue();
}
}
public static void Step(bool stepInto)
{
IDebugger debugger = CurrentDebugger;
if (debugger == null || !debugger.SupportsStepping) {
return;
}
if (stepInto) {
debugger.StepInto();
} else {
debugger.StepOver();
}
}
public static void StepOut()
{
IDebugger debugger = CurrentDebugger;
if (debugger == null || !debugger.SupportsStepping) {
return;
}
debugger.StepOut();
}
public static void Stop()
{
if (standardProcess != null) {
// OnTextMessage(new TextMessageEventArgs(String.Format("Killing {0}{1}\n",standardProcess.ProcessName,Environment.NewLine)));
standardProcess.Exited -= new EventHandler(StandardProcessExited);
standardProcess.Kill();
standardProcess.Close();
standardProcess.Dispose();
standardProcess = null;
} else {
IDebugger debugger = CurrentDebugger;
if (debugger != null) {
debugger.Stop();
}
}
isRunning = false;
}
static void StandardProcessExited(object sender, EventArgs e)
{
standardProcess.Exited -= new EventHandler(StandardProcessExited);
standardProcess.Dispose();
standardProcess = null;
isRunning = false;
}
public static event EventHandler BreakPointChanged;
public static event EventHandler BreakPointAdded;
public static event EventHandler BreakPointRemoved;

122
src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs

@ -3,6 +3,7 @@ using System; @@ -3,6 +3,7 @@ using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using System.Diagnostics;
namespace ICSharpCode.Core
{
@ -11,32 +12,14 @@ namespace ICSharpCode.Core @@ -11,32 +12,14 @@ namespace ICSharpCode.Core
System.Diagnostics.Process attachedProcess = null;
public bool IsDebugging {
get {
return IsProcessRunning;
}
}
public bool IsProcessRunning {
get {
return attachedProcess != null;
}
}
public bool SupportsStartStop {
get {
return true;
}
}
public bool SupportsExecutionControl {
get {
return false;
}
}
public bool SupportsStepping {
public bool IsProcessRunning {
get {
return false;
return IsDebugging;
}
}
@ -45,41 +28,50 @@ namespace ICSharpCode.Core @@ -45,41 +28,50 @@ namespace ICSharpCode.Core
return true;
}
public void Start(string fileName, string workingDirectory, string arguments)
public void Start(ProcessStartInfo processStartInfo)
{
if (attachedProcess != null) {
return;
}
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.FileName = fileName;
psi.WorkingDirectory = workingDirectory;
psi.Arguments = arguments;
try {
attachedProcess = new System.Diagnostics.Process();
attachedProcess.StartInfo = psi;
attachedProcess.StartInfo = processStartInfo;
attachedProcess.Exited += new EventHandler(AttachedProcessExited);
attachedProcess.EnableRaisingEvents = true;
attachedProcess.Start();
OnDebugStarted(EventArgs.Empty);
} catch (Exception) {
throw new ApplicationException("Can't execute " + "\"" + psi.FileName + "\"\n");
throw new ApplicationException("Can't execute " + "\"" + processStartInfo.FileName + "\"\n");
}
}
public void Stop()
void AttachedProcessExited(object sender, EventArgs e)
{
if (attachedProcess != null) {
attachedProcess.Exited -= new EventHandler(AttachedProcessExited);
attachedProcess.Kill();
attachedProcess.Close();
attachedProcess.Dispose();
attachedProcess = null;
attachedProcess.Exited -= new EventHandler(AttachedProcessExited);
attachedProcess.Dispose();
attachedProcess = null;
OnDebugStopped(EventArgs.Empty);
}
public bool SupportsStart {
get {
return true;
}
}
#region System.IDisposable interface implementation
public void Dispose()
public void StartWithoutDebugging(ProcessStartInfo processStartInfo)
{
throw new NotSupportedException();
}
public bool SupportsStartWithoutDebugging {
get {
return false;
}
}
public void Stop()
{
if (attachedProcess != null) {
attachedProcess.Exited -= new EventHandler(AttachedProcessExited);
@ -89,7 +81,12 @@ namespace ICSharpCode.Core @@ -89,7 +81,12 @@ namespace ICSharpCode.Core
attachedProcess = null;
}
}
#endregion
public bool SupportsStop {
get {
return true;
}
}
// ExecutionControl:
@ -103,6 +100,14 @@ namespace ICSharpCode.Core @@ -103,6 +100,14 @@ namespace ICSharpCode.Core
throw new NotSupportedException();
}
public bool SupportsExecutionControl {
get {
return false;
}
}
// Stepping:
public void StepInto()
{
throw new NotSupportedException();
@ -117,15 +122,35 @@ namespace ICSharpCode.Core @@ -117,15 +122,35 @@ namespace ICSharpCode.Core
{
throw new NotSupportedException();
}
void AttachedProcessExited(object sender, EventArgs e)
public bool SupportsStepping {
get {
return false;
}
}
public event EventHandler DebugStarted;
protected virtual void OnDebugStarted(EventArgs e)
{
attachedProcess.Exited -= new EventHandler(AttachedProcessExited);
attachedProcess.Dispose();
attachedProcess = null;
OnDebugStopped(EventArgs.Empty);
if (DebugStarted != null) {
DebugStarted(this, e);
}
}
public event EventHandler IsProcessRunningChanged;
protected virtual void OnIsProcessRunningChanged(EventArgs e)
{
if (IsProcessRunningChanged != null) {
IsProcessRunningChanged(this, e);
}
}
public event EventHandler DebugStopped;
protected virtual void OnDebugStopped(EventArgs e)
{
if (DebugStopped != null) {
@ -133,8 +158,6 @@ namespace ICSharpCode.Core @@ -133,8 +158,6 @@ namespace ICSharpCode.Core
}
}
public event EventHandler DebugStopped;
/// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// </summary>
@ -142,5 +165,10 @@ namespace ICSharpCode.Core @@ -142,5 +165,10 @@ namespace ICSharpCode.Core
{
return null;
}
public void Dispose()
{
Stop();
}
}
}

62
src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
using System;
using ICSharpCode.SharpDevelop.Project;
using System.Diagnostics;
namespace ICSharpCode.Core
{
@ -20,38 +21,34 @@ namespace ICSharpCode.Core @@ -20,38 +21,34 @@ namespace ICSharpCode.Core
get;
}
bool SupportsStartStop {
get;
}
bool CanDebug(IProject project);
/// <summary>
/// Break/Continue
/// Starts process and attaches debugger
/// </summary>
bool SupportsExecutionControl {
void Start(ProcessStartInfo processStartInfo);
bool SupportsStart {
get;
}
/// <summary>
/// Step/Step into/Step over
/// Starts process and does not attach debugger
/// </summary>
bool SupportsStepping {
void StartWithoutDebugging(ProcessStartInfo processStartInfo);
bool SupportsStartWithoutDebugging {
get;
}
bool CanDebug(IProject project);
/// <summary>
/// Starts process and attaches debugger
/// </summary>
/// <param name="fileName"></param>
/// <param name="workingDirectory"></param>
/// <param name="arguments"></param>
void Start(string fileName, string workingDirectory, string arguments);
/// <summary>
/// Stops/terminates attached process
/// </summary>
void Stop();
bool SupportsStop {
get;
}
// ExecutionControl:
@ -59,17 +56,40 @@ namespace ICSharpCode.Core @@ -59,17 +56,40 @@ namespace ICSharpCode.Core
void Continue();
bool SupportsExecutionControl {
get;
}
// Stepping:
void StepInto();
void StepOver();
void StepOut();
event EventHandler DebugStopped;
bool SupportsStepping {
get;
}
/// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// </summary>
string GetValueAsString(string variable);
/// <summary>
/// Ocurrs after the debugger has started.
/// </summary>
event EventHandler DebugStarted;
/// <summary>
/// Ocurrs when the value of IsProcessRunning changes.
/// </summary>
event EventHandler IsProcessRunningChanged;
/// <summary>
/// Ocurrs after the debugging of program is finished.
/// </summary>
event EventHandler DebugStopped;
}
}

Loading…
Cancel
Save