internal void DebugBreak() { if (Debugger == null) { Core.AddToOutput("No debugger attached"); return; } if ((Core.MainForm.m_CurrentActiveTool != null) && (!Core.MainForm.EmulatorSupportsDebugging(Core.MainForm.m_CurrentActiveTool))) { return; } if (Core.MainForm.AppState == Types.StudioState.DEBUGGING_RUN) { // send any command to break into the monitor again try { Debugger.Break(); Core.Executing.BringStudioToForeground(); } catch (Exception ex) { Core.AddToOutput("Exception while debug break:" + ex.ToString()); } Core.MainForm.AppState = Types.StudioState.DEBUGGING_BROKEN; FirstActionAfterBreak = true; Core.MainForm.SetGUIForDebugging(true); } }
/// <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)); }