The SubScript debugger is a graphical tool that visualizes the execution of a SubScript program. It has been programmed in SubScript itself, thereby showing that multiple SubScript scripts may be run at the same time from Scala code.
A typical snapshot is:
At the top is the controller panel, with
- an area for the program description
- a step button
- an “auto step” check box
- a speed slider
- an Exit button
On the far left there is a panel with check boxes for several kinds of graph messages, that determine whether
- the debugger breaks on such messages (to step or to autostep)
- the message is logged in the panels a bit more to the right
On the left there are panels with
- a depiction of the template trees related to called scripts
- a log list of handled call graph messages
- the call graph message currently being handled
- the queue of call graph messages to be handled
There are two options to activate the debugger:
- When working from an SBT project as described in the README.md document, you can start the debugger with:
Make sure you have the SubScript Swing dependency before doing so, because the debugger a part of this library:
libraryDependencies += "org.subscript-lang" %% "subscript-swing" % "2.0.0"
- In your program code, pass the debugger as an argument to the subscript.vm._execute method. E.g., instead of:
You may optionally insert as the first parameter to the debugger a description string, that will be displayed at the top left area of the debugger window. E.g.,
val debugger = new GraphicalDebugger _execute(_main(args), debugger)
Click the Step button to see how execution unfolds. You may “automate” this by checking the “Auto” check box; then the speed slider determines the pace.
Deselecting some check boxes on the left may speed up the debugging.
Debugging the Debugger
As the debugger is a SubScript application itself, you may debug it in a debug session. Just run a little different command:
build/pack/bin/scala subscript.swing.GraphicalDebugger \ subscript.swing.GraphicalDebugger2 HelloWorld