Optional machine debugging
A CPU plugin can implement Debugging alongside CPU. emuStudio owns breakpoints, watches, recording, and execution control. The plugin supplies its machine’s values, such as processor registers or symbolic tape cells.
Debugging interface
Implement Debugging on the CPU plugin root to supply machine-specific expressions and report executed instructions. emuStudio already manages watches, breakpoints, and recordings.
In compile(), parse the expression and resolve names without reading the current machine state. Read the state when the returned expression is tested or displayed. Use ExpressionParser to share the expression syntax and ByteMemoryExpressions for byte memory. In getExpressionsHelp(), list the syntax, registers or other names, and functions the Watches panel accepts.
| Capture mode | What to provide |
|---|---|
INSTRUCTION | The decoded instruction and resulting address. |
ACCESSES | The same instruction details plus guest accesses. |
FULL | The instruction details, guest accesses, and a recorded StepView. |
Engine integration
- Call
beforeStep()before the instruction changes the machine. If it returnstrue, stop before executing it. - Capture the decoded instruction before executing it. After the attempt, call
afterStep()with whether it completed and the resulting program counter when available. Stop if that callback returnstrue. - For an interrupt or a failure without a decoded instruction, report only the details you have. Include a
StepViewonly inFULLmode.
DebuggingSupport can manage the observer and capture mode. Use the CPU’s memory mapping for inspection and keep those reads out of the guest access log. Record a guest write attempt even when the target rejects it.
Plugin controls apply register and memory edits directly, including while the CPU is running. Keep Swing work on its event-dispatch thread.
Values and recorded presentation
Use ValueView for the text and formats shown in a watch. Use StepView for a recorded instruction’s summary and details, such as a register’s before and after values. Capture the values during execution so a later display can use them independently of the live machine.
To link an access to an earlier write, tag the write row and put a NavLink with the same tag on the access row.
Failure behavior
Report an invalid watch or an instrumentation failure through the debugger so the user can correct it. Keep emulation running unless an observer requested a stop. During recording, deliver the requested events even when writing the recording slows execution.
Runtime instruction flow
Report the PC produced by execution, including after branches, calls, and returns. The debugger adds these transitions to its graph. A successful CPU reset clears the graph and keeps annotations.
Optimized execution
Use ExecutedBlock only when DebuggingSupport.begin() allows execution and canBatchInstructions() permits instruction-only batching. Report the executed transitions, including the final instruction and its resulting PC, in endBlock(). Report fresh information after reset or when the observer changes.
Use individual steps when batching would hide a stop, a fault, a device access, or requested details. Keep blocks short enough for pause and stop requests to take effect promptly.
Reference
See Debugging, StepView, and DecodedInstruction for the complete API.