home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / watcher.seq < prev    next >
Text File  |  1991-04-10  |  3KB  |  90 lines

  1. \\ WATCHER.SEQ           Watch window for debugger       by Tom Zimmer
  2.  
  3.   Created at the suggestion of Jerry Boutelle
  4.  
  5.   Links into the debugger through the words: .WATCH, .WATCHER & SETWATCH
  6. to provide a way to have a small area of memory watched while you step
  7. through a program.
  8.  
  9. {
  10.  
  11. only forth also definitions hidden also
  12.  
  13. 0 value watch_address
  14.  
  15. : %.watch       ( -- )
  16.                 watch_address 0= ?exit          \ if not watching, leave
  17.                 savecursor >attrib3
  18.                 save> base hex                  \ dump is in HEX
  19.                 save> dumpseg ?cs: dumpseg !    \ dump code segment
  20.                 0 split-l#    at eeol           \ clear the watch line
  21.                 0 split-l# 1- at                \ move to watch line-1
  22.                 watch_address dln
  23.                 restore> dumpseg
  24.                 restore> base                   \ restore the base
  25.                 restcursor ;
  26.  
  27. ' %.watch is .watcher
  28.  
  29. watchon         \ enable watchpoints in the debugger
  30.  
  31. 0 value depth_save
  32.  
  33. 32 array stibbuf
  34.  
  35. : watch_cmd     ( -- f1 )
  36.                 tib 31 expect  span @ #tib ! >in off
  37.                 bl word  skip'c' ?uppercase
  38.                 c@ 0= dup ?exit drop            \ leave if empty input
  39.                 here 1+ c@ ''' <>
  40.                 if      here find
  41.                         if      !csp execute
  42.                                 sp@ csp @ =
  43.                                 if      !> watch_address true
  44.                                 else    sp0 @ sp!       \ clear stack
  45.                                         0 0 0 0
  46.                                         beep false
  47.                                 then
  48.                         else    %number nip
  49.                                 if      !> watch_address true
  50.                                 else    drop false
  51.                                 then
  52.                         then
  53.                 else    here count 1 /string here place
  54.                         bl here count + c!      \ add trailing blank
  55.                         here find
  56.                         if      !> watch_address true
  57.                         else    drop beep false
  58.                         then
  59.                 then    ;
  60.  
  61. : %setwatch     ( -- )
  62.                 savecursor
  63.                 depth dup !> depth_save
  64.                 begin   dup 0>
  65.                 while   1- swap >r
  66.                 repeat  drop 0 0 0 0    \ some dummy parameters
  67.                 0 split-l# at >attrib3
  68.                 ."  Enter watch WORD, 'WORD or address [0=remove]:"
  69.                 stibbuf save!> 'tib
  70.                 save> #tib #tib off
  71.                 save> >in
  72.                 at? 2>r
  73.                 begin   2r@ at eeol 2r@ at
  74.                         watch_cmd
  75.                 until   2r> 2drop
  76.                 restore> >in
  77.                 restore> #tib
  78.                 restore> 'tib
  79.                 depth 0 ?do drop loop           \ clear dummy parameters
  80.                 begin   depth_save 0>           \ recover stack contents
  81.                 while   r> -1 +!> depth_save
  82.                 repeat
  83.                 restcursor ;
  84.  
  85. ' %setwatch is setwatch
  86.  
  87. }
  88.  
  89.  
  90.