File:  [gforth] / gforth / Attic / debugging.fs
Revision 1.3: download - view: text, annotated - select for diffs
Mon Oct 16 18:33:05 1995 UTC (27 years, 1 month ago) by anton
Branches: MAIN
CVS tags: HEAD
added answords.fs and strsignal.c
added checking of documenetation of ANS Forth words
Fixed many documentation errors and added some documentation
signal handling now uses strsignal and can handle signals not present on all machines

    1: \ Simple debugging aids
    2: 
    3: \ They are meant to support a different style of debugging than the
    4: \ tracing/stepping debuggers used in languages with long turn-around
    5: \ times.
    6: 
    7: \ IMO, a much better (faster) way in fast-compilig languages is to add
    8: \ printing code at well-selected places, let the program run, look at
    9: \ the output, see where things went wrong, add more printing code, etc.,
   10: \ until the bug is found.
   11: 
   12: \ We support fast insertion and removal of the printing code.
   13: 
   14: \ !!Warning: the default debugging actions will destroy the contents
   15: \ of the pictured numeric output string (i.e., don't use ~~ between <#
   16: \ and #>).
   17: 
   18: 
   19: defer printdebugdata ( -- ) \ gforth
   20: ' .s IS printdebugdata
   21: defer printdebugline ( addr -- ) \ gforth
   22: 
   23: : (printdebugline) ( addr -- )
   24:     cr
   25:     dup 2@ type ." :" cell+ cell+
   26:     @ 0 .r ." :"
   27:     \ it would be nice to print the name of the following word,
   28:     \ but that's not easily possible for primitives
   29:     printdebugdata
   30:     cr ;
   31: 
   32: ' (printdebugline) IS printdebugline
   33: 
   34: : (~~) ( -- )
   35:     r@ printdebugline
   36:     r> 3 cells + >r ;
   37: 
   38: : ~~ ( compilation  -- ; run-time  -- ) \ gforth tilde-tilde
   39:     POSTPONE (~~) loadfilename 2@ 2, loadline @ , ; immediate
   40: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>