Go to the first, previous, next, last section, table of contents.


The simple debugging aids provided in `debugs.fs' are meant to support a different style of debugging than the tracing/stepping debuggers used in languages with long turn-around times.

A much better (faster) way in fast-compiling languages is to add printing code at well-selected places, let the program run, look at the output, see where things went wrong, add more printing code, etc., until the bug is found.

The word ~~ is easy to insert. It just prints debugging information (by default the source location and the stack contents). It is also easy to remove (C-x ~ in the Emacs Forth mode to query-replace them with nothing). The deferred words printdebugdata and printdebugline control the output of ~~. The default source location output format works well with Emacs' compilation mode, so you can step through the program at the source level using C-x ` (the advantage over a stepping debugger is that you can step in any direction and you know where the crash has happened or where the strange data has occurred).

Note that the default actions clobber the contents of the pictured numeric output string, so you should not use ~~, e.g., between <# and #>.

~~       compilation  -- ; run-time  --         gforth       ``tilde-tilde''

printdebugdata       --         gforth       ``printdebugdata''

printdebugline       addr --         gforth       ``printdebugline''

Go to the first, previous, next, last section, table of contents.