Fix interpreter crash when debugger is not attached

This commit is contained in:
Yoshi Askharoun
2023-10-08 23:54:26 -05:00
parent a442d66213
commit be78b55a30
+9 -5
View File
@@ -72,10 +72,12 @@ namespace Microsoft.Iris.Markup
while (!errorsDetected)
{
OpCode opCode = (OpCode)reader.ReadByte();
InterpreterEntry entry = new(opCode, reader.CurrentOffset, loadResult.Uri);
InterpreterEntry entry = new(new(opCode, reader.CurrentOffset, loadResult.Uri));
if (debugging)
{
// Fetch line and column numbers from the table
if (debugging && context.LoadResult.LineNumberTable.TryLookup(reader.CurrentOffset, out int line, out int column))
if (context.LoadResult.LineNumberTable.TryLookup(reader.CurrentOffset, out int line, out int column))
{
bool ShouldBreak(Breakpoint b)
=> b.Enabled && b.Equals(loadResult.Uri, line, column, reader.CurrentOffset);
@@ -83,15 +85,17 @@ namespace Microsoft.Iris.Markup
// Check if a breakpoint has been set at this location
bool shouldBreakHere = Application.DebugSettings.Breakpoints.Any(ShouldBreak);
if (shouldBreakHere)
{
Application.Debugger.DebuggerCommand = InterpreterCommand.Break;
//System.Diagnostics.Debugger.Break();
}
}
// Stop exeuction while the debugger is in break mode
while (Application.Debugger.DebuggerCommand == InterpreterCommand.Break) ;
// If the debugger requested a single step, immediately set the debugger
// to break again for the next instruction
if (Application.Debugger.DebuggerCommand == InterpreterCommand.Step)
Application.Debugger.DebuggerCommand = InterpreterCommand.Break;
}
switch (opCode)
{