Browse Source

Break command and break on start debugging

pull/310/merge
Ronny Klier 14 years ago
committed by Daniel Grunwald
parent
commit
decceeb761
  1. 6
      Debugger/Debugger.Core/Process.cs
  2. 3
      Debugger/Debugger.Core/SourcecodeSegment.cs
  3. 38
      Debugger/ILSpy.Debugger/Commands/DebuggerCommands.cs
  4. 25
      Debugger/ILSpy.Debugger/DebuggerSettings.cs
  5. 10
      Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj
  6. BIN
      Debugger/ILSpy.Debugger/Images/Break.png
  7. 4
      Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
  8. 3
      Debugger/ILSpy.Debugger/UI/CallStackPanel.xaml.cs
  9. 3
      Debugger/ILSpy.Debugger/UI/DebuggerSettingsPanel.xaml
  10. 8
      ILSpy.SharpDevelop.LGPL/AvalonEdit/IconBarMargin.cs
  11. 5
      ILSpy/TextView/DecompilerTextView.cs

6
Debugger/Debugger.Core/Process.cs

@ -306,14 +306,14 @@ namespace Debugger
DebuggeeState debuggeeState;
/// <summary>
/// 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
/// </summary>
public PauseSession PauseSession {
get { return pauseSession; }
}
/// <summary>
/// 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
/// </summary>
public DebuggeeState DebuggeeState {
get { return debuggeeState; }
@ -341,7 +341,7 @@ namespace Debugger
}
}
/// <summary> Sets up the eviroment and raises user events </summary>
/// <summary> Sets up the environment and raises user events </summary>
internal void RaisePausedEvents()
{
AssertPaused();

3
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;

38
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",

25
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
}
}
/// <summary>
/// Break debugged process after attach or start.
/// </summary>
[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)

10
Debugger/ILSpy.Debugger/ILSpy.Debugger.csproj

@ -121,12 +121,7 @@
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Images" />
<Folder Include="Models\TreeModel" />
<Folder Include="Commands" />
<Folder Include="ToolTips" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Page Include="ToolTips\DebuggerTooltipControl.xaml" />
<Page Include="ToolTips\PinControlsDictionary.xaml" />
@ -244,5 +239,8 @@
<ItemGroup>
<Resource Include="Images\application-x-executable.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Break.png" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

BIN
Debugger/ILSpy.Debugger/Images/Break.png

After

Width: 16  |  Height: 16  |  Size: 341 B

4
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);
}
}
}

3
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();

3
Debugger/ILSpy.Debugger/UI/DebuggerSettingsPanel.xaml

@ -7,6 +7,7 @@
<CheckBox IsChecked="{Binding ShowWarnings}">Show warning messages</CheckBox>
<CheckBox IsChecked="{Binding AskForArguments}">Ask for arguments and working directory before executing a process</CheckBox>
<CheckBox IsChecked="{Binding ShowAllBookmarks}">Show all bookmarks in breakpoints window</CheckBox>
</StackPanel>
<CheckBox IsChecked="{Binding BreakAtBeginning}">Break debugged process at start or attach</CheckBox>
</StackPanel>
</Grid>
</UserControl>

8
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;

5
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);

Loading…
Cancel
Save