www.delorie.com/gnu/docs/gforth/gforth_185.html   search  
 
Buy GNU books!


Gforth Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.22.3 Debugging

Languages with a slow edit/compile/link/test development loop tend to require sophisticated tracing/stepping debuggers to facilate debugging.

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 simple debugging aids provided in `debugs.fs' are meant to support this style of debugging.

The word ~~ prints debugging information (by default the source location and the stack contents). It is easy to insert. If you use Emacs 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).

doc-~~ doc-printdebugdata doc-printdebugline


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003