Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/icsharpcode/ILSpy
Browse files Browse the repository at this point in the history
  • Loading branch information
pentp committed Aug 25, 2011
2 parents fad596b + eba7aa2 commit fc1fe8a
Show file tree
Hide file tree
Showing 47 changed files with 1,060 additions and 160 deletions.
31 changes: 28 additions & 3 deletions Debugger/ILSpy.Debugger/Commands/BreakpointCommand.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// 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.Linq;
using System.Windows;

using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.AvalonEdit;
using ICSharpCode.ILSpy.Bookmarks;
using ICSharpCode.ILSpy.Debugger.Bookmarks;
using ICSharpCode.ILSpy.Debugger.Services;
using Mono.Cecil;

namespace ICSharpCode.ILSpy.Debugger.Commands
{
Expand All @@ -23,17 +28,18 @@ public void Execute(int line)
// check if the codemappings exists for this line
var storage = DebugInformation.CodeMappings;
int token = 0;
foreach (var key in storage.Keys) {
var instruction = storage[key].GetInstructionByLineNumber(line, out token);
foreach (var storageEntry in storage) {
var instruction = storageEntry.Value.GetInstructionByLineNumber(line, out token);

if (instruction == null) {
continue;
}

// no bookmark on the line: create a new breakpoint
DebuggerService.ToggleBreakpointAt(
DebugInformation.DecompiledMemberReferences[key],
instruction.MemberMapping.MemberReference,
line,
token,
instruction.ILInstructionOffset,
DebugInformation.Language);
break;
Expand All @@ -47,4 +53,23 @@ public void Execute(int line)
}
}
}

[ExportBookmarkContextMenuEntry(Header="Disable Breakpoint", Category="Debugger")]
public class DisableBreakpointCommand : IBookmarkContextMenuEntry
{
public bool IsVisible(IBookmark[] bookmarks)
{
return bookmarks.Any(b => b is BreakpointBookmark && (b as BreakpointBookmark).IsEnabled);
}

public bool IsEnabled(IBookmark[] bookmarks)
{
return true;
}

public void Execute(IBookmark[] bookmarks)
{
throw new NotImplementedException();
}
}
}
3 changes: 2 additions & 1 deletion Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected void EnableDebuggerUI(bool enable)
foreach (var item in items.First().Items.OfType<MenuItem>()) {
string header = (string)item.Header;

if (header.StartsWith("Remove")) continue;
if (header.StartsWith("Remove") || header.StartsWith("Show")) continue;

if (header.StartsWith("Attach") || header.StartsWith("Debug"))
item.IsEnabled = enable;
Expand Down Expand Up @@ -307,6 +307,7 @@ internal sealed class ContinueDebuggingCommand : DebuggerCommand
public override void Execute(object parameter)
{
if (CurrentDebugger.IsDebugging && !CurrentDebugger.IsProcessRunning) {
CurrentLineBookmark.Remove();
CurrentDebugger.Continue();
MainWindow.Instance.SetStatus("Running...", Brushes.Black);
}
Expand Down
120 changes: 117 additions & 3 deletions Debugger/ILSpy.Debugger/DebuggerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,73 @@

using System;
using System.ComponentModel;
using System.Xml.Linq;

namespace ICSharpCode.ILSpy.Debugger
{
public class DebuggerSettings : INotifyPropertyChanged
{
bool showWarnings = true;
bool askArguments = true;
bool debugWholeTypesOnly = false;
#region members
private static readonly string DEBUGGER_SETTINGS = "DebuggerSettings";
private static readonly string SHOW_WARNINGS = "showWarnings";
private static readonly string ASK_ARGUMENTS = "askForArguments";
private static readonly string SHOW_BOOKMARKS = "showAllBookmarks";
private static readonly string SHOW_MODULE = "showModuleName";
private static readonly string SHOW_ARGUMENTS = "showArguments";
private static readonly string SHOW_ARGUMENTVALUE = "showArgumentValues";

private bool showWarnings = true;
private bool askArguments = true;
private bool debugWholeTypesOnly = false;
private bool showAllBookmarks = false;
private bool showModuleName = true;
private bool showArguments = false;
private bool showArgumentValues = false;

private static DebuggerSettings s_instance;
#endregion

public static DebuggerSettings Instance
{
get {
if (null == s_instance)
s_instance = new DebuggerSettings();
return s_instance;
}
}

private DebuggerSettings()
{
}

public void Load(ILSpySettings settings)
{
XElement e = settings[DEBUGGER_SETTINGS];
ShowWarnings = (bool?)e.Attribute(SHOW_WARNINGS) ?? ShowWarnings;
AskForArguments = (bool?)e.Attribute(ASK_ARGUMENTS) ?? AskForArguments;
ShowAllBookmarks = (bool?)e.Attribute(SHOW_BOOKMARKS) ?? ShowAllBookmarks;
ShowModuleName = (bool?)e.Attribute(SHOW_MODULE) ?? ShowModuleName;
ShowArguments = (bool?)e.Attribute(SHOW_ARGUMENTS) ?? ShowArguments;
ShowArgumentValues = (bool?)e.Attribute(SHOW_ARGUMENTVALUE) ?? ShowArgumentValues;
}

public void Save(XElement root)
{
XElement section = new XElement(DEBUGGER_SETTINGS);
section.SetAttributeValue(SHOW_WARNINGS, ShowWarnings);
section.SetAttributeValue(ASK_ARGUMENTS, AskForArguments);
section.SetAttributeValue(SHOW_BOOKMARKS, ShowAllBookmarks);
section.SetAttributeValue(SHOW_MODULE, ShowModuleName);
section.SetAttributeValue(SHOW_ARGUMENTS, ShowArguments);
section.SetAttributeValue(SHOW_ARGUMENTVALUE, ShowArgumentValues);

XElement existingElement = root.Element(DEBUGGER_SETTINGS);
if (existingElement != null)
existingElement.ReplaceWith(section);
else
root.Add(section);
}

/// <summary>
/// Show warnings messages.
/// <remarks>Default value is true.</remarks>
Expand Down Expand Up @@ -56,6 +114,61 @@ public bool DebugWholeTypesOnly {
}
}

/// <summary>
/// Show all bookmarks in breakpoints window.
/// </summary>
[DefaultValue(false)]
public bool ShowAllBookmarks {
get { return showAllBookmarks; }
set {
if (showAllBookmarks != value) {
showAllBookmarks = value;
OnPropertyChanged("ShowAllBookmarks");
}
}
}

/// <summary>
/// Show module name in callstack panel.
/// </summary>
[DefaultValue(true)]
public bool ShowModuleName {
get { return showModuleName; }
set {
if (showModuleName != value) {
showModuleName = value;
OnPropertyChanged("ShowModuleName");
}
}
}

/// <summary>
/// Show module name in callstack panel.
/// </summary>
[DefaultValue(false)]
public bool ShowArguments {
get { return showArguments; }
set {
if (showArguments != value) {
showArguments = value;
OnPropertyChanged("ShowArguments");
}
}
}
/// <summary>
/// Show module name in callstack panel.
/// </summary>
[DefaultValue(false)]
public bool ShowArgumentValues {
get { return showArgumentValues; }
set {
if (showArgumentValues != value) {
showArgumentValues = value;
OnPropertyChanged("ShowArgumentValues");
}
}
}

public event PropertyChangedEventHandler PropertyChanged;

protected virtual void OnPropertyChanged(string propertyName)
Expand All @@ -64,5 +177,6 @@ protected virtual void OnPropertyChanged(string propertyName)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}

}
}
15 changes: 10 additions & 5 deletions Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,32 @@
<Compile Include="Models\TreeModel\TreeNode.cs" />
<Compile Include="Models\TreeModel\Utils.cs" />
<Compile Include="Services\Debugger\DebuggerHelper.cs" />
<Compile Include="Services\Debugger\DebuggerService.cs" />
<Compile Include="Services\Debugger\IDebugger.cs" />
<Compile Include="Services\Debugger\ListHelper.cs" />
<Compile Include="Services\Debugger\TypeResolverExtension.cs" />
<Compile Include="Services\Debugger\WindowsDebugger.cs" />
<Compile Include="Services\ExtensionMethods.cs" />
<Compile Include="Services\ImageService\ImageService.cs" />
<Compile Include="Models\RunningProcess.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ParserService\ParserService.cs" />
<Compile Include="ToolTips\DebuggerPopup.cs" />
<Compile Include="ToolTips\DebuggerTooltipControl.xaml.cs">
<DependentUpon>DebuggerTooltipControl.xaml</DependentUpon>
</Compile>
<Compile Include="ToolTips\LazyItemsControl.cs" />
<Compile Include="ToolTips\Models\ToolTipRequestEventArgs.cs" />
<Compile Include="ToolTips\TextEditorListener.cs" />
<Compile Include="ToolTips\VirtualizingIEnumerable.cs" />
<Compile Include="UI\AttachToProcessWindow.xaml.cs">
<DependentUpon>AttachToProcessWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="UI\BreakpointPanel.xaml.cs" >
<DependentUpon>BreakpointPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="UI\CallStackPanel.xaml.cs" >
<DependentUpon>CallStackPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="UI\DebuggerSettingsPanel.xaml.cs">
<DependentUpon>DebuggerSettingsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
Expand All @@ -123,13 +127,14 @@
<Folder Include="Models\TreeModel" />
<Folder Include="Commands" />
<Folder Include="ToolTips" />
<Folder Include="ToolTips\Models" />
</ItemGroup>
<ItemGroup>
<Page Include="ToolTips\DebuggerTooltipControl.xaml" />
<Page Include="ToolTips\PinControlsDictionary.xaml" />
<Page Include="ToolTips\VisualizerPicker.xaml" />
<Page Include="UI\AttachToProcessWindow.xaml" />
<Page Include="UI\BreakpointPanel.xaml" />
<Page Include="UI\CallStackPanel.xaml" />
<Page Include="UI\DebuggerSettingsPanel.xaml" />
<Page Include="UI\ExecuteProcessWindow.xaml" />
</ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
Expand All @@ -27,6 +28,7 @@

namespace ICSharpCode.ILSpy.Debugger.Services
{
[Export(typeof(IDebugger))]
public class WindowsDebugger : IDebugger
{
enum StopAttachedProcessDialogResult {
Expand Down Expand Up @@ -283,7 +285,7 @@ SourceCodeMapping GetCurrentCodeMapping(out StackFrame frame, out bool isMatch)
int key = frame.MethodInfo.MetadataToken;

// get the mapped instruction from the current line marker or the next one
if (!DebugInformation.CodeMappings.ContainsKey(key))
if (DebugInformation.CodeMappings == null || !DebugInformation.CodeMappings.ContainsKey(key))
return null;

return DebugInformation.CodeMappings[key].GetInstructionByTokenAndOffset(key, frame.IP, out isMatch);
Expand Down Expand Up @@ -550,7 +552,7 @@ void AddBreakpoint(BreakpointBookmark bookmark)
debugger,
bookmark.MemberReference.DeclaringType.FullName,
bookmark.LineNumber,
bookmark.MemberReference.MetadataToken.ToInt32(),
bookmark.FunctionToken,
bookmark.ILRange.From,
bookmark.IsEnabled);

Expand Down Expand Up @@ -796,11 +798,12 @@ public void JumpToCurrentLine()
int line;
MemberReference memberReference;

if (DebugInformation.CodeMappings.ContainsKey(token) &&
if (DebugInformation.CodeMappings != null &&
DebugInformation.CodeMappings.ContainsKey(token) &&
DebugInformation.CodeMappings[token].GetInstructionByTokenAndOffset(token, ilOffset, out memberReference, out line)) {
DebugInformation.DebugStepInformation = null; // we do not need to step into/out
DebuggerService.RemoveCurrentLineMarker();
DebuggerService.JumpToCurrentLine(memberReference, line, 0, line, 0);
DebuggerService.JumpToCurrentLine(memberReference, line, 0, line, 0, ilOffset);
}
else {
StepIntoUnknownFrame(frame);
Expand Down
Loading

0 comments on commit fc1fe8a

Please sign in to comment.