[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Debugging functions



   Here is a functional version of the lucid debugger :L command so you
can compose expressions using local vars. while inside the debugger.

Up with functions !  Down with command processors !

-- jim


(export '(dbg-arg dbg-loc))

(defun dbg-arg (index-or-name)
  "This is a LUCID version of the standard Symbolics DBG:ARG and DBG:LOC
functions.  It is also similar to the lucid debugger `:L' command.  Called
by a user from inside the debugger, it returns the value of the specified
local variable for the current stack frame.  The argument is either an
index number or the name of the local."
  (let* ((frame-index lucid::*frame-index*)
	 (env lucid::*frame-environment*)
	 (frame-length (lucid::stack-frame-length frame-index env))
	 (local-index nil)
	 )
    (declare (special lucid::*frame-environment* lucid::*frame-index*))
    (etypecase index-or-name
      ((integer 0)
       (cond ((< index-or-name frame-length)
	      (setq local-index index-or-name)
	      )
	     (t
	      (error "The index ~D is out of range.  There are only ~D local variables for this frame."
		     index-or-name frame-length)
	      )))
      (symbol
       (dotimes (i frame-length)
	 (let ((loc (lucid::debugger-locate-local frame-index env i))
	       )
	   (when (eq (lucid::stack-frame-local-name frame-index env loc)
		     index-or-name)
	     (setq local-index i)
	     (return nil)
	     )))
       (unless local-index
	 (error "The was no local variable named ~S in this stack frame."
		index-or-name))
       ))

    (lucid::stack-frame-local-value
      frame-index env (lucid::debugger-locate-local frame-index env local-index))
    ))

;;; No difference twixt the two on Lucid

(defun dbg-loc (index-or-name) 
  "This is a LUCID version of the standard Symbolics DBG:ARG and DBG:LOC
functions.  It is also similar to the lucid debugger `:L' command.  Called
by a user from inside the debugger, it returns the value of the specified
local variable for the current stack frame.  The argument is either an
index number or the name of the local."
  (dbg-arg index-or-name)
  )