/// <summary> /// Updates the Hardware pad if the specified debugger state is Suspended. /// </summary> /// <param name="state">The debugger controller state.</param> protected override void UpdateHardwarePad(DebuggerController.States state) { var c = HardwarePad.Content; if (state == DebuggerController.States.Suspended) { c["Registers"]["PC"] = Platform.DebuggerController.Debugger.Target.Registers["PC"].ToString(); c["Registers"]["SP"] = Platform.DebuggerController.Debugger.Target.Registers["SP"].ToString(); var target = Platform.DebuggerController.Debugger.Target as MessyLab.Debugger.Target.Pico.PicoTarget; string asm; string bin; target.VirtualMachine.Disassembler.Disassemble(out asm, out bin); c["Current Instruction"]["Symbolic"] = asm; if (bin.Contains(" ")) { string[] b = bin.Split(new string[] { " " }, StringSplitOptions.None); c["Current Instruction"]["Instruction"] = b[0]; c["Current Instruction"]["Constant"] = b[1]; } else { c["Current Instruction"]["Instruction"] = bin; c["Current Instruction"]["Constant"] = string.Empty; } } else { c["Registers"]["PC"] = "?"; c["Registers"]["SP"] = "?"; c["Current Instruction"]["Symbolic"] = "?"; c["Current Instruction"]["Instruction"] = "?"; c["Current Instruction"]["Constant"] = "?"; } }
/// <summary> /// Updates Debug Menus and Toolbars according to the specified debugger state. /// </summary> /// <param name="state">The debugger state.</param> protected virtual void UpdateDebugMenusAndToolbars(DebuggerController.States state) { DebugToolStripMenuItem.Enabled = DebugToolStripButton.Enabled = state != DebuggerController.States.Running; PauseToolStripMenuItem.Enabled = PauseToolStripButton.Enabled = state == DebuggerController.States.Running; StopToolStripMenuItem.Enabled = StopToolStripButton.Enabled = state != DebuggerController.States.NotLoaded; RestartToolStripMenuItem.Enabled = RestartToolStripButton.Enabled = state != DebuggerController.States.NotLoaded; StepIntoToolStripMenuItem.Enabled = state == DebuggerController.States.NotLoaded || state == DebuggerController.States.Suspended; bool suspended = state == DebuggerController.States.Suspended; StepOverToolStripMenuItem.Enabled = suspended; StepOutToolStripMenuItem.Enabled = suspended; StepBackIntoToolStripMenuItem.Enabled = suspended; StepBackOverToolStripMenuItem.Enabled = suspended; StepBackOutToolStripMenuItem.Enabled = suspended; }
/// <summary> /// Updates the content of the Watch pad according to the specified debugger state. /// </summary> /// <param name="state">The debugger state.</param> protected virtual void UpdateWatchPad(DebuggerController.States state) { WatchPad.CanEdit = state == DebuggerController.States.Suspended; foreach (var item in WatchPad.WatchItems) { UpdateWatchItem(item); } }
/// <summary> /// Updates the content of the Breakpoints pad according to the specified debugger state. /// </summary> /// <param name="state">The debugger state.</param> protected virtual void UpdateBreakpointsPad(DebuggerController.States state) { if (state == DebuggerController.States.Suspended) { var reason = Platform.DebuggerController.ExecutionInterruptReason; if (reason != null && reason.HitBreakpoints != null) { BreakpointsPad.HighlightBreakpoints(reason.HitBreakpoints); } } }
/// <summary> /// Loads breakpoints to debugger on program start. /// </summary> /// <param name="state">The current debugger state.</param> protected void DebuggerController_StateChanged(DebuggerController.States state) { if (state != DebuggerController.States.NotLoaded) { if (_debuggerControllerState == DebuggerController.States.NotLoaded) { LoadLineBreakpointsFromOpenEditors(); LoadBreakpointsToDebugger(); } } _debuggerControllerState = state; }
/// <summary> /// Updates GUI elements according to the specified debugger state. /// </summary> /// <param name="state">The debugger state.</param> public virtual void Update(DebuggerController.States state) { UpdateDebugMenusAndToolbars(state); UpdateWatchPad(state); UpdateHardwarePad(state); UpdateBreakpointsPad(state); // Debugger Exception handling. if (state == DebuggerController.States.Suspended) { HandleDebuggerException(); } }
/// <summary> /// Handles the debugger state change. /// </summary> /// <param name="state"></param> protected void DebuggerController_StateChanged(DebuggerController.States state) { var editors = Editors as DebuggableEditorProvider; editors.Update(state); var gui = Gui as DebuggableGuiProvider; gui.Update(state); // Note: Using a reverse order, i.e. GUI, then Editors would cause // the editor not the highlight the current line at the prompt // displayed by the GUI update on exception. // It would not be a bug per se, but it would be an inconvenience // for the user.. }
/// <summary> /// Updates editors according to the specified debugger state. /// </summary> /// <param name="state">The debugger state.</param> public virtual void Update(DebuggerController.States state) { switch (state) { case DebuggerController.States.NotLoaded: EditorsReadOnly = false; ClearHighlightedLines(); break; case DebuggerController.States.Suspended: EditorsReadOnly = true; var dc = Platform.DebuggerController; HighlightLine(dc.HighlightedFile, dc.HighlightedLine); break; case DebuggerController.States.Running: EditorsReadOnly = true; ClearHighlightedLines(); break; } }
/// <summary> /// Updates the content of the Hardware pad according to the specified debugger state. /// </summary> /// <param name="state">The debugger state.</param> protected abstract void UpdateHardwarePad(DebuggerController.States state);
/// <summary> /// Loads breakpoints to debugger on program start. /// </summary> /// <param name="state">The current debugger state.</param> protected void DebuggerController_StateChanged(DebuggerController.States state) { if (state != DebuggerController.States.NotLoaded) { if (_debuggerControllerState == DebuggerController.States.NotLoaded) { LoadLineBreakpointsFromOpenEditors(); LoadBreakpointsToDebugger(); } } _debuggerControllerState = state; }