public void Defect_1467570_Crash_In_Debug_Mode() { string src = @" class Test { IntArray : int[]; constructor FirstApproach(intArray : int[]) { IntArray = intArray; } def Transform(adjust : int) { return = Test.FirstApproach(this.IntArray + adjust); } } myTest = Test.FirstApproach({ 1, 2 }); myNeTwst = myTest.Transform(1); "; fsr.PreStart(src, runnerConfig); DebugRunner.VMState vms = fsr.Step(); // myTest = Test.FirstApproach({ 1, 2 }); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 15, CharNo = 5 };
private VMState RunVM(List <Instruction> breakPoints) { //Get the next available location and set a break point //Unset the break point at the current location Instruction currentInstr = null; // will be instantialized when a proper breakpoint is reached VMState vms = null; try { if (executionsuspended) { core.NotifyExecutionEvent(ProtoCore.ExecutionStateEventArgs.State.kExecutionResume); } Execute(core.DebugProps.DebugEntryPC, breakPoints); isEnded = true; // the script has ended smoothly, } catch (ProtoCore.Exceptions.DebugHalting) { if (core.CurrentExecutive == null) //This was before the VM was properly started { return(null); } currentInstr = GetCurrentInstruction(); // set the current instruction to the current breakpoint instruction core.NotifyExecutionEvent(ProtoCore.ExecutionStateEventArgs.State.kExecutionBreak); executionsuspended = true; } catch (ProtoCore.Exceptions.EndOfScript) { isEnded = true; } finally { ExecutionMirror execMirror = new ProtoCore.DSASM.Mirror.ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core); vms = new VMState(execMirror, core); vms.isEnded = isEnded; ProtoCore.CodeModel.CodePoint start = new ProtoCore.CodeModel.CodePoint(); ProtoCore.CodeModel.CodePoint end = new ProtoCore.CodeModel.CodePoint(); if (currentInstr != null) // equal to null means that the whole script has ended, reset the cursor { start = InstructionToBeginCodePoint(currentInstr); end = InstructionToEndCodePoint(currentInstr); } CurrentInstruction = currentInstr; vms.ExecutionCursor = new ProtoCore.CodeModel.CodeRange { StartInclusive = start, EndExclusive = end }; } return(vms); }
public void Defect_1467570_Crash_In_Debug_Mode() { string src = @" class Test { IntArray : int[]; constructor FirstApproach(intArray : int[]) { IntArray = intArray; } def Transform(adjust : int) { return = Test.FirstApproach(this.IntArray + adjust); } } myTest = Test.FirstApproach({ 1, 2 }); myNeTwst = myTest.Transform(1); "; fsr.PreStart(src, runnerConfig); DebugRunner.VMState vms = fsr.Step(); // myTest = Test.FirstApproach({ 1, 2 }); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 15, CharNo = 5 }; fsr.ToggleBreakpoint(cp); fsr.Run(); // line containing "this" ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, null); ExecutionMirror mirror = watchRunner.Execute(@"this"); Obj objExecVal = mirror.GetWatchValue(); Assert.AreNotEqual(null, objExecVal); Assert.AreNotEqual(null, objExecVal.Payload); Assert.AreEqual(mirror.GetType(objExecVal), "Test"); vms = fsr.StepOver(); watchRunner = new ExpressionInterpreterRunner(core, null); mirror = watchRunner.Execute(@"this"); objExecVal = mirror.GetWatchValue(); Assert.AreNotEqual(null, objExecVal); Assert.AreEqual(-1, (Int64)objExecVal.Payload); Assert.AreEqual(mirror.GetType(objExecVal), "null"); }
public void Defect_1467570_Crash_In_Debug_Mode() { string src = @" class Test { IntArray : int[]; constructor FirstApproach(intArray : int[]) { IntArray = intArray; } def Transform(adjust : int) { return = Test.FirstApproach(this.IntArray + adjust); } } myTest = Test.FirstApproach({ 1, 2 }); myNeTwst = myTest.Transform(1); "; // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3989 string defectID = "MAGN-3989 Inspection of 'this' pointer has issues in expression interpreter"; fsr.PreStart(src); DebugRunner.VMState vms = fsr.Step(); // myTest = Test.FirstApproach({ 1, 2 }); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 15, CharNo = 5 }; fsr.ToggleBreakpoint(cp); fsr.Run(); // line containing "this" ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); ExecutionMirror mirror = watchRunner.Execute(@"this"); Obj objExecVal = mirror.GetWatchValue(); Assert.AreNotEqual(null, objExecVal); Assert.AreNotEqual(null, objExecVal.Payload, defectID); Assert.AreEqual(mirror.GetType(objExecVal), "Test"); vms = fsr.StepOver(); watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); mirror = watchRunner.Execute(@"this"); objExecVal = mirror.GetWatchValue(); Assert.AreNotEqual(null, objExecVal); Assert.AreEqual(-1, (Int64)objExecVal.Payload, defectID); Assert.AreEqual(mirror.GetType(objExecVal), "null"); }
public void AddEntry(ProtoCore.DSASM.SymbolNode sn, int line, int col, string file) { ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint() { LineNo = line, CharNo = col, SourceLocation = new ProtoCore.CodeModel.CodeFile() { FilePath = file } }; Table[sn] = cp; }
public void T001_SampleTest() { //string errorString = "1463735 - Sprint 20 : rev 2147 : breakpoint cannot be set on property ' setter' and 'getter' methods "; string src = string.Format("{0}{1}", testCasePath, "T001_SampleTest.ds"); fsr.LoadAndPreStart(src, runnerConfig); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { CharNo = 8, LineNo = 17, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = Path.GetFullPath(src) } }; fsr.ToggleBreakpoint(cp); // First step should land on line "p = Point.Point();". ProtoScript.Runners.DebugRunner.VMState vms = fsr.StepOver(); Assert.AreEqual(14, vms.ExecutionCursor.StartInclusive.LineNo); // These are not used for now, so I'm commenting them out. // Object[] exp = { 1, 2, 3, new object[] { 4, 5 }, 6.0, 7, new object[] { 8.0, 9 } }; // Object[] exp2 = new Object[] { exp, 10 }; Obj stackValue = null; try { stackValue = vms.mirror.GetDebugValue("y"); } catch (ProtoCore.DSASM.Mirror.UninitializedVariableException exception) { // Variable "y" isn't valid as of now. Assert.AreEqual("y", exception.Name); } vms = fsr.Run(); // Run to breakpoint on property setter "p.x = 20;". Assert.AreEqual(17, vms.ExecutionCursor.StartInclusive.LineNo); Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.LineNo); Assert.AreEqual(14, vms.ExecutionCursor.EndExclusive.CharNo); stackValue = vms.mirror.GetDebugValue("y"); Assert.AreEqual("10", stackValue.Payload.ToString()); }
public void T001_SampleTest() { //string errorString = "1463735 - Sprint 20 : rev 2147 : breakpoint cannot be set on property ' setter' and 'getter' methods "; string src = string.Format("{0}{1}", testCasePath, "T001_SampleTest.ds"); fsr.LoadAndPreStart(src, runnerConfig); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { CharNo = 8, LineNo = 17, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = Path.GetFullPath(src) } }; fsr.ToggleBreakpoint(cp); // First step should land on line "p = Point.Point();". ProtoScript.Runners.DebugRunner.VMState vms = fsr.StepOver(); Assert.AreEqual(14, vms.ExecutionCursor.StartInclusive.LineNo); // These are not used for now, so I'm commenting them out. // Object[] exp = { 1, 2, 3, new object[] { 4, 5 }, 6.0, 7, new object[] { 8.0, 9 } }; // Object[] exp2 = new Object[] { exp, 10 }; Obj stackValue = null; try { stackValue = vms.mirror.GetDebugValue("y"); } catch (ProtoCore.DSASM.Mirror.UninitializedVariableException exception) { // Variable "y" isn't valid as of now. Assert.AreEqual("y", exception.Name); } vms = fsr.Run(); // Run to breakpoint on property setter "p.x = 20;". Assert.AreEqual(17, vms.ExecutionCursor.StartInclusive.LineNo); Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.LineNo); Assert.AreEqual(14, vms.ExecutionCursor.EndExclusive.CharNo); stackValue = vms.mirror.GetDebugValue("y"); Assert.AreEqual("10", stackValue.Payload.ToString()); }
private Breakpoint BuildBreakPointFromCodePoint(ProtoCore.CodeModel.CodePoint codePoint) { if (codePoint.SourceLocation == null) { codePoint.SourceLocation = new ProtoCore.CodeModel.CodeFile(); } // get the instructions with debug info in at cursor position and in the same file IEnumerable <Instruction> sameLine = allbreakPoints.Where(x => x.debug.Location.StartInclusive.SourceLocation == codePoint.SourceLocation && x.debug.Location.EndExclusive.SourceLocation == codePoint.SourceLocation && x.debug.Location.StartInclusive.LineNo == codePoint.LineNo); if (sameLine.Count() == 0) { return(null); } IEnumerable <Instruction> sameCol = sameLine.Where(x => x.debug.Location.StartInclusive.CharNo <= codePoint.CharNo && x.debug.Location.EndExclusive.CharNo >= codePoint.CharNo); Instruction instr = null; if (sameCol.Count() != 0) { instr = sameCol.ElementAt(0); foreach (Instruction i in sameCol) { if (i.debug.Location.EndExclusive.CharNo - i.debug.Location.StartInclusive.CharNo < instr.debug.Location.EndExclusive.CharNo - instr.debug.Location.StartInclusive.CharNo) { instr = i; } } } else { instr = sameLine.ElementAt(0); foreach (Instruction i in sameLine) { if (i.debug.Location.EndExclusive.CharNo - i.debug.Location.StartInclusive.CharNo > instr.debug.Location.EndExclusive.CharNo - instr.debug.Location.StartInclusive.CharNo) { instr = i; } } } return(new Breakpoint(instr.debug)); }
public bool ToggleBreakpoint(ProtoCore.CodeModel.CodePoint cp) { Breakpoint bp = BuildBreakPointFromCodePoint(cp); if (bp == null) { return(false); } if (RegisteredBreakpoints.Count(x => x.Location == bp.Location) != 0) { RegisteredBreakpoints.Remove(bp); } else { RegisteredBreakpoints.Add(bp); } return(true); }
using System;
public void T27_Modifier_Stack_Update() { string src = string.Format("{0}{1}", testPath, "T27_Modifier_Stack_Update.ds"); fsr.LoadAndPreStart(src); ProtoCore.CodeModel.CodePoint cp1 = new ProtoCore.CodeModel.CodePoint { CharNo = 8, LineNo = 9, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = Path.GetFullPath(src) } }; ProtoCore.CodeModel.CodePoint cp2 = new ProtoCore.CodeModel.CodePoint { CharNo = 2, LineNo = 10, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = Path.GetFullPath(src) } }; ProtoCore.CodeModel.CodePoint cp3 = new ProtoCore.CodeModel.CodePoint { CharNo = 2, LineNo = 11, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = Path.GetFullPath(src) } }; fsr.ToggleBreakpoint(cp1); ProtoScript.Runners.DebugRunner.VMState vms = fsr.Run(); thisTest.DebugModeVerification(vms.mirror, "a", 4); fsr.ToggleBreakpoint(cp2); fsr.Run(); thisTest.DebugModeVerification(vms.mirror, "a", 5); fsr.ToggleBreakpoint(cp3); fsr.Run(); Object n1 = null; thisTest.DebugModeVerification(vms.mirror, "a", n1); fsr.Run(); }
public void TV88_Defect_1463489_3() { // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-1510 string src = string.Format("{0}{1}", testPath, "TV88_Defect_1463489_3.ds"); fsr.LoadAndPreStart(src, runnerConfig); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { CharNo = 8, LineNo = 35, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = Path.GetFullPath(src) } }; fsr.ToggleBreakpoint(cp); ProtoScript.Runners.DebugRunner.VMState vms = fsr.Run(); thisTest.DebugModeVerification(vms.mirror, "y1", true); thisTest.DebugModeVerification(vms.mirror, "y3", true); thisTest.DebugModeVerification(vms.mirror, "y2", false); thisTest.DebugModeVerification(vms.mirror, "y4", false); fsr.Run(); thisTest.DebugModeVerification(vms.mirror, "y1", false); thisTest.DebugModeVerification(vms.mirror, "y3", false); thisTest.DebugModeVerification(vms.mirror, "y2", true); thisTest.DebugModeVerification(vms.mirror, "y4", true); }
public void ToggleBreakPoint006() { string src = @" a=1; "; fsr.PreStart(src); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 1, CharNo = 2 }; fsr.ToggleBreakpoint(cp); DebugRunner.VMState vms = fsr.Run(); Obj o2 = vms.mirror.GetDebugValue("a"); Assert.IsTrue((Int64)o2.Payload == 1); Assert.IsTrue(vms.isEnded); }
public void ToggleBreakPoint002() { string src = @" def foo : int(i : int, j : int) { return = i + j; } a = 0; a = 1 + 2 + foo(3, 4) + 5 + foo(5, 6); "; fsr.PreStart(src); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 7, CharNo = 44 }; fsr.ToggleBreakpoint(cp); cp = new ProtoCore.CodeModel.CodePoint { LineNo = 7, CharNo = 60 }; fsr.ToggleBreakpoint(cp); fsr.ToggleBreakpoint(cp); DebugRunner.VMState vms = fsr.Run(); Obj o = vms.mirror.GetDebugValue("a"); vms = fsr.Run(); Obj o2 = vms.mirror.GetDebugValue("a"); Assert.IsTrue((Int64)o.Payload == 0); Assert.IsTrue((Int64)o2.Payload == 26); Assert.IsTrue(vms.isEnded); }
public void ToggleBreakPoint_Associative_004() { string src = @" a : int = 0; b : int = 0; [Associative] { a = 10; b = a * 2; a = 15; } "; fsr.PreStart(src); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 8, CharNo = 8 }; fsr.ToggleBreakpoint(cp); fsr.Step(); DebugRunner.VMState vms = fsr.Run(); Obj o2 = vms.mirror.GetDebugValue("a"); Assert.IsTrue((Int64)o2.Payload == 10); vms = fsr.Run(); vms = fsr.Run(); Assert.IsTrue(vms.isEnded); }
public void breakPoint_Cursor_1471() { string src = @" class Point { } p = 0..10..#5; def foo() { return = 5; } isPass5 = foo() == 5 ? true : false; // verification startPts = Point.Point(); isPass6 = foo() == 5 ? true : false ; // verification endPts = foo() >= 1 ? Point.Point() : Point.Point(); isPass7 = foo() == 5 ? true : false ; // verification"; fsr.PreStart(src); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 13, CharNo = 10 }; fsr.ToggleBreakpoint(cp); fsr.Run(); DebugRunner.VMState vms = fsr.Run(); Assert.IsTrue(vms.isEnded); }
{ x : double; y : int; z : bool; a : int[]; b : B; } class B { b : double; } def goo : var() { return = A.A(); } def foo : A () { return = goo(); } a = foo(); t1 = a.x; t2 = a.y; t3 = a.z; t4 = a.a; t5 = a.b.b;
public void Defect_711_debug_GC_array_itemmodified() { string src = @" import(""ProtoGeometry.dll""); WCS = CoordinateSystem.Identity(); class SphereCone { shape; constructor(x, y, z, size) { Origin = Point.ByCoordinates(x, y, z); shape = { Sphere.ByCenterPointRadius(Origin, size * 0.25), Cone.ByCenterLineRadius(Line.ByStartPointDirectionLength(Origin, CoordinateSystem.WCS.ZAxis, -size), size * 0.01, size * 0.5) }; } } xs = -12..12..12; // xs = {-12, 0, 12} sizes = 2..2..#Count(xs); // shapes = SphereCone(xs, 10, 0, sizes); xs = -12..12..6; [Imperative] { for(index in 0..4) { sizes[index] = index + 1; } } shapes[2] = Sphere.ByCenterPointRadius(WCS.Origin, 1); "; fsr.PreStart(src, runnerConfig); DebugRunner.VMState vms = fsr.Step(); // myTest = Test.FirstApproach({ 1, 2 }); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 29, CharNo = 5 }; fsr.ToggleBreakpoint(cp); fsr.Run(); // closing brace of Transform() ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core); ExecutionMirror mirror = watchRunner.Execute(@"shapes"); Obj objExecVal = mirror.GetWatchValue(); Assert.AreNotEqual(null, objExecVal); Assert.AreNotEqual(null, objExecVal.Payload); List<Obj> lo = vms.mirror.GetArrayElements(objExecVal); string type1 = vms.mirror.GetType(lo[0]); string type2 = vms.mirror.GetType(lo[1]); string type3 = vms.mirror.GetType(lo[2]); string type4 = vms.mirror.GetType(lo[3]); string type5 = vms.mirror.GetType(lo[4]); Assert.IsTrue(type1 == "SphereCone"); Assert.IsTrue(type2 == "SphereCone"); Assert.IsTrue(type3 == "Sphere"); Assert.IsTrue(type4 == "SphereCone"); Assert.IsTrue(type5 == "SphereCone"); }
public void ToggleBreakPoint005() { string src = @" a = 10; // single value b = a * 2; a = { 1, 4, -2 }; // arbitrary collection a = 1..10; // range expression... assume 1 as increment a = 1..10..2; // range expression with defined increment a = 1..10..~2; // range expression with 'appropriate' increment a = 1..10..#3; // range expression with specified number of cases a = 10; // back to single values; b = 2; c = a * b; // define an expression; a = 10..12; b = 2..4; c = a<2> * b<1>; // cartesian replication "; fsr.PreStart(src, runnerConfig); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 9, CharNo = 5 }; fsr.ToggleBreakpoint(cp); fsr.Run(); DebugRunner.VMState vms = fsr.Run(); Obj o2 = vms.mirror.GetDebugValue("b"); Assert.IsTrue((Int64)o2.Payload == 2); Assert.IsTrue(vms.isEnded); }
public void ToggleBreakPoint001() { string src = @" def foo : int(i : int, j : int) { return = i + j; } a = 0; a = 1 + 2 + foo(3, 4) + 5 + foo(5, 6); "; // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3991 string defectID = "MAGN-3991 Defects with Toggle breakpoint"; fsr.PreStart(src); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 7, CharNo = 44 }; fsr.ToggleBreakpoint(cp); cp = new ProtoCore.CodeModel.CodePoint { LineNo = 7, CharNo = 60 }; fsr.ToggleBreakpoint(cp); DebugRunner.VMState vms = fsr.Run(); Obj o = vms.mirror.GetDebugValue("a"); vms = fsr.Run(); Obj o2 = vms.mirror.GetDebugValue("a"); Assert.IsTrue((Int64)o.Payload == 0, defectID); Assert.IsTrue((Int64)o2.Payload == 26, defectID); }
public void Defect_1467570_Crash_In_Debug_Mode() { string src = @" class Test { IntArray : int[]; constructor FirstApproach(intArray : int[]) { IntArray = intArray; } def Transform(adjust : int) { return = Test.FirstApproach(this.IntArray + adjust); } } myTest = Test.FirstApproach({ 1, 2 }); myNeTwst = myTest.Transform(1); "; // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3989 string defectID = "MAGN-3989 Inspection of 'this' pointer has issues in expression interpreter"; fsr.PreStart(src); DebugRunner.VMState vms = fsr.Step(); // myTest = Test.FirstApproach({ 1, 2 }); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 15, CharNo = 5 }; fsr.ToggleBreakpoint(cp); fsr.Run(); // line containing "this" ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); ExecutionMirror mirror = watchRunner.Execute(@"this"); Obj objExecVal = mirror.GetWatchValue(); Assert.AreNotEqual(null, objExecVal); Assert.AreNotEqual(null, objExecVal.Payload, defectID); Assert.AreEqual(mirror.GetType(objExecVal), "Test"); vms = fsr.StepOver(); watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); mirror = watchRunner.Execute(@"this"); objExecVal = mirror.GetWatchValue(); Assert.AreNotEqual(null, objExecVal); Assert.AreEqual(-1, (Int64)objExecVal.Payload, defectID); Assert.AreEqual(mirror.GetType(objExecVal), "null"); }
public void ToggleBreakPoint005() { string src = @" a = 10; // single value b = a * 2; a = { 1, 4, -2 }; // arbitrary collection a = 1..10; // range expression... assume 1 as increment a = 1..10..2; // range expression with defined increment a = 1..10..~2; // range expression with 'appropriate' increment a = 1..10..#3; // range expression with specified number of cases a = 10; // back to single values; b = 2; c = a * b; // define an expression; a = 10..12; b = 2..4; c = a<2> * b<1>; // cartesian replication "; // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3991 string defectID = "MAGN-3991 Defects with Toggle breakpoint"; fsr.PreStart(src); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 18, CharNo = 5 }; fsr.ToggleBreakpoint(cp); DebugRunner.VMState vms = fsr.Run(); Obj o2 = vms.mirror.GetDebugValue("b"); Assert.IsTrue((Int64)o2.Payload == 2, defectID); fsr.Run(); Assert.IsTrue(vms.isEnded, defectID); }
public void TV88_Defect_1463489_3() { // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-1510 string src = string.Format("{0}{1}", testPath, "TV88_Defect_1463489_3.ds"); fsr.LoadAndPreStart(src); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { CharNo = 8, LineNo = 35, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = Path.GetFullPath(src) } }; fsr.ToggleBreakpoint(cp); ProtoScript.Runners.DebugRunner.VMState vms = fsr.Run(); Assert.AreEqual((bool)vms.mirror.GetDebugValue("y1").Payload, true); Assert.AreEqual((bool)vms.mirror.GetDebugValue("y3").Payload, true); Assert.AreEqual((bool)vms.mirror.GetDebugValue("y2").Payload, false); Assert.AreEqual((bool)vms.mirror.GetDebugValue("y4").Payload, false); fsr.Run(); Assert.AreEqual((bool)vms.mirror.GetDebugValue("y1").Payload, false); Assert.AreEqual((bool)vms.mirror.GetDebugValue("y3").Payload, false); Assert.AreEqual((bool)vms.mirror.GetDebugValue("y2").Payload, true); Assert.AreEqual((bool)vms.mirror.GetDebugValue("y4").Payload, true); }
public void ToggleBreakPointApiTest() { string src = @"class A { w : int; } zz = A.A(); [Imperative] { def g() { return = 3; } def f(a : int) { return = a; } c2 = A.A(); c1 = c3 = c2.w = f(g()); z = 67; } "; fsr.PreStart(src); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 19, CharNo = 27 }; fsr.ToggleBreakpoint(cp); DebugRunner.VMState vms = fsr.Run(); Assert.AreEqual(19, vms.ExecutionCursor.StartInclusive.LineNo); Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); Assert.AreEqual(19, vms.ExecutionCursor.EndExclusive.LineNo); Assert.AreEqual(32, vms.ExecutionCursor.EndExclusive.CharNo); vms = fsr.Step(); Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.CharNo); Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); Assert.AreEqual(20, vms.ExecutionCursor.EndExclusive.CharNo); }
public void AddEntry(ProtoCore.DSASM.SymbolNode sn, int line, int col, string file) { ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint() { LineNo = line, CharNo = col, SourceLocation = new ProtoCore.CodeModel.CodeFile() { FilePath = file } }; Table[sn] = cp; }
public void ImportTest001() { string src = Path.GetFullPath(string.Format("{0}{1}", testPath, "ImportTest001.ds")); string imp1 = Path.GetFullPath(string.Format("{0}{1}", testPath, "import001.ds")); string imp2 = Path.GetFullPath(string.Format("{0}{1}", testPath, "import002.ds")); fsr.LoadAndPreStart(src); ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint { LineNo = 5, CharNo = 3, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = src } }; fsr.ToggleBreakpoint(cp); cp = new ProtoCore.CodeModel.CodePoint { LineNo = 3, CharNo = 9, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = imp1 } }; fsr.ToggleBreakpoint(cp); fsr.ToggleBreakpoint(cp); cp = new ProtoCore.CodeModel.CodePoint { LineNo = 3, CharNo = 9, SourceLocation = new ProtoCore.CodeModel.CodeFile { FilePath = imp2 } }; fsr.ToggleBreakpoint(cp); DebugRunner.VMState vms = fsr.Run(); Obj o1 = vms.mirror.GetDebugValue("a"); Assert.IsTrue(vms.ExecutionCursor.StartInclusive.SourceLocation.FilePath == src); Assert.IsTrue((Int64)o1.Payload == 10); vms = fsr.Run(); Obj o2 = vms.mirror.GetDebugValue("j"); Assert.IsTrue((Int64)o2.Payload == 20); Assert.IsTrue(vms.ExecutionCursor.StartInclusive.SourceLocation.FilePath == imp2); }
private VMState RunVM(List<Instruction> breakPoints) { //Get the next available location and set a break point //Unset the break point at the current location Instruction currentInstr = null; // will be instantialized when a proper breakpoint is reached VMState vms = null; try { if (executionsuspended) runtimeCore.NotifyExecutionEvent(ProtoCore.ExecutionStateEventArgs.State.kExecutionResume); Execute(runtimeCore.DebugProps.DebugEntryPC, breakPoints); isEnded = true; // the script has ended smoothly, } catch (ProtoCore.Exceptions.DebugHalting) { if (runtimeCore.CurrentExecutive == null) //This was before the VM was properly started return null; currentInstr = GetCurrentInstruction(); // set the current instruction to the current breakpoint instruction runtimeCore.NotifyExecutionEvent(ProtoCore.ExecutionStateEventArgs.State.kExecutionBreak); executionsuspended = true; } catch (ProtoCore.Exceptions.EndOfScript) { isEnded = true; } finally { ExecutionMirror execMirror = new ProtoCore.DSASM.Mirror.ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore); vms = new VMState(execMirror, core); vms.isEnded = isEnded; ProtoCore.CodeModel.CodePoint start = new ProtoCore.CodeModel.CodePoint(); ProtoCore.CodeModel.CodePoint end = new ProtoCore.CodeModel.CodePoint(); if (currentInstr != null) // equal to null means that the whole script has ended, reset the cursor { start = InstructionToBeginCodePoint(currentInstr); end = InstructionToEndCodePoint(currentInstr); } CurrentInstruction = currentInstr; vms.ExecutionCursor = new ProtoCore.CodeModel.CodeRange { StartInclusive = start, EndExclusive = end }; } return vms; }