Debugging tools

Miscellaneous

: ?dump         \ addr len --
Now redundant, but does nothing for "addr 0 DUMP".

: .decimal      \ n --
display a value in decimal.

: .hex          \ n --
display a value in hexadecimal.

Using the system console

: consoleIO     \ --
Select debug console for output. By default this is the CONSOLE device.

: [con          \ -- ; R: -- ipvec opvec
Save the current I/O devices on the return stack, and set I/O to the console. Restore the previous state with io].

  [con ... io]

: con]          \ -- ; R: ipvec opvec --
Restore the I/O devices from the return stack.

: .ConLine      \ caddr len --
Display text with leading CR on Forth console.

: debug_emit    \ char --
As EMIT but always uses the CONSOLE device.

: debug_cr      \ --
As CR but always uses the CONSOLE device.

: debug_space   \ --
As SPACE but always uses the CONSOLE device.

: debug_spaces  \ n --
As SPACES but always uses the CONSOLE device.

: debug_>pos    \ n --
Position the console output to column n.

: debug_type    \ addr len --
As TYPE but always uses the CONSOLE device.

: debug_count&type      \ c-addr --
As COUNT TYPE but always uses the CONSOLE device.

: debug_.       \ n --
As . but always uses the CONSOLE device.

: debug_.hex    \ n --
As .HEX but always uses the CONSOLE device.

: debug_.decimal        \ n --
As .DECIMAL but always uses the CONSOLE device.

: debug_.lword  \ n --
As .LWORD but always uses the CONSOLE device.

: debug_.byte   \ n --
As .BYTE but always uses the CONSOLE device.

: debug_.ASCII  \ char --
As .ASCII but always uses the CONSOLE device.

: debug_.s      \ --
As .S but always uses the CONSOLE device.

: debug_dump    \ addr len --
As DUMP but always uses the CONSOLE device.

Stack checking

: ?StackEmpty   \ --
If the stack depth is non-zero, issue a console warning message and clear the stack. This is often used at the end of a task loop.

: DictTop  here  ;
Used by some debug tools as the highest permitted address in the dictionary. If not previously defined, HERE is used.

: name?         \ addr -- flag                                   MPE.0000
Check to see if the supplied address is a valid NFA, returning true if the address appears to be a valid NFA. This word is implementation dependent. For MPE cross compilers, a valid NFA for MPE embedded systems satisfies the following:

: ip>nfa        \ addr -- nfa
Attempt to move backwards from an address within a definition to the relevant NFA.

: SF{           \ n -- ; R: -- depth
You can check for stack faults with:

 n SF{ .... }SF

where n describes the stack change between SF{ and }SF. If the stack change is different, an error message is generated. This word will work on most systems in which the return address is held on the return stack.

: }SF           \ -- ; R: depth -- ; perform stack check
The end of an SF{ ... }SF structure. This word is not strictly portable as it assumes that the Forth return stack holds a valid return address. In the vast majority of cases the assumption is true, but beware of some 8051 implementations. See SF{

: rdepth        \ -- n
Return the number of items on the return stack.

: .rs           \ --
Display to the console the current contents of the return stack. Where possible a word name is also displayed with the data value.

Cold Chain

: showExecChain \ item --
Show the contents of a chain, given an item in the chain.

: showColdChain \ --
Display the cold chain.