diff --git a/Tests/SimpleDebugClient/Program.cs b/Tests/SimpleDebugClient/Program.cs index 9ceb51b..0b63783 100644 --- a/Tests/SimpleDebugClient/Program.cs +++ b/Tests/SimpleDebugClient/Program.cs @@ -17,7 +17,7 @@ internal class Program Debugger = new ZmqDebuggerClient(connectionString); Debugger.DispatcherStep += Debugger_DispatcherStep; - Debugger.InterpreterStep += Debugger_InterpreterStep; + //Debugger.InterpreterStep += Debugger_InterpreterStep; Console.WriteLine("Listening for debug messages. Press Ctrl-C to exit."); Console.ReadLine(); @@ -36,6 +36,6 @@ internal class Program private static void Debugger_InterpreterStep(object? sender, InterpreterEntry e) { - Console.WriteLine(e); + } } \ No newline at end of file diff --git a/Tests/SimpleIrisApp/Program.cs b/Tests/SimpleIrisApp/Program.cs index 913e393..349263a 100644 --- a/Tests/SimpleIrisApp/Program.cs +++ b/Tests/SimpleIrisApp/Program.cs @@ -20,6 +20,8 @@ internal class Program Application.DebugSettings.DebugConnectionUri = args.Length >= 2 ? args[1] : "tcp://127.0.0.1:5556"; + + Application.DebugSettings.Breakpoints.Add(new("clr-res://SimpleIrisApp!MainPage.uix", 3, 22)); #endif Console.WriteLine("Initializing Iris..."); diff --git a/UIX/Microsoft/Iris/Markup/Interpreter.cs b/UIX/Microsoft/Iris/Markup/Interpreter.cs index 9f0b7e7..db2cca2 100644 --- a/UIX/Microsoft/Iris/Markup/Interpreter.cs +++ b/UIX/Microsoft/Iris/Markup/Interpreter.cs @@ -73,6 +73,16 @@ namespace Microsoft.Iris.Markup OpCode opCode = (OpCode)reader.ReadByte(); Debug.Data.InterpreterEntry entry = new(opCode); + // Fetch line and column numbers from the table + if (debugging && context.LoadResult.LineNumberTable.TryLookup(reader.CurrentOffset, out int line, out int column)) + { + // Check if a breakpoint has been set at this location + bool shouldBreak = Application.DebugSettings.Breakpoints + .Any(b => b.Line == line && b.Column == column && b.Uri.Equals(loadResult.Uri, StringComparison.OrdinalIgnoreCase)); + if (shouldBreak) + System.Diagnostics.Debugger.Break(); + } + switch (opCode) { case OpCode.ConstructObject: diff --git a/UIX/Microsoft/Iris/Markup/InterpreterContext.cs b/UIX/Microsoft/Iris/Markup/InterpreterContext.cs index e5fd7b0..103aafd 100644 --- a/UIX/Microsoft/Iris/Markup/InterpreterContext.cs +++ b/UIX/Microsoft/Iris/Markup/InterpreterContext.cs @@ -31,7 +31,7 @@ namespace Microsoft.Iris.Markup uint currentOffset = _loadResult.ObjectSection.CurrentOffset; if (currentOffset > 0U) --currentOffset; - _loadResult.LineNumberTable.Lookup(currentOffset, out line, out column); + _loadResult.LineNumberTable.TryLookup(currentOffset, out line, out column); } public IMarkupTypeBase Instance => _instance; diff --git a/UIX/Microsoft/Iris/Markup/MarkupLineNumberTable.cs b/UIX/Microsoft/Iris/Markup/MarkupLineNumberTable.cs index cc9a09d..21c03ad 100644 --- a/UIX/Microsoft/Iris/Markup/MarkupLineNumberTable.cs +++ b/UIX/Microsoft/Iris/Markup/MarkupLineNumberTable.cs @@ -42,7 +42,7 @@ namespace Microsoft.Iris.Markup _lookupTable = null; } - public void Lookup(uint offset, out int line, out int column) + public bool TryLookup(uint offset, out int line, out int column) { int length = _runtimeList.Length; int index = 0; @@ -52,11 +52,13 @@ namespace Microsoft.Iris.Markup { line = UnpackLine(_runtimeList[index]); column = UnpackColumn(_runtimeList[index]); + return true; } else { line = -1; column = -1; + return false; } } @@ -69,10 +71,10 @@ namespace Microsoft.Iris.Markup private static ulong Pack(uint offset, int line, int column) => (ulong)(offset | (long)line << 22 | (long)column << 43); - private static uint UnpackOffset(ulong value) => (uint)(value & 4194303UL); + private static uint UnpackOffset(ulong value) => (uint)(value & 0x3F_FFFFUL); - private static int UnpackLine(ulong value) => (int)((value & 8796088827904UL) >> 22); + private static int UnpackLine(ulong value) => (int)((value & 0x7FF_FFC0_0000UL) >> 22); - private static int UnpackColumn(ulong value) => (int)((value & 18446735277616529408UL) >> 43); + private static int UnpackColumn(ulong value) => (int)((value & 0xFFFF_F800_0000_0000UL) >> 43); } }