diff --git a/Debugger/Debugger.Core/Process.cs b/Debugger/Debugger.Core/Process.cs
index 44ad35bac..e83d1f620 100644
--- a/Debugger/Debugger.Core/Process.cs
+++ b/Debugger/Debugger.Core/Process.cs
@@ -306,14 +306,14 @@ namespace Debugger
DebuggeeState debuggeeState;
///
- /// Indentification of the current debugger session. This value changes whenever debugger is continued
+ /// Identification of the current debugger session. This value changes whenever debugger is continued
///
public PauseSession PauseSession {
get { return pauseSession; }
}
///
- /// Indentification of the state of the debugee. This value changes whenever the state of the debugee significatntly changes
+ /// Identification of the state of the debugee. This value changes whenever the state of the debugee significantly changes
///
public DebuggeeState DebuggeeState {
get { return debuggeeState; }
@@ -341,7 +341,7 @@ namespace Debugger
}
}
- /// Sets up the eviroment and raises user events
+ /// Sets up the environment and raises user events
internal void RaisePausedEvents()
{
AssertPaused();
diff --git a/Debugger/Debugger.Core/SourcecodeSegment.cs b/Debugger/Debugger.Core/SourcecodeSegment.cs
index 459d34451..b341d9efe 100644
--- a/Debugger/Debugger.Core/SourcecodeSegment.cs
+++ b/Debugger/Debugger.Core/SourcecodeSegment.cs
@@ -372,6 +372,9 @@ namespace Debugger
public static SourcecodeSegment ResolveForIL(Module module, ICorDebugFunction corFunction, int line, int offset, int[] ranges)
{
+ if (ranges == null)
+ return null; // this would lead to a catched exception and the same result
+
try {
SourcecodeSegment segment = new SourcecodeSegment();
segment.module = module;
diff --git a/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs b/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs
index e54dfa1ef..eceee8719 100644
--- a/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs
+++ b/Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs
@@ -94,6 +94,7 @@ namespace ICSharpCode.ILSpy.Debugger.Commands
protected void StartExecutable(string fileName, string workingDirectory, string arguments)
{
+ CurrentDebugger.BreakAtBeginning = DebuggerSettings.Instance.BreakAtBeginning;
CurrentDebugger.Start(new ProcessStartInfo {
FileName = fileName,
WorkingDirectory = workingDirectory ?? Path.GetDirectoryName(fileName),
@@ -104,6 +105,7 @@ namespace ICSharpCode.ILSpy.Debugger.Commands
protected void StartAttaching(Process process)
{
+ CurrentDebugger.BreakAtBeginning = DebuggerSettings.Instance.BreakAtBeginning;
CurrentDebugger.Attach(process);
Finish();
}
@@ -202,10 +204,7 @@ namespace ICSharpCode.ILSpy.Debugger.Commands
if (!CurrentDebugger.IsDebugging) {
AssemblyTreeNode n = selectedNodes[0] as AssemblyTreeNode;
- var settings = ILSpySettings.Load();
- XElement e = settings["DebuggerSettings"];
- var askForArguments = (bool?)e.Attribute("askForArguments");
- if (askForArguments.HasValue && askForArguments.Value) {
+ if (DebuggerSettings.Instance.AskForArguments) {
var window = new ExecuteProcessWindow { Owner = MainWindow.Instance,
SelectedExecutable = n.LoadedAssembly.FileName };
if (window.ShowDialog() == true) {
@@ -236,10 +235,8 @@ namespace ICSharpCode.ILSpy.Debugger.Commands
public override void Execute(object parameter)
{
if (!CurrentDebugger.IsDebugging) {
- var settings = ILSpySettings.Load();
- XElement e = settings["DebuggerSettings"];
- var askForArguments = (bool?)e.Attribute("askForArguments");
- if (askForArguments.HasValue && askForArguments.Value) {
+ if (DebuggerSettings.Instance.AskForArguments)
+ {
var window = new ExecuteProcessWindow { Owner = MainWindow.Instance };
if (window.ShowDialog() == true) {
string fileName = window.SelectedExecutable;
@@ -280,10 +277,7 @@ namespace ICSharpCode.ILSpy.Debugger.Commands
{
if (!CurrentDebugger.IsDebugging) {
- var settings = ILSpySettings.Load();
- XElement e = settings["DebuggerSettings"];
- var showWarnings = (bool?)e.Attribute("showWarnings");
- if ((showWarnings.HasValue && showWarnings.Value) || !showWarnings.HasValue)
+ if (DebuggerSettings.Instance.ShowWarnings)
MessageBox.Show("Warning: When attaching to an application, some local variables might not be available. If possible, use the \"Start Executable\" command.",
"Attach to a process", MessageBoxButton.OK, MessageBoxImage.Warning);
@@ -313,7 +307,25 @@ namespace ICSharpCode.ILSpy.Debugger.Commands
}
}
}
-
+
+ [ExportMainMenuCommand(Menu = "_Debugger",
+ MenuIcon = "Images/Break.png",
+ MenuCategory = "SteppingArea",
+ Header = "Break",
+ IsEnabled = false,
+ MenuOrder = 2.1)]
+ internal sealed class BreakDebuggingCommand : DebuggerCommand
+ {
+ public override void Execute(object parameter)
+ {
+ if (CurrentDebugger.IsDebugging && CurrentDebugger.IsProcessRunning)
+ {
+ CurrentDebugger.Break();
+ MainWindow.Instance.SetStatus("Debugging...", Brushes.Red);
+ }
+ }
+ }
+
[ExportMainMenuCommand(Menu = "_Debugger",
MenuIcon = "Images/StepInto.png",
MenuCategory = "SteppingArea",
diff --git a/Debugger/ILSpy.Debugger/DebuggerSettings.cs b/Debugger/ILSpy.Debugger/DebuggerSettings.cs
index ab9f7e6d9..0548f19c4 100644
--- a/Debugger/ILSpy.Debugger/DebuggerSettings.cs
+++ b/Debugger/ILSpy.Debugger/DebuggerSettings.cs
@@ -17,6 +17,7 @@ namespace ICSharpCode.ILSpy.Debugger
private static readonly string SHOW_MODULE = "showModuleName";
private static readonly string SHOW_ARGUMENTS = "showArguments";
private static readonly string SHOW_ARGUMENTVALUE = "showArgumentValues";
+ private static readonly string BREAK_AT_BEGINNING = "breakAtBeginning";
private bool showWarnings = true;
private bool askArguments = true;
@@ -25,6 +26,7 @@ namespace ICSharpCode.ILSpy.Debugger
private bool showModuleName = true;
private bool showArguments = false;
private bool showArgumentValues = false;
+ private bool breakAtBeginning = false;
private static DebuggerSettings s_instance;
#endregion
@@ -32,8 +34,11 @@ namespace ICSharpCode.ILSpy.Debugger
public static DebuggerSettings Instance
{
get {
- if (null == s_instance)
+ if (null == s_instance) {
s_instance = new DebuggerSettings();
+ ILSpySettings settings = ILSpySettings.Load();
+ s_instance.Load(settings);
+ }
return s_instance;
}
}
@@ -51,6 +56,7 @@ namespace ICSharpCode.ILSpy.Debugger
ShowModuleName = (bool?)e.Attribute(SHOW_MODULE) ?? ShowModuleName;
ShowArguments = (bool?)e.Attribute(SHOW_ARGUMENTS) ?? ShowArguments;
ShowArgumentValues = (bool?)e.Attribute(SHOW_ARGUMENTVALUE) ?? ShowArgumentValues;
+ BreakAtBeginning = (bool?)e.Attribute(BREAK_AT_BEGINNING) ?? BreakAtBeginning;
}
public void Save(XElement root)
@@ -60,8 +66,9 @@ namespace ICSharpCode.ILSpy.Debugger
section.SetAttributeValue(ASK_ARGUMENTS, AskForArguments);
section.SetAttributeValue(SHOW_BOOKMARKS, ShowAllBookmarks);
section.SetAttributeValue(SHOW_MODULE, ShowModuleName);
- section.SetAttributeValue(SHOW_ARGUMENTS, ShowArguments);
+ section.SetAttributeValue(SHOW_ARGUMENTS, ShowArguments);
section.SetAttributeValue(SHOW_ARGUMENTVALUE, ShowArgumentValues);
+ section.SetAttributeValue(BREAK_AT_BEGINNING, BreakAtBeginning);
XElement existingElement = root.Element(DEBUGGER_SETTINGS);
if (existingElement != null)
@@ -169,6 +176,20 @@ namespace ICSharpCode.ILSpy.Debugger
}
}
+ ///
+ /// Break debugged process after attach or start.
+ ///
+ [DefaultValue(false)]
+ public bool BreakAtBeginning {
+ get { return breakAtBeginning; }
+ set {
+ if (breakAtBeginning != value) {
+ breakAtBeginning = value;
+ OnPropertyChanged("BreakAtBeginning");
+ }
+ }
+ }
+
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
diff --git a/Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj b/Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj
index 6018f627e..0ae541cf2 100644
--- a/Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj
+++ b/Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj
@@ -121,12 +121,7 @@
Code
-
-
-
-
-
-
+
@@ -244,5 +239,8 @@
+
+
+
\ No newline at end of file
diff --git a/Debugger/ILSpy.Debugger/Images/Break.png b/Debugger/ILSpy.Debugger/Images/Break.png
new file mode 100644
index 000000000..2f5ff8c89
Binary files /dev/null and b/Debugger/ILSpy.Debugger/Images/Break.png differ
diff --git a/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs b/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
index 31bd7766b..1af17ab75 100644
--- a/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
+++ b/Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
@@ -341,8 +341,10 @@ namespace ICSharpCode.ILSpy.Debugger.Services
MessageBox.Show(errorCannotStepNoActiveFunction, "StepOver");
} else {
var frame = GetStackFrame();
- if (frame != null)
+ if (frame != null) {
frame.AsyncStepOver();
+ //Utils.DoEvents(frame.Process);
+ }
}
}
@@ -786,7 +788,9 @@ namespace ICSharpCode.ILSpy.Debugger.Services
public void JumpToCurrentLine()
{
if (debuggedProcess != null && debuggedProcess.SelectedThread != null) {
-
+
+ MainWindow.Instance.Activate();
+
// use most recent stack frame because we don't have the symbols
var frame = debuggedProcess.SelectedThread.MostRecentStackFrame;
@@ -829,6 +833,8 @@ namespace ICSharpCode.ILSpy.Debugger.Services
TypeDefinition nestedTypeDef = null;
foreach (var assembly in DebugInformation.LoadedAssemblies) {
+ if (null == assembly)
+ continue;
if ((assembly.FullName.StartsWith("System") || assembly.FullName.StartsWith("Microsoft") || assembly.FullName.StartsWith("mscorlib")) &&
!assembly.Name.Version.ToString().StartsWith(debuggeeVersion))
continue;
diff --git a/Debugger/ILSpy.Debugger/UI/CallStackPanel.xaml.cs b/Debugger/ILSpy.Debugger/UI/CallStackPanel.xaml.cs
index 2b743841c..c3910e24e 100644
--- a/Debugger/ILSpy.Debugger/UI/CallStackPanel.xaml.cs
+++ b/Debugger/ILSpy.Debugger/UI/CallStackPanel.xaml.cs
@@ -52,9 +52,6 @@ namespace ICSharpCode.ILSpy.Debugger.UI
{
if (!IsVisible)
{
- // load debugger settings (to update context menu)
- ILSpySettings settings = ILSpySettings.Load();
- DebuggerSettings.Instance.Load(settings);
DebuggerSettings.Instance.PropertyChanged += new PropertyChangedEventHandler(OnDebuggerSettingChanged);
SwitchModuleColumn();
diff --git a/Debugger/ILSpy.Debugger/UI/DebuggerSettingsPanel.xaml b/Debugger/ILSpy.Debugger/UI/DebuggerSettingsPanel.xaml
index 92acbd1c9..384ca2929 100644
--- a/Debugger/ILSpy.Debugger/UI/DebuggerSettingsPanel.xaml
+++ b/Debugger/ILSpy.Debugger/UI/DebuggerSettingsPanel.xaml
@@ -7,6 +7,7 @@
Show warning messages
Ask for arguments and working directory before executing a process
Show all bookmarks in breakpoints window
-
+ Break debugged process at start or attach
+
\ No newline at end of file
diff --git a/ILSpy.SharpDevelop.LGPL/AvalonEdit/IconBarMargin.cs b/ILSpy.SharpDevelop.LGPL/AvalonEdit/IconBarMargin.cs
index 770159e1c..b0dd2465f 100644
--- a/ILSpy.SharpDevelop.LGPL/AvalonEdit/IconBarMargin.cs
+++ b/ILSpy.SharpDevelop.LGPL/AvalonEdit/IconBarMargin.cs
@@ -141,9 +141,11 @@ namespace ICSharpCode.ILSpy.AvalonEdit
foreach (BookmarkBase bm in BookmarkManager.Bookmarks) {
if (bm.LineNumber != line)
continue;
- if (DebugInformation.CodeMappings == null || DebugInformation.CodeMappings.Count == 0 ||
- !DebugInformation.CodeMappings.ContainsKey(((BreakpointBookmark)bm).FunctionToken))
- continue;
+ if (bm is BreakpointBookmark) {
+ if (DebugInformation.CodeMappings == null || DebugInformation.CodeMappings.Count == 0 ||
+ !DebugInformation.CodeMappings.ContainsKey(((BreakpointBookmark)bm).FunctionToken))
+ continue;
+ }
if (result == null || bm.ZOrder > result.ZOrder)
return result;
diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs
index 20bdbf65b..a2a171a2f 100644
--- a/ILSpy/TextView/DecompilerTextView.cs
+++ b/ILSpy/TextView/DecompilerTextView.cs
@@ -479,8 +479,9 @@ namespace ICSharpCode.ILSpy.TextView
MemberReference member;
if (DebugInformation.CodeMappings == null || !DebugInformation.CodeMappings.ContainsKey(token))
return;
-
- DebugInformation.CodeMappings[token].GetInstructionByTokenAndOffset(ilOffset, out member, out line);
+
+ if (!DebugInformation.CodeMappings[token].GetInstructionByTokenAndOffset(ilOffset, out member, out line))
+ return;
// update marker
DebuggerService.JumpToCurrentLine(member, line, 0, line, 0, ilOffset);