Browse Source

Merge remote branch 'eusebiu/master'

pull/15/head
Eusebiu Marcu 15 years ago
parent
commit
8d447b5b69
  1. 1495
      src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
  2. 359
      src/AddIns/Debugger/Debugger.Core/Breakpoint.cs
  3. 1294
      src/AddIns/Debugger/Debugger.Core/Process.cs
  4. 54
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  5. 14
      src/Main/Base/Project/Src/Commands/DebugCommands.cs
  6. 5
      src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs
  7. 7
      src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

1495
src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs

File diff suppressed because it is too large Load Diff

359
src/AddIns/Debugger/Debugger.Core/Breakpoint.cs

@ -1,175 +1,184 @@ @@ -1,175 +1,184 @@
// 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.Runtime.InteropServices;
using Debugger.Interop.CorDebug;
namespace Debugger
{
public class Breakpoint: DebuggerObject
{
NDebugger debugger;
string fileName;
byte[] checkSum;
int line;
int column;
bool enabled;
SourcecodeSegment originalLocation;
List<ICorDebugFunctionBreakpoint> corBreakpoints = new List<ICorDebugFunctionBreakpoint>();
public event EventHandler<BreakpointEventArgs> Hit;
public event EventHandler<BreakpointEventArgs> Set;
[Debugger.Tests.Ignore]
public NDebugger Debugger {
get { return debugger; }
}
public string FileName {
get { return fileName; }
}
public byte[] CheckSum {
get { return checkSum; }
}
public int Line {
get { return line; }
set { line = value; }
}
public int Column {
get { return column; }
}
public bool Enabled {
get { return enabled; }
set {
enabled = value;
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) {
corBreakpoint.Activate(enabled ? 1 : 0);
}
}
}
public SourcecodeSegment OriginalLocation {
get { return originalLocation; }
}
public bool IsSet {
get {
return corBreakpoints.Count > 0;
}
}
protected virtual void OnHit(BreakpointEventArgs e)
{
if (Hit != null) {
Hit(this, e);
}
}
internal void NotifyHit()
{
OnHit(new BreakpointEventArgs(this));
debugger.Breakpoints.OnHit(this);
}
protected virtual void OnSet(BreakpointEventArgs e)
{
if (Set != null) {
Set(this, e);
}
}
public Breakpoint(NDebugger debugger, string fileName, byte[] checkSum, int line, int column, bool enabled)
{
this.debugger = debugger;
this.fileName = fileName;
this.checkSum = checkSum;
this.line = line;
this.column = column;
this.enabled = enabled;
}
internal bool IsOwnerOf(ICorDebugBreakpoint breakpoint)
{
foreach(ICorDebugFunctionBreakpoint corFunBreakpoint in corBreakpoints) {
if (((ICorDebugBreakpoint)corFunBreakpoint).Equals(breakpoint)) return true;
}
return false;
}
internal void Deactivate()
{
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) {
#if DEBUG
// Get repro
corBreakpoint.Activate(0);
#else
try {
corBreakpoint.Activate(0);
} catch(COMException e) {
// Sometimes happens, but we had not repro yet.
// 0x80131301: Process was terminated.
if ((uint)e.ErrorCode == 0x80131301)
continue;
throw;
}
#endif
}
corBreakpoints.Clear();
}
internal void MarkAsDeactivated()
{
corBreakpoints.Clear();
}
internal bool SetBreakpoint(Module module)
{
SourcecodeSegment segment = SourcecodeSegment.Resolve(module, FileName, CheckSum, Line, Column);
if (segment == null) return false;
originalLocation = segment;
ICorDebugFunctionBreakpoint corBreakpoint = segment.CorFunction.GetILCode().CreateBreakpoint((uint)segment.ILStart);
corBreakpoint.Activate(enabled ? 1 : 0);
corBreakpoints.Add(corBreakpoint);
OnSet(new BreakpointEventArgs(this));
return true;
}
/// <summary> Remove this breakpoint </summary>
public void Remove()
{
debugger.Breakpoints.Remove(this);
}
}
[Serializable]
public class BreakpointEventArgs : DebuggerEventArgs
{
Breakpoint breakpoint;
public Breakpoint Breakpoint {
get {
return breakpoint;
}
}
public BreakpointEventArgs(Breakpoint breakpoint): base(breakpoint.Debugger)
{
this.breakpoint = breakpoint;
}
}
}
// 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.Runtime.InteropServices;
using Debugger.Interop.CorDebug;
namespace Debugger
{
public class Breakpoint: DebuggerObject
{
NDebugger debugger;
string fileName;
byte[] checkSum;
int line;
int column;
bool enabled;
SourcecodeSegment originalLocation;
List<ICorDebugFunctionBreakpoint> corBreakpoints = new List<ICorDebugFunctionBreakpoint>();
public event EventHandler<BreakpointEventArgs> Hit;
public event EventHandler<BreakpointEventArgs> Set;
[Debugger.Tests.Ignore]
public NDebugger Debugger {
get { return debugger; }
}
public string FileName {
get { return fileName; }
}
public byte[] CheckSum {
get { return checkSum; }
}
public int Line {
get { return line; }
set { line = value; }
}
public int Column {
get { return column; }
}
public bool Enabled {
get { return enabled; }
set {
enabled = value;
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) {
corBreakpoint.Activate(enabled ? 1 : 0);
}
}
}
public SourcecodeSegment OriginalLocation {
get { return originalLocation; }
}
public bool IsSet {
get {
return corBreakpoints.Count > 0;
}
}
protected virtual void OnHit(BreakpointEventArgs e)
{
if (Hit != null) {
Hit(this, e);
}
}
internal void NotifyHit()
{
OnHit(new BreakpointEventArgs(this));
debugger.Breakpoints.OnHit(this);
}
protected virtual void OnSet(BreakpointEventArgs e)
{
if (Set != null) {
Set(this, e);
}
}
public Breakpoint(NDebugger debugger, ICorDebugFunctionBreakpoint corBreakpoint)
{
this.debugger = debugger;
this.corBreakpoints.Add(corBreakpoint);
}
public Breakpoint(NDebugger debugger, string fileName, byte[] checkSum, int line, int column, bool enabled)
{
this.debugger = debugger;
this.fileName = fileName;
this.checkSum = checkSum;
this.line = line;
this.column = column;
this.enabled = enabled;
}
internal bool IsOwnerOf(ICorDebugBreakpoint breakpoint)
{
foreach(ICorDebugFunctionBreakpoint corFunBreakpoint in corBreakpoints) {
if (((ICorDebugBreakpoint)corFunBreakpoint).Equals(breakpoint)) return true;
}
return false;
}
internal void Deactivate()
{
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) {
#if DEBUG
// Get repro
corBreakpoint.Activate(0);
#else
try {
corBreakpoint.Activate(0);
} catch(COMException e) {
// Sometimes happens, but we had not repro yet.
// 0x80131301: Process was terminated.
if ((uint)e.ErrorCode == 0x80131301)
continue;
throw;
}
#endif
}
corBreakpoints.Clear();
}
internal void MarkAsDeactivated()
{
corBreakpoints.Clear();
}
internal bool SetBreakpoint(Module module)
{
if (this.fileName == null)
return false;
SourcecodeSegment segment = SourcecodeSegment.Resolve(module, FileName, CheckSum, Line, Column);
if (segment == null) return false;
originalLocation = segment;
ICorDebugFunctionBreakpoint corBreakpoint = segment.CorFunction.GetILCode().CreateBreakpoint((uint)segment.ILStart);
corBreakpoint.Activate(enabled ? 1 : 0);
corBreakpoints.Add(corBreakpoint);
OnSet(new BreakpointEventArgs(this));
return true;
}
/// <summary> Remove this breakpoint </summary>
public void Remove()
{
debugger.Breakpoints.Remove(this);
}
}
[Serializable]
public class BreakpointEventArgs : DebuggerEventArgs
{
Breakpoint breakpoint;
public Breakpoint Breakpoint {
get {
return breakpoint;
}
}
public BreakpointEventArgs(Breakpoint breakpoint): base(breakpoint.Debugger)
{
this.breakpoint = breakpoint;
}
}
}

1294
src/AddIns/Debugger/Debugger.Core/Process.cs

File diff suppressed because it is too large Load Diff

54
src/Main/Base/Project/ICSharpCode.SharpDevelop.addin

@ -928,9 +928,9 @@ @@ -928,9 +928,9 @@
</ComplexCondition>
</Condition>
<Condition name="IsProcessRunning" isdebugging = "True">
<Condition name="DebuggerSupports" debuggersupports = "Stepping">
<Condition name="IsProcessRunning" isprocessrunning = "False" action = "Disable">
<Condition name="DebuggerSupports" debuggersupports = "Stepping">
<Condition name = "SolutionOpen" action = "Disable">
<Condition name="DebuggerSupports" debuggersupports = "Start">
<ToolbarItem id = "SteppingSeparator" type = "Separator" />
<ToolbarItem id = "Step over"
icon = "Icons.16x16.Debug.StepOver"
@ -940,10 +940,12 @@ @@ -940,10 +940,12 @@
icon = "Icons.16x16.Debug.StepInto"
tooltip = "${res:XML.MainMenu.DebugMenu.StepInto.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"/>
<ToolbarItem id = "Step out"
icon = "Icons.16x16.Debug.StepOut"
tooltip = "${res:XML.MainMenu.DebugMenu.StepOut.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/>
<Condition name="IsProcessRunning" isdebugging = "True">
<ToolbarItem id = "Step out"
icon = "Icons.16x16.Debug.StepOut"
tooltip = "${res:XML.MainMenu.DebugMenu.StepOut.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/>
</Condition>
</Condition>
</Condition>
</Condition>
@ -1548,23 +1550,27 @@ @@ -1548,23 +1550,27 @@
</Condition>
<Condition name="DebuggerSupports" debuggersupports = "Stepping">
<Condition name="IsProcessRunning" isprocessrunning = "False" isdebugging = "True" action = "Disable">
<MenuItem id = "BeforeSteppingSeparator" type = "Separator" />
<MenuItem id = "Step over"
label = "${res:XML.MainMenu.DebugMenu.StepOver}"
icon = "Icons.16x16.Debug.StepOver"
shortcut = "F10"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepDebuggingCommand"/>
<MenuItem id = "Step into"
label = "${res:XML.MainMenu.DebugMenu.StepInto}"
icon = "Icons.16x16.Debug.StepInto"
shortcut = "F11"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"/>
<MenuItem id = "Step out"
label = "${res:XML.MainMenu.DebugMenu.StepOut}"
icon = "Icons.16x16.Debug.StepOut"
shortcut = "Shift|F11"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/>
<Condition name = "SolutionOpen" action = "Disable">
<Condition name="DebuggerSupports" debuggersupports = "Start">
<MenuItem id = "BeforeSteppingSeparator" type = "Separator" />
<MenuItem id = "Step over"
label = "${res:XML.MainMenu.DebugMenu.StepOver}"
icon = "Icons.16x16.Debug.StepOver"
shortcut = "F10"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepDebuggingCommand"/>
<MenuItem id = "Step into"
label = "${res:XML.MainMenu.DebugMenu.StepInto}"
icon = "Icons.16x16.Debug.StepInto"
shortcut = "F11"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"/>
<Condition name="IsProcessRunning" isdebugging = "True">
<MenuItem id = "Step out"
label = "${res:XML.MainMenu.DebugMenu.StepOut}"
icon = "Icons.16x16.Debug.StepOut"
shortcut = "Shift|F11"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/>
</Condition>
</Condition>
</Condition>
</Condition>

14
src/Main/Base/Project/Src/Commands/DebugCommands.cs

@ -83,7 +83,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -83,7 +83,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public override void Run()
{
LoggingService.Info("Debugger Command: StepOver");
DebuggerService.CurrentDebugger.StepOver();
if (!DebuggerService.CurrentDebugger.IsDebugging) {
DebuggerService.CurrentDebugger.BreakAtBegining = true;
new Execute().Run();
} else {
DebuggerService.CurrentDebugger.StepOver();
}
}
}
@ -92,7 +97,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -92,7 +97,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public override void Run()
{
LoggingService.Info("Debugger Command: StepInto");
DebuggerService.CurrentDebugger.StepInto();
if (!DebuggerService.CurrentDebugger.IsDebugging) {
DebuggerService.CurrentDebugger.BreakAtBegining = true;
new Execute().Run();
} else {
DebuggerService.CurrentDebugger.StepOver();
}
}
}

5
src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs

@ -25,6 +25,11 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -25,6 +25,11 @@ namespace ICSharpCode.SharpDevelop.Debugging
}
}
/// <inheritdoc/>
public bool BreakAtBegining {
get; set;
}
public bool CanDebug(IProject project)
{
return true;

7
src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

@ -25,6 +25,13 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -25,6 +25,13 @@ namespace ICSharpCode.SharpDevelop.Debugging
get;
}
/// <summary>
/// Gets or sets whether the debugger should break at the first line of execution.
/// </summary>
bool BreakAtBegining {
get; set;
}
bool CanDebug(IProject project);
/// <summary>

Loading…
Cancel
Save