home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lisp / interpre / xlispplu / lsp / stepper.doc < prev    next >
Encoding:
Text File  |  1992-01-14  |  4.6 KB  |  122 lines

  1. This is the latest version of my stepper.   I posted an early version of
  2. it about a year ago;  this differs from the old one as follows:
  3.   o  May change both print depth and print length of forms
  4.     (old version only allowed print depth to be changed)
  5.   o  Uses 'get-key' for user input, (in particular this is PC specific,
  6.     I only use XLISP on PC's;  I use KCL on real computers)
  7.   o  New 'u' command (execute until enclosing form returns)
  8.   o  New 'r' command (use a given expression as the return value
  9.     for the current form)
  10.   o  Correct handling of '(go label)' statements
  11.   o  Uses *debug-io* to determine output stream
  12.  
  13. The attached listing is a step debugger inspired by the "step.lsp"
  14. stepper included with XLISP 2.1, originally written by Jonathan Engdahl
  15. (jengdahl on BIX).  This version has the ability to set/reset
  16. breakpoints, and a few bells and whistles.
  17.  
  18. To invoke the stepper:
  19.     (step (form with args))
  20.  
  21. The stepper will stop and print every form, then wait for user input.
  22. Forms are printed compressed, i.e. to a depth and length of 3.  This
  23. may be changed by assigning the desired depth and length values to
  24. *pdepth* and *plen* before invoking the stepper, or from within the
  25. stepper via the . and # commands.
  26.  
  27. For example, suppose you have the following defined:
  28.  
  29. (defun fib (n)
  30.   (if (or (eql n 1) (eql n 2))
  31.       1
  32.       (+ (fib (- n 2)) (fib (- n 1)))))
  33.  
  34. Then (step (fib 4)) will produce the following:
  35.  
  36. 0 >==> (fib 4)
  37.  1 >==> (if (or (eql n 1) (eql n 2)) 1 ...) :
  38.  
  39. The colon is the stepper's prompt.  For a list of commands, type h.
  40. this produces:
  41.  
  42. Stepper Commands
  43. ----------------
  44.  n or space - next form
  45.  s or <cr>  - step over form
  46.  f FUNCTION - go until FUNCTION is called
  47.  b FUNCTION - set breakpoint at FUNCTION
  48.  b <list>   - set breakpoint at each function in list
  49.  c FUNCTION - clear breakpoint at FUNCTION
  50.  c <list>   - clear breakpoint at each function in list
  51.  c *all*    - clear all breakpoints
  52.           g - go until a breakpoint is reached
  53.           u - go up; continue until enclosing form is done
  54.           w - where am I? -- backtrace
  55.           t - toggle trace on/off
  56.           q - quit stepper, continue execution
  57.           p - pretty-print current form (uncompressed)
  58.           e - print environment
  59.    x <expr> - execute expression in current environment
  60.    r <expr> - execute and return expression
  61.        # nn - set print depth to nn
  62.        . nn - set print length to nn
  63.           h - print this summary
  64.  
  65. Breakpoints may be set with the b command.  You may set breakpoints at
  66. one function, e.g. b FOO<cr> sets a breakpoint at the function FOO,
  67. or at various functions at once, e.g. b (FOO FIE FUM)<cr> sets
  68. breakpoints at the functions FOO, FIE, and FUM.  Breakpoints are cleared
  69. with the c command in an analogous way.  Furthermore, a special form of
  70. the c command, c *all* <cr>, clears all previously set breakpoints.
  71. Breakpoints are remembered from one invocation of step to the next, so
  72. it is only neccessary to set them once in a debugging session.
  73.  
  74. The g command causes execution to proceed until a breakpoint is reached,
  75. at which time more stepper commands can be entered.
  76.  
  77. The f command sets a temporary breakpoint at one function, and causes
  78. execution to proceed until that function is called.
  79.  
  80. The u command continues execution until the form enlosing the current
  81. form is done, then re-enters the stepper.
  82.  
  83. The w command prints a back trace.
  84.  
  85. The q command quits and causes execution to continue uninterrupted.
  86.  
  87. Entry and exit to functions are traced after a g, f, u, or q command.  To
  88. turn off tracing, use the t command which toggles the trace on/off.
  89. Also, with trace off, the values of function parameters are not printed.
  90.  
  91. The s command causes the current form to be evaluated.
  92.  
  93. The n command steps into the current form.
  94.  
  95. The . and # commands change the compression of displayed forms.  E.g. in the
  96. previous example:
  97.  
  98.  1 >==> (if (or (eql n 1) (eql n 2)) 1 ...) : . 2
  99.  1 >==> (if (or (eql n ...) ...) ...) :
  100.  
  101. changes the print length to 2, and
  102.  
  103.  1 >==> (if (or (eql n ...) ...) ...) : # 2
  104.  1 >==> (if (or #\# ...) ...) :
  105.  
  106. changes the print depth to 2.
  107.  
  108. To print the entire form use the p command, which pretty-prints the
  109. entire form.
  110.  
  111. The e command causes the current environment to be printed;
  112.  
  113. The x command causes an expression to be executed in the current
  114. environment.  Note that this permits the user to alter values while
  115. the program is running, and may affect execution of the program.
  116.  
  117. The r command causes the value of the given expression to be returned,
  118. i.e. makes it the return value of the current form.
  119.  
  120. Enjoy,
  121.       Ray
  122.