Ficl release 2.05 includes a simple step debugger for colon definitions
and does> words. If you use it and can suggest improvements (or better
yet if you write some), please let me know.
Using the debuggerTo debug a word, set up the stack with any parameters the word requires, then type:debug <your word here> If the word is unnamed, or all you have is an xt, you can instead use: debug-xt ( xt -- ) The debugger invokes see on the word, printing a crude source listing, then stops at the first instruction of the definition. There are four (case insensitive) commands you can use from here onwards:
The on-step eventIf there is a defined word named on-step when the debugger starts, that word will be executed before every step. As a guideline, this word should have no side effects. Its intended use is to display the stack, but you may have some better ideas. Please let me know.: on-step ." Stack: " .s cr ; Debugger internalsThe debugger words are mostly located in source file tools.c. There is one supporting word (debug) in softcore.fr as well. There are two main words that make the debugger go: debug-xt and step-break. Debug-xt takes the xt 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 xt 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. |