Download ALisp User`s Guide

Transcript
Lisp Debugging
(CATCH-ERROR F1 F2)
MACRO
Evaluate F1 and return the result of the evaluation. Should an error occur
during the evaluation of F1, then F2 is evaluated if supplied and an error
condition is returned which looks like:
(:ERRCOND (ERRNO "errmsg" XX))
where xx could be different things depending on the error. The function
ERROR? can be used for testing if CATCH-ERROR returned an error
condition. The functions ERRCOND-ARG, ERRCOND-NUMBER and
ERRCOND-MSG are used for accessing error conditions.
(CATCHDEMON LOC VAL)
LAMBDA
See SETDEMON.
(CATCHINTERRUPT)
LAMBDA
This system function is called whenever the user hits CTRL-C. Different
actions will be taken depending on the state of the system.
(DEBUGGING FLAG)
SUBR
If FLAG!=NIL the system will start running in debug mode (See. Sec. 7. Lisp
Debugging) where warning messages are printed and the system checks
assertions. Turn off debug mode by calling with FLAG==NIL.
_DEBUGGING_
GLOBAL
Global flag indicating that the system runs in debug mode. Set by the
function DEBUGGING.
(ERRCOND-ARG EC)
LAMBDA
Get the argument of an error condition.
(ERRCOND-MSG EC)
LAMBDA
Get the error message of an error condition.
(ERRCOND-NUMBER EC)
LAMBDA
Get the error number of an error condition.
(ERROR MSG X)
LAMBDA
Print message MSG followed by ’: ’ and X and then generates an error.
(ERROR? X)
LAMBDA
True if X is an error condition.
(FAULTEVAL ERRNO ERRMSG X FORM ENV)
LAMBDA FAULTEVAL is called whenever the system detects an error. If the system
runs in debug mode FAULTEVAL then enters a break loop (Sec. 7. Lisp
Debugging). If the system is not in debug mode FAULTEVAL prints the
error message and calls (RESET).
(FRAMENO)
SUBR
Return the frame number of the top frame of the stack.
(HARDRESET)
SUBR
Does a ’hard’ reset that cannot be caught to the top level reset point (usually
the top loop). Called after fatal errors such as stack overflow.
(RESET)
SUBR
Return to the current reset point of ALisp. The rest point is either the ALisp
top loop or the previous call to UNWIND-PROTECT.
(UNWIND-PROTECT FORM CL)
*SPECIAL
UNWIND-PROTECT enables the user to clean up after a local or non-local
exit. For example, a throw form may cause a catcher to be exited leaving a
file open. This is clearly undesirable, so a mechanism is needed to close the
file and do any other essential cleaning up on termination of a construct, no
matter how or when the termination is caused. UNWIND-PROTECT can be
used to achieve this. The FORM is evaluated as usual until it is terminated,
whether naturally or by means of a regular exit or a RESET or THROW call.
The cleanup form CL is then evaluated before control is handed back. Note
that the cleanup form of an UNWIND-PROTECT is not protected by that
UNWIND-PROTECT so errors produced during evaluation of CL can cause
problems. The solution is to nest UNWIND-PROTECT. The function
(HARDRESET) bypasses UNWIND-PROTECT.
7.
Lisp Debugging
This sections documents the debugging facilities of ALisp.
To enable run time debugging of ALisp programs the system should be put in debug mode. This is done by calling
(DEBUGGING T). In debug mode the system checks assertions and analyses defined Lisp code for semantic errors,
21