Browse Source

move most of the IDebugger DebuggerService infrastructure to Debugger.AddIn

filemodels
Siegfried Pammer 12 years ago
parent
commit
04d8d26fab
  1. 95
      src/AddIns/Analysis/UnitTesting/Interfaces/UnitTestDebuggerService.cs
  2. 2
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestDebugger.cs
  3. 10
      src/AddIns/Analysis/UnitTesting/TestRunner/TestDebuggerBase.cs
  4. 3
      src/AddIns/Analysis/UnitTesting/UnitTesting.csproj
  5. 10
      src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/WebBehavior.cs
  6. 4
      src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs
  7. 35
      src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmark.cs
  8. 2
      src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmarkEventArgs.cs
  9. 7
      src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml
  10. 24
      src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml.cs
  11. 18
      src/AddIns/Debugger/Debugger.AddIn/Breakpoints/CurrentLineBookmark.cs
  12. 13
      src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin
  13. 8
      src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
  14. 3
      src/AddIns/Debugger/Debugger.AddIn/Pads/BreakPointsPad.cs
  15. 2
      src/AddIns/Debugger/Debugger.AddIn/Pads/ConsolePad.cs
  16. 2
      src/AddIns/Debugger/Debugger.AddIn/Service/AttachToProcessForm.cs
  17. 9
      src/AddIns/Debugger/Debugger.AddIn/Service/DebuggerCommands.cs
  18. 1
      src/AddIns/Debugger/Debugger.AddIn/Service/EditBreakpointScriptWindow.xaml.cs
  19. 121
      src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
  20. 3
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/GraphVisualizer/ObjectGraphControl.xaml.cs
  21. 3
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/GraphVisualizer/ObjectGraphWindow.xaml.cs
  22. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IconBarMargin.cs
  23. 13
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs
  24. 4
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs
  25. 214
      src/Main/Base/Project/Debugging/BaseDebuggerService.cs
  26. 326
      src/Main/Base/Project/Debugging/IDebuggerService.cs
  27. 15
      src/Main/Base/Project/Editor/Bookmarks/BookmarkBase.cs
  28. 2
      src/Main/Base/Project/Editor/Bookmarks/BookmarkPad.cs
  29. 10
      src/Main/Base/Project/Editor/Bookmarks/BookmarkPadToolbarCommands.cs
  30. 13
      src/Main/Base/Project/Editor/Bookmarks/SDBookmark.cs
  31. 2
      src/Main/Base/Project/Editor/ToolTipService.cs
  32. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  33. 10
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  34. 9
      src/Main/Base/Project/Services/SD.cs
  35. 4
      src/Main/Base/Project/Src/Commands/BuildCommands.cs
  36. 42
      src/Main/Base/Project/Src/Commands/DebugCommands.cs
  37. 16
      src/Main/Base/Project/Src/Internal/ConditionEvaluators/DebuggerSupportsEvaluator.cs
  38. 4
      src/Main/Base/Project/Src/Internal/ConditionEvaluators/IsProcessRunningEvaluator.cs
  39. 4
      src/Main/Base/Project/Src/Project/Behaviors/DefaultProjectBehavior.cs
  40. 129
      src/Main/Base/Project/Src/Services/Debugger/DebuggerDoozer.cs
  41. 253
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  42. 197
      src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs
  43. 122
      src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs
  44. 10
      src/Main/Base/Project/Src/Services/Tasks/ErrorPainter.cs
  45. 8
      src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs

95
src/AddIns/Analysis/UnitTesting/Interfaces/UnitTestDebuggerService.cs

@ -17,18 +17,101 @@ @@ -17,18 +17,101 @@
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Debugging;
namespace ICSharpCode.UnitTesting
{
public class UnitTestDebuggerService : IUnitTestDebuggerService
public class UnitTestDebuggerService : BaseDebuggerService
{
public bool IsDebuggerLoaded {
get { return DebuggerService.IsDebuggerLoaded; }
public override bool CanDebug(ICSharpCode.SharpDevelop.Project.IProject project)
{
return SD.Debugger.CanDebug(project);
}
public IDebugger CurrentDebugger {
get { return DebuggerService.CurrentDebugger; }
public override bool Supports(DebuggerFeatures feature)
{
return SD.Debugger.Supports(feature);
}
public override void Start(System.Diagnostics.ProcessStartInfo processStartInfo)
{
SD.Debugger.Start(processStartInfo);
}
public override void StartWithoutDebugging(System.Diagnostics.ProcessStartInfo processStartInfo)
{
SD.Debugger.StartWithoutDebugging(processStartInfo);
}
public override void Stop()
{
SD.Debugger.Stop();
}
public override void Break()
{
SD.Debugger.Break();
}
public override void Continue()
{
SD.Debugger.Continue();
}
public override void StepInto()
{
SD.Debugger.StepInto();
}
public override void StepOver()
{
SD.Debugger.StepOver();
}
public override void StepOut()
{
SD.Debugger.StepOut();
}
public override void ShowAttachDialog()
{
SD.Debugger.ShowAttachDialog();
}
public override void Attach(System.Diagnostics.Process process)
{
SD.Debugger.Attach();
}
public override void Detach()
{
SD.Debugger.Detach();
}
public override bool SetInstructionPointer(string filename, int line, int column, bool dryRun)
{
return SD.Debugger.SetInstructionPointer(filename, line, column, dryRun);
}
public override void HandleToolTipRequest(ICSharpCode.SharpDevelop.Editor.ToolTipRequestEventArgs e)
{
SD.Debugger.HandleToolTipRequest(e);
}
public override void ToggleBreakpointAt(ICSharpCode.SharpDevelop.Editor.ITextEditor editor, int lineNumber)
{
SD.Debugger.ToggleBreakpointAt(editor, lineNumber);
}
public override void RemoveCurrentLineMarker()
{
SD.Debugger.RemoveCurrentLineMarker();
}
public override bool IsDebugging {
get { return SD.Debugger.IsDebugging; }
}
public override bool IsProcessRunning {
get {
return SD.Debugger.IsProcessRunning;
}
}
public override bool BreakAtBeginning {
get {
return SD.Debugger.BreakAtBeginning;
}
set {
SD.Debugger.BreakAtBeginning = value;
}
}
public override bool IsAttached {
get {
return SD.Debugger.IsAttached;
}
}
}
}

2
src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestDebugger.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.UnitTesting @@ -38,7 +38,7 @@ namespace ICSharpCode.UnitTesting
{
}
public NUnitTestDebugger(IUnitTestDebuggerService debuggerService,
public NUnitTestDebugger(IDebuggerService debuggerService,
IMessageService messageService,
ITestResultsReader testResultsReader,
UnitTestingOptions options)

10
src/AddIns/Analysis/UnitTesting/TestRunner/TestDebuggerBase.cs

@ -28,9 +28,8 @@ namespace ICSharpCode.UnitTesting @@ -28,9 +28,8 @@ namespace ICSharpCode.UnitTesting
{
public abstract class TestDebuggerBase : TestRunnerBase
{
IUnitTestDebuggerService debuggerService;
IMessageService messageService;
IDebugger debugger;
IDebuggerService debugger;
ITestResultsReader testResultsReader;
public TestDebuggerBase()
@ -40,14 +39,13 @@ namespace ICSharpCode.UnitTesting @@ -40,14 +39,13 @@ namespace ICSharpCode.UnitTesting
{
}
public TestDebuggerBase(IUnitTestDebuggerService debuggerService,
public TestDebuggerBase(IDebuggerService debuggerService,
IMessageService messageService,
ITestResultsReader testResultsReader)
{
this.debuggerService = debuggerService;
this.debugger = debuggerService;
this.messageService = messageService;
this.testResultsReader = testResultsReader;
this.debugger = debuggerService.CurrentDebugger;
testResultsReader.TestFinished += OnTestFinished;
}
@ -70,7 +68,7 @@ namespace ICSharpCode.UnitTesting @@ -70,7 +68,7 @@ namespace ICSharpCode.UnitTesting
}
public bool IsDebuggerRunning {
get { return debuggerService.IsDebuggerLoaded && debugger.IsDebugging; }
get { return debugger.IsDebuggerLoaded && debugger.IsDebugging; }
}
bool CanStopDebugging()

3
src/AddIns/Analysis/UnitTesting/UnitTesting.csproj

@ -56,6 +56,7 @@ @@ -56,6 +56,7 @@
<Compile Include="Commands\RunningTestsCondition.cs" />
<Compile Include="Commands\TestableCondition.cs" />
<Compile Include="Commands\UnitTestCommands.cs" />
<Compile Include="Interfaces\UnitTestDebuggerService.cs" />
<Compile Include="Pad\UnitTestNodeFactory.cs" />
<Compile Include="Service\ITestService.cs" />
<Compile Include="Model\ITest.cs" />
@ -64,7 +65,6 @@ @@ -64,7 +65,6 @@
<Compile Include="Model\ITestSolution.cs" />
<Compile Include="Model\TestBase.cs" />
<Compile Include="Interfaces\IBuildOptions.cs" />
<Compile Include="Interfaces\IUnitTestDebuggerService.cs" />
<Compile Include="Interfaces\IUnitTestSaveAllFilesCommand.cs" />
<Compile Include="Interfaces\IUnitTestTaskService.cs" />
<Compile Include="Interfaces\UnitTestBuildOptions.cs" />
@ -82,7 +82,6 @@ @@ -82,7 +82,6 @@
<Compile Include="Pad\TestTreeView.cs" />
<Compile Include="Pad\UnitTestNode.cs" />
<Compile Include="Pad\UnitTestsPad.cs" />
<Compile Include="Interfaces\UnitTestDebuggerService.cs" />
<Compile Include="Interfaces\UnitTestSaveAllFilesCommand.cs" />
<Compile Include="Interfaces\UnitTestTaskService.cs" />
<Compile Include="Model\TestSolution.cs" />

10
src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/WebBehavior.cs

@ -112,7 +112,7 @@ namespace ICSharpCode.AspNet.Mvc @@ -112,7 +112,7 @@ namespace ICSharpCode.AspNet.Mvc
case StartAction.Program:
ProcessStartInfo processInfo = DotNetStartBehavior.CreateStartInfo(StartProgram, Project.Directory, StartWorkingDirectory, StartArguments);
if (withDebugging) {
DebuggerService.CurrentDebugger.Start(processInfo);
SD.Debugger.Start(processInfo);
} else {
Process.Start(processInfo);
}
@ -152,14 +152,14 @@ namespace ICSharpCode.AspNet.Mvc @@ -152,14 +152,14 @@ namespace ICSharpCode.AspNet.Mvc
int index = Array.FindIndex(processes, p => properties.UseIISExpress ? p.Id == LastStartedIISExpressProcessId : p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));
if (index > -1) {
if (withDebugging)
DebuggerService.CurrentDebugger.Attach(processes[index]);
SD.Debugger.Attach(processes[index]);
} else {
if (properties.UseIISExpress) {
// start IIS express and attach to it
if (WebProjectService.IsIISExpressInstalled) {
ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject);
if (withDebugging) {
DebuggerService.CurrentDebugger.Start(processInfo);
SD.Debugger.Start(processInfo);
} else {
var process = Process.Start(processInfo);
LastStartedIISExpressProcessId = process.Id;
@ -192,9 +192,9 @@ namespace ICSharpCode.AspNet.Mvc @@ -192,9 +192,9 @@ namespace ICSharpCode.AspNet.Mvc
if (index == -1)
return;
if (withDebugging) {
DebuggerService.CurrentDebugger.Attach(processes[index]);
SD.Debugger.Attach(processes[index]);
if (!DebuggerService.CurrentDebugger.IsAttached) {
if (!SD.Debugger.IsAttached) {
if(properties.UseIIS) {
string format = ResourceService.GetString("ICSharpCode.WebProjectOptionsPanel.NoIISWP");
MessageService.ShowMessage(string.Format(format, processName));

4
src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs

@ -27,12 +27,12 @@ namespace ICSharpCode.Scripting @@ -27,12 +27,12 @@ namespace ICSharpCode.Scripting
{
public class RunScriptingConsoleApplicationCommand : AbstractMenuCommand
{
IDebugger debugger;
IDebuggerService debugger;
IScriptingWorkbench workbench;
ScriptingConsoleApplication scriptingConsoleApplication;
public RunScriptingConsoleApplicationCommand(IScriptingWorkbench workbench,
IDebugger debugger,
IDebuggerService debugger,
ScriptingConsoleApplication scriptingConsoleApplication)
{
this.workbench = workbench;

35
src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs → src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmark.cs

@ -19,17 +19,21 @@ @@ -19,17 +19,21 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor.Bookmarks;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.SharpDevelop.Debugging
namespace Debugger.AddIn.Breakpoints
{
public class BreakpointBookmark : SDMarkerBookmark
public class BreakpointBookmark : SDMarkerBookmark, IHaveStateEnabled
{
bool isHealthy = true;
bool isEnabled = true;
@ -95,11 +99,6 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -95,11 +99,6 @@ namespace ICSharpCode.SharpDevelop.Debugging
this.FileName = fileName;
}
public const string BreakpointMarker = "Breakpoint";
public static readonly Color DefaultBackground = Color.FromRgb(180, 38, 38);
public static readonly Color DefaultForeground = Colors.White;
public static IImage BreakpointImage {
get { return SD.ResourceService.GetImage("Bookmarks.Breakpoint"); }
}
@ -132,16 +131,16 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -132,16 +131,16 @@ namespace ICSharpCode.SharpDevelop.Debugging
IDocumentLine line = this.Document.GetLineByNumber(this.LineNumber);
ITextMarker marker = markerService.Create(line.Offset, line.Length);
IHighlighter highlighter = this.Document.GetService(typeof(IHighlighter)) as IHighlighter;
marker.BackgroundColor = DefaultBackground;
marker.ForegroundColor = DefaultForeground;
marker.MarkerColor = DefaultBackground;
marker.BackgroundColor = BookmarkBase.BreakpointDefaultBackground;
marker.ForegroundColor = BookmarkBase.BreakpointDefaultForeground;
marker.MarkerColor = BookmarkBase.BreakpointDefaultBackground;
marker.MarkerTypes = TextMarkerTypes.CircleInScrollBar;
if (highlighter != null) {
var color = highlighter.GetNamedColor(BreakpointMarker);
var color = highlighter.GetNamedColor(BookmarkBase.BreakpointMarkerName);
if (color != null) {
marker.BackgroundColor = color.Background.GetColor(null);
marker.MarkerColor = color.Background.GetColor(null) ?? DefaultBackground;
marker.MarkerColor = color.Background.GetColor(null) ?? BookmarkBase.BreakpointDefaultForeground;
marker.ForegroundColor = color.Foreground.GetColor(null);
}
}
@ -152,5 +151,17 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -152,5 +151,17 @@ namespace ICSharpCode.SharpDevelop.Debugging
{
return string.Format("{0} @{1}", this.FileName, this.LineNumber);
}
public override object CreateTooltipContent()
{
return new Popup {
StaysOpen = false,
Child = new Border {
Child = new BreakpointEditor(this),
BorderBrush = Brushes.Black,
BorderThickness = new Thickness(1)
}
};
}
}
}

2
src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmarkEventArgs.cs → src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmarkEventArgs.cs

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
using System;
namespace ICSharpCode.SharpDevelop.Debugging
namespace Debugger.AddIn.Breakpoints
{
public class BreakpointBookmarkEventArgs : EventArgs
{

7
src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
<UserControl x:Class="Debugger.AddIn.Breakpoints.BreakpointEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
</Grid>
</UserControl>

24
src/AddIns/Analysis/UnitTesting/Interfaces/IUnitTestDebuggerService.cs → src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml.cs

@ -17,13 +17,25 @@ @@ -17,13 +17,25 @@
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop.Debugging;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace ICSharpCode.UnitTesting
namespace Debugger.AddIn.Breakpoints
{
public interface IUnitTestDebuggerService
/// <summary>
/// Interaction logic for BreakpointEditor.xaml
/// </summary>
public partial class BreakpointEditor : UserControl
{
bool IsDebuggerLoaded { get; }
IDebugger CurrentDebugger { get; }
public BreakpointEditor(BreakpointBookmark target)
{
InitializeComponent();
}
}
}
}

18
src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs → src/AddIns/Debugger/Debugger.AddIn/Breakpoints/CurrentLineBookmark.cs

@ -85,11 +85,6 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -85,11 +85,6 @@ namespace ICSharpCode.SharpDevelop.Debugging
get { return false; }
}
public const string Name = "Current statement";
public static readonly Color DefaultBackground = Colors.Yellow;
public static readonly Color DefaultForeground = Colors.Blue;
public override int ZOrder {
get { return 100; }
}
@ -98,8 +93,9 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -98,8 +93,9 @@ namespace ICSharpCode.SharpDevelop.Debugging
get { return false; }
}
public override bool IsVisibleInBookmarkPad {
get { return false; }
public override bool ShowInPad(BookmarkPadBase pad)
{
return false;
}
public override IImage Image {
@ -114,11 +110,11 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -114,11 +110,11 @@ namespace ICSharpCode.SharpDevelop.Debugging
int eOffset = Math.Min(eLine.Offset + endColumn - 1, eLine.EndOffset);
ITextMarker marker = markerService.Create(sOffset, Math.Max(eOffset - sOffset, 1));
IHighlighter highlighter = this.Document.GetService(typeof(IHighlighter)) as IHighlighter;
marker.BackgroundColor = DefaultBackground;
marker.ForegroundColor = DefaultForeground;
marker.BackgroundColor = BookmarkBase.CurrentLineDefaultBackground;
marker.ForegroundColor = BookmarkBase.CurrentLineDefaultForeground;
if (highlighter != null) {
var color = highlighter.GetNamedColor(Name);
var color = highlighter.GetNamedColor(BookmarkBase.CurrentLineBookmarkName);
if (color != null) {
marker.BackgroundColor = color.Background.GetColor(null);
marker.ForegroundColor = color.Foreground.GetColor(null);
@ -136,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -136,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
// call async because the Debugger seems to use Application.DoEvents(), but we don't want to process events
// because Drag'N'Drop operation has finished
SD.MainThread.InvokeAsyncAndForget(delegate {
DebuggerService.CurrentDebugger.SetInstructionPointer(this.FileName, lineNumber, 1, false);
SD.Debugger.SetInstructionPointer(this.FileName, lineNumber, 1, false);
});
}
}

13
src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
</Manifest>
<Runtime>
<Import assembly=":ICSharpCode.SharpDevelop" />
<Import assembly="Debugger.AddIn.dll">
<ConditionEvaluator name = "IsBreakpointSet" class = "Debugger.AddIn.IsBreakpointCondition"/>
<ConditionEvaluator name = "IsBreakpointActive" class="Debugger.AddIn.IsActiveBreakpointCondition" />
@ -16,13 +17,9 @@ @@ -16,13 +17,9 @@
<Import assembly="Debugger.Core.dll"/>
</Runtime>
<Path name="/SharpDevelop/Services/DebuggerService/Debugger">
<Debugger id="DefaultDebugger"
supportsStepping = "true"
supportsExecutionControl = "true"
supportsAttaching = "true"
supportsDetaching = "true"
class="ICSharpCode.SharpDevelop.Services.WindowsDebugger"/>
<Path name="/SharpDevelop/Services">
<Service id="ICSharpCode.SharpDevelop.Debugging.IDebuggerService"
class="ICSharpCode.SharpDevelop.Services.WindowsDebugger" />
</Path>
<Path name = "/SharpDevelop/ViewContent/TextEditor/ContextMenu">
@ -75,7 +72,7 @@ @@ -75,7 +72,7 @@
label = "${res:MainWindow.Windows.Debug.DebugExecutable}"
class = "Debugger.AddIn.DebugExecutableMenuCommand"/>
</Condition>
<!-- <MenuItem id="AddExpressionBreakpoint"
<!-- <MenuItem id="AddExpressionBreakpoint"
insertafter="Toggle Breakpoint"
label = "${res:MainWindow.Windows.Debug.AddExpressionBreakpoint}"
shortcut="Shift|F7"

8
src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj

@ -97,6 +97,12 @@ @@ -97,6 +97,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Breakpoints\BreakpointBookmark.cs" />
<Compile Include="Breakpoints\BreakpointBookmarkEventArgs.cs" />
<Compile Include="Breakpoints\BreakpointEditor.xaml.cs">
<DependentUpon>BreakpointEditor.xaml</DependentUpon>
</Compile>
<Compile Include="Breakpoints\CurrentLineBookmark.cs" />
<Compile Include="NRefactory\ExpressionEvaluationVisitor.cs" />
<Compile Include="NRefactory\ExpressionExtensionMethods.cs" />
<Compile Include="Options\DebuggingOptionsPanel.xaml.cs">
@ -296,6 +302,7 @@ @@ -296,6 +302,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Breakpoints" />
<Folder Include="Tooltips" />
<Folder Include="Visualizers" />
<Folder Include="Visualizers\Commands" />
@ -315,6 +322,7 @@ @@ -315,6 +322,7 @@
<Folder Include="Visualizers\Presentation" />
<Folder Include="Visualizers\TextVisualizer" />
<Folder Include="Visualizers\Utils" />
<Page Include="Breakpoints\BreakpointEditor.xaml" />
<Page Include="Options\DebuggingOptionsPanel.xaml" />
<Page Include="Options\DebuggingSymbolsPanel.xaml" />
<Page Include="Pads\CommonResources.xaml" />

3
src/AddIns/Debugger/Debugger.AddIn/Pads/BreakPointsPad.cs

@ -22,6 +22,7 @@ using System.Windows.Controls; @@ -22,6 +22,7 @@ using System.Windows.Controls;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Editor.Bookmarks;
using Debugger.AddIn.Breakpoints;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
@ -42,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -42,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
protected override bool ShowBookmarkInThisPad(SDBookmark mark)
{
return mark.IsVisibleInBookmarkPad && mark is BreakpointBookmark;
return mark.ShowInPad(this) && mark is BreakpointBookmark;
}
}
}

2
src/AddIns/Debugger/Debugger.AddIn/Pads/ConsolePad.cs

@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public ConsolePad()
{
WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger;
WindowsDebugger debugger = (WindowsDebugger)SD.Debugger;
}
protected override void AbstractConsolePadTextEntered(object sender, TextCompositionEventArgs e)

2
src/AddIns/Debugger/Debugger.AddIn/Service/AttachToProcessForm.cs

@ -72,7 +72,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -72,7 +72,7 @@ namespace ICSharpCode.SharpDevelop.Services
protected override void RefreshProcessList(ListView listView, bool showNonManaged)
{
listView.Items.Clear();
WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger;
WindowsDebugger debugger = (WindowsDebugger)SD.Debugger;
Process currentProcess = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcesses()) {
try {

9
src/AddIns/Debugger/Debugger.AddIn/Service/DebuggerCommands.cs

@ -26,6 +26,7 @@ using ICSharpCode.SharpDevelop; @@ -26,6 +26,7 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Editor;
using Microsoft.Win32;
using Debugger.AddIn.Breakpoints;
using ICSharpCode.SharpDevelop.Services;
namespace Debugger.AddIn
@ -47,10 +48,10 @@ namespace Debugger.AddIn @@ -47,10 +48,10 @@ namespace Debugger.AddIn
{
ITextEditor textEditor = SD.GetActiveViewContentService<ITextEditor>();
if (textEditor == null || DebuggerService.CurrentDebugger == null)
if (textEditor == null || SD.Debugger == null)
return;
DebuggerService.CurrentDebugger.SetInstructionPointer(textEditor.FileName, textEditor.Caret.Line, textEditor.Caret.Column, false);
SD.Debugger.SetInstructionPointer(textEditor.FileName, textEditor.Caret.Line, textEditor.Caret.Column, false);
}
}
@ -144,8 +145,8 @@ namespace Debugger.AddIn @@ -144,8 +145,8 @@ namespace Debugger.AddIn
void StartExecutable(string fileName, string workingDirectory = null, string arguments = null)
{
DebuggerService.CurrentDebugger.BreakAtBeginning = DebuggingOptions.Instance.BreakAtBeginning;
DebuggerService.CurrentDebugger.Start(new ProcessStartInfo {
SD.Debugger.BreakAtBeginning = DebuggingOptions.Instance.BreakAtBeginning;
SD.Debugger.Start(new ProcessStartInfo {
FileName = fileName,
WorkingDirectory = workingDirectory ?? Path.GetDirectoryName(fileName),
Arguments = arguments

1
src/AddIns/Debugger/Debugger.AddIn/Service/EditBreakpointScriptWindow.xaml.cs

@ -31,6 +31,7 @@ using ICSharpCode.AvalonEdit.Highlighting; @@ -31,6 +31,7 @@ using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop.Debugging;
using Debugger.AddIn.Breakpoints;
namespace Debugger.AddIn
{

121
src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs

@ -25,8 +25,10 @@ using System.Linq; @@ -25,8 +25,10 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Debugger;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.Pads;
using Debugger.AddIn;
using Debugger.AddIn.Breakpoints;
using Debugger.AddIn.Tooltips;
using Debugger.AddIn.TreeModel;
using Debugger.Interop.CorPublish;
@ -43,7 +45,7 @@ using TreeNode = Debugger.AddIn.TreeModel.TreeNode; @@ -43,7 +45,7 @@ using TreeNode = Debugger.AddIn.TreeModel.TreeNode;
namespace ICSharpCode.SharpDevelop.Services
{
public class WindowsDebugger : IDebugger
public class WindowsDebugger : BaseDebuggerService
{
public static WindowsDebugger Instance { get; set; }
@ -97,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -97,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.Services
ICorPublish corPublish;
/// <inheritdoc/>
public bool BreakAtBeginning { get; set; }
public override bool BreakAtBeginning { get; set; }
public bool ServiceInitialized {
get { return CurrentDebugger != null; }
@ -116,30 +118,35 @@ namespace ICSharpCode.SharpDevelop.Services @@ -116,30 +118,35 @@ namespace ICSharpCode.SharpDevelop.Services
// string errorProcessPaused = "${res:XML.MainMenu.DebugMenu.Error.ProcessPaused}";
// string errorCannotStepNoActiveFunction = "${res:MainWindow.Windows.Debug.Threads.CannotStepNoActiveFunction}";
public bool IsDebugging {
public override bool IsDebugging {
get {
return ServiceInitialized && CurrentProcess != null;
}
}
public bool IsAttached {
public override bool IsAttached {
get {
return ServiceInitialized && attached;
}
}
public bool IsProcessRunning {
public override bool IsProcessRunning {
get {
return IsDebugging && CurrentProcess.IsRunning;
}
}
public bool CanDebug(IProject project)
public override bool CanDebug(IProject project)
{
return true;
}
public void Start(ProcessStartInfo processStartInfo)
public override bool Supports(DebuggerFeatures feature)
{
return true;
}
public override void Start(ProcessStartInfo processStartInfo)
{
if (IsDebugging) {
MessageService.ShowMessage(errorDebugging);
@ -162,8 +169,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -162,8 +169,7 @@ namespace ICSharpCode.SharpDevelop.Services
MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.KernelDebuggerEnabled}");
} else {
attached = false;
if (DebugStarting != null)
DebugStarting(this, EventArgs.Empty);
OnDebugStarting(EventArgs.Empty);
UpdateBreakpointLines();
@ -186,8 +192,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -186,8 +192,7 @@ namespace ICSharpCode.SharpDevelop.Services
}
MessageService.ShowMessage(msg);
if (DebugStopped != null)
DebugStopped(this, EventArgs.Empty);
OnDebugStopped(EventArgs.Empty);
} else {
throw;
}
@ -195,7 +200,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -195,7 +200,7 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
public void ShowAttachDialog()
public override void ShowAttachDialog()
{
using (AttachToProcessForm attachForm = new AttachToProcessForm()) {
if (attachForm.ShowDialog(SD.WinForms.MainWin32Window) == DialogResult.OK) {
@ -204,7 +209,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -204,7 +209,7 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
public void Attach(System.Diagnostics.Process existingProcess)
public override void Attach(System.Diagnostics.Process existingProcess)
{
if (existingProcess == null)
return;
@ -221,8 +226,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -221,8 +226,7 @@ namespace ICSharpCode.SharpDevelop.Services
if (version.StartsWith("v1.0")) {
MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.Net10NotSupported}");
} else {
if (DebugStarting != null)
DebugStarting(this, EventArgs.Empty);
OnDebugStarting(EventArgs.Empty);
UpdateBreakpointLines();
@ -237,8 +241,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -237,8 +241,7 @@ namespace ICSharpCode.SharpDevelop.Services
string msg = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Error.CannotAttachToProcess}");
MessageService.ShowMessage(msg + " " + e.Message);
if (DebugStopped != null)
DebugStopped(this, EventArgs.Empty);
OnDebugStopped(EventArgs.Empty);
} else {
throw;
}
@ -246,18 +249,18 @@ namespace ICSharpCode.SharpDevelop.Services @@ -246,18 +249,18 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
public void Detach()
public override void Detach()
{
ClassBrowserSupport.Detach(CurrentProcess);
CurrentDebugger.Detach();
}
public void StartWithoutDebugging(ProcessStartInfo processStartInfo)
public override void StartWithoutDebugging(ProcessStartInfo processStartInfo)
{
System.Diagnostics.Process.Start(processStartInfo);
}
public void Stop()
public override void Stop()
{
if (!IsDebugging) {
MessageService.ShowMessage(errorNotDebugging, "${res:XML.MainMenu.DebugMenu.Stop}");
@ -280,53 +283,41 @@ namespace ICSharpCode.SharpDevelop.Services @@ -280,53 +283,41 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
public void Break()
public override void Break()
{
if (CurrentProcess != null && CurrentProcess.IsRunning) {
CurrentProcess.Break();
}
}
public void Continue()
public override void Continue()
{
if (CurrentProcess != null && CurrentProcess.IsPaused) {
CurrentProcess.AsyncContinue();
}
}
public void StepInto()
public override void StepInto()
{
if (CurrentStackFrame != null) {
CurrentStackFrame.AsyncStepInto();
}
}
public void StepOver()
public override void StepOver()
{
if (CurrentStackFrame != null) {
CurrentStackFrame.AsyncStepOver();
}
}
public void StepOut()
public override void StepOut()
{
if (CurrentStackFrame != null) {
CurrentStackFrame.AsyncStepOut();
}
}
public event EventHandler DebugStarting;
public event EventHandler DebugStarted;
public event EventHandler DebugStopped;
public event EventHandler IsProcessRunningChanged;
protected virtual void OnIsProcessRunningChanged(EventArgs e)
{
if (IsProcessRunningChanged != null) {
IsProcessRunningChanged(this, e);
}
}
public bool IsManaged(int processId)
{
corPublish = new CorpubPublishClass();
@ -339,7 +330,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -339,7 +330,7 @@ namespace ICSharpCode.SharpDevelop.Services
return false;
}
public bool SetInstructionPointer(string filename, int line, int column, bool dryRun)
public override bool SetInstructionPointer(string filename, int line, int column, bool dryRun)
{
if (CurrentStackFrame != null) {
if (CurrentStackFrame.SetIP(filename, line, column, dryRun)) {
@ -350,11 +341,6 @@ namespace ICSharpCode.SharpDevelop.Services @@ -350,11 +341,6 @@ namespace ICSharpCode.SharpDevelop.Services
return false;
}
public void Dispose()
{
Stop();
}
#endregion
public event EventHandler Initialize;
@ -431,7 +417,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -431,7 +417,7 @@ namespace ICSharpCode.SharpDevelop.Services
return false;
} catch (GetValueException e) {
string errorMessage = "Error while evaluating breakpoint condition " + code + ":\n" + e.Message + "\n";
DebuggerService.PrintDebugMessage(errorMessage);
BaseDebuggerService.PrintDebugMessage(errorMessage);
SD.MainThread.InvokeAsyncAndForget(() => MessageService.ShowWarning(errorMessage));
return true;
}
@ -439,14 +425,12 @@ namespace ICSharpCode.SharpDevelop.Services @@ -439,14 +425,12 @@ namespace ICSharpCode.SharpDevelop.Services
void LogMessage(object sender, MessageEventArgs e)
{
DebuggerService.PrintDebugMessage(e.Message);
BaseDebuggerService.PrintDebugMessage(e.Message);
}
void debugger_ProcessStarted()
{
if (DebugStarted != null) {
DebugStarted(this, EventArgs.Empty);
}
OnDebugStarted(EventArgs.Empty);
CurrentProcess.ModuleLoaded += (s, e) => UpdateBreakpointIcons();
CurrentProcess.ModuleLoaded += (s, e) => RefreshPads();
@ -462,9 +446,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -462,9 +446,7 @@ namespace ICSharpCode.SharpDevelop.Services
void debugger_ProcessExited()
{
if (DebugStopped != null) {
DebugStopped(this, EventArgs.Empty);
}
OnDebugStopped(EventArgs.Empty);
ClassBrowserSupport.Detach(CurrentProcess);
CurrentProcess = null;
@ -572,7 +554,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -572,7 +554,7 @@ namespace ICSharpCode.SharpDevelop.Services
} else {
if (EvaluateCondition(bookmark.Condition)) {
breakProcess = true;
DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber, bookmark.FileName, bookmark.Condition));
BaseDebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber, bookmark.FileName, bookmark.Condition));
}
}
}
@ -588,7 +570,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -588,7 +570,7 @@ namespace ICSharpCode.SharpDevelop.Services
void debuggedProcess_DebuggingResumed(object sender, DebuggerEventArgs e)
{
OnIsProcessRunningChanged(EventArgs.Empty);
DebuggerService.RemoveCurrentLineMarker();
RemoveCurrentLineMarker();
CurrentThread = null;
CurrentStackFrame = null;
@ -612,10 +594,10 @@ namespace ICSharpCode.SharpDevelop.Services @@ -612,10 +594,10 @@ namespace ICSharpCode.SharpDevelop.Services
return;
SD.Workbench.MainWindow.Activate();
DebuggerService.RemoveCurrentLineMarker();
RemoveCurrentLineMarker();
SequencePoint nextStatement = CurrentStackFrame.NextStatement;
if (nextStatement != null) {
DebuggerService.JumpToCurrentLine(nextStatement.Filename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn);
JumpToCurrentLine(nextStatement.Filename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn);
}
}
@ -637,7 +619,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -637,7 +619,7 @@ namespace ICSharpCode.SharpDevelop.Services
.ForEach(p => e.Module.LoadSymbolsFromDisk(new []{ Path.GetDirectoryName(p.OutputAssemblyFullPath) }));
}
public void HandleToolTipRequest(ToolTipRequestEventArgs e)
public override void HandleToolTipRequest(ToolTipRequestEventArgs e)
{
if (!(IsDebugging && CurrentProcess.IsPaused))
return;
@ -665,5 +647,32 @@ namespace ICSharpCode.SharpDevelop.Services @@ -665,5 +647,32 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
}
public override void RemoveCurrentLineMarker()
{
CurrentLineBookmark.Remove();
}
public override void ToggleBreakpointAt(ITextEditor editor, int lineNumber)
{
if (editor == null)
throw new ArgumentNullException("editor");
if (!SD.BookmarkManager.RemoveBookmarkAt(editor.FileName, lineNumber, b => b is BreakpointBookmark)) {
SD.BookmarkManager.AddMark(new BreakpointBookmark(), editor.Document, lineNumber);
}
}
public override void JumpToCurrentLine(string sourceFullFilename, int startLine, int startColumn, int endLine, int endColumn)
{
IViewContent viewContent = FileService.OpenFile(sourceFullFilename);
if (viewContent != null) {
IPositionable positionable = viewContent.GetService<IPositionable>();
if (positionable != null) {
positionable.JumpTo(startLine, startColumn);
}
}
CurrentLineBookmark.SetPosition(viewContent, startLine, startColumn, endLine, endColumn);
}
}
}

3
src/AddIns/Debugger/Debugger.AddIn/Visualizers/GraphVisualizer/ObjectGraphControl.xaml.cs

@ -28,6 +28,7 @@ using System.Windows.Documents; @@ -28,6 +28,7 @@ using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.SharpDevelop;
using Debugger.AddIn.TreeModel;
using Debugger.AddIn.Visualizers.Graph.Layout;
using ICSharpCode.NRefactory.Ast;
@ -60,7 +61,7 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -60,7 +61,7 @@ namespace Debugger.AddIn.Visualizers.Graph
{
InitializeComponent();
debuggerService = DebuggerService.CurrentDebugger as WindowsDebugger;
debuggerService = SD.Debugger as WindowsDebugger;
if (debuggerService == null) throw new ApplicationException("Only windows debugger is currently supported");
this.layoutViewModel = new EnumViewModel<LayoutDirection>();

3
src/AddIns/Debugger/Debugger.AddIn/Visualizers/GraphVisualizer/ObjectGraphWindow.xaml.cs

@ -29,6 +29,7 @@ using System.Windows.Input; @@ -29,6 +29,7 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ICSharpCode.SharpDevelop;
using Debugger.AddIn.Visualizers.Graph.Layout;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Services;
@ -46,7 +47,7 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -46,7 +47,7 @@ namespace Debugger.AddIn.Visualizers.Graph
{
InitializeComponent();
debuggerService = DebuggerService.CurrentDebugger as WindowsDebugger;
debuggerService = SD.Debugger as WindowsDebugger;
if (debuggerService == null) throw new DebuggerVisualizerException("Only windows debugger is currently supported");
}

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IconBarMargin.cs

@ -265,7 +265,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -265,7 +265,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
// no bookmark on the line: create a new breakpoint
ITextEditor textEditor = TextView.GetService(typeof(ITextEditor)) as ITextEditor;
if (textEditor != null) {
DebuggerService.ToggleBreakpointAt(textEditor, line);
SD.Debugger.ToggleBreakpointAt(textEditor, line);
return;
}
}

13
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs

@ -38,6 +38,7 @@ using ICSharpCode.NRefactory.Utils; @@ -38,6 +38,7 @@ using ICSharpCode.NRefactory.Utils;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Bookmarks;
using ICSharpCode.SharpDevelop.Gui;
using Microsoft.Win32;
@ -496,7 +497,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -496,7 +497,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
items.Add(messageMarker);
IHighlightingItem breakpointMarker = new SimpleHighlightingItem(
BreakpointBookmark.BreakpointMarker,
BookmarkBase.BreakpointMarkerName,
ta => {
ta.Document.Text = "some code with a breakpoint";
ITextMarker marker = textMarkerService.Create(0, ta.Document.TextLength);
@ -506,15 +507,15 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -506,15 +507,15 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
};
})
{
Background = BreakpointBookmark.DefaultBackground,
Foreground = BreakpointBookmark.DefaultForeground
Background = BookmarkBase.BreakpointDefaultBackground,
Foreground = BookmarkBase.BreakpointDefaultForeground
};
breakpointMarker = new CustomizedHighlightingItem(customizationList, breakpointMarker, language, canSetFont: false);
breakpointMarker.PropertyChanged += item_PropertyChanged;
items.Add(breakpointMarker);
IHighlightingItem currentStatementMarker = new SimpleHighlightingItem(
CurrentLineBookmark.Name,
BookmarkBase.CurrentLineBookmarkName,
ta => {
ta.Document.Text = "current statement line";
ITextMarker marker = textMarkerService.Create(0, ta.Document.TextLength);
@ -524,8 +525,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -524,8 +525,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
};
})
{
Background = CurrentLineBookmark.DefaultBackground,
Foreground = CurrentLineBookmark.DefaultForeground
Background = BookmarkBase.CurrentLineDefaultBackground,
Foreground = BookmarkBase.CurrentLineDefaultForeground
};
currentStatementMarker = new CustomizedHighlightingItem(customizationList, currentStatementMarker, language, canSetFont: false);
currentStatementMarker.PropertyChanged += item_PropertyChanged;

4
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs

@ -143,7 +143,7 @@ namespace ICSharpCode.FormsDesigner @@ -143,7 +143,7 @@ namespace ICSharpCode.FormsDesigner
this.IsActiveViewContentChanged += this.IsActiveViewContentChangedHandler;
FileService.FileRemoving += this.FileServiceFileRemoving;
ICSharpCode.SharpDevelop.Debugging.DebuggerService.DebugStarting += this.DebugStarting;
SD.Debugger.DebugStarting += this.DebugStarting;
}
public FormsDesignerViewContent(IViewContent primaryViewContent, IDesignerLoaderProvider loaderProvider)
@ -715,7 +715,7 @@ namespace ICSharpCode.FormsDesigner @@ -715,7 +715,7 @@ namespace ICSharpCode.FormsDesigner
// to SaveInternal which requires the designer to be loaded.
base.Dispose();
} finally {
ICSharpCode.SharpDevelop.Debugging.DebuggerService.DebugStarting -= this.DebugStarting;
SD.Debugger.DebugStarting -= this.DebugStarting;
FileService.FileRemoving -= this.FileServiceFileRemoving;
this.UnloadDesigner();

214
src/Main/Base/Project/Debugging/BaseDebuggerService.cs

@ -0,0 +1,214 @@ @@ -0,0 +1,214 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Debugging
{
public abstract class BaseDebuggerService : IDebuggerService
{
protected BaseDebuggerService()
{
SD.ProjectService.SolutionOpened += delegate {
ClearDebugMessages();
};
SD.ProjectService.SolutionClosing += OnSolutionClosing;
}
public virtual void Dispose()
{
SD.ProjectService.SolutionClosing -= OnSolutionClosing;
}
bool debuggerStarted;
/// <summary>
/// Gets whether the debugger is currently active.
/// </summary>
public bool IsDebuggerStarted {
get {
return debuggerStarted;
}
}
public event EventHandler DebugStarted;
protected virtual void OnDebugStarted(EventArgs e)
{
debuggerStarted = true;
if (DebugStarted != null) {
DebugStarted(this, e);
}
}
IAnalyticsMonitorTrackedFeature debugFeature;
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)
{
debuggerStarted = false;
if (debugFeature != null)
debugFeature.EndTracking();
RemoveCurrentLineMarker();
SD.Workbench.CurrentLayoutConfiguration = "Default";
if (DebugStopped != null) {
DebugStopped(this, e);
}
}
public event EventHandler DebugStarting;
protected virtual void OnDebugStarting(EventArgs e)
{
SD.Workbench.CurrentLayoutConfiguration = "Debug";
debugFeature = SD.AnalyticsMonitor.TrackFeature("Debugger");
ClearDebugMessages();
if (DebugStarting != null)
DebugStarting(null, e);
}
void OnSolutionClosing(object sender, SolutionClosingEventArgs e)
{
if (IsDebugging) {
if (!e.AllowCancel) {
Stop();
return;
}
string caption = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Stop}");
string message = StringParser.Parse("${res:MainWindow.Windows.Debug.StopDebugging.Message}");
string[] buttonLabels = new string[] {
StringParser.Parse("${res:Global.Yes}"),
StringParser.Parse("${res:Global.No}")
};
int result = MessageService.ShowCustomDialog(caption, message, 0, // yes
1, // no
buttonLabels);
if (result == 0) {
Stop();
} else {
e.Cancel = true;
}
}
}
public abstract bool CanDebug(IProject project);
public abstract bool Supports(DebuggerFeatures feature);
public abstract void Start(ProcessStartInfo processStartInfo);
public abstract void StartWithoutDebugging(ProcessStartInfo processStartInfo);
public abstract void Stop();
public abstract void Break();
public abstract void Continue();
public abstract void StepInto();
public abstract void StepOver();
public abstract void StepOut();
public abstract void ShowAttachDialog();
public abstract void Attach(Process process);
public abstract void Detach();
public abstract bool SetInstructionPointer(string filename, int line, int column, bool dryRun);
public virtual bool IsDebuggerLoaded {
get {
return true;
}
}
public abstract bool IsDebugging {
get;
}
public abstract bool IsProcessRunning {
get;
}
public abstract bool BreakAtBeginning {
get;
set;
}
public abstract bool IsAttached {
get;
}
public abstract void HandleToolTipRequest(ToolTipRequestEventArgs e);
static MessageViewCategory debugCategory = null;
static void EnsureDebugCategory()
{
if (debugCategory == null) {
MessageViewCategory.Create(ref debugCategory, "Debug", "${res:MainWindow.Windows.OutputWindow.DebugCategory}");
}
}
public static void ClearDebugMessages()
{
EnsureDebugCategory();
debugCategory.ClearText();
}
public static void PrintDebugMessage(string msg)
{
EnsureDebugCategory();
debugCategory.AppendText(msg);
}
public abstract void ToggleBreakpointAt(ITextEditor editor, int lineNumber);
public abstract void RemoveCurrentLineMarker();
public virtual void JumpToCurrentLine(string sourceFullFilename, int startLine, int startColumn, int endLine, int endColumn)
{
IViewContent viewContent = FileService.OpenFile(sourceFullFilename);
if (viewContent != null) {
IPositionable positionable = viewContent.GetService<IPositionable>();
if (positionable != null) {
positionable.JumpTo(startLine, startColumn);
}
}
}
}
}

326
src/Main/Base/Project/Debugging/IDebuggerService.cs

@ -0,0 +1,326 @@ @@ -0,0 +1,326 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Debugging
{
[SDService("SD.Debugger", FallbackImplementation = typeof(DebuggerServiceFallback))]
public interface IDebuggerService : IDisposable, ITextAreaToolTipProvider
{
/// <summary>
/// Returns true if debugger is loaded.
/// </summary>
bool IsDebuggerLoaded {
get;
}
bool IsDebuggerStarted {
get;
}
/// <summary>
/// Returns true if debugger is attached to a process
/// </summary>
bool IsDebugging {
get;
}
/// <summary>
/// Returns true if process is running
/// Returns false if breakpoint is hit, program is breaked, program is stepped, etc...
/// </summary>
bool IsProcessRunning {
get;
}
/// <summary>
/// Gets or sets whether the debugger should break at the first line of execution.
/// </summary>
bool BreakAtBeginning {
get; set;
}
bool IsAttached {
get;
}
bool CanDebug(IProject project);
bool Supports(DebuggerFeatures feature);
/// <summary>
/// Starts process and attaches debugger
/// </summary>
void Start(ProcessStartInfo processStartInfo);
void StartWithoutDebugging(ProcessStartInfo processStartInfo);
/// <summary>
/// Stops/terminates attached process
/// </summary>
void Stop();
// ExecutionControl:
void Break();
void Continue();
// Stepping:
void StepInto();
void StepOver();
void StepOut();
/// <summary>
/// Shows a dialog so the user can attach to a process.
/// </summary>
void ShowAttachDialog();
/// <summary>
/// Used to attach to an existing process.
/// </summary>
void Attach(Process process);
void Detach();
/// <summary>
/// Set the instruction pointer to a given position.
/// </summary>
/// <returns>True if successful. False otherwise</returns>
bool SetInstructionPointer(string filename, int line, int column, bool dryRun);
void ToggleBreakpointAt(ITextEditor editor, int lineNumber);
void RemoveCurrentLineMarker();
void JumpToCurrentLine(string sourceFullFilename, int startLine, int startColumn, int endLine, int endColumn);
/// <summary>
/// Ocurrs when the debugger is starting.
/// </summary>
event EventHandler DebugStarting;
/// <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;
}
public enum DebuggerFeatures
{
Start,
StartWithoutDebugging,
Stop,
ExecutionControl,
Stepping,
Attaching,
Detaching
}
/// <summary>
/// Provides the default debugger tooltips on the text area.
/// </summary>
/// <remarks>
/// This class must be public because it is accessed via the AddInTree.
/// </remarks>
public class DebuggerTextAreaToolTipProvider : ITextAreaToolTipProvider
{
public void HandleToolTipRequest(ToolTipRequestEventArgs e)
{
if (SD.Debugger.IsDebuggerLoaded)
SD.Debugger.HandleToolTipRequest(e);
}
}
class DebuggerServiceFallback : BaseDebuggerService
{
Process attachedProcess = null;
public override bool IsDebugging {
get {
return attachedProcess != null;
}
}
public override bool IsProcessRunning {
get {
return IsDebugging;
}
}
/// <inheritdoc/>
public override bool BreakAtBeginning {
get; set;
}
public override bool CanDebug(IProject project)
{
return true;
}
public override bool Supports(DebuggerFeatures feature)
{
switch (feature) {
case DebuggerFeatures.Start:
case DebuggerFeatures.StartWithoutDebugging:
case DebuggerFeatures.Stop:
return true;
case DebuggerFeatures.ExecutionControl:
case DebuggerFeatures.Stepping:
case DebuggerFeatures.Attaching:
case DebuggerFeatures.Detaching:
return false;
default:
throw new ArgumentOutOfRangeException();
}
}
public override void Start(ProcessStartInfo processStartInfo)
{
if (attachedProcess != null) {
return;
}
OnDebugStarting(EventArgs.Empty);
try {
attachedProcess = new Process();
attachedProcess.StartInfo = processStartInfo;
attachedProcess.Exited += new EventHandler(AttachedProcessExited);
attachedProcess.EnableRaisingEvents = true;
attachedProcess.Start();
OnDebugStarted(EventArgs.Empty);
} catch (Exception) {
OnDebugStopped(EventArgs.Empty);
throw new ApplicationException("Can't execute \"" + processStartInfo.FileName + "\"\n");
}
}
public override void ShowAttachDialog()
{
}
public override void Attach(Process process)
{
}
public override void Detach()
{
}
void AttachedProcessExited(object sender, EventArgs e)
{
attachedProcess.Exited -= AttachedProcessExited;
attachedProcess.Dispose();
attachedProcess = null;
SD.MainThread.InvokeAsyncAndForget(() => new Action<EventArgs>(OnDebugStopped)(EventArgs.Empty));
}
public override void StartWithoutDebugging(ProcessStartInfo processStartInfo)
{
Process.Start(processStartInfo);
}
public override void Stop()
{
if (attachedProcess != null) {
attachedProcess.Exited -= AttachedProcessExited;
attachedProcess.Kill();
attachedProcess.Close();
attachedProcess.Dispose();
attachedProcess = null;
}
}
// ExecutionControl:
public override void Break()
{
throw new NotSupportedException();
}
public override void Continue()
{
throw new NotSupportedException();
}
// Stepping:
public override void StepInto()
{
throw new NotSupportedException();
}
public override void StepOver()
{
throw new NotSupportedException();
}
public override void StepOut()
{
throw new NotSupportedException();
}
public override void HandleToolTipRequest(ToolTipRequestEventArgs e)
{
}
public override bool SetInstructionPointer(string filename, int line, int column, bool dryRun)
{
return false;
}
public override void Dispose()
{
Stop();
base.Dispose();
}
public override bool IsAttached {
get {
return false;
}
}
public override void RemoveCurrentLineMarker()
{
}
public override void ToggleBreakpointAt(ITextEditor editor, int lineNumber)
{
}
}
}

15
src/Main/Base/Project/Editor/Bookmarks/BookmarkBase.cs

@ -199,5 +199,20 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks @@ -199,5 +199,20 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks
{
return null;
}
public const string BreakpointMarkerName = "Breakpoint";
public static readonly Color BreakpointDefaultBackground = Color.FromRgb(180, 38, 38);
public static readonly Color BreakpointDefaultForeground = Colors.White;
public const string CurrentLineBookmarkName = "Current statement";
public static readonly Color CurrentLineDefaultBackground = Colors.Yellow;
public static readonly Color CurrentLineDefaultForeground = Colors.Blue;
}
public interface IHaveStateEnabled
{
bool IsEnabled { get; set; }
}
}

2
src/Main/Base/Project/Editor/Bookmarks/BookmarkPad.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks @@ -41,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks
protected override bool ShowBookmarkInThisPad(SDBookmark bookmark)
{
return bookmark.IsVisibleInBookmarkPad && !(bookmark is BreakpointBookmark);
return bookmark.ShowInPad(this);
}
}

10
src/Main/Base/Project/Editor/Bookmarks/BookmarkPadToolbarCommands.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks @@ -34,7 +34,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks
BookmarkPadBase pad = (BookmarkPadBase)this.Owner;
if (pad.ListView.Items.Count > 0) {
pad.ListView.SelectedIndex = (pad.ListView.SelectedIndex + 1) % pad.ListView.Items.Count;
FileService.JumpToFilePosition(pad.SelectedItem.FileName, pad.SelectedItem.LineNumber, pad.SelectedItem.ColumnNumber);
SD.FileService.JumpToFilePosition(pad.SelectedItem.FileName, pad.SelectedItem.LineNumber, pad.SelectedItem.ColumnNumber);
}
}
}
@ -46,7 +46,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks @@ -46,7 +46,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks
BookmarkPadBase pad = (BookmarkPadBase)this.Owner;
if (pad.ListView.Items.Count > 0) {
pad.ListView.SelectedIndex = (pad.ListView.SelectedIndex - 1 + pad.ListView.Items.Count) % pad.ListView.Items.Count;
FileService.JumpToFilePosition(pad.SelectedItem.FileName, pad.SelectedItem.LineNumber, pad.SelectedItem.ColumnNumber);
SD.FileService.JumpToFilePosition(pad.SelectedItem.FileName, pad.SelectedItem.LineNumber, pad.SelectedItem.ColumnNumber);
}
}
}
@ -77,9 +77,9 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks @@ -77,9 +77,9 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks
{
public override void Run()
{
BookmarkPadBase pad = (BookmarkPadBase)this.Owner;
bool anyEnabled = pad.Items.OfType<BreakpointBookmark>().Any(bp => bp.IsEnabled);
foreach (var bp in pad.Items.OfType<BreakpointBookmark>()) {
BookmarkPadBase pad = (BookmarkPadBase)Owner;
bool anyEnabled = pad.Items.OfType<IHaveStateEnabled>().Any(bp => bp.IsEnabled);
foreach (var bp in pad.Items.OfType<IHaveStateEnabled>()) {
bp.IsEnabled = !anyEnabled;
}
}

13
src/Main/Base/Project/Editor/Bookmarks/SDBookmark.cs

@ -80,16 +80,11 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks @@ -80,16 +80,11 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks
}
/// <summary>
/// Gets/Sets if the bookmark is shown in the bookmark pad.
/// Gets whether the bookmark should be displayed in the given pad.
/// </summary>
/// <remarks>
/// Default is true, override this property if you are using the bookmark for
/// something special like like "CurrentLineBookmark" in the debugger.
/// </remarks>
public virtual bool IsVisibleInBookmarkPad {
get {
return true;
}
public virtual bool ShowInPad(BookmarkPadBase pad)
{
return true;
}
protected override void RemoveMark()

2
src/Main/Base/Project/Editor/ToolTipService.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -47,7 +47,7 @@ namespace ICSharpCode.SharpDevelop.Editor
}
if (CodeCompletionOptions.TooltipsOnlyWhenDebugging) {
if (!DebuggerService.IsDebuggerLoaded || !DebuggerService.CurrentDebugger.IsDebugging) {
if (!SD.Debugger.IsDebuggerLoaded || !SD.Debugger.IsDebugging) {
e.Handled = true;
return;
}

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.addin

@ -46,7 +46,6 @@ @@ -46,7 +46,6 @@
<Doozer name="TextEditorExtension" class="ICSharpCode.SharpDevelop.Editor.TextEditorExtensionDoozer"/>
<Doozer name="BrowserSchemeExtension" class="ICSharpCode.SharpDevelop.BrowserDisplayBinding.SchemeExtensionDoozer"/>
<Doozer name="CodeCompletionBinding" class="ICSharpCode.SharpDevelop.Editor.CodeCompletion.CodeCompletionBindingDoozer"/>
<Doozer name="Debugger" class="ICSharpCode.SharpDevelop.Debugging.DebuggerDoozer"/>
<Doozer name="Directory" class="ICSharpCode.SharpDevelop.DirectoryDoozer"/>
<Doozer name="TaskBoundAdditionalLogger" class="ICSharpCode.SharpDevelop.Project.TaskBoundAdditionalLoggerDoozer"/>
<Doozer name="TaskBoundLoggerFilter" class="ICSharpCode.SharpDevelop.Project.TaskBoundLoggerFilterDoozer"/>

10
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -82,6 +82,8 @@ @@ -82,6 +82,8 @@
<Compile Include="..\..\..\Libraries\ICSharpCode.Build.Tasks\Project\KnownFrameworkAssemblies.cs">
<Link>Src\Gui\Dialogs\ReferenceDialog\KnownFrameworkAssemblies.cs</Link>
</Compile>
<Compile Include="Debugging\BaseDebuggerService.cs" />
<Compile Include="Debugging\IDebuggerService.cs" />
<Compile Include="Designer\IDesignerTypeResolutionService.cs" />
<Compile Include="Designer\TypeResolutionService.cs" />
<Compile Include="Dom\ClassBrowser\AssemblyLoadErrorTreeNode.cs" />
@ -574,8 +576,6 @@ @@ -574,8 +576,6 @@
<Compile Include="Refactoring\IContextActionProvider.cs" />
<Compile Include="Src\Services\AmbienceService\DefaultAmbience.cs" />
<Compile Include="Src\Services\ClassBrowserIcons\ImageSourceImage.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmarkEventArgs.cs" />
<Compile Include="Workbench\File\IFileService.cs" />
<Compile Include="Workbench\File\OpenedFile.cs" />
<Compile Include="Src\Services\FileIconService.cs" />
@ -684,15 +684,12 @@ @@ -684,15 +684,12 @@
<Compile Include="Src\Commands\CustomStringTagProvider.cs" />
<Compile Include="Src\Commands\VBConverter\CSharpConvertBuffer.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\ActiveViewContentUntitledEvaluator.cs" />
<Compile Include="Src\Services\Debugger\DebuggerService.cs" />
<Compile Include="Src\Gui\Pads\CompilerMessageView\CompilerMessageView.cs" />
<Compile Include="Src\Internal\Templates\StandardHeaders.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\IsProcessRunningEvaluator.cs" />
<Compile Include="Src\Internal\Doozers\PadDoozer.cs" />
<Compile Include="Src\Gui\Pads\CompilerMessageView\MessageViewCategory.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\ActiveContentExtensionEvaluator.cs" />
<Compile Include="Src\Services\Debugger\IDebugger.cs" />
<Compile Include="Src\Services\Debugger\DefaultDebugger.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\ActiveWindowStateEvaluator.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\OpenWindowStateEvaluator.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\DebuggerSupportsEvaluator.cs" />
@ -790,10 +787,8 @@ @@ -790,10 +787,8 @@
<Compile Include="Src\Services\RefactoringService\RefactoringService.cs" />
<Compile Include="Src\Services\ProjectService\ParseableFileContentFinder.cs" />
<Compile Include="Src\Project\Items\ImportProjectItem.cs" />
<Compile Include="Src\Services\Debugger\CurrentLineBookmark.cs" />
<Compile Include="Src\Gui\BrowserDisplayBinding\BrowserCommands.cs" />
<Compile Include="Src\Gui\BrowserDisplayBinding\BrowserLocationConditionEvaluator.cs" />
<Compile Include="Src\Services\Debugger\DebuggerDoozer.cs" />
<Compile Include="Src\Project\ConfigurationGuiHelper.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\AbstractXmlFormsProjectOptionPanel.cs">
<SubType>UserControl</SubType>
@ -856,6 +851,7 @@ @@ -856,6 +851,7 @@
<Folder Include="Designer" />
<Folder Include="Dom\ClassBrowser" />
<Folder Include="Editor\ContextActions" />
<Folder Include="Debugging" />
<Folder Include="Project\TargetFrameworks" />
<Folder Include="Src\Editor\Dialogs" />
<Folder Include="Templates" />

9
src/Main/Base/Project/Services/SD.cs

@ -17,12 +17,10 @@ @@ -17,12 +17,10 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Linq.Expressions;
using System.Threading.Tasks;
using ICSharpCode.Core;
using ICSharpCode.Core.Implementation;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.ClassBrowser;
using ICSharpCode.SharpDevelop.Editor;
@ -281,5 +279,10 @@ namespace ICSharpCode.SharpDevelop @@ -281,5 +279,10 @@ namespace ICSharpCode.SharpDevelop
public static IClassBrowser ClassBrowser {
get { return GetRequiredService<IClassBrowser>(); }
}
/// <inheritdoc see="IDebuggerService"/>
public static IDebuggerService Debugger {
get { return GetRequiredService<IDebuggerService>(); }
}
}
}

4
src/Main/Base/Project/Src/Commands/BuildCommands.cs

@ -50,11 +50,11 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -50,11 +50,11 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public override void Run()
{
if (CanRunBuild) {
if (DebuggerService.IsDebuggerLoaded && DebuggerService.CurrentDebugger.IsDebugging) {
if (SD.Debugger.IsDebuggerLoaded && SD.Debugger.IsDebugging) {
if (MessageService.AskQuestion("${res:XML.MainMenu.RunMenu.Compile.StopDebuggingQuestion}",
"${res:XML.MainMenu.RunMenu.Compile.StopDebuggingTitle}"))
{
DebuggerService.CurrentDebugger.Stop();
SD.Debugger.Stop();
} else {
return;
}

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

@ -63,11 +63,11 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -63,11 +63,11 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
if (DebuggerService.CurrentDebugger.IsDebugging) {
LoggingService.Info("Debugger Command: Continue");
DebuggerService.CurrentDebugger.Continue();
if (SD.Debugger.IsDebugging) {
SD.Log.Info("Debugger Command: Continue");
SD.Debugger.Continue();
} else {
LoggingService.Info("Debugger Command: Run");
SD.Log.Info("Debugger Command: Run");
new Execute().Run();
}
}
@ -77,8 +77,8 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -77,8 +77,8 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
LoggingService.Info("Debugger Command: Break");
DebuggerService.CurrentDebugger.Break();
SD.Log.Info("Debugger Command: Break");
SD.Debugger.Break();
}
}
@ -86,8 +86,8 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -86,8 +86,8 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
LoggingService.Info("Debugger Command: Stop");
DebuggerService.CurrentDebugger.Stop();
SD.Log.Info("Debugger Command: Stop");
SD.Debugger.Stop();
}
}
@ -95,12 +95,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -95,12 +95,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
LoggingService.Info("Debugger Command: StepOver");
if (!DebuggerService.CurrentDebugger.IsDebugging) {
DebuggerService.CurrentDebugger.BreakAtBeginning = true;
SD.Log.Info("Debugger Command: StepOver");
if (!SD.Debugger.IsDebugging) {
SD.Debugger.BreakAtBeginning = true;
new Execute().Run();
} else {
DebuggerService.CurrentDebugger.StepOver();
SD.Debugger.StepOver();
}
}
}
@ -109,12 +109,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -109,12 +109,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
LoggingService.Info("Debugger Command: StepInto");
if (!DebuggerService.CurrentDebugger.IsDebugging) {
DebuggerService.CurrentDebugger.BreakAtBeginning = true;
SD.Log.Info("Debugger Command: StepInto");
if (!SD.Debugger.IsDebugging) {
SD.Debugger.BreakAtBeginning = true;
new Execute().Run();
} else {
DebuggerService.CurrentDebugger.StepInto();
SD.Debugger.StepInto();
}
}
}
@ -123,8 +123,8 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -123,8 +123,8 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
LoggingService.Info("Debugger Command: StepOut");
DebuggerService.CurrentDebugger.StepOut();
SD.Log.Info("Debugger Command: StepOut");
SD.Debugger.StepOut();
}
}
@ -136,7 +136,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -136,7 +136,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
if (editor != null) {
if (!string.IsNullOrEmpty(editor.FileName)) {
DebuggerService.ToggleBreakpointAt(editor, editor.Caret.Line);
SD.Debugger.ToggleBreakpointAt(editor, editor.Caret.Line);
}
}
}
@ -146,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -146,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
DebuggerService.CurrentDebugger.ShowAttachDialog();
SD.Debugger.ShowAttachDialog();
}
}
@ -154,7 +154,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -154,7 +154,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public override void Run()
{
DebuggerService.CurrentDebugger.Detach();
SD.Debugger.Detach();
}
}

16
src/Main/Base/Project/Src/Internal/ConditionEvaluators/DebuggerSupportsEvaluator.cs

@ -39,22 +39,22 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -39,22 +39,22 @@ namespace ICSharpCode.SharpDevelop.Debugging
{
public bool IsValid(object caller, Condition condition)
{
DebuggerDescriptor debugger = DebuggerService.Descriptor;
var debugger = SD.Debugger;
switch (condition.Properties["debuggersupports"]) {
case "Start":
return (debugger != null) ? debugger.SupportsStart : true;
return debugger.Supports(DebuggerFeatures.Start);
case "StartWithoutDebugging":
return (debugger != null) ? debugger.SupportsStartWithoutDebugging : true;
return debugger.Supports(DebuggerFeatures.StartWithoutDebugging);
case "Stop":
return (debugger != null) ? debugger.SupportsStop : true;
return debugger.Supports(DebuggerFeatures.Stop);
case "ExecutionControl":
return (debugger != null) ? debugger.SupportsExecutionControl : false;
return debugger.Supports(DebuggerFeatures.ExecutionControl);
case "Stepping":
return (debugger != null) ? debugger.SupportsStepping : false;
return debugger.Supports(DebuggerFeatures.Stepping);
case "Attaching":
return (debugger != null) ? debugger.SupportsAttaching : false;
return debugger.Supports(DebuggerFeatures.Attaching);
case "Detaching":
return (debugger != null) ? debugger.SupportsDetaching : false;
return debugger.Supports(DebuggerFeatures.Detaching);
default:
throw new ArgumentException("Unknown debugger support for : >" + condition.Properties["debuggersupports"] + "< please fix addin file.", "debuggersupports");
}

4
src/Main/Base/Project/Src/Internal/ConditionEvaluators/IsProcessRunningEvaluator.cs

@ -49,8 +49,8 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -49,8 +49,8 @@ namespace ICSharpCode.SharpDevelop.Debugging
{
string isdebugging = condition.Properties.Get("isdebugging", String.Empty);
string isprocessrunning = condition.Properties.Get("isprocessrunning", String.Empty);
bool debuggerIsDebugging = DebuggerService.IsDebuggerLoaded ? DebuggerService.CurrentDebugger.IsDebugging : false;
bool debuggerIsProcessRunning = DebuggerService.IsDebuggerLoaded ? DebuggerService.CurrentDebugger.IsProcessRunning : false;
bool debuggerIsDebugging = SD.Debugger.IsDebuggerLoaded ? SD.Debugger.IsDebugging : false;
bool debuggerIsProcessRunning = SD.Debugger.IsDebuggerLoaded ? SD.Debugger.IsProcessRunning : false;
bool isdebuggingPassed = (isdebugging == String.Empty) ||
(debuggerIsDebugging == Boolean.Parse(isdebugging));

4
src/Main/Base/Project/Src/Project/Behaviors/DefaultProjectBehavior.cs

@ -60,9 +60,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -60,9 +60,9 @@ namespace ICSharpCode.SharpDevelop.Project
return;
}
if (withDebugging) {
DebuggerService.CurrentDebugger.Start(psi);
SD.Debugger.Start(psi);
} else {
DebuggerService.CurrentDebugger.StartWithoutDebugging(psi);
SD.Debugger.StartWithoutDebugging(psi);
}
}

129
src/Main/Base/Project/Src/Services/Debugger/DebuggerDoozer.cs

@ -1,129 +0,0 @@ @@ -1,129 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Debugging
{
/// <summary>
/// Creates debuggers.
/// </summary>
/// <attribute name="class" use="required">
/// Name of the IDebugger class.
/// </attribute>
/// <attribute name="supportsStart" use="optional">
/// Specifies if the debugger supports the 'Start' command. Default: true
/// </attribute>
/// <attribute name="supportsStartWithoutDebugger" use="optional">
/// Specifies if the debugger supports the 'StartWithoutDebugger' command. Default: true
/// </attribute>
/// <attribute name="supportsStop" use="optional">
/// Specifies if the debugger supports the 'Stop' (kill running process) command. Default: true
/// </attribute>
/// <attribute name="supportsStepping" use="optional">
/// Specifies if the debugger supports stepping. Default: false
/// </attribute>
/// <attribute name="supportsExecutionControl" use="optional">
/// Specifies if the debugger supports execution control (break, resume). Default: false
/// </attribute>
/// <usage>Only in /SharpDevelop/Services/DebuggerService/Debugger</usage>
/// <returns>
/// An DebuggerDescriptor object that exposes the attributes and the IDebugger object (lazy-loading).
/// </returns>
public class DebuggerDoozer : IDoozer
{
/// <summary>
/// Gets if the doozer handles codon conditions on its own.
/// If this property return false, the item is excluded when the condition is not met.
/// </summary>
public bool HandleConditions {
get {
return false;
}
}
public object BuildItem(BuildItemArgs args)
{
return new DebuggerDescriptor(args.Codon);
}
}
public class DebuggerDescriptor
{
Codon codon;
public DebuggerDescriptor(Codon codon)
{
this.codon = codon;
}
IDebugger debugger;
public IDebugger Debugger {
get {
if (debugger == null)
debugger = (IDebugger)codon.AddIn.CreateObject(codon.Properties["class"]);
return debugger;
}
}
public bool SupportsStart {
get {
return codon.Properties["supportsStart"] != "false";
}
}
public bool SupportsStartWithoutDebugging {
get {
return codon.Properties["supportsStartWithoutDebugger"] != "false";
}
}
public bool SupportsStop {
get {
return codon.Properties["supportsStop"] != "false";
}
}
public bool SupportsStepping {
get {
return codon.Properties["supportsStepping"] == "true";
}
}
public bool SupportsExecutionControl {
get {
return codon.Properties["supportsExecutionControl"] == "true";
}
}
public bool SupportsAttaching {
get {
return codon.Properties["supportsAttaching"] == "true";
}
}
public bool SupportsDetaching {
get {
return codon.Properties["supportsDetaching"] == "true";
}
}
}
}

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

@ -1,253 +0,0 @@ @@ -1,253 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Bookmarks;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Debugging
{
public static class DebuggerService
{
static IDebugger currentDebugger;
static DebuggerDescriptor[] debuggers;
static DebuggerService()
{
SD.ProjectService.SolutionOpened += delegate {
ClearDebugMessages();
};
SD.ProjectService.SolutionClosing += OnSolutionClosing;
}
static void GetDescriptors()
{
if (debuggers == null) {
debuggers = AddInTree.BuildItems<DebuggerDescriptor>("/SharpDevelop/Services/DebuggerService/Debugger", null, false).ToArray();
}
}
static IDebugger GetCompatibleDebugger()
{
GetDescriptors();
// IProject project = null;
// if (ProjectService.OpenSolution != null) {
// project = ProjectService.OpenSolution.StartupProject;
// }
foreach (DebuggerDescriptor d in debuggers) {
if (d.Debugger != null /*&& d.Debugger.CanDebug(project)*/) {
return d.Debugger;
}
}
return new DefaultDebugger();
}
/// <summary>
/// Gets the current debugger. The debugger addin is loaded on demand; so if you
/// just want to check a property like IsDebugging, check <see cref="IsDebuggerLoaded"/>
/// before using this property.
/// </summary>
public static IDebugger CurrentDebugger {
get {
if (currentDebugger == null) {
currentDebugger = GetCompatibleDebugger();
currentDebugger.DebugStarting += new EventHandler(OnDebugStarting);
currentDebugger.DebugStarted += new EventHandler(OnDebugStarted);
currentDebugger.DebugStopped += new EventHandler(OnDebugStopped);
}
return currentDebugger;
}
}
public static DebuggerDescriptor Descriptor {
get {
GetDescriptors();
if (debuggers.Length > 0)
return debuggers[0];
return null;
}
}
/// <summary>
/// Returns true if debugger is already loaded.
/// </summary>
public static bool IsDebuggerLoaded {
get {
return currentDebugger != null;
}
}
static bool debuggerStarted;
/// <summary>
/// Gets whether the debugger is currently active.
/// </summary>
public static bool IsDebuggerStarted {
get { return debuggerStarted; }
}
public static event EventHandler DebugStarting;
public static event EventHandler DebugStarted;
public static event EventHandler DebugStopped;
static IAnalyticsMonitorTrackedFeature debugFeature;
static void OnDebugStarting(object sender, EventArgs e)
{
SD.Workbench.CurrentLayoutConfiguration = "Debug";
debugFeature = SD.AnalyticsMonitor.TrackFeature("Debugger");
ClearDebugMessages();
if (DebugStarting != null)
DebugStarting(null, e);
}
static void OnDebugStarted(object sender, EventArgs e)
{
debuggerStarted = true;
if (DebugStarted != null)
DebugStarted(null, e);
}
static void OnDebugStopped(object sender, EventArgs e)
{
debuggerStarted = false;
if (debugFeature != null)
debugFeature.EndTracking();
RemoveCurrentLineMarker();
SD.Workbench.CurrentLayoutConfiguration = "Default";
if (DebugStopped != null)
DebugStopped(null, e);
}
static MessageViewCategory debugCategory = null;
static void EnsureDebugCategory()
{
if (debugCategory == null) {
MessageViewCategory.Create(ref debugCategory, "Debug", "${res:MainWindow.Windows.OutputWindow.DebugCategory}");
}
}
public static void ClearDebugMessages()
{
EnsureDebugCategory();
debugCategory.ClearText();
}
public static void PrintDebugMessage(string msg)
{
EnsureDebugCategory();
debugCategory.AppendText(msg);
}
static void OnSolutionClosing(object sender, SolutionClosingEventArgs e)
{
if (currentDebugger == null)
return;
if (currentDebugger.IsDebugging) {
if (!e.AllowCancel) {
currentDebugger.Stop();
return;
}
string caption = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Stop}");
string message = StringParser.Parse("${res:MainWindow.Windows.Debug.StopDebugging.Message}");
string[] buttonLabels = new string[] { StringParser.Parse("${res:Global.Yes}"), StringParser.Parse("${res:Global.No}") };
int result = MessageService.ShowCustomDialog(caption,
message,
0, // yes
1, // no
buttonLabels);
if (result == 0) {
currentDebugger.Stop();
} else {
e.Cancel = true;
}
}
}
/// <summary>
/// Toggles a breakpoint bookmark.
/// </summary>
/// <param name="editor">Text editor where the bookmark is toggled.</param>
/// <param name="lineNumber">Line number.</param>
/// <param name="breakpointType">Type of breakpoint bookmark.</param>
/// <param name="parameters">Optional constructor parameters.</param>
public static void ToggleBreakpointAt(ITextEditor editor, int lineNumber)
{
if (editor == null)
throw new ArgumentNullException("editor");
if (!SD.BookmarkManager.RemoveBookmarkAt(editor.FileName, lineNumber, b => b is BreakpointBookmark)) {
SD.BookmarkManager.AddMark(new BreakpointBookmark(), editor.Document, lineNumber);
}
}
/* TODO: reimplement this stuff
static void ViewContentOpened(object sender, ViewContentEventArgs e)
{
textArea.IconBarMargin.MouseDown += IconBarMouseDown;
textArea.ToolTipRequest += TextAreaToolTipRequest;
textArea.MouseLeave += TextAreaMouseLeave;
}*/
public static void RemoveCurrentLineMarker()
{
CurrentLineBookmark.Remove();
}
public static void JumpToCurrentLine(string sourceFullFilename, int startLine, int startColumn, int endLine, int endColumn)
{
IViewContent viewContent = FileService.OpenFile(sourceFullFilename);
if (viewContent != null) {
IPositionable positionable = viewContent.GetService<IPositionable>();
if (positionable != null) {
positionable.JumpTo(startLine, startColumn);
}
}
CurrentLineBookmark.SetPosition(viewContent, startLine, startColumn, endLine, endColumn);
}
}
/// <summary>
/// Provides the default debugger tooltips on the text area.
/// </summary>
/// <remarks>
/// This class must be public because it is accessed via the AddInTree.
/// </remarks>
public class DebuggerTextAreaToolTipProvider : ITextAreaToolTipProvider
{
public void HandleToolTipRequest(ToolTipRequestEventArgs e)
{
if (DebuggerService.IsDebuggerLoaded)
DebuggerService.CurrentDebugger.HandleToolTipRequest(e);
}
}
}

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

@ -1,197 +0,0 @@ @@ -1,197 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Debugging
{
public class DefaultDebugger : IDebugger
{
Process attachedProcess = null;
public bool IsDebugging {
get {
return attachedProcess != null;
}
}
public bool IsProcessRunning {
get {
return IsDebugging;
}
}
/// <inheritdoc/>
public bool BreakAtBeginning {
get; set;
}
public bool CanDebug(IProject project)
{
return true;
}
public void Start(ProcessStartInfo processStartInfo)
{
if (attachedProcess != null) {
return;
}
OnDebugStarting(EventArgs.Empty);
try {
attachedProcess = new Process();
attachedProcess.StartInfo = processStartInfo;
attachedProcess.Exited += new EventHandler(AttachedProcessExited);
attachedProcess.EnableRaisingEvents = true;
attachedProcess.Start();
OnDebugStarted(EventArgs.Empty);
} catch (Exception) {
OnDebugStopped(EventArgs.Empty);
throw new ApplicationException("Can't execute \"" + processStartInfo.FileName + "\"\n");
}
}
public void ShowAttachDialog()
{
}
public void Attach(Process process)
{
}
public void Detach()
{
}
void AttachedProcessExited(object sender, EventArgs e)
{
attachedProcess.Exited -= new EventHandler(AttachedProcessExited);
attachedProcess.Dispose();
attachedProcess = null;
SD.MainThread.InvokeAsyncAndForget(() => new Action<EventArgs>(OnDebugStopped)(EventArgs.Empty));
}
public void StartWithoutDebugging(ProcessStartInfo processStartInfo)
{
Process.Start(processStartInfo);
}
public void Stop()
{
if (attachedProcess != null) {
attachedProcess.Exited -= new EventHandler(AttachedProcessExited);
attachedProcess.Kill();
attachedProcess.Close();
attachedProcess.Dispose();
attachedProcess = null;
}
}
// ExecutionControl:
public void Break()
{
throw new NotSupportedException();
}
public void Continue()
{
throw new NotSupportedException();
}
// Stepping:
public void StepInto()
{
throw new NotSupportedException();
}
public void StepOver()
{
throw new NotSupportedException();
}
public void StepOut()
{
throw new NotSupportedException();
}
public void HandleToolTipRequest(ToolTipRequestEventArgs e)
{
}
public bool SetInstructionPointer(string filename, int line, int column, bool dryRun)
{
return false;
}
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);
}
}
public event EventHandler DebugStarting;
protected virtual void OnDebugStarting(EventArgs e)
{
if (DebugStarting != null) {
DebugStarting(this, e);
}
}
public void Dispose()
{
Stop();
}
public bool IsAttached {
get {
return false;
}
}
}
}

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

@ -1,122 +0,0 @@ @@ -1,122 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Debugging
{
public interface IDebugger : IDisposable, ITextAreaToolTipProvider
{
/// <summary>
/// Returns true if debuger is attached to a process
/// </summary>
bool IsDebugging {
get;
}
/// <summary>
/// Returns true if process is running
/// Returns false if breakpoint is hit, program is breaked, program is stepped, etc...
/// </summary>
bool IsProcessRunning {
get;
}
/// <summary>
/// Gets or sets whether the debugger should break at the first line of execution.
/// </summary>
bool BreakAtBeginning {
get; set;
}
bool IsAttached {
get;
}
bool CanDebug(IProject project);
/// <summary>
/// Starts process and attaches debugger
/// </summary>
void Start(ProcessStartInfo processStartInfo);
void StartWithoutDebugging(ProcessStartInfo processStartInfo);
/// <summary>
/// Stops/terminates attached process
/// </summary>
void Stop();
// ExecutionControl:
void Break();
void Continue();
// Stepping:
void StepInto();
void StepOver();
void StepOut();
/// <summary>
/// Shows a dialog so the user can attach to a process.
/// </summary>
void ShowAttachDialog();
/// <summary>
/// Used to attach to an existing process.
/// </summary>
void Attach(Process process);
void Detach();
/// <summary>
/// Set the instruction pointer to a given position.
/// </summary>
/// <returns>True if successful. False otherwise</returns>
bool SetInstructionPointer(string filename, int line, int column, bool dryRun);
/// <summary>
/// Ocurrs when the debugger is starting.
/// </summary>
event EventHandler DebugStarting;
/// <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;
}
}

10
src/Main/Base/Project/Src/Services/Tasks/ErrorPainter.cs

@ -44,8 +44,8 @@ namespace ICSharpCode.SharpDevelop @@ -44,8 +44,8 @@ namespace ICSharpCode.SharpDevelop
TaskService.Added += OnAdded;
TaskService.Removed += OnRemoved;
TaskService.Cleared += OnCleared;
DebuggerService.DebugStarted += OnDebugStartedStopped;
DebuggerService.DebugStopped += OnDebugStartedStopped;
SD.Debugger.DebugStarted += OnDebugStartedStopped;
SD.Debugger.DebugStopped += OnDebugStartedStopped;
textEditor.Options.PropertyChanged += textEditor_Options_PropertyChanged;
ErrorColor = Colors.Red;
@ -69,8 +69,8 @@ namespace ICSharpCode.SharpDevelop @@ -69,8 +69,8 @@ namespace ICSharpCode.SharpDevelop
TaskService.Added -= OnAdded;
TaskService.Removed -= OnRemoved;
TaskService.Cleared -= OnCleared;
DebuggerService.DebugStarted -= OnDebugStartedStopped;
DebuggerService.DebugStopped -= OnDebugStartedStopped;
SD.Debugger.DebugStarted -= OnDebugStartedStopped;
SD.Debugger.DebugStopped -= OnDebugStartedStopped;
textEditor.Options.PropertyChanged -= textEditor_Options_PropertyChanged;
ClearErrors();
instances.Remove(this);
@ -142,7 +142,7 @@ namespace ICSharpCode.SharpDevelop @@ -142,7 +142,7 @@ namespace ICSharpCode.SharpDevelop
void UpdateEnabled()
{
bool newEnabled = textEditor.Options.UnderlineErrors;
if (DebuggerService.IsDebuggerStarted)
if (SD.Debugger.IsDebuggerStarted)
newEnabled = false;
if (isEnabled != newEnabled) {

8
src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs

@ -178,10 +178,10 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser @@ -178,10 +178,10 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
IAssemblyModel assemblyModel = (IAssemblyModel) parameter;
// Start debugger with given assembly
DebuggerService.CurrentDebugger.Start(new ProcessStartInfo {
FileName = assemblyModel.Context.Location,
WorkingDirectory = Path.GetDirectoryName(assemblyModel.Context.Location)
});
SD.Debugger.Start(new ProcessStartInfo {
FileName = assemblyModel.Context.Location,
WorkingDirectory = Path.GetDirectoryName(assemblyModel.Context.Location)
});
}
}

Loading…
Cancel
Save