Internal Debugging Interface
****************************

--- The name of this chapter needs to clearly distinguish it from the appendix describing the debugger UI.  The intro should have a pointer to the UI appendix.

 -- primitive: display-error stack port subr message args rest
     Display an error message to the output port PORT. STACK is the saved stack for the error, SUBR is the name of the procedure in which the error occured and MESSAGE is the actual error message, which may contain formatting instructions. These will format the arguments in the list ARGS accordingly.  REST is currently ignored.

 -- primitive: display-application frame [port [indent]]
     Display a procedure application FRAME to the output port PORT. INDENT specifies the indentation of the output.

 -- primitive: display-backtrace stack port [first [depth]]
     Display a backtrace to the output port PORT. STACK is the stack to take the backtrace from, FIRST specifies where in the stack to start and DEPTH how much frames to display. Both FIRST and DEPTH can be #f, which means that default values will be used.

 -- primitive: backtrace
     Display a backtrace of the stack saved by the last error to the current output port.

 -- primitive: malloc-stats
     Return an alist ((WHAT . N) ...) describing number of malloced objects. WHAT is the second argument to scm_must_malloc, N is the number of objects of that type currently allocated.

 -- primitive: debug-options-interface [setting]
     Option interface for the debug options. Instead of using this procedure directly, use the procedures debug-enable, debug-disable, debug-set! and DEBUG-OPTIONS.

 -- primitive: with-traps thunk
     Call THUNK with traps enabled.

 -- primitive: memoized? obj
     Return #t if OBJ is memoized.

 -- primitive: unmemoize m
     Unmemoize the memoized expression M,

 -- primitive: memoized-environment m
     Return the environment of the memoized expression M.

 -- primitive: procedure-name proc
     Return the name of the procedure PROC

 -- primitive: procedure-source proc
     Return the source of the procedure PROC.

 -- primitive: procedure-environment proc
     Return the environment of the procedure PROC.

 -- primitive: debug-object? obj
     Return #t if OBJ is a debug object.

 -- primitive: frame-arguments frame
     Return the arguments of FRAME.

 -- primitive: frame-evaluating-args? frame
     Return #t if FRAME contains evaluated arguments.

 -- primitive: frame-next frame
     Return the next frame of FRAME, or #f if FRAME is the last frame in its stack.

 -- primitive: frame-number frame
     Return the frame number of FRAME.

 -- primitive: frame-overflow? frame
     Return #t if FRAME is an overflow frame.

 -- primitive: frame-previous frame
     Return the previous frame of FRAME, or #f if FRAME is the first frame in its stack.

 -- primitive: frame-procedure frame
     Return the procedure for FRAME, or #f if no procedure is associated with FRAME.

 -- primitive: frame-procedure? frame
     Return #t if a procedure is associated with FRAME.

 -- primitive: frame-real? frame
     Return #t if FRAME is a real frame.

 -- primitive: frame-source frame
     Return the source of FRAME.

 -- primitive: frame? obj
     Return #t if OBJ is a stack frame.

 -- primitive: last-stack-frame obj
     Return a stack which consists of a single frame, which is the last stack frame for OBJ. OBJ must be either a debug object or a continuation.

 -- primitive: make-stack obj . args
     Create a new stack. If OBJ is #t, the current evaluation stack is used for creating the stack frames, otherwise the frames are taken from OBJ (which must be either a debug object or a continuation). ARGS must be a list if integers and specifies how the resulting stack will be narrowed.

 -- primitive: stack-id stack
     Return the identifier given to STACK by start-stack.

 -- primitive: stack-length stack
     Return the length of STACK.

 -- primitive: stack-ref stack i
     Return the I'th frame from STACK.

 -- primitive: stack? obj
     Return #t if OBJ is a calling stack.