;;;; -*- mode:lisp;coding:utf-8 -*-
;;;;FILE:               stepper-packages.lisp
;;;;LANGUAGE:           Common-Lisp
;;;;SYSTEM:             Common-Lisp
;;;;    Defines the Common Lisp Stepper packages.
;;;;    <PJB> Pascal J. Bourguignon <pjb@informatimago.com>
;;;;    2012-08-09 <PJB> Extracted from stepper.lisp
;;;;    AGPL3
;;;;    Copyright Pascal J. Bourguignon 2012 - 2012
;;;;    This program is free software: you can redistribute it and/or modify
;;;;    it under the terms of the GNU Affero General Public License as published by
;;;;    the Free Software Foundation, either version 3 of the License, or
;;;;    (at your option) any later version.
;;;;    This program is distributed in the hope that it will be useful,
;;;;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;;    GNU Affero General Public License for more details.
;;;;    You should have received a copy of the GNU Affero General Public License
;;;;    along with this program.  If not, see <http://www.gnu.org/licenses/>.

;; We define an internal package that uses COMMON-LISP to easily
;; define functions and macros, since the CL-STEPPER package shadows
;; all the special operators and defun, defgeneric and defmacro
;; macros.
;; The CL-STEPPER package only contains those shadowed macro
;; definitions.


  (:use "COMMON-LISP"








  (:documentation "
This is an internal package of the Common Lisp stepper.
This package exports the  stepper generator functions,
and defines stepper interactive functions (not exported).

See the documentation of the package

BUGS: we should probably design it with hooks so that clients may
      define the stepping/tracing user interface.

Copyright Pascal J. Bourguignon 2012 - 2012
This package is provided under the Afero General Public License 3.
See the source file for details.



  (:nicknames "COMMON-LISP-STEPPER"

  (:use "COMMON-LISP"

  (:shadow ;; macros

  (:shadow ;; special operators

  (:export ;; everything from COMMON-LISP
   . #.(cl:let ((e '()))
         (cl:do-external-symbols (s "COMMON-LISP" e)
           (push (string s) e))))



   "STEPPER" "DISABLE" #| "TRACE" already exported as CL symbol |#
   ;; (declare (stepper disable)) ; to prevent instrumentation of the
   ;; enclosing sexp and sub expressions.

  (:documentation "
Implements a Portable Common Lisp Stepper.

This package should be used instead of COMMON-LISP, and the code
recompiled or reloaded.  This will instrumentalize the functions so
that tracing and stepping is available.

To start running some code step-by-step, you can use:

    (step (some-expression)) ; note: it's cl-stepper:step, not cl:step.

Or you may use STEP-TRACE-FUNCTION, to activate tracing of some functions (that
must have been compiled with CL-STEPPER), or STEP-BREAK-ENTRY or
STEP-BREAK-EXIT to enter the stepper upon entry or exit of the named

It is also possible to run the tracer on all the code that has been
compiled with CL-STEPPER, with:

   (setf *step-mode* :trace)

Reset it with:

   (setf *step-mode* :run)

If you load a lot of packages with CL-STEPPER, you may want to set
*STEP-MAX-CALL-DEPTH* to a small integer when using *STEP-MODE*
:trace, to avoid very big output.  You may also redirect the tracing
output to a different stream setting *STEP-TRACE-OUTPUT*.

Note: when tracing a function with (step-trace-function fun), the depth is
reset while tracing that function (*step-max-call-depth* still applies
for the call tree starting from that function).

The stepper menu is:

    Step Into (s, si, RET), Step over (so), Trace (t), Run (r),
    Debugger (d), Abort (a, q)?

Step Into:

    Continue evaluating each forms and subforms step by step.

Step Over:

    Evaluate the current form in one step.


    The code is executed, and all the instrumented code produces traces.


    The code is executed silently.


    The debugger is invoked with a STEP-CONDITION.  There are restarts
    installed to invoke all the stepper menu commands.


    The evaluation of the STEP form is aborted.

With the Step Over, Trace, and Run commands,  if a function with a
break-point or an active trace is reached, it will still enter the
stepper menu again, or trace it.

To disable instrumentation of a form, you can insert (stepper disable)
declarations in the places where declarations are allowed.

   (declaim (declaration stepper)) ; for when CL-STEPPER is not used.

     (declare (stepper disable))

declarations.  Use (locally (declare (stepper disable)) …) to disable
in random places.

Similarly, to force tracing a function or a form,
use the (declare (stepper trace)) declaration.
\(stepper disable) has priority over (stepper trace).

Copyright Pascal J. Bourguignon 2012 - 2012
This package is provided under the Afero General Public License 3.
See the source file for details.


;;;; THE END ;;;;