mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Add more flexibility to Breakpoint
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.Debug;
|
||||
|
||||
public struct Breakpoint : IEquatable<Breakpoint>
|
||||
{
|
||||
public Breakpoint(string uri, int line, int column, bool enabled = true)
|
||||
{
|
||||
Uri = uri;
|
||||
Line = line;
|
||||
Column = column;
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public string Uri { get; set; }
|
||||
|
||||
public int Line { get; set; }
|
||||
|
||||
public int Column { get; set; }
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public bool Equals(string uri, int line, int column) => uri == Uri && line == Line && column == Column;
|
||||
|
||||
public bool Equals(Breakpoint other) => Equals(other.Uri, other.Line, other.Column);
|
||||
|
||||
public static bool operator ==(Breakpoint left, Breakpoint right) => left.Equals(right);
|
||||
|
||||
public static bool operator !=(Breakpoint left, Breakpoint right) => !(left == right);
|
||||
|
||||
public override bool Equals(object obj) => obj is Breakpoint bp && Equals(bp);
|
||||
|
||||
public override string ToString() => $"{(Enabled ? '+' : '-')} {Uri} ({Line}, {Column})";
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Iris.Debug.Data;
|
||||
|
||||
public struct Breakpoint : IEquatable<Breakpoint>
|
||||
{
|
||||
public Breakpoint(string uri, int line, int column, bool enabled = true) : this(uri, enabled)
|
||||
{
|
||||
Line = line;
|
||||
Column = column;
|
||||
}
|
||||
|
||||
public Breakpoint(string uri, uint offset, bool enabled = true) : this(uri, enabled)
|
||||
{
|
||||
Offset = offset;
|
||||
}
|
||||
|
||||
private Breakpoint(string uri, bool enabled)
|
||||
{
|
||||
Uri = uri;
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public string Uri { get; set; }
|
||||
|
||||
public int Line { get; set; } = -1;
|
||||
|
||||
public int Column { get; set; } = -1;
|
||||
|
||||
public uint Offset { get; set; } = uint.MaxValue;
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public bool Equals(string uri, int line, int column) => uri == Uri && line == Line && column == Column;
|
||||
|
||||
public bool Equals(Breakpoint other) => Equals(other.Uri, other.Line, other.Column);
|
||||
|
||||
public static bool operator ==(Breakpoint left, Breakpoint right) => left.Equals(right);
|
||||
|
||||
public static bool operator !=(Breakpoint left, Breakpoint right) => !(left == right);
|
||||
|
||||
public override bool Equals(object obj) => obj is Breakpoint bp && Equals(bp);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
|
||||
sb.Append(Enabled ? '+' : '-');
|
||||
sb.Append(' ');
|
||||
sb.Append(Uri);
|
||||
sb.Append(' ');
|
||||
|
||||
if (Line >= 0 && Column >= 0)
|
||||
sb.Append($"({Line}, {Column})");
|
||||
else
|
||||
sb.Append($"0x{Offset:X}");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public override int GetHashCode() => ToString().GetHashCode();
|
||||
}
|
||||
@@ -79,14 +79,16 @@ namespace Microsoft.Iris.Markup
|
||||
{
|
||||
bool ShouldBreak(Breakpoint b)
|
||||
=> b.Enabled
|
||||
&& b.Line == line && b.Column == column
|
||||
&& b.Uri.Equals(loadResult.Uri, StringComparison.OrdinalIgnoreCase);
|
||||
&& b.Uri.Equals(loadResult.Uri, StringComparison.OrdinalIgnoreCase)
|
||||
&& (b.Offset == reader.CurrentOffset || (b.Line == line && b.Column == column));
|
||||
|
||||
// Check if a breakpoint has been set at this location
|
||||
bool shouldBreakHere = Application.DebugSettings.Breakpoints.Any(ShouldBreak);
|
||||
if (shouldBreakHere)
|
||||
{
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
switch (opCode)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user