7 changed files with 1654 additions and 1574 deletions
File diff suppressed because it is too large
Load Diff
@ -1,175 +1,184 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
// 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)
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
using System; |
using System; |
||||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||||
using System.Runtime.InteropServices; |
using System.Runtime.InteropServices; |
||||||
|
|
||||||
using Debugger.Interop.CorDebug; |
using Debugger.Interop.CorDebug; |
||||||
|
|
||||||
namespace Debugger |
namespace Debugger |
||||||
{ |
{ |
||||||
public class Breakpoint: DebuggerObject |
public class Breakpoint: DebuggerObject |
||||||
{ |
{ |
||||||
NDebugger debugger; |
NDebugger debugger; |
||||||
|
|
||||||
string fileName; |
string fileName; |
||||||
byte[] checkSum; |
byte[] checkSum; |
||||||
int line; |
int line; |
||||||
int column; |
int column; |
||||||
bool enabled; |
bool enabled; |
||||||
|
|
||||||
SourcecodeSegment originalLocation; |
SourcecodeSegment originalLocation; |
||||||
|
|
||||||
List<ICorDebugFunctionBreakpoint> corBreakpoints = new List<ICorDebugFunctionBreakpoint>(); |
List<ICorDebugFunctionBreakpoint> corBreakpoints = new List<ICorDebugFunctionBreakpoint>(); |
||||||
|
|
||||||
public event EventHandler<BreakpointEventArgs> Hit; |
public event EventHandler<BreakpointEventArgs> Hit; |
||||||
public event EventHandler<BreakpointEventArgs> Set; |
public event EventHandler<BreakpointEventArgs> Set; |
||||||
|
|
||||||
[Debugger.Tests.Ignore] |
[Debugger.Tests.Ignore] |
||||||
public NDebugger Debugger { |
public NDebugger Debugger { |
||||||
get { return debugger; } |
get { return debugger; } |
||||||
} |
} |
||||||
|
|
||||||
public string FileName { |
public string FileName { |
||||||
get { return fileName; } |
get { return fileName; } |
||||||
} |
} |
||||||
|
|
||||||
public byte[] CheckSum { |
public byte[] CheckSum { |
||||||
get { return checkSum; } |
get { return checkSum; } |
||||||
} |
} |
||||||
|
|
||||||
public int Line { |
public int Line { |
||||||
get { return line; } |
get { return line; } |
||||||
set { line = value; } |
set { line = value; } |
||||||
} |
} |
||||||
|
|
||||||
public int Column { |
public int Column { |
||||||
get { return column; } |
get { return column; } |
||||||
} |
} |
||||||
|
|
||||||
public bool Enabled { |
public bool Enabled { |
||||||
get { return enabled; } |
get { return enabled; } |
||||||
set { |
set { |
||||||
enabled = value; |
enabled = value; |
||||||
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) { |
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) { |
||||||
corBreakpoint.Activate(enabled ? 1 : 0); |
corBreakpoint.Activate(enabled ? 1 : 0); |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
public SourcecodeSegment OriginalLocation { |
public SourcecodeSegment OriginalLocation { |
||||||
get { return originalLocation; } |
get { return originalLocation; } |
||||||
} |
} |
||||||
|
|
||||||
public bool IsSet { |
public bool IsSet { |
||||||
get { |
get { |
||||||
return corBreakpoints.Count > 0; |
return corBreakpoints.Count > 0; |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
protected virtual void OnHit(BreakpointEventArgs e) |
protected virtual void OnHit(BreakpointEventArgs e) |
||||||
{ |
{ |
||||||
if (Hit != null) { |
if (Hit != null) { |
||||||
Hit(this, e); |
Hit(this, e); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
internal void NotifyHit() |
internal void NotifyHit() |
||||||
{ |
{ |
||||||
OnHit(new BreakpointEventArgs(this)); |
OnHit(new BreakpointEventArgs(this)); |
||||||
debugger.Breakpoints.OnHit(this); |
debugger.Breakpoints.OnHit(this); |
||||||
} |
} |
||||||
|
|
||||||
protected virtual void OnSet(BreakpointEventArgs e) |
protected virtual void OnSet(BreakpointEventArgs e) |
||||||
{ |
{ |
||||||
if (Set != null) { |
if (Set != null) { |
||||||
Set(this, e); |
Set(this, e); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
public Breakpoint(NDebugger debugger, string fileName, byte[] checkSum, int line, int column, bool enabled) |
public Breakpoint(NDebugger debugger, ICorDebugFunctionBreakpoint corBreakpoint) |
||||||
{ |
{ |
||||||
this.debugger = debugger; |
this.debugger = debugger; |
||||||
this.fileName = fileName; |
this.corBreakpoints.Add(corBreakpoint); |
||||||
this.checkSum = checkSum; |
} |
||||||
this.line = line; |
|
||||||
this.column = column; |
public Breakpoint(NDebugger debugger, string fileName, byte[] checkSum, int line, int column, bool enabled) |
||||||
this.enabled = enabled; |
{ |
||||||
} |
this.debugger = debugger; |
||||||
|
this.fileName = fileName; |
||||||
internal bool IsOwnerOf(ICorDebugBreakpoint breakpoint) |
this.checkSum = checkSum; |
||||||
{ |
this.line = line; |
||||||
foreach(ICorDebugFunctionBreakpoint corFunBreakpoint in corBreakpoints) { |
this.column = column; |
||||||
if (((ICorDebugBreakpoint)corFunBreakpoint).Equals(breakpoint)) return true; |
this.enabled = enabled; |
||||||
} |
} |
||||||
return false; |
|
||||||
} |
internal bool IsOwnerOf(ICorDebugBreakpoint breakpoint) |
||||||
|
{ |
||||||
internal void Deactivate() |
foreach(ICorDebugFunctionBreakpoint corFunBreakpoint in corBreakpoints) { |
||||||
{ |
if (((ICorDebugBreakpoint)corFunBreakpoint).Equals(breakpoint)) return true; |
||||||
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) { |
} |
||||||
#if DEBUG
|
return false; |
||||||
// Get repro
|
} |
||||||
corBreakpoint.Activate(0); |
|
||||||
#else
|
internal void Deactivate() |
||||||
try { |
{ |
||||||
corBreakpoint.Activate(0); |
foreach(ICorDebugFunctionBreakpoint corBreakpoint in corBreakpoints) { |
||||||
} catch(COMException e) { |
#if DEBUG
|
||||||
// Sometimes happens, but we had not repro yet.
|
// Get repro
|
||||||
// 0x80131301: Process was terminated.
|
corBreakpoint.Activate(0); |
||||||
if ((uint)e.ErrorCode == 0x80131301) |
#else
|
||||||
continue; |
try { |
||||||
throw; |
corBreakpoint.Activate(0); |
||||||
} |
} catch(COMException e) { |
||||||
#endif
|
// Sometimes happens, but we had not repro yet.
|
||||||
} |
// 0x80131301: Process was terminated.
|
||||||
corBreakpoints.Clear(); |
if ((uint)e.ErrorCode == 0x80131301) |
||||||
} |
continue; |
||||||
|
throw; |
||||||
internal void MarkAsDeactivated() |
} |
||||||
{ |
#endif
|
||||||
corBreakpoints.Clear(); |
} |
||||||
} |
corBreakpoints.Clear(); |
||||||
|
} |
||||||
internal bool SetBreakpoint(Module module) |
|
||||||
{ |
internal void MarkAsDeactivated() |
||||||
SourcecodeSegment segment = SourcecodeSegment.Resolve(module, FileName, CheckSum, Line, Column); |
{ |
||||||
if (segment == null) return false; |
corBreakpoints.Clear(); |
||||||
|
} |
||||||
originalLocation = segment; |
|
||||||
|
internal bool SetBreakpoint(Module module) |
||||||
ICorDebugFunctionBreakpoint corBreakpoint = segment.CorFunction.GetILCode().CreateBreakpoint((uint)segment.ILStart); |
{ |
||||||
corBreakpoint.Activate(enabled ? 1 : 0); |
if (this.fileName == null) |
||||||
|
return false; |
||||||
corBreakpoints.Add(corBreakpoint); |
|
||||||
|
SourcecodeSegment segment = SourcecodeSegment.Resolve(module, FileName, CheckSum, Line, Column); |
||||||
OnSet(new BreakpointEventArgs(this)); |
if (segment == null) return false; |
||||||
|
|
||||||
return true; |
originalLocation = segment; |
||||||
} |
|
||||||
|
ICorDebugFunctionBreakpoint corBreakpoint = segment.CorFunction.GetILCode().CreateBreakpoint((uint)segment.ILStart); |
||||||
/// <summary> Remove this breakpoint </summary>
|
corBreakpoint.Activate(enabled ? 1 : 0); |
||||||
public void Remove() |
|
||||||
{ |
corBreakpoints.Add(corBreakpoint); |
||||||
debugger.Breakpoints.Remove(this); |
|
||||||
} |
OnSet(new BreakpointEventArgs(this)); |
||||||
} |
|
||||||
|
return true; |
||||||
[Serializable] |
} |
||||||
public class BreakpointEventArgs : DebuggerEventArgs |
|
||||||
{ |
/// <summary> Remove this breakpoint </summary>
|
||||||
Breakpoint breakpoint; |
public void Remove() |
||||||
|
{ |
||||||
public Breakpoint Breakpoint { |
debugger.Breakpoints.Remove(this); |
||||||
get { |
} |
||||||
return breakpoint; |
} |
||||||
} |
|
||||||
} |
[Serializable] |
||||||
|
public class BreakpointEventArgs : DebuggerEventArgs |
||||||
public BreakpointEventArgs(Breakpoint breakpoint): base(breakpoint.Debugger) |
{ |
||||||
{ |
Breakpoint breakpoint; |
||||||
this.breakpoint = breakpoint; |
|
||||||
} |
public Breakpoint Breakpoint { |
||||||
} |
get { |
||||||
} |
return breakpoint; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public BreakpointEventArgs(Breakpoint breakpoint): base(breakpoint.Debugger) |
||||||
|
{ |
||||||
|
this.breakpoint = breakpoint; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue