public void TestCyclicPointer01() { var core = thisTest.GetTestCore(); DebugRunner fsr = new DebugRunner(core); // Execute and verify the main script in a debug session fsr.PreStart( @" class Obj { x : var; constructor Obj() { x = null; } } p = Obj.Obj(); p.x = p; // Assign the member x to its own 'this' pointer. This creates a cycle m = p.x; "); DebugRunner.VMState vms = fsr.StepOver(); vms = fsr.StepOver(); vms = fsr.StepOver(); // Test the heap contains a cycle var runtimeCore = fsr.runtimeCore; Assert.IsTrue(runtimeCore.Heap.IsHeapCyclic()); }
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"); }
internal static ProtoCore.Core DebugRunnerStepOver(string code) { //Internal setup ProtoCore.Core core; DebugRunner fsr; ProtoScript.Config.RunConfiguration runnerConfig; string testPath = @"..\..\..\Scripts\Debugger\"; // Specify some of the requirements of IDE. var options = new ProtoCore.Options(); options.ExecutionMode = ProtoCore.ExecutionMode.Serial; options.SuppressBuildOutput = false; core = new ProtoCore.Core(options); core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core)); core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core)); runnerConfig = new ProtoScript.Config.RunConfiguration(); runnerConfig.IsParrallel = false; fsr = new DebugRunner(core); DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); CLRModuleType.ClearTypes(); //Run fsr.PreStart(code, runnerConfig); DebugRunner.VMState vms = null; while (!fsr.isEnded) vms = fsr.StepOver(); return core; }
internal static void DebugRunnerStepIn(string includePath, string code, /*string logFile*/Dictionary<int, List<string>> map, bool watchNestedMode = false, string defectID = "") { //Internal setup ProtoCore.Core core; DebugRunner fsr; // Specify some of the requirements of IDE. var options = new ProtoCore.Options(); options.ExecutionMode = ProtoCore.ExecutionMode.Serial; options.SuppressBuildOutput = false; options.GCTempVarsOnDebug = false; // Cyclic dependency threshold is lowered from the default (2000) // as this causes the test framework to be painfully slow options.kDynamicCycleThreshold = 5; // Pass the absolute path so that imported filepaths can be resolved // in "FileUtils.GetDSFullPathName()" if (!String.IsNullOrEmpty(includePath)) { includePath = Path.GetDirectoryName(includePath); options.IncludeDirectories.Add(includePath); } core = new ProtoCore.Core(options); core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core)); core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core)); fsr = new DebugRunner(core); DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); //Run fsr.PreStart(code); RuntimeCore runtimeCore = fsr.runtimeCore; //StreamReader log = new StreamReader(logFile); //bool isPrevBreakAtPop = false; int lineAtPrevBreak = -1; string symbolName = null; DebugRunner.VMState vms = null; while (!fsr.isEnded) { vms = fsr.LastState; OpCode opCode = OpCode.NONE; DebugInfo debug = null; if (vms != null) { // check if previous break is a POP // if so, get the line no. and LHS opCode = fsr.CurrentInstruction.opCode; debug = fsr.CurrentInstruction.debug; if (opCode == ProtoCore.DSASM.OpCode.POP) { //isPrevBreakAtPop = true; lineAtPrevBreak = vms.ExecutionCursor.StartInclusive.LineNo; } } DebugRunner.VMState currentVms = fsr.Step(); //if (isPrevBreakAtPop) if (debug != null) { // Do not do the verification for imported DS files, for which the FilePath is non null if (debug.Location.StartInclusive.SourceLocation.FilePath == null) { if (opCode == ProtoCore.DSASM.OpCode.POP) { VerifyWatch_Run(lineAtPrevBreak, runtimeCore.DebugProps.CurrentSymbolName, core, runtimeCore, map, watchNestedMode, defectID: defectID); } // if previous breakpoint was at a CALLR else if (opCode == ProtoCore.DSASM.OpCode.CALLR) { if (runtimeCore.DebugProps.IsPopmCall) { int ci = (int)currentVms.mirror.MirrorTarget.rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata; VerifyWatch_Run(InjectionExecutive.callrLineNo, runtimeCore.DebugProps.CurrentSymbolName, core, runtimeCore, map, watchNestedMode, ci, defectID); } } } } //isPrevBreakAtPop = false; } runtimeCore.Cleanup(); }
internal static ProtoCore.Core DebugRunnerRunOnly(string code, out RuntimeCore runtimeCore) { ProtoCore.Core core; DebugRunner fsr; // Specify some of the requirements of IDE. var options = new ProtoCore.Options(); options.ExecutionMode = ProtoCore.ExecutionMode.Serial; options.SuppressBuildOutput = false; options.GCTempVarsOnDebug = false; string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\"; options.IncludeDirectories.Add(testPath); core = new ProtoCore.Core(options); core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core)); core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core)); fsr = new DebugRunner(core); DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); CLRModuleType.ClearTypes(); //Run fsr.PreStart(code); DebugRunner.VMState vms = null; vms = fsr.Run(); runtimeCore = fsr.runtimeCore; return core; }