ficlPageHeader("ficl debugger") ficlAddToNavBarAs("Debugger") ?>
Ficl includes a simple step debugger for colon definitions
and DOES> words.
ficlHeader1("Using The Ficl Debugger") ?>
To debug a word, set up the stack with any parameters the word requires,
then execute:
DEBUG your-word-name-here
If the word is unnamed, or all you have is an execution token,
you can instead use DEBUG-XT
The debugger invokes SEE on the word which prints a crude source listing. It then stops at the first instruction of the definition. There are six (case insensitive) commands you can use from here onwards:
X DROP 3 \ change top argument on stack to 3
ON-STEP Event") ?>
If there is a defined word named ON-STEP when the debugger starts, that
word will be executed before every step. Its intended use is to display the stacks
and any other VM state you find interesting. The default ON-STEP is:
: ON-STEP ." S: " .S-SIMPLE CR ;If you redefine
ON-STEP, we recommend you ensure the word has no
side-effects (for instance, adding or removing values from any stack).
ficlHeader3("Other Useful Words For Debugging And ON-STEP") ?>
.ENV ( -- )
.S ( -- )
.S-SIMPLE ( -- )
F.S ( -- )
FICL_WANT_FLOAT is enabled).
R.S ( -- )
The debugger words are mostly located in source file tools.c. There are
supporting words (DEBUG and ON-STEP) in softcore.fr as well.
There are two main words that make the debugger go: debug-xt and step-break.
debug-xt takes the execution token of a word to debug (as returned by ' for example) ,
checks to see if it is debuggable (not a primitive), sets a breakpoint at its
first instruction, and runs see on it. To set a breakpoint,
debug-xt
replaces the instruction at the breakpoint with the execution token of step-break, and
stores the original instruction and its address in a static breakpoint
record. To clear the breakpoint, step-break simply replaces the original
instruction and adjusts the target virtual machine's instruction pointer
to run it.
step-break is responsible for processing debugger commands and setting
breakpoints at subsequent instructions.
ficlHeader1("Future Enhancements") ?>