From e67c669eb18a310cdb5608df79579e1cc4fc9d88 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 16 Jul 2013 22:52:23 +0200 Subject: [PATCH] add "debug executable" --- .../Debugger.AddIn/Debugger.AddIn.addin | 9 ++ .../Debugger.AddIn/Debugger.AddIn.csproj | 4 + .../Options/DebuggingOptions.cs | 10 ++ .../Options/DebuggingOptionsPanel.xaml | 8 ++ .../Service/DebuggerCommands.cs | 42 ++++++- .../Service/ExecuteProcessWindow.xaml | 113 ++++++++++++++++++ .../Service/ExecuteProcessWindow.xaml.cs | 84 +++++++++++++ .../Debugger.AddIn/Service/WindowsDebugger.cs | 2 +- .../Debugger/Debugger.Core/PdbSymbolSource.cs | 35 +++--- 9 files changed, 289 insertions(+), 18 deletions(-) create mode 100644 src/AddIns/Debugger/Debugger.AddIn/Service/ExecuteProcessWindow.xaml create mode 100644 src/AddIns/Debugger/Debugger.AddIn/Service/ExecuteProcessWindow.xaml.cs diff --git a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin index 42f941260f..4d7ad92c6b 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin +++ b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin @@ -68,6 +68,15 @@ + + + + + + EditBreakpointScriptWindow.xaml Code + + ExecuteProcessWindow.xaml + @@ -312,6 +315,7 @@ + diff --git a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs index 8192c68cbf..0b50c9ee59 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs @@ -69,6 +69,16 @@ namespace ICSharpCode.SharpDevelop.Services set { PS.Set("Debugger.PauseOnHandledExceptions", value); } } + public bool AskForArguments { + get { return PS.Get("Debugger.AskForArguments", false); } + set { PS.Set("Debugger.AskForArguments", value); } + } + + public bool BreakAtBeginning { + get { return PS.Get("Debugger.BreakAtBeginning", false); } + set { PS.Set("Debugger.BreakAtBeginning", value); } + } + public ShowIntegersAs ShowIntegersAs { get { return PS.Get("Debugger.ShowIntegersAs", ShowIntegersAs.Decimal); } set { PS.Set("Debugger.ShowIntegersAs", value); } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptionsPanel.xaml b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptionsPanel.xaml index 5cc4caef34..7134b3fa66 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptionsPanel.xaml +++ b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptionsPanel.xaml @@ -34,5 +34,13 @@ IsChecked="{sd:OptionBinding debugger:DebuggingOptions.SuppressNGENOptimization}" /> + + + + + + \ No newline at end of file diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/DebuggerCommands.cs b/src/AddIns/Debugger/Debugger.AddIn/Service/DebuggerCommands.cs index 87f76cf11e..76b61a22a7 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Service/DebuggerCommands.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Service/DebuggerCommands.cs @@ -3,11 +3,14 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.IO; using System.Linq; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Editor; +using Microsoft.Win32; using ICSharpCode.SharpDevelop.Services; namespace Debugger.AddIn @@ -28,7 +31,7 @@ namespace Debugger.AddIn public override void Run() { ITextEditor textEditor = SD.GetActiveViewContentService(); - + if (textEditor == null || DebuggerService.CurrentDebugger == null) return; @@ -97,4 +100,41 @@ namespace Debugger.AddIn return BreakpointUtil.BreakpointsOnCaret.Any(); } } + + public class DebugExecutableMenuCommand : AbstractMenuCommand + { + public override void Run() + { + if (DebuggingOptions.Instance.AskForArguments) { + var window = new ExecuteProcessWindow { Owner = SD.Workbench.MainWindow }; + if (window.ShowDialog() == true) { + string fileName = window.SelectedExecutable; + + // execute the process + StartExecutable(fileName, window.WorkingDirectory, window.Arguments); + } + } else { + OpenFileDialog dialog = new OpenFileDialog() { + Filter = ".NET Executable (*.exe) | *.exe", + RestoreDirectory = true, + DefaultExt = "exe" + }; + if (dialog.ShowDialog() == true) { + string fileName = dialog.FileName; + // execute the process + StartExecutable(fileName); + } + } + } + + void StartExecutable(string fileName, string workingDirectory = null, string arguments = null) + { + DebuggerService.CurrentDebugger.BreakAtBeginning = DebuggingOptions.Instance.BreakAtBeginning; + DebuggerService.CurrentDebugger.Start(new ProcessStartInfo { + FileName = fileName, + WorkingDirectory = workingDirectory ?? Path.GetDirectoryName(fileName), + Arguments = arguments + }); + } + } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/ExecuteProcessWindow.xaml b/src/AddIns/Debugger/Debugger.AddIn/Service/ExecuteProcessWindow.xaml new file mode 100644 index 0000000000..e3e510fcc0 --- /dev/null +++ b/src/AddIns/Debugger/Debugger.AddIn/Service/ExecuteProcessWindow.xaml @@ -0,0 +1,113 @@ + + + + + + + +