public DebugForm(IDebugFrame debugFrame, Stack stack) { _CurrentInstruction = debugFrame.CurrentInstruction; _CodeFrame = debugFrame.CodeFrame; _stack = stack; InitializeComponent(); }
/// <summary> /// Executes a compiled SML program /// </summary> /// <exception cref="SvmRuntimeException"> /// If an unexpected error occurs during /// program execution /// </exception> private void Run() { DateTime start = DateTime.Now; #region TASK 2 - TO BE IMPLEMENTED BY THE STUDENT //loop for (int programCounter = 0; programCounter < program.Count;) { if (debugger != null && breakpoints.Capacity != 0) { if (breakpoints.Contains(programCounter)) { debugFrame = new DebugFrame(program[programCounter], RetrieveInstructions(program, programCounter)); debugger.VirtualMachine = this; debugger.Break(debugFrame); } } program[programCounter].VirtualMachine = this; program[programCounter].Run(); programCounter++; if (gotoLine != null) { programCounter = (int)gotoLine; gotoLine = null; } } #region TASKS 5 & 7 - MAY REQUIRE MODIFICATION BY THE STUDENT // For task 5 (debugging), you should construct a IDebugFrame instance and // call the Break() method on the IDebugger instance stored in the debugger field #endregion #endregion long memUsed = System.Environment.WorkingSet; TimeSpan elapsed = DateTime.Now - start; Console.WriteLine(String.Format( "\r\n\r\nExecution finished in {0} milliseconds. Memory used = {1} bytes", elapsed.Milliseconds, memUsed)); }
public void Break(IDebugFrame debugFrame) { List <string> stacks = new List <string>(); IInstruction current = debugFrame.CurrentInstruction; List <IInstruction> list = debugFrame.CodeFrame; UI.listBox1.DataSource = null; UI.listBox2.DataSource = null; string currentLineString = current.ToString(); UI.listBox1.DataSource = debugFrame.CodeFrame; foreach (var intstack in virtualMachine.Stack) { stacks.Add(intstack.ToString()); } UI.listBox2.DataSource = stacks; int count = virtualMachine.ProgramCounter; UI.listBox1.SelectedItem = current; UI.ShowDialog(); }
public void Break(IDebugFrame debugFrame, Stack stack) { DebugForm debugForm = new DebugForm(debugFrame, stack); debugForm.ShowDialog(); }