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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/ExecuteProcessWindow.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Service/ExecuteProcessWindow.xaml.cs
new file mode 100644
index 0000000000..56f37ee09a
--- /dev/null
+++ b/src/AddIns/Debugger/Debugger.AddIn/Service/ExecuteProcessWindow.xaml.cs
@@ -0,0 +1,84 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Windows;
+using System.Windows.Forms;
+
+namespace ICSharpCode.SharpDevelop.Services
+{
+ ///
+ /// Interaction logic for ExecuteProcessWindow.xaml
+ ///
+ public partial class ExecuteProcessWindow : Window
+ {
+ public ExecuteProcessWindow()
+ {
+ InitializeComponent();
+ }
+
+ public string SelectedExecutable {
+ get {
+ return pathTextBox.Text;
+ }
+ set {
+ pathTextBox.Text = value;
+ workingDirectoryTextBox.Text = Path.GetDirectoryName(value);
+ }
+ }
+
+ public string WorkingDirectory {
+ get {
+ return workingDirectoryTextBox.Text;
+ }
+ set {
+ workingDirectoryTextBox.Text = value;
+ }
+ }
+
+ public string Arguments {
+ get {
+ return argumentsTextBox.Text;
+ }
+ }
+
+ void pathButton_Click(object sender, RoutedEventArgs e)
+ {
+ OpenFileDialog dialog = new OpenFileDialog() {
+ Filter = ".NET Executable (*.exe) | *.exe",
+ InitialDirectory = workingDirectoryTextBox.Text,
+ RestoreDirectory = true,
+ DefaultExt = "exe"
+ };
+
+ if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
+ SelectedExecutable = dialog.FileName;
+ }
+ }
+
+ void ExecuteButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrEmpty(SelectedExecutable))
+ return;
+ this.DialogResult = true;
+ }
+
+ void CancelButton_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ void workingDirectoryButton_Click(object sender, RoutedEventArgs e)
+ {
+ FolderBrowserDialog dialog = new FolderBrowserDialog() {
+ SelectedPath = workingDirectoryTextBox.Text
+ };
+ if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
+ workingDirectoryTextBox.Text = dialog.SelectedPath;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
index 77ad2ab3bb..01c8757f64 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
@@ -466,7 +466,7 @@ namespace ICSharpCode.SharpDevelop.Services
CurrentProcess = e.Process;
CurrentThread = e.Thread;
- CurrentStackFrame = CurrentThread != null ? CurrentThread.MostRecentUserStackFrame : null;
+ CurrentStackFrame = CurrentThread != null ? CurrentThread.MostRecentStackFrame : null;
// We can have several events happening at the same time
bool breakProcess = e.Break;
diff --git a/src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs b/src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs
index 77722bf759..c8d7aa7fa4 100644
--- a/src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs
+++ b/src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs
@@ -12,7 +12,7 @@ using Debugger.Interop.CorSym;
using ICSharpCode.NRefactory.TypeSystem;
namespace Debugger
-{
+{
public class SequencePoint
{
public uint MethodDefToken { get; set; }
@@ -88,7 +88,9 @@ namespace Debugger
{
public bool Handles(IMethod method)
{
- return method.ParentAssembly.GetModule().SymReader != null;
+ return method.ParentAssembly.GetModule().HasSymbols
+ && !IsCompilerGenerated(method)
+ && GetSequencePoint(method, 0) != null;
}
public bool IsCompilerGenerated(IMethod method)
@@ -119,7 +121,7 @@ namespace Debugger
static IEnumerable RelocatePath(string basePath, string origPath)
{
if (!string.IsNullOrEmpty(origPath)) {
- if (Path.IsPathRooted(origPath)) {
+ if (Path.IsPathRooted(origPath)) {
// Try without relocating
yield return origPath;
@@ -169,18 +171,19 @@ namespace Debugger
// Find point for which (ilstart <= iloffset < ilend) or fallback to the next valid sequence point
var sequencePoint = realSeqPoints.FirstOrDefault(p => p.ILRanges.Any(r => r.From <= iloffset && iloffset < r.To)) ??
- realSeqPoints.FirstOrDefault(p => iloffset <= p.ILOffset);
-
- // VB.NET sometimes produces temporary files which it then deletes
- // (eg 17d14f5c-a337-4978-8281-53493378c1071.vb)
- string name = Path.GetFileName(sequencePoint.Filename);
- if (name.Length == 40 && name.EndsWith(".vb")) {
- if (name.Substring(0, name.Length - 3).All(c => ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || (c == '-'))) {
- return null;
- }
- }
+ realSeqPoints.FirstOrDefault(p => iloffset <= p.ILOffset);
if (sequencePoint != null) {
+ // VB.NET sometimes produces temporary files which it then deletes
+ // (eg 17d14f5c-a337-4978-8281-53493378c1071.vb)
+ string name = Path.GetFileName(sequencePoint.Filename);
+ if (name.Length == 40 && name.EndsWith(".vb")) {
+ if (name.Substring(0, name.Length - 3).All(c => ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || (c == '-'))) {
+ return null;
+ }
+ }
+
+
sequencePoint.Filename = GetSourceCodePath(method.ParentAssembly.GetModule().Process, sequencePoint.Filename);
}
@@ -195,7 +198,7 @@ namespace Debugger
ISymUnmanagedReader symReader = module.SymReader;
if (symReader == null)
return null; // No symbols
-
+
// Find ISymUnmanagedDocument which excactly matches the filename.
var symDoc = module.SymDocuments.FirstOrDefault(d => string.Equals(filename, d.GetURL(), StringComparison.OrdinalIgnoreCase));
@@ -218,7 +221,7 @@ namespace Debugger
SequencePoint seqPoint = null;
if (column != 0) {
seqPoint = seqPoints.FirstOrDefault(s => (s.StartLine < line || (s.StartLine == line && s.StartColumn <= column)) &&
- (line < s.EndLine || (line == s.EndLine && column <= s.EndColumn)));
+ (line < s.EndLine || (line == s.EndLine && column <= s.EndColumn)));
}
seqPoint = seqPoint ?? seqPoints.FirstOrDefault(s => line <= s.StartLine);
return seqPoint;
@@ -252,7 +255,7 @@ namespace Debugger
Type = method.GetLocalVariableType(index),
Name = symVar.GetName(),
IsCompilerGenerated = (symVar.GetAttributes() & 1) == 1,
- // symVar also has Get*Offset methods, but the are not implemented
+ // symVar also has Get*Offset methods, but the are not implemented
ILRanges = new [] { new ILRange() { From = (int)scope.GetStartOffset(), To = (int)scope.GetEndOffset() } }
});
}