Google

PFE-DEBUG Debugger words

The Portable Forth Environment provides a decompiler for colon words and a single stepper for debugging. After setting a breakpoint at a word saying DEBUG word. The next time the word gets executed the single stepper takes control.

When this happens you see the top stack items displayed in one line. The topmost stack item is the first in line, the second and following stack items are displayed throughout the end of line. This line is empty if the stack is empty when the word in question executes.

On the next line you see the first word to become executed inside the debugged word. There is a prompt > to the right of the displayed word. At this prompt you have several options. Choose one by typing a key ([h] shows helpscreen):

[enter], [x], [k], [down]
The displayed word will be executed without single stepping. Note that the execution of the word is slowed down a little compared to execution outside the single stepper. This is because the single stepper has to keep control to detect when the word has finished.

After the actual word finished execution the resulting stack is printed on the current line. The next line shows the next word to become executed.

Having repeated this step several times, you can see to the the right of every decompiled word what changes to the stack this word caused by comparing with the stack display just one line above.

[d], [l], [right]
Begin single step the execution of the actual word. The first word to become executed inside the definition is displayed on the next line. The word's display is intended by two spaces for each nesting level.

You can single step through colon-definitions and the children of defining words. Note that most of the words in PFE are rewritten in C for speed, and you can not step those kernel words.

[s], [j], [left]
Leaves the nesting level. The rest of the definition currently being executed is run with further prompt. If you leave the outmost level, the single stepper won't get control again. Otherwise the debugger stops after the current word is finished and offers the next word in the previous nesting level.
[space]
The next word to be executed is decompiled. This should help to decide as if to single step that word.
[q]
Quits from the debugger. The execution of the debugged word is not continued. The stacks are not cleared or changed.
[c]
Displays the profiling instruction counter.
[r]
Reset the instruction counter, to profile some code. The debugger counts how often the inner interpreter i.e. how many Forth-primitives are executed. Use this option to reset the counter to 0 to measure an arbitrary part of code.



DEBUG word ( -- )  

this word will place an debug-runtime into the CFA of the following word. If the word gets executed later, the user will be prompted and can decide to single-step the given word. The debug-stepper is interactive and should be self-explanatory. (use NO-DEBUG to turn it off again)

reference: p4_debug in ../src/debug.c:0580, export CO DEBUG

NO-DEBUG word ( -- )  

the inverse of " DEBUG word "

reference: p4_no_debug in ../src/debug.c:0601, export CO NO-DEBUG

(SEE) ( xt -- )  

decompile the token-sequence - used by SEE name

reference: p4_paren_see in ../src/debug.c:0619, export CO (SEE)